blob: 575b41d8564062d558eac93497cf5845fcc6f50d [file] [log] [blame]
aliceli15a36ed92006-10-20 23:57:05 +00001/*
darin@apple.com67276642016-08-16 16:56:07 +00002 * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
hausmann@webkit.orgf6964472008-09-29 12:47:08 +00003 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
aliceli15a36ed92006-10-20 23:57:05 +00004 *
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.com92047332014-03-15 04:08:27 +000014 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
aliceli15a36ed92006-10-20 23:57:05 +000015 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
mjs@apple.com92047332014-03-15 04:08:27 +000017 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
aliceli15a36ed92006-10-20 23:57:05 +000018 * 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.com67276642016-08-16 16:56:07 +000027#pragma once
aliceli15a36ed92006-10-20 23:57:05 +000028
bdakin8254b192006-11-20 01:21:56 +000029#include "EditorInsertAction.h"
mjsc13fa542007-02-19 07:54:13 +000030#include "TextAffinity.h"
aestes@apple.comdc9c8522012-05-31 21:03:16 +000031#include "TextChecking.h"
rniwa@webkit.org12e984a2011-12-16 22:04:58 +000032#include "UndoStep.h"
ggarenf8a628d2006-11-28 18:54:03 +000033#include <wtf/Forward.h>
sfalken9363b002007-04-25 04:22:56 +000034#include <wtf/Vector.h>
darind1fbfdc2007-02-12 19:05:07 +000035
mitz@apple.com28c9d4a2014-02-08 22:26:50 +000036#if PLATFORM(COCOA)
weinig@apple.comc122cb22012-01-17 23:46:16 +000037OBJC_CLASS NSString;
38OBJC_CLASS NSURL;
andersca@apple.comc71279a2010-06-18 21:09:31 +000039#endif
bdakin8254b192006-11-20 01:21:56 +000040
dbates@webkit.org4da1af82013-12-27 20:40:28 +000041#if PLATFORM(IOS)
42OBJC_CLASS NSArray;
43OBJC_CLASS NSDictionary;
44#endif
45
aliceli15a36ed92006-10-20 23:57:05 +000046namespace WebCore {
47
enrica@apple.com0f0dd6c2010-09-13 19:16:23 +000048class ArchiveResource;
enrica@apple.com0f0dd6c2010-09-13 19:16:23 +000049class DocumentFragment;
mitz@apple.com1f24e242010-09-02 06:43:50 +000050class Editor;
mjsc13fa542007-02-19 07:54:13 +000051class Element;
aliceli1c68d2a42006-11-29 07:25:53 +000052class Frame;
thatcherf780fa72006-10-21 18:40:03 +000053class HTMLElement;
adele1c204832007-01-23 19:37:35 +000054class KeyboardEvent;
beidson@apple.com29a2efc2014-04-25 22:22:14 +000055class LayoutRect;
aliceli168b13932006-11-28 22:02:12 +000056class Node;
anderscaf6232012006-11-15 00:36:50 +000057class Range;
enrica@apple.com7eb1d5b2013-01-31 21:14:58 +000058class SharedBuffer;
antti@apple.come5428c52013-11-28 20:53:22 +000059class StyleProperties;
morrita@google.com7692b422011-02-15 08:28:20 +000060class TextCheckerClient;
eric@webkit.org87ea95c2009-02-09 21:43:24 +000061class VisibleSelection;
sfalken9363b002007-04-25 04:22:56 +000062class VisiblePosition;
63
beidson@apple.comd5d9b082014-07-03 17:56:38 +000064struct GapRects;
morrita@google.com9b3829f2011-02-15 09:57:59 +000065struct GrammarDetail;
66
ggarenf8a628d2006-11-28 18:54:03 +000067class EditorClient {
aliceli15a36ed92006-10-20 23:57:05 +000068public:
ggarenf8a628d2006-11-28 18:54:03 +000069 virtual ~EditorClient() { }
morrita@google.com9da7b7c2012-05-18 10:17:52 +000070
ggarena4251702006-10-31 23:56:37 +000071 virtual bool shouldDeleteRange(Range*) = 0;
bdakin08b0dce2006-12-12 04:27:17 +000072 virtual bool smartInsertDeleteEnabled() = 0;
achristensen@apple.com09e70aa2017-04-27 16:42:13 +000073 virtual bool isSelectTrailingWhitespaceEnabled() const = 0;
sullivan63afd752006-10-31 01:25:52 +000074 virtual bool isContinuousSpellCheckingEnabled() = 0;
bdakin08b0dce2006-12-12 04:27:17 +000075 virtual void toggleContinuousSpellChecking() = 0;
sullivan63afd752006-10-31 01:25:52 +000076 virtual bool isGrammarCheckingEnabled() = 0;
bdakin08b0dce2006-12-12 04:27:17 +000077 virtual void toggleGrammarChecking() = 0;
sullivan63afd752006-10-31 01:25:52 +000078 virtual int spellCheckerDocumentTag() = 0;
thatcherf780fa72006-10-21 18:40:03 +000079
anderscaf2ad1b52006-11-09 00:51:35 +000080 virtual bool shouldBeginEditing(Range*) = 0;
81 virtual bool shouldEndEditing(Range*) = 0;
aliceli168b13932006-11-28 22:02:12 +000082 virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) = 0;
andersca@apple.com886544a2008-04-24 17:45:17 +000083 virtual bool shouldInsertText(const String&, Range*, EditorInsertAction) = 0;
mjsc13fa542007-02-19 07:54:13 +000084 virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting) = 0;
85
antti@apple.come5428c52013-11-28 20:53:22 +000086 virtual bool shouldApplyStyle(StyleProperties*, Range*) = 0;
rniwa@webkit.org669d79f2015-06-29 21:38:31 +000087 virtual void didApplyStyle() = 0;
justingf90e28d2007-07-30 18:25:19 +000088 virtual bool shouldMoveRangeAfterDelete(Range*, Range*) = 0;
darind1fbfdc2007-02-12 19:05:07 +000089
anderscaf2ad1b52006-11-09 00:51:35 +000090 virtual void didBeginEditing() = 0;
andersca3a621282006-11-09 19:48:13 +000091 virtual void respondToChangedContents() = 0;
tonikitoo@webkit.org73c1c052011-11-20 23:55:31 +000092 virtual void respondToChangedSelection(Frame*) = 0;
cdumez@apple.com51192982015-04-09 18:31:51 +000093 virtual void didChangeSelectionAndUpdateLayout() = 0;
bdakin@apple.comfe13ad32016-09-02 23:14:34 +000094 virtual void updateEditorStateAfterLayoutIfEditabilityChanged() = 0;
anderscaf2ad1b52006-11-09 00:51:35 +000095 virtual void didEndEditing() = 0;
enrica@apple.com7eb1d5b2013-01-31 21:14:58 +000096 virtual void willWriteSelectionToPasteboard(Range*) = 0;
aliceli1bab41322007-01-17 04:37:25 +000097 virtual void didWriteSelectionToPasteboard() = 0;
andersca@apple.comc3523f82013-10-18 23:41:24 +000098 virtual void getClientPasteboardDataForRange(Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData) = 0;
bdakin@apple.com92fe7c12016-04-05 23:33:47 +000099 virtual void requestCandidatesForSelection(const VisibleSelection&) { }
bdakin@apple.com24fba1e2016-05-17 23:24:19 +0000100 virtual void handleAcceptedCandidateWithSoftSpaces(TextCheckingResult) { }
ap@apple.comc9851362014-12-11 17:23:34 +0000101
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.com60bcd7a2016-11-04 23:55:00 +0000105 virtual void canceledComposition() = 0;
ap@apple.comc9851362014-12-11 17:23:34 +0000106
darin@apple.comc04189e2017-01-18 05:17:17 +0000107 virtual void registerUndoStep(UndoStep&) = 0;
108 virtual void registerRedoStep(UndoStep&) = 0;
anderscaf6232012006-11-15 00:36:50 +0000109 virtual void clearUndoRedoOperations() = 0;
110
rniwa@webkit.orgf5a84a02011-04-22 00:33:21 +0000111 virtual bool canCopyCut(Frame*, bool defaultValue) const = 0;
112 virtual bool canPaste(Frame*, bool defaultValue) const = 0;
anderscaf6232012006-11-15 00:36:50 +0000113 virtual bool canUndo() const = 0;
114 virtual bool canRedo() const = 0;
115
116 virtual void undo() = 0;
117 virtual void redo() = 0;
aliceli168b13932006-11-28 22:02:12 +0000118
ap@webkit.org6a506672007-12-11 19:11:46 +0000119 virtual void handleKeyboardEvent(KeyboardEvent*) = 0;
120 virtual void handleInputMethodKeydown(KeyboardEvent*) = 0;
mjsc13fa542007-02-19 07:54:13 +0000121
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.comfd21a092014-07-22 23:28:37 +0000128 virtual void overflowScrollPositionChanged() = 0;
adele1c204832007-01-23 19:37:35 +0000129
dbates@webkit.org4da1af82013-12-27 20:40:28 +0000130#if PLATFORM(IOS)
dbates@webkit.org4da1af82013-12-27 20:40:28 +0000131 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.com760090a2016-08-22 15:51:58 +0000138 virtual RefPtr<DocumentFragment> documentFragmentFromDelegate(int index) = 0;
dbates@webkit.org4da1af82013-12-27 20:40:28 +0000139 virtual bool performsTwoStepPaste(DocumentFragment*) = 0;
140 virtual int pasteboardChangeCount() = 0;
141#endif
142
mitz@apple.com28c9d4a2014-02-08 22:26:50 +0000143#if PLATFORM(COCOA)
achristensen@apple.com760090a2016-08-22 15:51:58 +0000144 virtual NSString *userVisibleString(NSURL *) = 0;
enrica@apple.com3728b402012-02-28 21:58:25 +0000145 virtual void setInsertionPasteboard(const String& pasteboardName) = 0;
achristensen@apple.com760090a2016-08-22 15:51:58 +0000146 virtual NSURL *canonicalizeURL(NSURL *) = 0;
147 virtual NSURL *canonicalizeURLString(NSString *) = 0;
sfalken79a17cb2007-04-25 19:01:22 +0000148#endif
149
aestes@apple.com57b50002012-06-07 06:20:18 +0000150#if USE(APPKIT)
adele@apple.comf4cbf342009-04-27 23:14:33 +0000151 virtual void uppercaseWord() = 0;
152 virtual void lowercaseWord() = 0;
153 virtual void capitalizeWord() = 0;
aestes@apple.comdc9c8522012-05-31 21:03:16 +0000154#endif
rniwa@webkit.org4098b4e2013-02-12 04:55:35 +0000155
aestes@apple.comdc9c8522012-05-31 21:03:16 +0000156#if USE(AUTOMATIC_TEXT_REPLACEMENT)
adele@apple.comf4cbf342009-04-27 23:14:33 +0000157 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.org4098b4e2013-02-12 04:55:35 +0000171
carlosgc@webkit.orgd45765c2012-03-15 18:28:53 +0000172#if PLATFORM(GTK)
173 virtual bool shouldShowUnicodeMenu() = 0;
174#endif
175
morrita@google.com7692b422011-02-15 08:28:20 +0000176 virtual TextCheckerClient* textChecker() = 0;
mitz@apple.com1f24e242010-09-02 06:43:50 +0000177
sfalken186e6022007-05-08 19:27:50 +0000178 virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail& detail) = 0;
sfalken9363b002007-04-25 04:22:56 +0000179 virtual void updateSpellingUIWithMisspelledWord(const String&) = 0;
180 virtual void showSpellingUI(bool show) = 0;
181 virtual bool spellingUIIsShowing() = 0;
commit-queue@webkit.org11f23fe2010-07-17 01:05:50 +0000182 virtual void willSetInputMethodState() = 0;
oliverf6949e92007-09-01 23:04:59 +0000183 virtual void setInputMethodState(bool enabled) = 0;
allan.jensen@nokia.comfc0f6af2012-09-07 12:51:44 +0000184
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; }
aliceli15a36ed92006-10-20 23:57:05 +0000188};
189
190}