initial import
[vuplus_webkit] / Source / WebKit / efl / WebCoreSupport / EditorClientEfl.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) 2008 INdT - Instituto Nokia de Tecnologia
6  * Copyright (C) 2009-2010 ProFUSION embedded systems
7  * Copyright (C) 2009-2010 Samsung Electronics
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
21  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef EditorClientEfl_h
34 #define EditorClientEfl_h
35
36 #include "EditorClient.h"
37 #include "TextCheckerClient.h"
38
39 #include <wtf/Deque.h>
40 #include <wtf/Forward.h>
41
42 typedef struct _Evas_Object Evas_Object;
43
44 namespace WebCore {
45 class Page;
46
47 class EditorClientEfl : public EditorClient, public TextCheckerClient {
48 protected:
49     bool m_isInRedo;
50     WTF::Deque<WTF::RefPtr<WebCore::EditCommand> > undoStack;
51     WTF::Deque<WTF::RefPtr<WebCore::EditCommand> > redoStack;
52
53 public:
54     EditorClientEfl(Evas_Object *view);
55     ~EditorClientEfl();
56
57     // from EditorClient
58     virtual void pageDestroyed();
59
60     virtual bool shouldDeleteRange(Range*);
61     virtual bool shouldShowDeleteInterface(HTMLElement*);
62     virtual bool smartInsertDeleteEnabled();
63     virtual bool isSelectTrailingWhitespaceEnabled();
64     virtual bool isContinuousSpellCheckingEnabled();
65     virtual void toggleContinuousSpellChecking();
66     virtual bool isGrammarCheckingEnabled();
67     virtual void toggleGrammarChecking();
68     virtual int spellCheckerDocumentTag();
69
70     virtual bool shouldBeginEditing(Range*);
71     virtual bool shouldEndEditing(Range*);
72     virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
73     virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
74     virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting);
75
76     virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
77
78     virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
79
80     virtual void didBeginEditing();
81     virtual void respondToChangedContents();
82     virtual void respondToChangedSelection();
83     virtual void didEndEditing();
84     virtual void didWriteSelectionToPasteboard();
85     virtual void didSetSelectionTypesForPasteboard();
86
87     virtual void registerCommandForUndo(WTF::PassRefPtr<EditCommand>);
88     virtual void registerCommandForRedo(WTF::PassRefPtr<EditCommand>);
89     virtual void clearUndoRedoOperations();
90
91     virtual bool canCopyCut(Frame*, bool defaultValue) const;
92     virtual bool canPaste(Frame*, bool defaultValue) const;
93     virtual bool canUndo() const;
94     virtual bool canRedo() const;
95
96     virtual void undo();
97     virtual void redo();
98
99     virtual const char* interpretKeyEvent(const KeyboardEvent*);
100     virtual bool handleEditingKeyboardEvent(KeyboardEvent*);
101     virtual void handleKeyboardEvent(KeyboardEvent*);
102     virtual void handleInputMethodKeydown(KeyboardEvent*);
103
104     virtual void textFieldDidBeginEditing(Element*);
105     virtual void textFieldDidEndEditing(Element*);
106     virtual void textDidChangeInTextField(Element*);
107     virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
108     virtual void textWillBeDeletedInTextField(Element*);
109     virtual void textDidChangeInTextArea(Element*);
110
111     virtual void ignoreWordInSpellDocument(const String&);
112     virtual void learnWord(const String&);
113     virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
114     virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);
115     virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
116     virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
117     virtual void updateSpellingUIWithMisspelledWord(const String&);
118     virtual void showSpellingUI(bool show);
119     virtual bool spellingUIIsShowing();
120     virtual void getGuessesForWord(const String& word, const String& context, WTF::Vector<String>& guesses);
121     virtual void willSetInputMethodState();
122     virtual void setInputMethodState(bool enabled);
123     virtual void requestCheckingOfString(WebCore::SpellChecker*, int, WebCore::TextCheckingTypeMask, const WTF::String&) { }
124     virtual TextCheckerClient* textChecker() { return this; }
125
126 private:
127     Evas_Object *m_view;
128 };
129 }
130
131 #endif // EditorClientEfl_h