2007-08-10 Holger Hans Peter Freyther <zecke@selfish.org>
[WebKit-https.git] / WebKit / gtk / WebCoreSupport / EditorClientGtk.cpp
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 #include "config.h"
31 #include "EditorClientGtk.h"
32
33 #include "EditCommand.h"
34 #include "Editor.h"
35 #include "FocusController.h"
36 #include "Frame.h"
37 #include "KeyboardCodes.h"
38 #include "KeyboardEvent.h"
39 #include "NotImplemented.h"
40 #include "Page.h"
41 #include "PlatformKeyboardEvent.h"
42 #include "webkitgtkprivate.h"
43
44 #include <stdio.h>
45
46 using namespace WebCore;
47
48 namespace WebKit {
49
50 bool EditorClient::shouldDeleteRange(Range*)
51 {
52     notImplemented();
53     return true;
54 }
55
56 bool EditorClient::shouldShowDeleteInterface(HTMLElement*)
57 {
58     return false;
59 }
60
61 bool EditorClient::isContinuousSpellCheckingEnabled()
62 {
63     notImplemented();
64     return false;
65 }
66
67 bool EditorClient::isGrammarCheckingEnabled()
68 {
69     notImplemented();
70     return false;
71 }
72
73 int EditorClient::spellCheckerDocumentTag()
74 {
75     notImplemented();
76     return 0;
77 }
78
79 bool EditorClient::shouldBeginEditing(WebCore::Range*)
80 {
81     notImplemented();
82     return true;
83 }
84
85 bool EditorClient::shouldEndEditing(WebCore::Range*)
86 {
87     notImplemented();
88     return true;
89 }
90
91 bool EditorClient::shouldInsertText(String, Range*, EditorInsertAction)
92 {
93     notImplemented();
94     return true;
95 }
96
97 bool EditorClient::shouldChangeSelectedRange(Range*, Range*, EAffinity, bool)
98 {
99     notImplemented();
100     return true;
101 }
102
103 bool EditorClient::shouldApplyStyle(WebCore::CSSStyleDeclaration*,
104                                       WebCore::Range*)
105 {
106     notImplemented();
107     return true;
108 }
109
110 bool EditorClient::shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*)
111 {
112     notImplemented();
113     return true;
114 }
115
116 void EditorClient::didBeginEditing()
117 {
118     notImplemented();
119 }
120
121 void EditorClient::respondToChangedContents()
122 {
123     notImplemented();
124 }
125
126 void EditorClient::respondToChangedSelection()
127 {
128     notImplemented();
129 }
130
131 void EditorClient::didEndEditing()
132 {
133     notImplemented();
134 }
135
136 void EditorClient::didWriteSelectionToPasteboard()
137 {
138     notImplemented();
139 }
140
141 void EditorClient::didSetSelectionTypesForPasteboard()
142 {
143     notImplemented();
144 }
145
146 bool EditorClient::isEditable()
147 {
148     notImplemented();
149     return false;
150 }
151
152 void EditorClient::registerCommandForUndo(WTF::PassRefPtr<WebCore::EditCommand>)
153 {
154     notImplemented();
155 }
156
157 void EditorClient::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand>)
158 {
159     notImplemented();
160 }
161
162 void EditorClient::clearUndoRedoOperations()
163 {
164     notImplemented();
165 }
166
167 bool EditorClient::canUndo() const
168 {
169     notImplemented();
170     return false;
171 }
172
173 bool EditorClient::canRedo() const
174 {
175     notImplemented();
176     return false;
177 }
178
179 void EditorClient::undo()
180 {
181     notImplemented();
182 }
183
184 void EditorClient::redo()
185 {
186     notImplemented();
187 }
188
189 bool EditorClient::shouldInsertNode(Node*, Range*, EditorInsertAction)
190 {
191     notImplemented();
192     return true;
193 }
194
195 void EditorClient::pageDestroyed()
196 {
197     delete this;
198 }
199
200 bool EditorClient::smartInsertDeleteEnabled()
201 {
202     notImplemented();
203     return false;
204 }
205
206 void EditorClient::toggleContinuousSpellChecking()
207 {
208     notImplemented();
209 }
210
211 void EditorClient::toggleGrammarChecking()
212 {
213 }
214
215 void EditorClient::handleKeypress(KeyboardEvent* event)
216 {
217     Frame* frame = core(m_page)->focusController()->focusedOrMainFrame();
218     if (!frame)
219         return;
220
221     const PlatformKeyboardEvent* kevent = event->keyEvent();
222     if (!kevent->isKeyUp()) {
223         Node* start = frame->selectionController()->start().node();
224         if (start && start->isContentEditable()) {
225             switch (kevent->WindowsKeyCode()) {
226             case VK_BACK:
227                 frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
228                                                      CharacterGranularity, false, true);
229                 break;
230             case VK_DELETE:
231                 frame->editor()->deleteWithDirection(SelectionController::FORWARD,
232                                                      CharacterGranularity, false, true);
233                 break;
234             case VK_LEFT:
235                 frame->editor()->execCommand("MoveLeft");
236                 break;
237             case VK_RIGHT:
238                 frame->editor()->execCommand("MoveRight");
239                 break;
240             case VK_UP:
241                 frame->editor()->execCommand("MoveUp");
242                 break;
243             case VK_DOWN:
244                 frame->editor()->execCommand("MoveDown");
245                 break;
246             default:
247                 frame->editor()->insertText(kevent->text(), event);
248             }
249             event->setDefaultHandled();
250         }
251     }
252 }
253
254
255 void EditorClient::handleInputMethodKeypress(KeyboardEvent*)
256 {
257     notImplemented();
258 }
259
260 EditorClient::EditorClient(WebKitGtkPage* page)
261     : m_page(page)
262 {
263 }
264
265 void EditorClient::textFieldDidBeginEditing(Element*)
266 {
267     notImplemented();
268 }
269
270 void EditorClient::textFieldDidEndEditing(Element*)
271 {
272     notImplemented();
273 }
274
275 void EditorClient::textDidChangeInTextField(Element*)
276 {
277     notImplemented();
278 }
279
280 bool EditorClient::doTextFieldCommandFromEvent(Element*, KeyboardEvent*)
281 {
282     notImplemented();
283     return false;
284 }
285
286 void EditorClient::textWillBeDeletedInTextField(Element*)
287 {
288     notImplemented();
289 }
290
291 void EditorClient::textDidChangeInTextArea(Element*)
292 {
293     notImplemented();
294 }
295
296 void EditorClient::ignoreWordInSpellDocument(const String&)
297 {
298     notImplemented();
299 }
300
301 void EditorClient::learnWord(const String&)
302 {
303     notImplemented();
304 }
305
306 void EditorClient::checkSpellingOfString(const UChar*, int, int*, int*)
307 {
308     notImplemented();
309 }
310
311 void EditorClient::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
312 {
313     notImplemented();
314 }
315
316 void EditorClient::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&)
317 {
318     notImplemented();
319 }
320
321 void EditorClient::updateSpellingUIWithMisspelledWord(const String&)
322 {
323     notImplemented();
324 }
325
326 void EditorClient::showSpellingUI(bool)
327 {
328     notImplemented();
329 }
330
331 bool EditorClient::spellingUIIsShowing()
332 {
333     notImplemented();
334     return false;
335 }
336
337 void EditorClient::getGuessesForWord(const String&, Vector<String>&)
338 {
339     notImplemented();
340 }
341
342 }
343
344 // vim: ts=4 sw=4 et