• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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) 2007 Ryan Leavengood <leavengood@gmail.com>
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26  * 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 EditorClientHaiku_H
32 #define EditorClientHaiku_H
33 
34 #include "EditorClient.h"
35 #include "RefCounted.h"
36 #include "Page.h"
37 
38 #include <wtf/Forward.h>
39 
40 
41 namespace WebCore {
42 
43     class EditorClientHaiku : public EditorClient {
44     public:
45         EditorClientHaiku();
46         void setPage( Page* page );
47 
48         virtual void pageDestroyed();
49 
50         virtual bool shouldDeleteRange(Range*);
51         virtual bool shouldShowDeleteInterface(HTMLElement*);
52         virtual bool smartInsertDeleteEnabled();
53         virtual bool isSelectTrailingWhitespaceEnabled();
54         virtual bool isContinuousSpellCheckingEnabled();
55         virtual void toggleContinuousSpellChecking();
56         virtual bool isGrammarCheckingEnabled();
57         virtual void toggleGrammarChecking();
58         virtual int spellCheckerDocumentTag();
59 
60         virtual bool isEditable();
61 
62         virtual bool shouldBeginEditing(Range*);
63         virtual bool shouldEndEditing(Range*);
64         virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
65         virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
66         virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange,
67                                                EAffinity, bool stillSelecting);
68 
69         virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
70         virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
71 
72         virtual void didBeginEditing();
73         virtual void respondToChangedContents();
74         virtual void respondToChangedSelection();
75         virtual void didEndEditing();
76         virtual void didWriteSelectionToPasteboard();
77         virtual void didSetSelectionTypesForPasteboard();
78 
79         virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
80         virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
81         virtual void clearUndoRedoOperations();
82 
83         virtual bool canUndo() const;
84         virtual bool canRedo() const;
85 
86         virtual void undo();
87         virtual void redo();
88 
89         virtual void handleKeyboardEvent(KeyboardEvent*);
90         virtual void handleInputMethodKeydown(KeyboardEvent*);
91 
92         virtual void textFieldDidBeginEditing(Element*);
93         virtual void textFieldDidEndEditing(Element*);
94         virtual void textDidChangeInTextField(Element*);
95         virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
96         virtual void textWillBeDeletedInTextField(Element*);
97         virtual void textDidChangeInTextArea(Element*);
98 
99         virtual void ignoreWordInSpellDocument(const String&);
100         virtual void learnWord(const String&);
101         virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation,
102                                            int* misspellingLength);
103         virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);
104         virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&,
105                                           int* badGrammarLocation, int* badGrammarLength);
106         virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
107         virtual void updateSpellingUIWithMisspelledWord(const String&);
108         virtual void showSpellingUI(bool show);
109         virtual bool spellingUIIsShowing();
110         virtual void getGuessesForWord(const String&, Vector<String>& guesses);
111         virtual void setInputMethodState(bool enabled);
112 
113         bool isEditing() const;
114 
115     private:
116         Page* m_page;
117         bool m_editing;
118         bool m_inUndoRedo; // our undo stack works differently - don't re-enter!
119     };
120 
121 } // namespace WebCore
122 
123 #endif // EditorClientHaiku_h
124 
125