2 * Copyright (C) 2006, 2007, 2008, 2013, 2014 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "CompositionUnderline.h"
29 #include "DataTransferAccessPolicy.h"
30 #include "DictationAlternative.h"
31 #include "DocumentMarker.h"
32 #include "EditAction.h"
33 #include "EditingBehavior.h"
34 #include "EditingStyle.h"
35 #include "EditorInsertAction.h"
36 #include "FindOptions.h"
37 #include "FrameSelection.h"
38 #include "PasteboardWriterData.h"
39 #include "TextChecking.h"
40 #include "TextEventInputType.h"
41 #include "TextIteratorBehavior.h"
42 #include "VisibleSelection.h"
43 #include "WritingDirection.h"
47 OBJC_CLASS NSAttributedString;
48 OBJC_CLASS NSDictionary;
49 OBJC_CLASS NSMutableDictionary;
58 class AlternativeTextController;
59 class ArchiveResource;
61 class CompositeEditCommand;
62 class DeleteButtonController;
64 class EditCommandComposition;
66 class EditorInternalCommand;
73 class PasteboardWriterData;
76 class SpellCheckRequest;
79 class StyleProperties;
81 class TextCheckerClient;
84 struct PasteboardPlainText;
86 struct TextCheckingResult;
88 enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM, CommandFromDOMWithUserInterface };
89 enum EditorParagraphSeparator { EditorParagraphSeparatorIsDiv, EditorParagraphSeparatorIsP };
91 enum class MailBlockquoteHandling {
98 struct FragmentAndResources {
99 RefPtr<DocumentFragment> fragment;
100 Vector<Ref<ArchiveResource>> resources;
105 enum TemporarySelectionOption : uint8_t {
106 // By default, no additional options are enabled.
107 TemporarySelectionOptionDefault = 0,
109 // Scroll to reveal the selection.
110 TemporarySelectionOptionRevealSelection = 1 << 0,
112 // Don't propagate selection changes to the client layer.
113 TemporarySelectionOptionIgnoreSelectionChanges = 1 << 1,
115 // Force the render tree to update selection state. Only respected on iOS.
116 TemporarySelectionOptionEnableAppearanceUpdates = 1 << 2
119 using TemporarySelectionOptions = uint8_t;
121 class TemporarySelectionChange {
123 TemporarySelectionChange(Frame&, std::optional<VisibleSelection> = std::nullopt, TemporarySelectionOptions = TemporarySelectionOptionDefault);
124 ~TemporarySelectionChange();
128 TemporarySelectionOptions m_options;
129 bool m_wasIgnoringSelectionChanges;
131 bool m_appearanceUpdatesWereEnabled;
133 std::optional<VisibleSelection> m_selectionToRestore;
137 WTF_MAKE_FAST_ALLOCATED;
139 explicit Editor(Frame&);
142 WEBCORE_EXPORT EditorClient* client() const;
143 WEBCORE_EXPORT TextCheckerClient* textChecker() const;
145 CompositeEditCommand* lastEditCommand() { return m_lastEditCommand.get(); }
147 void handleKeyboardEvent(KeyboardEvent&);
148 void handleInputMethodKeydown(KeyboardEvent&);
149 bool handleTextEvent(TextEvent&);
151 WEBCORE_EXPORT bool canEdit() const;
152 WEBCORE_EXPORT bool canEditRichly() const;
156 WEBCORE_EXPORT bool canDHTMLPaste();
159 WEBCORE_EXPORT bool tryDHTMLPaste();
161 WEBCORE_EXPORT bool canCut() const;
162 WEBCORE_EXPORT bool canCopy() const;
163 WEBCORE_EXPORT bool canPaste() const;
164 WEBCORE_EXPORT bool canDelete() const;
165 bool canSmartCopyOrDelete();
167 WEBCORE_EXPORT void cut();
168 WEBCORE_EXPORT void copy();
169 WEBCORE_EXPORT void paste();
170 void paste(Pasteboard&);
171 WEBCORE_EXPORT void pasteAsPlainText();
172 WEBCORE_EXPORT void performDelete();
174 WEBCORE_EXPORT void copyURL(const URL&, const String& title);
175 void copyURL(const URL&, const String& title, Pasteboard&);
176 PasteboardWriterData::URL pasteboardWriterURL(const URL&, const String& title);
178 WEBCORE_EXPORT void copyImage(const HitTestResult&);
181 String readPlainTextFromPasteboard(Pasteboard&);
183 WEBCORE_EXPORT void indent();
184 WEBCORE_EXPORT void outdent();
187 bool shouldInsertFragment(DocumentFragment&, Range*, EditorInsertAction);
188 bool shouldInsertText(const String&, Range*, EditorInsertAction) const;
189 WEBCORE_EXPORT bool shouldDeleteRange(Range*) const;
190 bool shouldApplyStyle(StyleProperties*, Range*);
192 void respondToChangedContents(const VisibleSelection& endingSelection);
194 bool selectionStartHasStyle(CSSPropertyID, const String& value) const;
195 WEBCORE_EXPORT TriState selectionHasStyle(CSSPropertyID, const String& value) const;
196 String selectionStartCSSPropertyValue(CSSPropertyID);
198 TriState selectionUnorderedListState() const;
199 TriState selectionOrderedListState() const;
200 WEBCORE_EXPORT RefPtr<Node> insertOrderedList();
201 WEBCORE_EXPORT RefPtr<Node> insertUnorderedList();
202 WEBCORE_EXPORT bool canIncreaseSelectionListLevel();
203 WEBCORE_EXPORT bool canDecreaseSelectionListLevel();
204 WEBCORE_EXPORT RefPtr<Node> increaseSelectionListLevel();
205 WEBCORE_EXPORT RefPtr<Node> increaseSelectionListLevelOrdered();
206 WEBCORE_EXPORT RefPtr<Node> increaseSelectionListLevelUnordered();
207 WEBCORE_EXPORT void decreaseSelectionListLevel();
209 void removeFormattingAndStyle();
211 void clearLastEditCommand();
213 WEBCORE_EXPORT void ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping();
216 WEBCORE_EXPORT bool deleteWithDirection(SelectionDirection, TextGranularity, bool killRing, bool isTypingAction);
217 WEBCORE_EXPORT void deleteSelectionWithSmartDelete(bool smartDelete, EditAction = EditActionDelete);
220 WEBCORE_EXPORT void removeUnchangeableStyles();
223 bool dispatchCPPEvent(const AtomicString&, DataTransferAccessPolicy);
225 WEBCORE_EXPORT void applyStyle(StyleProperties*, EditAction = EditActionUnspecified);
226 void applyStyle(RefPtr<EditingStyle>&&, EditAction);
227 void applyParagraphStyle(StyleProperties*, EditAction = EditActionUnspecified);
228 WEBCORE_EXPORT void applyStyleToSelection(StyleProperties*, EditAction);
229 WEBCORE_EXPORT void applyStyleToSelection(Ref<EditingStyle>&&, EditAction);
230 void applyParagraphStyleToSelection(StyleProperties*, EditAction);
232 // Returns whether or not we should proceed with editing.
233 bool willApplyEditing(CompositeEditCommand&, Vector<RefPtr<StaticRange>>&&) const;
234 bool willUnapplyEditing(const EditCommandComposition&) const;
235 bool willReapplyEditing(const EditCommandComposition&) const;
237 void appliedEditing(CompositeEditCommand&);
238 void unappliedEditing(EditCommandComposition&);
239 void reappliedEditing(EditCommandComposition&);
240 void unappliedSpellCorrection(const VisibleSelection& selectionOfCorrected, const String& corrected, const String& correction);
242 // This is off by default, since most editors want this behavior (originally matched IE but not Firefox).
243 void setShouldStyleWithCSS(bool flag) { m_shouldStyleWithCSS = flag; }
244 bool shouldStyleWithCSS() const { return m_shouldStyleWithCSS; }
248 WEBCORE_EXPORT Command();
249 Command(const EditorInternalCommand*, EditorCommandSource, Frame&);
251 WEBCORE_EXPORT bool execute(const String& parameter = String(), Event* triggeringEvent = nullptr) const;
252 WEBCORE_EXPORT bool execute(Event* triggeringEvent) const;
254 WEBCORE_EXPORT bool isSupported() const;
255 WEBCORE_EXPORT bool isEnabled(Event* triggeringEvent = nullptr) const;
257 WEBCORE_EXPORT TriState state(Event* triggeringEvent = nullptr) const;
258 String value(Event* triggeringEvent = nullptr) const;
260 WEBCORE_EXPORT bool isTextInsertion() const;
261 WEBCORE_EXPORT bool allowExecutionWhenDisabled() const;
264 const EditorInternalCommand* m_command { nullptr };
265 EditorCommandSource m_source;
266 RefPtr<Frame> m_frame;
268 WEBCORE_EXPORT Command command(const String& commandName); // Command source is CommandFromMenuOrKeyBinding.
269 Command command(const String& commandName, EditorCommandSource);
270 WEBCORE_EXPORT static bool commandIsSupportedFromMenuOrKeyBinding(const String& commandName); // Works without a frame.
272 WEBCORE_EXPORT bool insertText(const String&, Event* triggeringEvent, TextEventInputType = TextEventInputKeyboard);
273 bool insertTextForConfirmedComposition(const String& text);
274 WEBCORE_EXPORT bool insertDictatedText(const String&, const Vector<DictationAlternative>& dictationAlternatives, Event* triggeringEvent);
275 bool insertTextWithoutSendingTextEvent(const String&, bool selectInsertedText, TextEvent* triggeringEvent);
276 bool insertLineBreak();
277 bool insertParagraphSeparator();
278 WEBCORE_EXPORT bool insertParagraphSeparatorInQuotedContent();
280 WEBCORE_EXPORT bool isContinuousSpellCheckingEnabled() const;
281 WEBCORE_EXPORT void toggleContinuousSpellChecking();
282 bool isGrammarCheckingEnabled();
283 void toggleGrammarChecking();
284 void ignoreSpelling();
285 void learnSpelling();
286 int spellCheckerDocumentTag();
287 WEBCORE_EXPORT bool isSelectionUngrammatical();
288 String misspelledSelectionString() const;
289 String misspelledWordAtCaretOrRange(Node* clickedNode) const;
290 Vector<String> guessesForMisspelledWord(const String&) const;
291 Vector<String> guessesForMisspelledOrUngrammatical(bool& misspelled, bool& ungrammatical);
292 bool isSpellCheckingEnabledInFocusedNode() const;
293 bool isSpellCheckingEnabledFor(Node*) const;
294 WEBCORE_EXPORT void markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, const VisibleSelection& selectionAfterTyping, bool doReplacement);
295 void markMisspellings(const VisibleSelection&, RefPtr<Range>& firstMisspellingRange);
296 void markBadGrammar(const VisibleSelection&);
297 void markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelection, bool markGrammar, const VisibleSelection& grammarSelection);
298 void markAndReplaceFor(const SpellCheckRequest&, const Vector<TextCheckingResult>&);
300 bool isOverwriteModeEnabled() const { return m_overwriteModeEnabled; }
301 WEBCORE_EXPORT void toggleOverwriteModeEnabled();
303 void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask, Range* spellingRange, Range* grammarRange);
305 NO_RETURN_DUE_TO_ASSERT
307 void changeBackToReplacedString(const String& replacedString);
310 WEBCORE_EXPORT void advanceToNextMisspelling(bool startBeforeSelection = false);
312 void showSpellingGuessPanel();
313 bool spellingPanelIsShowing();
315 bool shouldBeginEditing(Range*);
316 bool shouldEndEditing(Range*);
318 void clearUndoRedoOperations();
324 void didBeginEditing();
325 void didEndEditing();
326 void willWriteSelectionToPasteboard(Range*);
327 void didWriteSelectionToPasteboard();
329 void showFontPanel();
330 void showStylesPanel();
331 void showColorPanel();
333 void toggleUnderline();
334 WEBCORE_EXPORT void setBaseWritingDirection(WritingDirection);
336 // smartInsertDeleteEnabled and selectTrailingWhitespaceEnabled are
337 // mutually exclusive, meaning that enabling one will disable the other.
338 bool smartInsertDeleteEnabled();
339 bool isSelectTrailingWhitespaceEnabled() const;
341 WEBCORE_EXPORT bool hasBidiSelection() const;
343 // international text input composition
344 bool hasComposition() const { return m_compositionNode; }
345 WEBCORE_EXPORT void setComposition(const String&, const Vector<CompositionUnderline>&, unsigned selectionStart, unsigned selectionEnd);
346 WEBCORE_EXPORT void confirmComposition();
347 WEBCORE_EXPORT void confirmComposition(const String&); // if no existing composition, replaces selection
348 WEBCORE_EXPORT void cancelComposition();
349 bool cancelCompositionIfSelectionIsInvalid();
350 WEBCORE_EXPORT RefPtr<Range> compositionRange() const;
351 WEBCORE_EXPORT bool getCompositionSelection(unsigned& selectionStart, unsigned& selectionEnd) const;
353 // getting international text input composition state (for use by InlineTextBox)
354 Text* compositionNode() const { return m_compositionNode.get(); }
355 unsigned compositionStart() const { return m_compositionStart; }
356 unsigned compositionEnd() const { return m_compositionEnd; }
357 bool compositionUsesCustomUnderlines() const { return !m_customCompositionUnderlines.isEmpty(); }
358 const Vector<CompositionUnderline>& customCompositionUnderlines() const { return m_customCompositionUnderlines; }
360 enum class RevealSelection { No, Yes };
361 WEBCORE_EXPORT void setIgnoreSelectionChanges(bool, RevealSelection shouldRevealExistingSelection = RevealSelection::Yes);
362 bool ignoreSelectionChanges() const { return m_ignoreSelectionChanges; }
364 WEBCORE_EXPORT RefPtr<Range> rangeForPoint(const IntPoint& windowPoint);
368 VisibleSelection selectionForCommand(Event*);
370 PAL::KillRing& killRing() const { return *m_killRing; }
371 SpellChecker& spellChecker() const { return *m_spellChecker; }
373 EditingBehavior behavior() const;
375 RefPtr<Range> selectedRange();
378 WEBCORE_EXPORT void confirmMarkedText();
379 WEBCORE_EXPORT void setTextAsChildOfElement(const String&, Element&);
380 WEBCORE_EXPORT void setTextAlignmentForChangedBaseWritingDirection(WritingDirection);
381 WEBCORE_EXPORT void insertDictationPhrases(Vector<Vector<String>>&& dictationPhrases, RetainPtr<id> metadata);
382 WEBCORE_EXPORT void setDictationPhrasesAsChildOfElement(const Vector<Vector<String>>& dictationPhrases, RetainPtr<id> metadata, Element&);
385 enum class KillRingInsertionMode { PrependText, AppendText };
386 void addRangeToKillRing(const Range&, KillRingInsertionMode);
387 void addTextToKillRing(const String&, KillRingInsertionMode);
388 void setStartNewKillRingSequence(bool);
390 void startAlternativeTextUITimer();
391 // If user confirmed a correction in the correction panel, correction has non-zero length, otherwise it means that user has dismissed the panel.
392 WEBCORE_EXPORT void handleAlternativeTextUIResult(const String& correction);
393 void dismissCorrectionPanelAsIgnored();
395 WEBCORE_EXPORT void pasteAsFragment(Ref<DocumentFragment>&&, bool smartReplace, bool matchStyle, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
396 WEBCORE_EXPORT void pasteAsPlainText(const String&, bool smartReplace);
398 // This is only called on the mac where paste is implemented primarily at the WebKit level.
399 WEBCORE_EXPORT void pasteAsPlainTextBypassingDHTML();
401 void clearMisspellingsAndBadGrammar(const VisibleSelection&);
402 void markMisspellingsAndBadGrammar(const VisibleSelection&);
404 Element* findEventTargetFrom(const VisibleSelection& selection) const;
406 WEBCORE_EXPORT String selectedText() const;
407 String selectedTextForDataTransfer() const;
408 WEBCORE_EXPORT bool findString(const String&, FindOptions);
410 WEBCORE_EXPORT RefPtr<Range> rangeOfString(const String&, Range*, FindOptions);
412 const VisibleSelection& mark() const; // Mark, to be used as emacs uses it.
413 void setMark(const VisibleSelection&);
415 void computeAndSetTypingStyle(EditingStyle& , EditAction = EditActionUnspecified);
416 WEBCORE_EXPORT void computeAndSetTypingStyle(StyleProperties& , EditAction = EditActionUnspecified);
417 WEBCORE_EXPORT void applyEditingStyleToBodyElement() const;
418 void applyEditingStyleToElement(Element*) const;
420 WEBCORE_EXPORT IntRect firstRectForRange(Range*) const;
422 void selectionWillChange();
423 void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions);
424 WEBCORE_EXPORT void updateEditorUINowIfScheduled();
425 bool shouldChangeSelection(const VisibleSelection& oldSelection, const VisibleSelection& newSelection, EAffinity, bool stillSelecting) const;
426 WEBCORE_EXPORT unsigned countMatchesForText(const String&, Range*, FindOptions, unsigned limit, bool markMatches, Vector<RefPtr<Range>>*);
427 bool markedTextMatchesAreHighlighted() const;
428 WEBCORE_EXPORT void setMarkedTextMatchesAreHighlighted(bool);
430 void textFieldDidBeginEditing(Element*);
431 void textFieldDidEndEditing(Element*);
432 void textDidChangeInTextField(Element*);
433 bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
434 void textWillBeDeletedInTextField(Element* input);
435 void textDidChangeInTextArea(Element*);
436 WEBCORE_EXPORT WritingDirection baseWritingDirectionForSelectionStart() const;
438 WEBCORE_EXPORT void replaceSelectionWithFragment(DocumentFragment&, bool selectReplacement, bool smartReplace, bool matchStyle, EditAction = EditActionInsert, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
439 WEBCORE_EXPORT void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace, EditAction = EditActionInsert);
440 WEBCORE_EXPORT bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int length) const;
441 void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSelection);
442 void deletedAutocorrectionAtPosition(const Position&, const String& originalString);
444 WEBCORE_EXPORT void simplifyMarkup(Node* startNode, Node* endNode);
446 EditorParagraphSeparator defaultParagraphSeparator() const { return m_defaultParagraphSeparator; }
447 void setDefaultParagraphSeparator(EditorParagraphSeparator separator) { m_defaultParagraphSeparator = separator; }
448 Vector<String> dictationAlternativesForMarker(const DocumentMarker&);
449 void applyDictationAlternativelternative(const String& alternativeString);
452 WEBCORE_EXPORT void uppercaseWord();
453 WEBCORE_EXPORT void lowercaseWord();
454 WEBCORE_EXPORT void capitalizeWord();
457 #if USE(AUTOMATIC_TEXT_REPLACEMENT)
458 WEBCORE_EXPORT void showSubstitutionsPanel();
459 WEBCORE_EXPORT bool substitutionsPanelIsShowing();
460 WEBCORE_EXPORT void toggleSmartInsertDelete();
461 WEBCORE_EXPORT bool isAutomaticQuoteSubstitutionEnabled();
462 WEBCORE_EXPORT void toggleAutomaticQuoteSubstitution();
463 WEBCORE_EXPORT bool isAutomaticLinkDetectionEnabled();
464 WEBCORE_EXPORT void toggleAutomaticLinkDetection();
465 WEBCORE_EXPORT bool isAutomaticDashSubstitutionEnabled();
466 WEBCORE_EXPORT void toggleAutomaticDashSubstitution();
467 WEBCORE_EXPORT bool isAutomaticTextReplacementEnabled();
468 WEBCORE_EXPORT void toggleAutomaticTextReplacement();
469 WEBCORE_EXPORT bool isAutomaticSpellingCorrectionEnabled();
470 WEBCORE_EXPORT void toggleAutomaticSpellingCorrection();
473 RefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, Range& context, bool allowPlainText, bool& chosePlainText);
475 WEBCORE_EXPORT const Font* fontForSelection(bool& hasMultipleFonts) const;
476 WEBCORE_EXPORT static const RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
479 void getTextDecorationAttributesRespectingTypingStyle(const RenderStyle&, NSMutableDictionary*) const;
480 WEBCORE_EXPORT RetainPtr<NSDictionary> fontAttributesForSelectionStart() const;
481 WEBCORE_EXPORT String stringSelectionForPasteboard();
482 String stringSelectionForPasteboardWithImageAltText();
484 bool canCopyExcludingStandaloneImages();
485 void takeFindStringFromSelection();
486 WEBCORE_EXPORT void readSelectionFromPasteboard(const String& pasteboardName, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
487 WEBCORE_EXPORT void replaceNodeFromPasteboard(Node*, const String& pasteboardName);
488 WEBCORE_EXPORT RefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
489 WEBCORE_EXPORT void applyFontStyles(const String& fontFamily, double fontSize, unsigned fontTraits);
490 #endif // !PLATFORM(IOS)
491 WEBCORE_EXPORT void replaceSelectionWithAttributedString(NSAttributedString *, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
494 #if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WPE)
495 WEBCORE_EXPORT void writeSelectionToPasteboard(Pasteboard&);
496 WEBCORE_EXPORT void writeImageToPasteboard(Pasteboard&, Element& imageElement, const URL&, const String& title);
497 void writeSelection(PasteboardWriterData&);
500 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
501 void scanSelectionForTelephoneNumbers();
502 const Vector<RefPtr<Range>>& detectedTelephoneNumberRanges() const { return m_detectedTelephoneNumberRanges; }
505 WEBCORE_EXPORT String stringForCandidateRequest() const;
506 WEBCORE_EXPORT void handleAcceptedCandidate(TextCheckingResult);
507 WEBCORE_EXPORT RefPtr<Range> contextRangeForCandidateRequest() const;
508 RefPtr<Range> rangeForTextCheckingResult(const TextCheckingResult&) const;
509 bool isHandlingAcceptedCandidate() const { return m_isHandlingAcceptedCandidate; }
511 void setIsGettingDictionaryPopupInfo(bool b) { m_isGettingDictionaryPopupInfo = b; }
512 bool isGettingDictionaryPopupInfo() const { return m_isGettingDictionaryPopupInfo; }
514 Ref<DocumentFragment> createFragmentForImageAndURL(const String&);
517 class WebContentReader;
519 Document& document() const;
521 bool canDeleteRange(Range*) const;
522 bool canSmartReplaceWithPasteboard(Pasteboard&);
523 void pasteAsPlainTextWithPasteboard(Pasteboard&);
524 void pasteWithPasteboard(Pasteboard*, bool allowPlainText, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
525 String plainTextFromPasteboard(const PasteboardPlainText&);
527 void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
528 void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
529 TextCheckingTypeMask resolveTextCheckingTypeMask(const Node& rootEditableElement, TextCheckingTypeMask);
531 WEBCORE_EXPORT String selectedText(TextIteratorBehavior) const;
533 void selectComposition();
534 enum SetCompositionMode { ConfirmComposition, CancelComposition };
535 void setComposition(const String&, SetCompositionMode);
537 void changeSelectionAfterCommand(const VisibleSelection& newSelection, FrameSelection::SetSelectionOptions);
539 enum EditorActionSpecifier { CutAction, CopyAction };
540 void performCutOrCopy(EditorActionSpecifier);
542 void editorUIUpdateTimerFired();
544 Element* findEventTargetFromSelection() const;
546 bool unifiedTextCheckerEnabled() const;
548 RefPtr<Range> adjustedSelectionRange();
551 RefPtr<SharedBuffer> selectionInWebArchiveFormat();
552 String selectionInHTMLFormat();
553 RefPtr<SharedBuffer> imageInWebArchiveFormat(Element&);
554 RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&);
555 RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);
556 FragmentAndResources createFragment(NSAttributedString *);
557 String userVisibleString(const URL&);
559 static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *);
560 static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *);
563 void postTextStateChangeNotificationForCut(const String&, const VisibleSelection&);
566 RefPtr<CompositeEditCommand> m_lastEditCommand;
567 RefPtr<Text> m_compositionNode;
568 unsigned m_compositionStart;
569 unsigned m_compositionEnd;
570 Vector<CompositionUnderline> m_customCompositionUnderlines;
571 bool m_ignoreSelectionChanges { false };
572 bool m_shouldStartNewKillRingSequence { false };
573 bool m_shouldStyleWithCSS { false };
574 const std::unique_ptr<PAL::KillRing> m_killRing;
575 const std::unique_ptr<SpellChecker> m_spellChecker;
576 const std::unique_ptr<AlternativeTextController> m_alternativeTextController;
577 VisibleSelection m_mark;
578 bool m_areMarkedTextMatchesHighlighted { false };
579 EditorParagraphSeparator m_defaultParagraphSeparator { EditorParagraphSeparatorIsDiv };
580 bool m_overwriteModeEnabled { false };
582 VisibleSelection m_oldSelectionForEditorUIUpdate;
583 Timer m_editorUIUpdateTimer;
584 bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar { false };
585 bool m_editorUIUpdateTimerWasTriggeredByDictation { false };
586 bool m_isHandlingAcceptedCandidate { false };
588 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
589 bool shouldDetectTelephoneNumbers();
590 void scanRangeForTelephoneNumbers(Range&, const StringView&, Vector<RefPtr<Range>>& markedRanges);
592 Timer m_telephoneNumberDetectionUpdateTimer;
593 Vector<RefPtr<Range>> m_detectedTelephoneNumberRanges;
596 bool m_isGettingDictionaryPopupInfo { false };
599 inline void Editor::setStartNewKillRingSequence(bool flag)
601 m_shouldStartNewKillRingSequence = flag;
604 inline const VisibleSelection& Editor::mark() const
609 inline void Editor::setMark(const VisibleSelection& selection)
614 inline bool Editor::markedTextMatchesAreHighlighted() const
616 return m_areMarkedTextMatchesHighlighted;
619 } // namespace WebCore