1/* 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 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 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef WebEditorClient_h 27#define WebEditorClient_h 28 29#include <WebCore/EditorClient.h> 30#include <WebCore/TextCheckerClient.h> 31 32namespace WebKit { 33 34class WebPage; 35 36class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient { 37public: 38 WebEditorClient(WebPage* page) 39 : m_page(page) 40 { 41 } 42 43private: 44 virtual void pageDestroyed() OVERRIDE; 45 virtual void frameWillDetachPage(WebCore::Frame*) OVERRIDE { } 46 47 virtual bool shouldDeleteRange(WebCore::Range*) OVERRIDE; 48 virtual bool smartInsertDeleteEnabled() OVERRIDE; 49 virtual bool isSelectTrailingWhitespaceEnabled() OVERRIDE; 50 virtual bool isContinuousSpellCheckingEnabled() OVERRIDE; 51 virtual void toggleContinuousSpellChecking() OVERRIDE; 52 virtual bool isGrammarCheckingEnabled() OVERRIDE; 53 virtual void toggleGrammarChecking() OVERRIDE; 54 virtual int spellCheckerDocumentTag() OVERRIDE; 55 56 virtual bool shouldBeginEditing(WebCore::Range*) OVERRIDE; 57 virtual bool shouldEndEditing(WebCore::Range*) OVERRIDE; 58 virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) OVERRIDE; 59 virtual bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) OVERRIDE; 60 virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) OVERRIDE; 61 62 virtual bool shouldApplyStyle(WebCore::StylePropertySet*, WebCore::Range*) OVERRIDE; 63 virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*) OVERRIDE; 64 65 virtual void didBeginEditing() OVERRIDE; 66 virtual void respondToChangedContents() OVERRIDE; 67 virtual void respondToChangedSelection(WebCore::Frame*) OVERRIDE; 68 virtual void didEndEditing() OVERRIDE; 69 virtual void willWriteSelectionToPasteboard(WebCore::Range*) OVERRIDE; 70 virtual void didWriteSelectionToPasteboard() OVERRIDE; 71 virtual void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) OVERRIDE; 72 virtual void didSetSelectionTypesForPasteboard() OVERRIDE; 73 74 virtual void registerUndoStep(PassRefPtr<WebCore::UndoStep>) OVERRIDE; 75 virtual void registerRedoStep(PassRefPtr<WebCore::UndoStep>) OVERRIDE; 76 virtual void clearUndoRedoOperations() OVERRIDE; 77 78 virtual bool canCopyCut(WebCore::Frame*, bool defaultValue) const OVERRIDE; 79 virtual bool canPaste(WebCore::Frame*, bool defaultValue) const OVERRIDE; 80 virtual bool canUndo() const OVERRIDE; 81 virtual bool canRedo() const OVERRIDE; 82 83 virtual void undo() OVERRIDE; 84 virtual void redo() OVERRIDE; 85 86 virtual void handleKeyboardEvent(WebCore::KeyboardEvent*) OVERRIDE; 87 virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*) OVERRIDE; 88 89 virtual void textFieldDidBeginEditing(WebCore::Element*) OVERRIDE; 90 virtual void textFieldDidEndEditing(WebCore::Element*) OVERRIDE; 91 virtual void textDidChangeInTextField(WebCore::Element*) OVERRIDE; 92 virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) OVERRIDE; 93 virtual void textWillBeDeletedInTextField(WebCore::Element*) OVERRIDE; 94 virtual void textDidChangeInTextArea(WebCore::Element*) OVERRIDE; 95 96#if PLATFORM(MAC) 97 virtual NSString *userVisibleString(NSURL *) OVERRIDE; 98 virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource>>&) OVERRIDE; 99 virtual void setInsertionPasteboard(const String& pasteboardName) OVERRIDE; 100 virtual NSURL* canonicalizeURL(NSURL*) OVERRIDE; 101 virtual NSURL* canonicalizeURLString(NSString*) OVERRIDE; 102#endif 103 104#if USE(APPKIT) 105 virtual void uppercaseWord() OVERRIDE; 106 virtual void lowercaseWord() OVERRIDE; 107 virtual void capitalizeWord() OVERRIDE; 108#endif 109#if USE(AUTOMATIC_TEXT_REPLACEMENT) 110 virtual void showSubstitutionsPanel(bool show) OVERRIDE; 111 virtual bool substitutionsPanelIsShowing() OVERRIDE; 112 virtual void toggleSmartInsertDelete() OVERRIDE; 113 virtual bool isAutomaticQuoteSubstitutionEnabled() OVERRIDE; 114 virtual void toggleAutomaticQuoteSubstitution() OVERRIDE; 115 virtual bool isAutomaticLinkDetectionEnabled() OVERRIDE; 116 virtual void toggleAutomaticLinkDetection() OVERRIDE; 117 virtual bool isAutomaticDashSubstitutionEnabled() OVERRIDE; 118 virtual void toggleAutomaticDashSubstitution() OVERRIDE; 119 virtual bool isAutomaticTextReplacementEnabled() OVERRIDE; 120 virtual void toggleAutomaticTextReplacement() OVERRIDE; 121 virtual bool isAutomaticSpellingCorrectionEnabled() OVERRIDE; 122 virtual void toggleAutomaticSpellingCorrection() OVERRIDE; 123#endif 124 125#if ENABLE(DELETION_UI) 126 virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*) OVERRIDE; 127#endif 128 129#if PLATFORM(GTK) 130 bool executePendingEditorCommands(WebCore::Frame*, Vector<WTF::String>, bool); 131 void getEditorCommandsForKeyEvent(const WebCore::KeyboardEvent*, Vector<WTF::String>&); 132#endif 133#if PLATFORM(GTK) || PLATFORM(QT) 134 void updateGlobalSelection(WebCore::Frame*); 135#endif 136 137 TextCheckerClient* textChecker() OVERRIDE { return this; } 138 139 virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const OVERRIDE; 140 virtual void ignoreWordInSpellDocument(const String&) OVERRIDE; 141 virtual void learnWord(const String&) OVERRIDE; 142 virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) OVERRIDE; 143 virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) OVERRIDE; 144 virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) OVERRIDE; 145#if USE(UNIFIED_TEXT_CHECKING) 146 virtual void checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, Vector<WebCore::TextCheckingResult>& results) OVERRIDE; 147#endif 148 virtual void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) OVERRIDE; 149 virtual void updateSpellingUIWithMisspelledWord(const String&) OVERRIDE; 150 virtual void showSpellingUI(bool show) OVERRIDE; 151 virtual bool spellingUIIsShowing() OVERRIDE; 152 virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) OVERRIDE; 153 virtual void willSetInputMethodState() OVERRIDE; 154 virtual void setInputMethodState(bool enabled) OVERRIDE; 155 virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) OVERRIDE; 156#if PLATFORM(GTK) 157 virtual bool shouldShowUnicodeMenu() OVERRIDE; 158#endif 159 160 virtual bool supportsGlobalSelection() OVERRIDE; 161 162 WebPage* m_page; 163}; 164 165} // namespace WebKit 166 167#endif // WebEditorClient_h 168