2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef WebEditorClient_H
27 #define WebEditorClient_H
30 #include <WebCore/EditorClient.h>
31 #include <WebCore/TextCheckerClient.h>
32 #include <wtf/OwnPtr.h>
35 class WebNotification;
36 class WebEditorUndoTarget;
38 class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient {
40 WebEditorClient(WebView*);
43 virtual void pageDestroyed();
45 virtual bool isContinuousSpellCheckingEnabled();
46 virtual void toggleGrammarChecking();
47 virtual bool isGrammarCheckingEnabled();
48 virtual void toggleContinuousSpellChecking();
49 virtual int spellCheckerDocumentTag();
51 virtual bool shouldBeginEditing(WebCore::Range*);
52 virtual bool shouldEndEditing(WebCore::Range*);
53 virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction);
55 virtual void didBeginEditing();
56 virtual void didEndEditing();
57 virtual void didWriteSelectionToPasteboard();
58 virtual void didSetSelectionTypesForPasteboard();
60 virtual void respondToChangedContents();
61 virtual void respondToChangedSelection();
63 bool shouldShowDeleteInterface(WebCore::HTMLElement*);
64 bool shouldDeleteRange(WebCore::Range*);
66 bool shouldInsertNode(WebCore::Node*, WebCore::Range* replacingRange, WebCore::EditorInsertAction);
67 bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
68 bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*);
69 bool shouldChangeTypingStyle(WebCore::CSSStyleDeclaration* currentStyle, WebCore::CSSStyleDeclaration* toProposedStyle);
71 void webViewDidChangeTypingStyle(WebNotification*);
72 void webViewDidChangeSelection(WebNotification*);
74 bool smartInsertDeleteEnabled();
75 bool isSelectTrailingWhitespaceEnabled();
77 void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>);
78 void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>);
79 void clearUndoRedoOperations();
81 bool canCopyCut(Frame*, bool defaultValue) const;
82 bool canPaste(Frame*, bool defaultValue) const;
89 virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting);
90 virtual void textFieldDidBeginEditing(WebCore::Element*);
91 virtual void textFieldDidEndEditing(WebCore::Element*);
92 virtual void textDidChangeInTextField(WebCore::Element*);
93 virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*);
94 virtual void textWillBeDeletedInTextField(WebCore::Element* input);
95 virtual void textDidChangeInTextArea(WebCore::Element*);
97 void handleKeyboardEvent(WebCore::KeyboardEvent*);
98 void handleInputMethodKeydown(WebCore::KeyboardEvent*);
100 virtual void ignoreWordInSpellDocument(const WTF::String&);
101 virtual void learnWord(const WTF::String&);
102 virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
103 virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&);
104 virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
105 virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail& detail);
106 virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
107 virtual void showSpellingUI(bool show);
108 virtual bool spellingUIIsShowing();
109 virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
111 virtual void willSetInputMethodState();
112 virtual void setInputMethodState(bool);
113 virtual void requestCheckingOfString(WebCore::SpellChecker*, int, WebCore::TextCheckingTypeMask, const WTF::String&) {}
114 virtual WebCore::TextCheckerClient* textChecker() { return this; }
118 WebEditorUndoTarget* m_undoTarget;
121 #endif // WebEditorClient_H