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 * 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 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. 16 * 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. 28 */ 29 30 #ifndef EditorClientQt_h 31 #define EditorClientQt_h 32 33 #include "EditorClient.h" 34 #include "TextCheckerClient.h" 35 #include "RefCounted.h" 36 37 #include <wtf/Forward.h> 38 39 class QWebPage; 40 41 namespace WebCore { 42 43 class EditorClientQt : public EditorClient, public TextCheckerClient { 44 public: 45 EditorClientQt(QWebPage* page); 46 47 virtual void pageDestroyed(); 48 49 virtual bool shouldDeleteRange(Range*); 50 virtual bool shouldShowDeleteInterface(HTMLElement*); 51 virtual bool smartInsertDeleteEnabled(); 52 virtual void toggleSmartInsertDelete(); 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 virtual bool selectWordBeforeMenuEvent(); 60 61 virtual bool shouldBeginEditing(Range*); 62 virtual bool shouldEndEditing(Range*); 63 virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction); 64 virtual bool shouldInsertText(const String&, Range*, EditorInsertAction); 65 virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting); 66 67 virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*); 68 69 virtual bool shouldMoveRangeAfterDelete(Range*, Range*); 70 71 virtual void didBeginEditing(); 72 virtual void respondToChangedContents(); 73 virtual void respondToChangedSelection(); 74 virtual void didEndEditing(); 75 virtual void didWriteSelectionToPasteboard(); 76 virtual void didSetSelectionTypesForPasteboard(); 77 78 virtual void registerCommandForUndo(PassRefPtr<EditCommand>); 79 virtual void registerCommandForRedo(PassRefPtr<EditCommand>); 80 virtual void clearUndoRedoOperations(); 81 82 virtual bool canCopyCut(bool defaultValue) const; 83 virtual bool canPaste(bool defaultValue) const; 84 virtual bool canUndo() const; 85 virtual bool canRedo() const; 86 87 virtual void undo(); 88 virtual void redo(); 89 90 virtual void handleKeyboardEvent(KeyboardEvent*); 91 virtual void handleInputMethodKeydown(KeyboardEvent*); 92 93 virtual void textFieldDidBeginEditing(Element*); 94 virtual void textFieldDidEndEditing(Element*); 95 virtual void textDidChangeInTextField(Element*); 96 virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*); 97 virtual void textWillBeDeletedInTextField(Element*); 98 virtual void textDidChangeInTextArea(Element*); 99 100 virtual void ignoreWordInSpellDocument(const String&); 101 virtual void learnWord(const String&); 102 virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength); 103 virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord); 104 virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); 105 virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&); 106 virtual void updateSpellingUIWithMisspelledWord(const String&); 107 virtual void showSpellingUI(bool show); 108 virtual bool spellingUIIsShowing(); 109 virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses); 110 virtual void willSetInputMethodState(); 111 virtual void setInputMethodState(bool enabled); requestCheckingOfString(SpellChecker *,int,WebCore::TextCheckingTypeMask,const String &)112 virtual void requestCheckingOfString(SpellChecker*, int, WebCore::TextCheckingTypeMask, const String&) {} textChecker()113 virtual TextCheckerClient* textChecker() { return this; } 114 115 bool isEditing() const; 116 117 static bool dumpEditingCallbacks; 118 static bool acceptsEditing; 119 120 private: 121 QWebPage* m_page; 122 bool m_editing; 123 bool m_inUndoRedo; // our undo stack works differently - don't re-enter! 124 }; 125 126 } 127 128 #endif 129 130 // vim: ts=4 sw=4 et 131