Home | History | Annotate | Download | only in WebCoreSupport
      1 /*
      2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef WebEditorClient_H
     27 #define WebEditorClient_H
     28 
     29 #include "WebKit.h"
     30 #pragma warning(push, 0)
     31 #include <WebCore/EditorClient.h>
     32 #include <wtf/OwnPtr.h>
     33 #pragma warning(pop)
     34 
     35 class WebView;
     36 class WebNotification;
     37 class WebEditorUndoTarget;
     38 
     39 class WebEditorClient : public WebCore::EditorClient {
     40 public:
     41     WebEditorClient(WebView*);
     42     ~WebEditorClient();
     43 
     44     virtual void pageDestroyed();
     45 
     46     virtual bool isContinuousSpellCheckingEnabled();
     47     virtual void toggleGrammarChecking();
     48     virtual bool isGrammarCheckingEnabled();
     49     virtual void toggleContinuousSpellChecking();
     50     virtual int spellCheckerDocumentTag();
     51 
     52     virtual bool isEditable();
     53 
     54     virtual bool shouldBeginEditing(WebCore::Range*);
     55     virtual bool shouldEndEditing(WebCore::Range*);
     56     virtual bool shouldInsertText(const WebCore::String&, WebCore::Range*, WebCore::EditorInsertAction);
     57 
     58     virtual void didBeginEditing();
     59     virtual void didEndEditing();
     60     virtual void didWriteSelectionToPasteboard();
     61     virtual void didSetSelectionTypesForPasteboard();
     62 
     63     virtual void respondToChangedContents();
     64     virtual void respondToChangedSelection();
     65 
     66     bool shouldShowDeleteInterface(WebCore::HTMLElement*);
     67     bool shouldDeleteRange(WebCore::Range*);
     68 
     69     bool shouldInsertNode(WebCore::Node*, WebCore::Range* replacingRange, WebCore::EditorInsertAction);
     70     bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
     71     bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*);
     72     bool shouldChangeTypingStyle(WebCore::CSSStyleDeclaration* currentStyle, WebCore::CSSStyleDeclaration* toProposedStyle);
     73 
     74     void webViewDidChangeTypingStyle(WebNotification*);
     75     void webViewDidChangeSelection(WebNotification*);
     76 
     77     bool smartInsertDeleteEnabled();
     78     bool isSelectTrailingWhitespaceEnabled();
     79 
     80     void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>);
     81     void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>);
     82     void clearUndoRedoOperations();
     83 
     84     bool canUndo() const;
     85     bool canRedo() const;
     86 
     87     void undo();
     88     void redo();
     89 
     90     virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting);
     91     virtual void textFieldDidBeginEditing(WebCore::Element*);
     92     virtual void textFieldDidEndEditing(WebCore::Element*);
     93     virtual void textDidChangeInTextField(WebCore::Element*);
     94     virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*);
     95     virtual void textWillBeDeletedInTextField(WebCore::Element* input);
     96     virtual void textDidChangeInTextArea(WebCore::Element*);
     97 
     98     void handleKeyboardEvent(WebCore::KeyboardEvent*);
     99     void handleInputMethodKeydown(WebCore::KeyboardEvent*);
    100 
    101     virtual void ignoreWordInSpellDocument(const WebCore::String&);
    102     virtual void learnWord(const WebCore::String&);
    103     virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
    104     virtual WebCore::String getAutoCorrectSuggestionForMisspelledWord(const WebCore::String&);
    105     virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
    106     virtual void updateSpellingUIWithGrammarString(const WebCore::String&, const WebCore::GrammarDetail& detail);
    107     virtual void updateSpellingUIWithMisspelledWord(const WebCore::String&);
    108     virtual void showSpellingUI(bool show);
    109     virtual bool spellingUIIsShowing();
    110     virtual void getGuessesForWord(const WebCore::String&, Vector<WebCore::String>& guesses);
    111 
    112     virtual void setInputMethodState(bool);
    113 
    114 private:
    115     WebView* m_webView;
    116     WebEditorUndoTarget* m_undoTarget;
    117 };
    118 
    119 #endif // WebEditorClient_H
    120