2
* Copyright (C) 2009 Google Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are
8
* * Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* * Redistributions in binary form must reproduce the above
11
* copyright notice, this list of conditions and the following disclaimer
12
* in the documentation and/or other materials provided with the
14
* * Neither the name of Google Inc. nor the names of its
15
* contributors may be used to endorse or promote products derived from
16
* this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
* THEORY 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.
31
#ifndef EditorClientImpl_h
32
#define EditorClientImpl_h
34
#include "EditorClient.h"
35
#include "TextCheckerClient.h"
37
#include <wtf/Deque.h>
38
#include <wtf/HashSet.h>
42
class HTMLInputElement;
47
class WebTextCheckingCompletionImpl;
49
class EditorClientImpl : public WebCore::EditorClient, public WebCore::TextCheckerClient {
51
EditorClientImpl(WebViewImpl* webView);
53
virtual ~EditorClientImpl();
54
virtual void pageDestroyed();
55
virtual void frameWillDetachPage(WebCore::Frame*) OVERRIDE;
57
virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*);
58
virtual bool smartInsertDeleteEnabled();
59
virtual bool isSelectTrailingWhitespaceEnabled();
60
virtual bool isContinuousSpellCheckingEnabled();
61
virtual void toggleContinuousSpellChecking();
62
virtual bool isGrammarCheckingEnabled();
63
virtual void toggleGrammarChecking();
64
virtual int spellCheckerDocumentTag();
65
virtual bool shouldBeginEditing(WebCore::Range*);
66
virtual bool shouldEndEditing(WebCore::Range*);
67
virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction);
68
virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction);
69
virtual bool shouldDeleteRange(WebCore::Range*);
70
virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange,
71
WebCore::EAffinity, bool stillSelecting);
72
virtual bool shouldApplyStyle(WebCore::StylePropertySet*, WebCore::Range*);
73
virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*);
74
virtual void didBeginEditing();
75
virtual void respondToChangedContents();
76
virtual void respondToChangedSelection(WebCore::Frame*);
77
virtual void didEndEditing();
78
virtual void didWriteSelectionToPasteboard();
79
virtual void didSetSelectionTypesForPasteboard();
80
virtual void registerUndoStep(PassRefPtr<WebCore::UndoStep>);
81
virtual void registerRedoStep(PassRefPtr<WebCore::UndoStep>);
82
virtual void clearUndoRedoOperations();
83
virtual bool canCopyCut(WebCore::Frame*, bool defaultValue) const;
84
virtual bool canPaste(WebCore::Frame*, bool defaultValue) const;
85
virtual bool canUndo() const;
86
virtual bool canRedo() const;
89
virtual const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
90
virtual bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
91
virtual void handleKeyboardEvent(WebCore::KeyboardEvent*);
92
virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*);
93
virtual void textFieldDidBeginEditing(WebCore::Element*);
94
virtual void textFieldDidEndEditing(WebCore::Element*);
95
virtual void textDidChangeInTextField(WebCore::Element*);
96
virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*);
97
virtual void textWillBeDeletedInTextField(WebCore::Element*);
98
virtual void textDidChangeInTextArea(WebCore::Element*);
99
virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const;
100
virtual void ignoreWordInSpellDocument(const WTF::String&);
101
virtual void learnWord(const WTF::String&);
102
virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
103
virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&,
104
int* badGrammarLocation, int* badGrammarLength);
105
virtual void checkTextOfParagraph(const UChar*, int length, WebCore::TextCheckingTypeMask checkingTypes,
106
WTF::Vector<WebCore::TextCheckingResult>& results);
107
virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&);
108
virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&);
109
virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
110
virtual void showSpellingUI(bool show);
111
virtual bool spellingUIIsShowing();
112
virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
113
virtual void willSetInputMethodState();
114
virtual void setInputMethodState(bool enabled);
115
virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>);
116
virtual bool supportsGlobalSelection() OVERRIDE;
118
virtual WebCore::TextCheckerClient* textChecker() { return this; }
121
void modifySelection(WebCore::Frame*, WebCore::KeyboardEvent*);
123
// Returns whether or not the focused control needs spell-checking.
124
// Currently, this function just retrieves the focused node and determines
125
// whether or not it is a <textarea> element or an element whose
126
// contenteditable attribute is true.
127
// FIXME: Bug 740540: This code just implements the default behavior
128
// proposed in this issue. We should also retrieve "spellcheck" attributes
129
// for text fields and create a flag to over-write the default behavior.
130
bool shouldSpellcheckByDefault();
132
WebViewImpl* m_webView;
135
typedef Deque<RefPtr<WebCore::UndoStep> > UndoManagerStack;
136
UndoManagerStack m_undoStack;
137
UndoManagerStack m_redoStack;
139
// This flag is set to false if spell check for this editor is manually
140
// turned off. The default setting is SpellCheckAutomatic.
146
int m_spellCheckThisFieldStatus;
149
} // namespace WebKit