2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef EditorClient_h
28 #define EditorClient_h
30 #include "EditorInsertAction.h"
31 #include "FloatRect.h"
32 #include "TextAffinity.h"
33 #include "TextChecking.h"
35 #include <wtf/Forward.h>
36 #include <wtf/Vector.h>
39 OBJC_CLASS NSAttributedString;
46 class ArchiveResource;
47 class DocumentFragment;
56 class StylePropertySet;
57 class TextCheckerClient;
58 class VisibleSelection;
59 class VisiblePosition;
65 virtual ~EditorClient() { }
66 virtual void pageDestroyed() = 0;
67 virtual void frameWillDetachPage(Frame*) = 0;
69 virtual bool shouldDeleteRange(Range*) = 0;
70 virtual bool shouldShowDeleteInterface(HTMLElement*) = 0;
71 virtual bool smartInsertDeleteEnabled() = 0;
72 virtual bool isSelectTrailingWhitespaceEnabled() = 0;
73 virtual bool isContinuousSpellCheckingEnabled() = 0;
74 virtual void toggleContinuousSpellChecking() = 0;
75 virtual bool isGrammarCheckingEnabled() = 0;
76 virtual void toggleGrammarChecking() = 0;
77 virtual int spellCheckerDocumentTag() = 0;
79 virtual bool shouldBeginEditing(Range*) = 0;
80 virtual bool shouldEndEditing(Range*) = 0;
81 virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) = 0;
82 virtual bool shouldInsertText(const String&, Range*, EditorInsertAction) = 0;
83 virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting) = 0;
85 virtual bool shouldApplyStyle(StylePropertySet*, Range*) = 0;
86 virtual bool shouldMoveRangeAfterDelete(Range*, Range*) = 0;
88 virtual void didBeginEditing() = 0;
89 virtual void respondToChangedContents() = 0;
90 virtual void respondToChangedSelection(Frame*) = 0;
91 virtual void didEndEditing() = 0;
92 virtual void didWriteSelectionToPasteboard() = 0;
93 virtual void didSetSelectionTypesForPasteboard() = 0;
95 virtual void registerUndoStep(PassRefPtr<UndoStep>) = 0;
96 virtual void registerRedoStep(PassRefPtr<UndoStep>) = 0;
97 virtual void clearUndoRedoOperations() = 0;
99 virtual bool canCopyCut(Frame*, bool defaultValue) const = 0;
100 virtual bool canPaste(Frame*, bool defaultValue) const = 0;
101 virtual bool canUndo() const = 0;
102 virtual bool canRedo() const = 0;
104 virtual void undo() = 0;
105 virtual void redo() = 0;
107 virtual void handleKeyboardEvent(KeyboardEvent*) = 0;
108 virtual void handleInputMethodKeydown(KeyboardEvent*) = 0;
110 virtual void textFieldDidBeginEditing(Element*) = 0;
111 virtual void textFieldDidEndEditing(Element*) = 0;
112 virtual void textDidChangeInTextField(Element*) = 0;
113 virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*) = 0;
114 virtual void textWillBeDeletedInTextField(Element*) = 0;
115 virtual void textDidChangeInTextArea(Element*) = 0;
118 virtual NSString* userVisibleString(NSURL*) = 0;
119 virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector< RefPtr<ArchiveResource> >&) = 0;
120 virtual void setInsertionPasteboard(const String& pasteboardName) = 0;
121 virtual NSURL* canonicalizeURL(NSURL*) = 0;
122 virtual NSURL* canonicalizeURLString(NSString*) = 0;
126 virtual void uppercaseWord() = 0;
127 virtual void lowercaseWord() = 0;
128 virtual void capitalizeWord() = 0;
130 #if USE(AUTOMATIC_TEXT_REPLACEMENT)
131 virtual void showSubstitutionsPanel(bool show) = 0;
132 virtual bool substitutionsPanelIsShowing() = 0;
133 virtual void toggleSmartInsertDelete() = 0;
134 virtual bool isAutomaticQuoteSubstitutionEnabled() = 0;
135 virtual void toggleAutomaticQuoteSubstitution() = 0;
136 virtual bool isAutomaticLinkDetectionEnabled() = 0;
137 virtual void toggleAutomaticLinkDetection() = 0;
138 virtual bool isAutomaticDashSubstitutionEnabled() = 0;
139 virtual void toggleAutomaticDashSubstitution() = 0;
140 virtual bool isAutomaticTextReplacementEnabled() = 0;
141 virtual void toggleAutomaticTextReplacement() = 0;
142 virtual bool isAutomaticSpellingCorrectionEnabled() = 0;
143 virtual void toggleAutomaticSpellingCorrection() = 0;
147 virtual bool shouldShowUnicodeMenu() = 0;
150 virtual TextCheckerClient* textChecker() = 0;
152 virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail& detail) = 0;
153 virtual void updateSpellingUIWithMisspelledWord(const String&) = 0;
154 virtual void showSpellingUI(bool show) = 0;
155 virtual bool spellingUIIsShowing() = 0;
156 virtual void willSetInputMethodState() = 0;
157 virtual void setInputMethodState(bool enabled) = 0;
158 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
159 virtual void setClipboardData(const String& data, const String& type) = 0;
160 virtual void setClipboardDataForPaste(const String& data, const String& type) = 0;
161 virtual void clearClipboardData() = 0;
164 #if ENABLE(TIZEN_ISF_PORT)
165 virtual void didCancelComposition(Node*) = 0;
171 #endif // EditorClient_h