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