aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | 6727664 | 2016-08-16 16:56:07 +0000 | [diff] [blame] | 2 | * Copyright (C) 2006-2016 Apple Inc. All rights reserved. |
hausmann@webkit.org | f696447 | 2008-09-29 12:47:08 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 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 | * 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. |
| 13 | * |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 14 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 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. |
| 25 | */ |
| 26 | |
darin@apple.com | 6727664 | 2016-08-16 16:56:07 +0000 | [diff] [blame] | 27 | #pragma once |
aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 28 | |
bdakin | 8254b19 | 2006-11-20 01:21:56 +0000 | [diff] [blame] | 29 | #include "EditorInsertAction.h" |
mjs | c13fa54 | 2007-02-19 07:54:13 +0000 | [diff] [blame] | 30 | #include "TextAffinity.h" |
aestes@apple.com | dc9c852 | 2012-05-31 21:03:16 +0000 | [diff] [blame] | 31 | #include "TextChecking.h" |
rniwa@webkit.org | 12e984a | 2011-12-16 22:04:58 +0000 | [diff] [blame] | 32 | #include "UndoStep.h" |
ggaren | f8a628d | 2006-11-28 18:54:03 +0000 | [diff] [blame] | 33 | #include <wtf/Forward.h> |
sfalken | 9363b00 | 2007-04-25 04:22:56 +0000 | [diff] [blame] | 34 | #include <wtf/Vector.h> |
darin | d1fbfdc | 2007-02-12 19:05:07 +0000 | [diff] [blame] | 35 | |
mitz@apple.com | 28c9d4a | 2014-02-08 22:26:50 +0000 | [diff] [blame] | 36 | #if PLATFORM(COCOA) |
weinig@apple.com | c122cb2 | 2012-01-17 23:46:16 +0000 | [diff] [blame] | 37 | OBJC_CLASS NSString; |
| 38 | OBJC_CLASS NSURL; |
andersca@apple.com | c71279a | 2010-06-18 21:09:31 +0000 | [diff] [blame] | 39 | #endif |
bdakin | 8254b19 | 2006-11-20 01:21:56 +0000 | [diff] [blame] | 40 | |
dbates@webkit.org | 4da1af8 | 2013-12-27 20:40:28 +0000 | [diff] [blame] | 41 | #if PLATFORM(IOS) |
| 42 | OBJC_CLASS NSArray; |
| 43 | OBJC_CLASS NSDictionary; |
| 44 | #endif |
| 45 | |
aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 46 | namespace WebCore { |
| 47 | |
enrica@apple.com | 0f0dd6c | 2010-09-13 19:16:23 +0000 | [diff] [blame] | 48 | class ArchiveResource; |
enrica@apple.com | 0f0dd6c | 2010-09-13 19:16:23 +0000 | [diff] [blame] | 49 | class DocumentFragment; |
mitz@apple.com | 1f24e24 | 2010-09-02 06:43:50 +0000 | [diff] [blame] | 50 | class Editor; |
mjs | c13fa54 | 2007-02-19 07:54:13 +0000 | [diff] [blame] | 51 | class Element; |
aliceli1 | c68d2a4 | 2006-11-29 07:25:53 +0000 | [diff] [blame] | 52 | class Frame; |
thatcher | f780fa7 | 2006-10-21 18:40:03 +0000 | [diff] [blame] | 53 | class HTMLElement; |
adele | 1c20483 | 2007-01-23 19:37:35 +0000 | [diff] [blame] | 54 | class KeyboardEvent; |
beidson@apple.com | 29a2efc | 2014-04-25 22:22:14 +0000 | [diff] [blame] | 55 | class LayoutRect; |
aliceli1 | 68b1393 | 2006-11-28 22:02:12 +0000 | [diff] [blame] | 56 | class Node; |
andersca | f623201 | 2006-11-15 00:36:50 +0000 | [diff] [blame] | 57 | class Range; |
enrica@apple.com | 7eb1d5b | 2013-01-31 21:14:58 +0000 | [diff] [blame] | 58 | class SharedBuffer; |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 59 | class StyleProperties; |
morrita@google.com | 7692b42 | 2011-02-15 08:28:20 +0000 | [diff] [blame] | 60 | class TextCheckerClient; |
eric@webkit.org | 87ea95c | 2009-02-09 21:43:24 +0000 | [diff] [blame] | 61 | class VisibleSelection; |
sfalken | 9363b00 | 2007-04-25 04:22:56 +0000 | [diff] [blame] | 62 | class VisiblePosition; |
| 63 | |
beidson@apple.com | d5d9b08 | 2014-07-03 17:56:38 +0000 | [diff] [blame] | 64 | struct GapRects; |
morrita@google.com | 9b3829f | 2011-02-15 09:57:59 +0000 | [diff] [blame] | 65 | struct GrammarDetail; |
| 66 | |
ggaren | f8a628d | 2006-11-28 18:54:03 +0000 | [diff] [blame] | 67 | class EditorClient { |
aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 68 | public: |
ggaren | f8a628d | 2006-11-28 18:54:03 +0000 | [diff] [blame] | 69 | virtual ~EditorClient() { } |
morrita@google.com | 9da7b7c | 2012-05-18 10:17:52 +0000 | [diff] [blame] | 70 | |
ggaren | a425170 | 2006-10-31 23:56:37 +0000 | [diff] [blame] | 71 | virtual bool shouldDeleteRange(Range*) = 0; |
bdakin | 08b0dce | 2006-12-12 04:27:17 +0000 | [diff] [blame] | 72 | virtual bool smartInsertDeleteEnabled() = 0; |
achristensen@apple.com | 09e70aa | 2017-04-27 16:42:13 +0000 | [diff] [blame] | 73 | virtual bool isSelectTrailingWhitespaceEnabled() const = 0; |
sullivan | 63afd75 | 2006-10-31 01:25:52 +0000 | [diff] [blame] | 74 | virtual bool isContinuousSpellCheckingEnabled() = 0; |
bdakin | 08b0dce | 2006-12-12 04:27:17 +0000 | [diff] [blame] | 75 | virtual void toggleContinuousSpellChecking() = 0; |
sullivan | 63afd75 | 2006-10-31 01:25:52 +0000 | [diff] [blame] | 76 | virtual bool isGrammarCheckingEnabled() = 0; |
bdakin | 08b0dce | 2006-12-12 04:27:17 +0000 | [diff] [blame] | 77 | virtual void toggleGrammarChecking() = 0; |
sullivan | 63afd75 | 2006-10-31 01:25:52 +0000 | [diff] [blame] | 78 | virtual int spellCheckerDocumentTag() = 0; |
thatcher | f780fa7 | 2006-10-21 18:40:03 +0000 | [diff] [blame] | 79 | |
andersca | f2ad1b5 | 2006-11-09 00:51:35 +0000 | [diff] [blame] | 80 | virtual bool shouldBeginEditing(Range*) = 0; |
| 81 | virtual bool shouldEndEditing(Range*) = 0; |
aliceli1 | 68b1393 | 2006-11-28 22:02:12 +0000 | [diff] [blame] | 82 | virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) = 0; |
andersca@apple.com | 886544a | 2008-04-24 17:45:17 +0000 | [diff] [blame] | 83 | virtual bool shouldInsertText(const String&, Range*, EditorInsertAction) = 0; |
mjs | c13fa54 | 2007-02-19 07:54:13 +0000 | [diff] [blame] | 84 | virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting) = 0; |
| 85 | |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 86 | virtual bool shouldApplyStyle(StyleProperties*, Range*) = 0; |
rniwa@webkit.org | 669d79f | 2015-06-29 21:38:31 +0000 | [diff] [blame] | 87 | virtual void didApplyStyle() = 0; |
justing | f90e28d | 2007-07-30 18:25:19 +0000 | [diff] [blame] | 88 | virtual bool shouldMoveRangeAfterDelete(Range*, Range*) = 0; |
darin | d1fbfdc | 2007-02-12 19:05:07 +0000 | [diff] [blame] | 89 | |
andersca | f2ad1b5 | 2006-11-09 00:51:35 +0000 | [diff] [blame] | 90 | virtual void didBeginEditing() = 0; |
andersca | 3a62128 | 2006-11-09 19:48:13 +0000 | [diff] [blame] | 91 | virtual void respondToChangedContents() = 0; |
tonikitoo@webkit.org | 73c1c05 | 2011-11-20 23:55:31 +0000 | [diff] [blame] | 92 | virtual void respondToChangedSelection(Frame*) = 0; |
cdumez@apple.com | 5119298 | 2015-04-09 18:31:51 +0000 | [diff] [blame] | 93 | virtual void didChangeSelectionAndUpdateLayout() = 0; |
bdakin@apple.com | fe13ad3 | 2016-09-02 23:14:34 +0000 | [diff] [blame] | 94 | virtual void updateEditorStateAfterLayoutIfEditabilityChanged() = 0; |
andersca | f2ad1b5 | 2006-11-09 00:51:35 +0000 | [diff] [blame] | 95 | virtual void didEndEditing() = 0; |
enrica@apple.com | 7eb1d5b | 2013-01-31 21:14:58 +0000 | [diff] [blame] | 96 | virtual void willWriteSelectionToPasteboard(Range*) = 0; |
aliceli1 | bab4132 | 2007-01-17 04:37:25 +0000 | [diff] [blame] | 97 | virtual void didWriteSelectionToPasteboard() = 0; |
andersca@apple.com | c3523f8 | 2013-10-18 23:41:24 +0000 | [diff] [blame] | 98 | virtual void getClientPasteboardDataForRange(Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData) = 0; |
bdakin@apple.com | 92fe7c1 | 2016-04-05 23:33:47 +0000 | [diff] [blame] | 99 | virtual void requestCandidatesForSelection(const VisibleSelection&) { } |
bdakin@apple.com | 24fba1e | 2016-05-17 23:24:19 +0000 | [diff] [blame] | 100 | virtual void handleAcceptedCandidateWithSoftSpaces(TextCheckingResult) { } |
ap@apple.com | c985136 | 2014-12-11 17:23:34 +0000 | [diff] [blame] | 101 | |
| 102 | // Notify an input method that a composition was voluntarily discarded by WebCore, so that it could clean up too. |
| 103 | // This function is not called when a composition is closed per a request from an input method. |
| 104 | virtual void discardedComposition(Frame*) = 0; |
wenson_hsieh@apple.com | 60bcd7a | 2016-11-04 23:55:00 +0000 | [diff] [blame] | 105 | virtual void canceledComposition() = 0; |
ap@apple.com | c985136 | 2014-12-11 17:23:34 +0000 | [diff] [blame] | 106 | |
darin@apple.com | c04189e | 2017-01-18 05:17:17 +0000 | [diff] [blame] | 107 | virtual void registerUndoStep(UndoStep&) = 0; |
| 108 | virtual void registerRedoStep(UndoStep&) = 0; |
andersca | f623201 | 2006-11-15 00:36:50 +0000 | [diff] [blame] | 109 | virtual void clearUndoRedoOperations() = 0; |
| 110 | |
rniwa@webkit.org | f5a84a0 | 2011-04-22 00:33:21 +0000 | [diff] [blame] | 111 | virtual bool canCopyCut(Frame*, bool defaultValue) const = 0; |
| 112 | virtual bool canPaste(Frame*, bool defaultValue) const = 0; |
andersca | f623201 | 2006-11-15 00:36:50 +0000 | [diff] [blame] | 113 | virtual bool canUndo() const = 0; |
| 114 | virtual bool canRedo() const = 0; |
| 115 | |
| 116 | virtual void undo() = 0; |
| 117 | virtual void redo() = 0; |
aliceli1 | 68b1393 | 2006-11-28 22:02:12 +0000 | [diff] [blame] | 118 | |
ap@webkit.org | 6a50667 | 2007-12-11 19:11:46 +0000 | [diff] [blame] | 119 | virtual void handleKeyboardEvent(KeyboardEvent*) = 0; |
| 120 | virtual void handleInputMethodKeydown(KeyboardEvent*) = 0; |
mjs | c13fa54 | 2007-02-19 07:54:13 +0000 | [diff] [blame] | 121 | |
| 122 | virtual void textFieldDidBeginEditing(Element*) = 0; |
| 123 | virtual void textFieldDidEndEditing(Element*) = 0; |
| 124 | virtual void textDidChangeInTextField(Element*) = 0; |
| 125 | virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*) = 0; |
| 126 | virtual void textWillBeDeletedInTextField(Element*) = 0; |
| 127 | virtual void textDidChangeInTextArea(Element*) = 0; |
enrica@apple.com | fd21a09 | 2014-07-22 23:28:37 +0000 | [diff] [blame] | 128 | virtual void overflowScrollPositionChanged() = 0; |
adele | 1c20483 | 2007-01-23 19:37:35 +0000 | [diff] [blame] | 129 | |
dbates@webkit.org | 4da1af8 | 2013-12-27 20:40:28 +0000 | [diff] [blame] | 130 | #if PLATFORM(IOS) |
dbates@webkit.org | 4da1af8 | 2013-12-27 20:40:28 +0000 | [diff] [blame] | 131 | virtual void startDelayingAndCoalescingContentChangeNotifications() = 0; |
| 132 | virtual void stopDelayingAndCoalescingContentChangeNotifications() = 0; |
| 133 | virtual void writeDataToPasteboard(NSDictionary*) = 0; |
| 134 | virtual NSArray* supportedPasteboardTypesForCurrentSelection() = 0; |
| 135 | virtual NSArray* readDataFromPasteboard(NSString* type, int index) = 0; |
| 136 | virtual bool hasRichlyEditableSelection() = 0; |
| 137 | virtual int getPasteboardItemsCount() = 0; |
achristensen@apple.com | 760090a | 2016-08-22 15:51:58 +0000 | [diff] [blame] | 138 | virtual RefPtr<DocumentFragment> documentFragmentFromDelegate(int index) = 0; |
dbates@webkit.org | 4da1af8 | 2013-12-27 20:40:28 +0000 | [diff] [blame] | 139 | virtual bool performsTwoStepPaste(DocumentFragment*) = 0; |
| 140 | virtual int pasteboardChangeCount() = 0; |
| 141 | #endif |
| 142 | |
mitz@apple.com | 28c9d4a | 2014-02-08 22:26:50 +0000 | [diff] [blame] | 143 | #if PLATFORM(COCOA) |
achristensen@apple.com | 760090a | 2016-08-22 15:51:58 +0000 | [diff] [blame] | 144 | virtual NSString *userVisibleString(NSURL *) = 0; |
enrica@apple.com | 3728b40 | 2012-02-28 21:58:25 +0000 | [diff] [blame] | 145 | virtual void setInsertionPasteboard(const String& pasteboardName) = 0; |
achristensen@apple.com | 760090a | 2016-08-22 15:51:58 +0000 | [diff] [blame] | 146 | virtual NSURL *canonicalizeURL(NSURL *) = 0; |
| 147 | virtual NSURL *canonicalizeURLString(NSString *) = 0; |
sfalken | 79a17cb | 2007-04-25 19:01:22 +0000 | [diff] [blame] | 148 | #endif |
| 149 | |
aestes@apple.com | 57b5000 | 2012-06-07 06:20:18 +0000 | [diff] [blame] | 150 | #if USE(APPKIT) |
adele@apple.com | f4cbf34 | 2009-04-27 23:14:33 +0000 | [diff] [blame] | 151 | virtual void uppercaseWord() = 0; |
| 152 | virtual void lowercaseWord() = 0; |
| 153 | virtual void capitalizeWord() = 0; |
aestes@apple.com | dc9c852 | 2012-05-31 21:03:16 +0000 | [diff] [blame] | 154 | #endif |
rniwa@webkit.org | 4098b4e | 2013-02-12 04:55:35 +0000 | [diff] [blame] | 155 | |
aestes@apple.com | dc9c852 | 2012-05-31 21:03:16 +0000 | [diff] [blame] | 156 | #if USE(AUTOMATIC_TEXT_REPLACEMENT) |
adele@apple.com | f4cbf34 | 2009-04-27 23:14:33 +0000 | [diff] [blame] | 157 | virtual void showSubstitutionsPanel(bool show) = 0; |
| 158 | virtual bool substitutionsPanelIsShowing() = 0; |
| 159 | virtual void toggleSmartInsertDelete() = 0; |
| 160 | virtual bool isAutomaticQuoteSubstitutionEnabled() = 0; |
| 161 | virtual void toggleAutomaticQuoteSubstitution() = 0; |
| 162 | virtual bool isAutomaticLinkDetectionEnabled() = 0; |
| 163 | virtual void toggleAutomaticLinkDetection() = 0; |
| 164 | virtual bool isAutomaticDashSubstitutionEnabled() = 0; |
| 165 | virtual void toggleAutomaticDashSubstitution() = 0; |
| 166 | virtual bool isAutomaticTextReplacementEnabled() = 0; |
| 167 | virtual void toggleAutomaticTextReplacement() = 0; |
| 168 | virtual bool isAutomaticSpellingCorrectionEnabled() = 0; |
| 169 | virtual void toggleAutomaticSpellingCorrection() = 0; |
| 170 | #endif |
rniwa@webkit.org | 4098b4e | 2013-02-12 04:55:35 +0000 | [diff] [blame] | 171 | |
carlosgc@webkit.org | d45765c | 2012-03-15 18:28:53 +0000 | [diff] [blame] | 172 | #if PLATFORM(GTK) |
| 173 | virtual bool shouldShowUnicodeMenu() = 0; |
| 174 | #endif |
| 175 | |
morrita@google.com | 7692b42 | 2011-02-15 08:28:20 +0000 | [diff] [blame] | 176 | virtual TextCheckerClient* textChecker() = 0; |
mitz@apple.com | 1f24e24 | 2010-09-02 06:43:50 +0000 | [diff] [blame] | 177 | |
sfalken | 186e602 | 2007-05-08 19:27:50 +0000 | [diff] [blame] | 178 | virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail& detail) = 0; |
sfalken | 9363b00 | 2007-04-25 04:22:56 +0000 | [diff] [blame] | 179 | virtual void updateSpellingUIWithMisspelledWord(const String&) = 0; |
| 180 | virtual void showSpellingUI(bool show) = 0; |
| 181 | virtual bool spellingUIIsShowing() = 0; |
commit-queue@webkit.org | 11f23fe | 2010-07-17 01:05:50 +0000 | [diff] [blame] | 182 | virtual void willSetInputMethodState() = 0; |
oliver | f6949e9 | 2007-09-01 23:04:59 +0000 | [diff] [blame] | 183 | virtual void setInputMethodState(bool enabled) = 0; |
allan.jensen@nokia.com | fc0f6af | 2012-09-07 12:51:44 +0000 | [diff] [blame] | 184 | |
| 185 | // Support for global selections, used on platforms like the X Window System that treat |
| 186 | // selection as a type of clipboard. |
| 187 | virtual bool supportsGlobalSelection() { return false; } |
aliceli1 | 5a36ed9 | 2006-10-20 23:57:05 +0000 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | } |