• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2007, The Android Open Source Project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *  * Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef EditorClientAndroid_h
27 #define EditorClientAndroid_h
28 
29 #include "EditorClient.h"
30 #include "Page.h"
31 
32 using namespace WebCore;
33 
34 namespace android {
35 
36 class EditorClientAndroid : public EditorClient {
37 public:
EditorClientAndroid()38     EditorClientAndroid() {
39         m_shouldChangeSelectedRange = true;
40         m_uiGeneratedSelectionChange = false;
41     }
42     virtual void pageDestroyed();
43 
44     virtual bool shouldDeleteRange(Range*);
45     virtual bool shouldShowDeleteInterface(HTMLElement*);
46     virtual bool smartInsertDeleteEnabled();
47     virtual bool isSelectTrailingWhitespaceEnabled();
48     virtual bool isContinuousSpellCheckingEnabled();
49     virtual void toggleContinuousSpellChecking();
50     virtual bool isGrammarCheckingEnabled();
51     virtual void toggleGrammarChecking();
52     virtual int spellCheckerDocumentTag();
53 
54     virtual bool isEditable();
55 
56     virtual bool shouldBeginEditing(Range*);
57     virtual bool shouldEndEditing(Range*);
58     virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
59     virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
60     virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting);
61 
62     virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
63 //  virtual bool shouldChangeTypingStyle(CSSStyleDeclaration* fromStyle, CSSStyleDeclaration* toStyle);
64 //  virtual bool doCommandBySelector(SEL selector);
65     virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
66 
67     virtual void didBeginEditing();
68     virtual void respondToChangedContents();
69     virtual void respondToChangedSelection();
70     virtual void didEndEditing();
71     virtual void didWriteSelectionToPasteboard();
72     virtual void didSetSelectionTypesForPasteboard();
73 //  virtual void didChangeTypingStyle:(NSNotification *)notification;
74 //  virtual void didChangeSelection:(NSNotification *)notification;
75 //  virtual NSUndoManager* undoManager:(WebView *)webView;
76 
77     virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
78     virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
79     virtual void clearUndoRedoOperations();
80 
81     virtual bool canUndo() const;
82     virtual bool canRedo() const;
83 
84     virtual void undo();
85     virtual void redo();
86 
87     virtual void handleKeyboardEvent(KeyboardEvent*);
88     virtual void handleInputMethodKeydown(KeyboardEvent*);
89 
90     virtual void textFieldDidBeginEditing(Element*);
91     virtual void textFieldDidEndEditing(Element*);
92     virtual void textDidChangeInTextField(Element*);
93     virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
94     virtual void textWillBeDeletedInTextField(Element*);
95     virtual void textDidChangeInTextArea(Element*);
96 
97     virtual void ignoreWordInSpellDocument(const String&);
98     virtual void learnWord(const String&);
99     virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
100     virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWorld);
101     virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
102     virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail& detail);
103     virtual void updateSpellingUIWithMisspelledWord(const String&);
104     virtual void showSpellingUI(bool show);
105     virtual bool spellingUIIsShowing();
106     virtual void getGuessesForWord(const String&, WTF::Vector<String>& guesses);
107     virtual void setInputMethodState(bool);
108 
109     // Android specific:
setPage(Page * page)110     void setPage(Page* page) { m_page = page; }
setShouldChangeSelectedRange(bool shouldChangeSelectedRange)111     void setShouldChangeSelectedRange(bool shouldChangeSelectedRange) { m_shouldChangeSelectedRange = shouldChangeSelectedRange; }
setUiGeneratedSelectionChange(bool uiGenerated)112     void setUiGeneratedSelectionChange(bool uiGenerated) { m_uiGeneratedSelectionChange = uiGenerated; }
113 private:
114     Page* m_page;
115     bool  m_shouldChangeSelectedRange;
116     bool  m_uiGeneratedSelectionChange;
117 };
118 
119 }
120 
121 #endif
122