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.
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
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.
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.
31
#include "EditorClientGtk.h"
33
#include "EditCommand.h"
35
#include "FocusController.h"
37
#include "KeyboardCodes.h"
38
#include "KeyboardEvent.h"
39
#include "NotImplemented.h"
41
#include "PlatformKeyboardEvent.h"
42
#include "webkitgtkprivate.h"
46
using namespace WebCore;
50
bool EditorClient::shouldDeleteRange(Range*)
56
bool EditorClient::shouldShowDeleteInterface(HTMLElement*)
61
bool EditorClient::isContinuousSpellCheckingEnabled()
67
bool EditorClient::isGrammarCheckingEnabled()
73
int EditorClient::spellCheckerDocumentTag()
79
bool EditorClient::shouldBeginEditing(WebCore::Range*)
85
bool EditorClient::shouldEndEditing(WebCore::Range*)
91
bool EditorClient::shouldInsertText(String, Range*, EditorInsertAction)
97
bool EditorClient::shouldChangeSelectedRange(Range*, Range*, EAffinity, bool)
103
bool EditorClient::shouldApplyStyle(WebCore::CSSStyleDeclaration*,
110
bool EditorClient::shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*)
116
void EditorClient::didBeginEditing()
121
void EditorClient::respondToChangedContents()
126
void EditorClient::respondToChangedSelection()
131
void EditorClient::didEndEditing()
136
void EditorClient::didWriteSelectionToPasteboard()
141
void EditorClient::didSetSelectionTypesForPasteboard()
146
bool EditorClient::isEditable()
152
void EditorClient::registerCommandForUndo(WTF::PassRefPtr<WebCore::EditCommand>)
157
void EditorClient::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand>)
162
void EditorClient::clearUndoRedoOperations()
167
bool EditorClient::canUndo() const
173
bool EditorClient::canRedo() const
179
void EditorClient::undo()
184
void EditorClient::redo()
189
bool EditorClient::shouldInsertNode(Node*, Range*, EditorInsertAction)
195
void EditorClient::pageDestroyed()
200
bool EditorClient::smartInsertDeleteEnabled()
206
void EditorClient::toggleContinuousSpellChecking()
211
void EditorClient::toggleGrammarChecking()
215
void EditorClient::handleKeypress(KeyboardEvent* event)
217
Frame* frame = core(m_page)->focusController()->focusedOrMainFrame();
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()) {
227
frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
228
CharacterGranularity, false, true);
231
frame->editor()->deleteWithDirection(SelectionController::FORWARD,
232
CharacterGranularity, false, true);
235
frame->editor()->execCommand("MoveLeft");
238
frame->editor()->execCommand("MoveRight");
241
frame->editor()->execCommand("MoveUp");
244
frame->editor()->execCommand("MoveDown");
247
frame->editor()->insertText(kevent->text(), event);
249
event->setDefaultHandled();
255
void EditorClient::handleInputMethodKeypress(KeyboardEvent*)
260
EditorClient::EditorClient(WebKitGtkPage* page)
265
void EditorClient::textFieldDidBeginEditing(Element*)
270
void EditorClient::textFieldDidEndEditing(Element*)
275
void EditorClient::textDidChangeInTextField(Element*)
280
bool EditorClient::doTextFieldCommandFromEvent(Element*, KeyboardEvent*)
286
void EditorClient::textWillBeDeletedInTextField(Element*)
291
void EditorClient::textDidChangeInTextArea(Element*)
296
void EditorClient::ignoreWordInSpellDocument(const String&)
301
void EditorClient::learnWord(const String&)
306
void EditorClient::checkSpellingOfString(const UChar*, int, int*, int*)
311
void EditorClient::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
316
void EditorClient::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&)
321
void EditorClient::updateSpellingUIWithMisspelledWord(const String&)
326
void EditorClient::showSpellingUI(bool)
331
bool EditorClient::spellingUIIsShowing()
337
void EditorClient::getGuessesForWord(const String&, Vector<String>&)