~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit/chromium/src/EditorClientImpl.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Google Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions are
 
6
 * met:
 
7
 *
 
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
 
13
 * distribution.
 
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.
 
17
 *
 
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.
 
29
 */
 
30
 
 
31
#ifndef EditorClientImpl_h
 
32
#define EditorClientImpl_h
 
33
 
 
34
#include "EditorClient.h"
 
35
#include "TextCheckerClient.h"
 
36
#include "Timer.h"
 
37
#include <wtf/Deque.h>
 
38
#include <wtf/HashSet.h>
 
39
 
 
40
namespace WebCore {
 
41
class Frame;
 
42
class HTMLInputElement;
 
43
}
 
44
 
 
45
namespace WebKit {
 
46
class WebViewImpl;
 
47
class WebTextCheckingCompletionImpl;
 
48
 
 
49
class EditorClientImpl : public WebCore::EditorClient, public WebCore::TextCheckerClient {
 
50
public:
 
51
    EditorClientImpl(WebViewImpl* webView);
 
52
 
 
53
    virtual ~EditorClientImpl();
 
54
    virtual void pageDestroyed();
 
55
    virtual void frameWillDetachPage(WebCore::Frame*) OVERRIDE;
 
56
 
 
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;
 
87
    virtual void undo();
 
88
    virtual void redo();
 
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;
 
117
 
 
118
    virtual WebCore::TextCheckerClient* textChecker() { return this; }
 
119
 
 
120
private:
 
121
    void modifySelection(WebCore::Frame*, WebCore::KeyboardEvent*);
 
122
 
 
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();
 
131
 
 
132
    WebViewImpl* m_webView;
 
133
    bool m_inRedo;
 
134
 
 
135
    typedef Deque<RefPtr<WebCore::UndoStep> > UndoManagerStack;
 
136
    UndoManagerStack m_undoStack;
 
137
    UndoManagerStack m_redoStack;
 
138
 
 
139
    // This flag is set to false if spell check for this editor is manually
 
140
    // turned off. The default setting is SpellCheckAutomatic.
 
141
    enum {
 
142
        SpellCheckAutomatic,
 
143
        SpellCheckForcedOn,
 
144
        SpellCheckForcedOff
 
145
    };
 
146
    int m_spellCheckThisFieldStatus;
 
147
};
 
148
 
 
149
} // namespace WebKit
 
150
 
 
151
#endif