1 /* 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15 * its contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #import <WebCore/EditorClient.h> 31 #import <wtf/RetainPtr.h> 32 #import <wtf/Forward.h> 33 #import <wtf/Vector.h> 34 35 @class WebView; 36 @class WebEditorUndoTarget; 37 38 class WebEditorClient : public WebCore::EditorClient { 39 public: 40 WebEditorClient(WebView *); 41 42 virtual void pageDestroyed(); 43 44 virtual bool isGrammarCheckingEnabled(); 45 virtual void toggleGrammarChecking(); 46 virtual bool isContinuousSpellCheckingEnabled(); 47 virtual void toggleContinuousSpellChecking(); 48 virtual int spellCheckerDocumentTag(); 49 50 virtual bool smartInsertDeleteEnabled(); 51 virtual bool isSelectTrailingWhitespaceEnabled(); 52 virtual bool isEditable(); 53 54 virtual bool shouldDeleteRange(WebCore::Range*); 55 virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*); 56 57 virtual bool shouldBeginEditing(WebCore::Range*); 58 virtual bool shouldEndEditing(WebCore::Range*); 59 virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction); 60 virtual bool shouldInsertText(const WebCore::String&, WebCore::Range*, WebCore::EditorInsertAction); 61 virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting); 62 63 virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*); 64 65 virtual bool shouldMoveRangeAfterDelete(WebCore::Range* range, WebCore::Range* rangeToBeReplaced); 66 67 virtual void didBeginEditing(); 68 virtual void didEndEditing(); 69 virtual void didWriteSelectionToPasteboard(); 70 virtual void didSetSelectionTypesForPasteboard(); 71 72 virtual NSString* userVisibleString(NSURL*); 73 #ifdef BUILDING_ON_TIGER 74 virtual NSArray* pasteboardTypesForSelection(WebCore::Frame*); 75 #endif 76 77 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 78 virtual void uppercaseWord(); 79 virtual void lowercaseWord(); 80 virtual void capitalizeWord(); 81 virtual void showSubstitutionsPanel(bool show); 82 virtual bool substitutionsPanelIsShowing(); 83 virtual void toggleSmartInsertDelete(); 84 virtual bool isAutomaticQuoteSubstitutionEnabled(); 85 virtual void toggleAutomaticQuoteSubstitution(); 86 virtual bool isAutomaticLinkDetectionEnabled(); 87 virtual void toggleAutomaticLinkDetection(); 88 virtual bool isAutomaticDashSubstitutionEnabled(); 89 virtual void toggleAutomaticDashSubstitution(); 90 virtual bool isAutomaticTextReplacementEnabled(); 91 virtual void toggleAutomaticTextReplacement(); 92 virtual bool isAutomaticSpellingCorrectionEnabled(); 93 virtual void toggleAutomaticSpellingCorrection(); 94 #endif 95 96 virtual void respondToChangedContents(); 97 virtual void respondToChangedSelection(); 98 99 virtual void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>); 100 virtual void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>); 101 virtual void clearUndoRedoOperations(); 102 103 virtual bool canUndo() const; 104 virtual bool canRedo() const; 105 106 virtual void undo(); 107 virtual void redo(); 108 109 virtual void handleKeyboardEvent(WebCore::KeyboardEvent*); 110 virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*); 111 112 virtual void textFieldDidBeginEditing(WebCore::Element*); 113 virtual void textFieldDidEndEditing(WebCore::Element*); 114 virtual void textDidChangeInTextField(WebCore::Element*); 115 virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*); 116 virtual void textWillBeDeletedInTextField(WebCore::Element*); 117 virtual void textDidChangeInTextArea(WebCore::Element*); 118 119 virtual void ignoreWordInSpellDocument(const WebCore::String&); 120 virtual void learnWord(const WebCore::String&); 121 virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength); 122 virtual WebCore::String getAutoCorrectSuggestionForMisspelledWord(const WebCore::String&); 123 virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); 124 virtual void checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, WTF::Vector<WebCore::TextCheckingResult>& results); 125 virtual void updateSpellingUIWithGrammarString(const WebCore::String&, const WebCore::GrammarDetail&); 126 virtual void updateSpellingUIWithMisspelledWord(const WebCore::String&); 127 virtual void showSpellingUI(bool show); 128 virtual bool spellingUIIsShowing(); 129 virtual void getGuessesForWord(const WebCore::String&, WTF::Vector<WebCore::String>& guesses); 130 virtual void setInputMethodState(bool enabled); 131 private: 132 void registerCommandForUndoOrRedo(PassRefPtr<WebCore::EditCommand>, bool isRedo); 133 WebEditorClient(); 134 135 WebView *m_webView; 136 RetainPtr<WebEditorUndoTarget> m_undoTarget; 137 138 bool m_haveUndoRedoOperations; 139 }; 140