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.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef EditorClientQt_h
31 #define EditorClientQt_h
33 #include "EditorClient.h"
34 #include "RefCounted.h"
35 #include "TextCheckerClientQt.h"
36 #include <wtf/Forward.h>
42 class EditorClientQt : public EditorClient {
44 EditorClientQt(QWebPage* page);
46 virtual void pageDestroyed();
48 virtual bool shouldDeleteRange(Range*);
49 virtual bool shouldShowDeleteInterface(HTMLElement*);
50 virtual bool smartInsertDeleteEnabled();
51 virtual void toggleSmartInsertDelete();
52 virtual bool isSelectTrailingWhitespaceEnabled();
53 virtual bool isContinuousSpellCheckingEnabled();
54 virtual void toggleContinuousSpellChecking();
55 virtual bool isGrammarCheckingEnabled();
56 virtual void toggleGrammarChecking();
57 virtual int spellCheckerDocumentTag();
58 virtual bool selectWordBeforeMenuEvent();
60 virtual bool shouldBeginEditing(Range*);
61 virtual bool shouldEndEditing(Range*);
62 virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
63 virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
64 virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting);
66 virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
68 virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
70 virtual void didBeginEditing();
71 virtual void respondToChangedContents();
72 virtual void respondToChangedSelection(Frame*);
73 virtual void didEndEditing();
74 virtual void didWriteSelectionToPasteboard();
75 virtual void didSetSelectionTypesForPasteboard();
77 virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
78 virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
79 virtual void clearUndoRedoOperations();
81 virtual bool canCopyCut(Frame*, bool defaultValue) const;
82 virtual bool canPaste(Frame*, bool defaultValue) const;
83 virtual bool canUndo() const;
84 virtual bool canRedo() const;
89 virtual void handleKeyboardEvent(KeyboardEvent*);
90 virtual void handleInputMethodKeydown(KeyboardEvent*);
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*);
99 virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
100 virtual void updateSpellingUIWithMisspelledWord(const String&);
101 virtual void showSpellingUI(bool show);
102 virtual bool spellingUIIsShowing();
103 virtual void willSetInputMethodState();
104 virtual void setInputMethodState(bool enabled);
105 virtual TextCheckerClient* textChecker() { return &m_textCheckerClient; }
107 bool isEditing() const;
109 static bool dumpEditingCallbacks;
110 static bool acceptsEditing;
113 TextCheckerClientQt m_textCheckerClient;
116 bool m_inUndoRedo; // our undo stack works differently - don't re-enter!