|
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 "IWebEditingDelegate.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(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 |
|
79 void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>); |
|
80 void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>); |
|
81 void clearUndoRedoOperations(); |
|
82 |
|
83 bool canUndo() const; |
|
84 bool canRedo() const; |
|
85 |
|
86 void undo(); |
|
87 void redo(); |
|
88 |
|
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*); |
|
96 |
|
97 void handleKeypress(WebCore::KeyboardEvent*); |
|
98 void handleInputMethodKeypress(WebCore::KeyboardEvent*); |
|
99 |
|
100 virtual void ignoreWordInSpellDocument(const WebCore::String&); |
|
101 virtual void learnWord(const WebCore::String&); |
|
102 virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength); |
|
103 virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); |
|
104 virtual void updateSpellingUIWithGrammarString(const WebCore::String&, const WebCore::GrammarDetail& detail); |
|
105 virtual void updateSpellingUIWithMisspelledWord(const WebCore::String&); |
|
106 virtual void showSpellingUI(bool show); |
|
107 virtual bool spellingUIIsShowing(); |
|
108 virtual void getGuessesForWord(const WebCore::String&, Vector<WebCore::String>& guesses); |
|
109 |
|
110 virtual void setInputMethodState(bool); |
|
111 |
|
112 private: |
|
113 WebView* m_webView; |
|
114 WebEditorUndoTarget* m_undoTarget; |
|
115 }; |
|
116 |
|
117 #endif // WebEditorClient_H |