[GLIB] Use GUniquePtr instead of GOwnPtr
[WebKit-https.git] / Source / WebKit / gtk / WebCoreSupport / EditorClientGtk.h
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  * Copyright (C) 2010 Martin Robinson <mrobinson@webkit.org>
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef EditorClientGtk_h
32 #define EditorClientGtk_h
33
34 #include "EditorClient.h"
35 #include "KeyBindingTranslator.h"
36 #include "TextCheckerClient.h"
37 #include <wtf/Deque.h>
38 #include <wtf/Forward.h>
39 #include <wtf/gobject/GRefPtr.h>
40
41 #if ENABLE(SPELLCHECK)
42 #include "TextCheckerClientGtk.h"
43 #else
44 #include "EmptyClients.h"
45 #endif
46
47 typedef struct _WebKitWebView WebKitWebView;
48
49 namespace WebCore {
50 class Frame;
51 class KeyboardEvent;
52 }
53
54 namespace WebKit {
55
56 class EditorClient : public WebCore::EditorClient {
57     protected:
58         bool m_isInRedo;
59
60         WTF::Deque<WTF::RefPtr<WebCore::UndoStep> > undoStack;
61         WTF::Deque<WTF::RefPtr<WebCore::UndoStep> > redoStack;
62
63     public:
64         EditorClient(WebKitWebView*);
65         ~EditorClient();
66         WebKitWebView* webView() { return m_webView; }
67         void addPendingEditorCommand(const char* command) { m_pendingEditorCommands.append(command); }
68         void generateEditorCommands(const WebCore::KeyboardEvent*);
69         bool executePendingEditorCommands(WebCore::Frame*, bool);
70
71         // from EditorClient
72         virtual void pageDestroyed();
73
74         virtual bool shouldDeleteRange(WebCore::Range*);
75         virtual bool smartInsertDeleteEnabled();
76         virtual bool isSelectTrailingWhitespaceEnabled();
77         virtual bool isContinuousSpellCheckingEnabled();
78         virtual void toggleContinuousSpellChecking();
79         virtual bool isGrammarCheckingEnabled();
80         virtual void toggleGrammarChecking();
81         virtual int spellCheckerDocumentTag();
82
83         virtual bool shouldBeginEditing(WebCore::Range*);
84         virtual bool shouldEndEditing(WebCore::Range*);
85         virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction);
86         virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction);
87         virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting);
88
89         virtual bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*);
90
91         virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*);
92
93         virtual void didBeginEditing();
94         virtual void respondToChangedContents();
95         virtual void respondToChangedSelection(WebCore::Frame*);
96         virtual void didEndEditing();
97         virtual void willWriteSelectionToPasteboard(WebCore::Range*);
98         virtual void didWriteSelectionToPasteboard();
99         virtual void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer> >& pasteboardData);
100
101         virtual void registerUndoStep(WTF::PassRefPtr<WebCore::UndoStep>);
102         virtual void registerRedoStep(WTF::PassRefPtr<WebCore::UndoStep>);
103         virtual void clearUndoRedoOperations();
104
105         virtual bool canCopyCut(WebCore::Frame*, bool defaultValue) const;
106         virtual bool canPaste(WebCore::Frame*, bool defaultValue) const;
107         virtual bool canUndo() const;
108         virtual bool canRedo() const;
109
110         virtual void undo();
111         virtual void redo();
112
113         virtual void handleKeyboardEvent(WebCore::KeyboardEvent*);
114         virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*);
115
116         virtual void textFieldDidBeginEditing(WebCore::Element*);
117         virtual void textFieldDidEndEditing(WebCore::Element*);
118         virtual void textDidChangeInTextField(WebCore::Element*);
119         virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*);
120         virtual void textWillBeDeletedInTextField(WebCore::Element*);
121         virtual void textDidChangeInTextArea(WebCore::Element*);
122
123         virtual WebCore::TextCheckerClient* textChecker() { return &m_textCheckerClient; }
124
125         virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&);
126         virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
127         virtual void showSpellingUI(bool show);
128         virtual bool spellingUIIsShowing();
129         virtual void willSetInputMethodState();
130         virtual void setInputMethodState(bool enabled);
131
132         virtual bool shouldShowUnicodeMenu();
133
134         virtual bool supportsGlobalSelection() override;
135
136     private:
137 #if ENABLE(SPELLCHECK)
138         TextCheckerClientGtk m_textCheckerClient;
139 #else
140         WebCore::EmptyTextCheckerClient m_textCheckerClient;
141 #endif
142         WebKitWebView* m_webView;
143         WebCore::KeyBindingTranslator m_keyBindingTranslator;
144         Vector<WTF::String> m_pendingEditorCommands;
145     };
146 }
147
148 #endif
149
150 // vim: ts=4 sw=4 et