Changeset 260831 in webkit
- Timestamp:
- Apr 28, 2020 9:36:38 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r260830 r260831 1 2020-04-28 Jack Lee <shihchieh_lee@apple.com> 2 3 Nullptr crash in EditCommand::EditCommand via CompositeEditCommand::removeNode 4 https://bugs.webkit.org/show_bug.cgi?id=207600 5 <rdar://problem/56969450> 6 7 Reviewed by Geoffrey Garen. 8 9 Added a regression test for the crash. 10 11 * editing/inserting/insert-list-then-edit-command-crash-expected.txt: Added. 12 * editing/inserting/insert-list-then-edit-command-crash.html: Added. 13 14 Modify the test result. FrameSelection is being destructed along with 15 document so an additional selection change notification is expected. 16 17 * platform/mac/editing/pasteboard/drag-drop-dead-frame-expected.txt: 18 1 19 2020-04-28 Alejandro G. Castro <alex@igalia.com> 2 20 -
trunk/LayoutTests/platform/mac/editing/pasteboard/drag-drop-dead-frame-expected.txt
r177774 r260831 5 5 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 6 6 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification 7 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 7 8 layer at (0,0) size 800x600 8 9 RenderView at (0,0) size 800x600 -
trunk/Source/WebCore/ChangeLog
r260828 r260831 1 2020-04-28 Jack Lee <shihchieh_lee@apple.com> 2 3 Nullptr crash in EditCommand::EditCommand via CompositeEditCommand::removeNode 4 https://bugs.webkit.org/show_bug.cgi?id=207600 5 <rdar://problem/56969450> 6 7 Reviewed by Geoffrey Garen. 8 9 Move FrameSelection and Editor objects from Frame to Document so when a document is detached 10 in nested command executions, the next EditCommand would not fail in constructor. 11 12 Test: editing/inserting/insert-list-then-edit-command-crash.html 13 14 * dom/Document.cpp: 15 (WebCore::m_selection): 16 (WebCore::Document::prepareForDestruction): 17 (WebCore::m_undoManager): Deleted. 18 * dom/Document.h: 19 (WebCore::Document::editor): 20 (WebCore::Document::editor const): 21 (WebCore::Document::selection): 22 (WebCore::Document::selection const): 23 * dom/PositionIterator.cpp: 24 (WebCore::PositionIterator::isCandidate const): 25 * editing/AlternativeTextController.cpp: 26 (WebCore::AlternativeTextController::AlternativeTextController): 27 (WebCore::AlternativeTextController::stopPendingCorrection): 28 (WebCore::AlternativeTextController::isSpellingMarkerAllowed const): 29 (WebCore::AlternativeTextController::applyAutocorrectionBeforeTypingIfAppropriate): 30 (WebCore::AlternativeTextController::respondToUnappliedSpellCorrection): 31 (WebCore::AlternativeTextController::timerFired): 32 (WebCore::AlternativeTextController::handleAlternativeTextUIResult): 33 (WebCore::AlternativeTextController::rootViewRectForRange const): 34 (WebCore::AlternativeTextController::respondToChangedSelection): 35 (WebCore::AlternativeTextController::respondToAppliedEditing): 36 (WebCore::AlternativeTextController::respondToUnappliedEditing): 37 (WebCore::AlternativeTextController::editorClient): 38 (WebCore::AlternativeTextController::markPrecedingWhitespaceForDeletedAutocorrectionAfterCommand): 39 (WebCore::AlternativeTextController::processMarkersOnTextToBeReplacedByResult): 40 (WebCore::AlternativeTextController::respondToMarkerAtEndOfWord): 41 (WebCore::AlternativeTextController::alternativeTextClient): 42 (WebCore::AlternativeTextController::applyAlternativeTextToRange): 43 (WebCore::AlternativeTextController::insertDictatedText): 44 (WebCore::AlternativeTextController::applyDictationAlternative): 45 * editing/AlternativeTextController.h: 46 (WebCore::AlternativeTextController::UNLESS_ENABLED): 47 * editing/CompositeEditCommand.cpp: 48 (WebCore::EditCommandComposition::unapply): 49 (WebCore::EditCommandComposition::reapply): 50 (WebCore::CompositeEditCommand::willApplyCommand): 51 (WebCore::CompositeEditCommand::didApplyCommand): 52 (WebCore::CompositeEditCommand::targetRanges const): 53 (WebCore::CompositeEditCommand::moveParagraphs): 54 * editing/DeleteSelectionCommand.cpp: 55 (WebCore::DeleteSelectionCommand::saveTypingStyleState): 56 (WebCore::DeleteSelectionCommand::mergeParagraphs): 57 (WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete): 58 (WebCore::DeleteSelectionCommand::doApply): 59 * editing/EditCommand.cpp: 60 (WebCore::EditCommand::EditCommand): 61 (WebCore::EditCommand::isEditingTextAreaOrTextInput const): 62 (WebCore::EditCommand::postTextStateChangeNotification): 63 (WebCore::EditCommand::frame): Deleted. 64 (WebCore::EditCommand::frame const): Deleted. 65 * editing/EditCommand.h: 66 * editing/Editing.cpp: 67 (WebCore::createDefaultParagraphElement): 68 * editing/EditingStyle.cpp: 69 (WebCore::StyleChange::StyleChange): 70 * editing/Editor.cpp: 71 (WebCore::ClearTextCommand::CreateAndApply): 72 (WebCore::TemporarySelectionChange::TemporarySelectionChange): 73 (WebCore::TemporarySelectionChange::~TemporarySelectionChange): 74 (WebCore::TemporarySelectionChange::setSelection): 75 (WebCore::Editor::selectionForCommand): 76 (WebCore::Editor::behavior const): 77 (WebCore::Editor::client const): 78 (WebCore::Editor::canEdit const): 79 (WebCore::Editor::canEditRichly const): 80 (WebCore::Editor::canDHTMLCut): 81 (WebCore::Editor::canDHTMLCopy): 82 (WebCore::Editor::canCopy const): 83 (WebCore::Editor::canPaste const): 84 (WebCore::Editor::canDelete const): 85 (WebCore::Editor::shouldSmartDelete): 86 (WebCore::Editor::deleteWithDirection): 87 (WebCore::Editor::deleteSelectionWithSmartDelete): 88 (WebCore::Editor::clearText): 89 (WebCore::Editor::replaceSelectionWithFragment): 90 (WebCore::Editor::selectedRange): 91 (WebCore::Editor::tryDHTMLCopy): 92 (WebCore::Editor::tryDHTMLCut): 93 (WebCore::Editor::shouldInsertText const): 94 (WebCore::Editor::hasBidiSelection const): 95 (WebCore::Editor::selectionUnorderedListState const): 96 (WebCore::Editor::selectionOrderedListState const): 97 (WebCore::Editor::increaseSelectionListLevel): 98 (WebCore::Editor::increaseSelectionListLevelOrdered): 99 (WebCore::Editor::increaseSelectionListLevelUnordered): 100 (WebCore::Editor::decreaseSelectionListLevel): 101 (WebCore::Editor::findEventTargetFromSelection const): 102 (WebCore::Editor::applyStyle): 103 (WebCore::Editor::applyParagraphStyle): 104 (WebCore::Editor::applyStyleToSelection): 105 (WebCore::Editor::applyParagraphStyleToSelection): 106 (WebCore::Editor::selectionStartHasStyle const): 107 (WebCore::Editor::selectionHasStyle const): 108 (WebCore::Editor::selectionStartCSSPropertyValue): 109 (WebCore::Editor::appliedEditing): 110 (WebCore::Editor::Editor): 111 (WebCore::Editor::clear): 112 (WebCore::Editor::insertText): 113 (WebCore::Editor::insertTextForConfirmedComposition): 114 (WebCore::Editor::insertTextWithoutSendingTextEvent): 115 (WebCore::Editor::insertLineBreak): 116 (WebCore::Editor::insertParagraphSeparator): 117 (WebCore::Editor::performCutOrCopy): 118 (WebCore::Editor::paste): 119 (WebCore::Editor::pasteAsQuotation): 120 (WebCore::Editor::renderLayerDidScroll): 121 (WebCore::Editor::setBaseWritingDirection): 122 (WebCore::Editor::baseWritingDirectionForSelectionStart const): 123 (WebCore::Editor::selectComposition): 124 (WebCore::SetCompositionScope::SetCompositionScope): 125 (WebCore::SetCompositionScope::~SetCompositionScope): 126 (WebCore::Editor::setComposition): 127 (WebCore::Editor::ignoreSpelling): 128 (WebCore::Editor::learnSpelling): 129 (WebCore::Editor::advanceToNextMisspelling): 130 (WebCore::Editor::misspelledWordAtCaretOrRange const): 131 (WebCore::Editor::isSelectionUngrammatical): 132 (WebCore::Editor::guessesForMisspelledWord const): 133 (WebCore::Editor::guessesForMisspelledOrUngrammatical): 134 (WebCore::Editor::markMisspellingsAfterTypingToWord): 135 (WebCore::Editor::isSpellCheckingEnabledInFocusedNode const): 136 (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): 137 (WebCore::Editor::markAndReplaceFor): 138 (WebCore::Editor::updateMarkersForWordsAffectedByEditing): 139 (WebCore::Editor::rangeForPoint): 140 (WebCore::Editor::revealSelectionAfterEditingOperation): 141 (WebCore::Editor::setIgnoreSelectionChanges): 142 (WebCore::Editor::getCompositionSelection const): 143 (WebCore::Editor::transpose): 144 (WebCore::Editor::changeSelectionAfterCommand): 145 (WebCore::Editor::selectedText const): 146 (WebCore::Editor::selectedTextForDataTransfer const): 147 (WebCore::Editor::insertTextPlaceholder): 148 (WebCore::Editor::removeTextPlaceholder): 149 (WebCore::Editor::shouldChangeSelection const): 150 (WebCore::Editor::computeAndSetTypingStyle): 151 (WebCore::Editor::findString): 152 (WebCore::Editor::countMatchesForText): 153 (WebCore::Editor::respondToChangedSelection): 154 (WebCore::Editor::shouldDetectTelephoneNumbers): 155 (WebCore::Editor::scanSelectionForTelephoneNumbers): 156 (WebCore::Editor::editorUIUpdateTimerFired): 157 (WebCore::Editor::selectionStartHasMarkerFor const): 158 (WebCore::candidateRangeForSelection): 159 (WebCore::Editor::stringForCandidateRequest const): 160 (WebCore::Editor::contextRangeForCandidateRequest const): 161 (WebCore::Editor::fontAttributesAtSelectionStart const): 162 (WebCore::Editor::notifyClientOfAttachmentUpdates): 163 (WebCore::Editor::handleAcceptedCandidate): 164 (WebCore::Editor::unifiedTextCheckerEnabled const): 165 (WebCore::Editor::toggleOverwriteModeEnabled): 166 (WebCore::Editor::fontForSelection const): 167 (WebCore::Editor::canCopyExcludingStandaloneImages const): 168 (WebCore::Editor::document const): Deleted. 169 * editing/Editor.h: 170 (WebCore::TemporarySelectionChange::TemporarySelectionChange): 171 (WebCore::IgnoreSelectionChangeForScope::IgnoreSelectionChangeForScope): 172 (WebCore::Editor::document const): 173 * editing/EditorCommand.cpp: 174 (WebCore::executeSwapWithMark): 175 (WebCore::Editor::command): 176 (WebCore::Editor::Command::Command): 177 (WebCore::Editor::Command::execute const): 178 * editing/FrameSelection.cpp: 179 (WebCore::shouldAlwaysUseDirectionalSelection): 180 (WebCore::FrameSelection::FrameSelection): 181 (WebCore::FrameSelection::rootEditableElementOrDocumentElement const): 182 (WebCore::FrameSelection::setSelectionByMouseIfDifferent): 183 (WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance): 184 (WebCore::FrameSelection::setSelection): 185 (WebCore::updateSelectionByUpdatingLayoutOrStyle): 186 (WebCore::FrameSelection::setNeedsSelectionUpdate): 187 (WebCore::FrameSelection::updateAndRevealSelection): 188 (WebCore::FrameSelection::updateDataDetectorsForSelection): 189 (WebCore::FrameSelection::positionForPlatform const): 190 (WebCore::FrameSelection::nextWordPositionForPlatform): 191 (WebCore::FrameSelection::modifyMovingRight): 192 (WebCore::FrameSelection::modifyMovingLeft): 193 (WebCore::FrameSelection::modify): 194 (WebCore::FrameSelection::prepareForDestruction): 195 (WebCore::FrameSelection::absoluteCaretBounds): 196 (WebCore::FrameSelection::recomputeCaretRect): 197 (WebCore::FrameSelection::contains const): 198 (WebCore::FrameSelection::selectAll): 199 (WebCore::FrameSelection::focusedOrActiveStateChanged): 200 (WebCore::FrameSelection::isFocusedAndActive const): 201 (WebCore::shouldStopBlinkingDueToTypingCommand): 202 (WebCore::FrameSelection::updateAppearance): 203 (WebCore::FrameSelection::setCaretVisibility): 204 (WebCore::FrameSelection::setFocusedElementIfNeeded): 205 (WebCore::FrameSelection::shouldDeleteSelection const): 206 (WebCore::FrameSelection::selectionBounds const): 207 (WebCore::FrameSelection::getClippedVisibleTextRectangles const): 208 (WebCore::FrameSelection::currentForm const): 209 (WebCore::FrameSelection::revealSelection): 210 (WebCore::FrameSelection::setSelectionFromNone): 211 (WebCore::FrameSelection::shouldChangeSelection const): 212 (WebCore::FrameSelection::setShouldShowBlockCursor): 213 (WebCore::FrameSelection::appearanceUpdateTimerFired): 214 (WebCore::FrameSelection::updateAppearanceAfterLayoutOrStyleChange): 215 (WebCore::FrameSelection::selectRangeOnElement): 216 (WebCore::FrameSelection::setCaretBlinks): 217 * editing/FrameSelection.h: 218 * editing/InsertIntoTextNodeCommand.cpp: 219 (WebCore::InsertIntoTextNodeCommand::doApply): 220 * editing/InsertLineBreakCommand.cpp: 221 (WebCore::InsertLineBreakCommand::doApply): 222 * editing/InsertTextCommand.cpp: 223 (WebCore::InsertTextCommand::doApply): 224 * editing/ReplaceRangeWithTextCommand.cpp: 225 (WebCore::ReplaceRangeWithTextCommand::doApply): 226 * editing/ReplaceSelectionCommand.cpp: 227 (WebCore::ReplaceSelectionCommand::doApply): 228 * editing/SetSelectionCommand.cpp: 229 (WebCore::SetSelectionCommand::doApply): 230 (WebCore::SetSelectionCommand::doUnapply): 231 * editing/SpellChecker.cpp: 232 (WebCore::SpellChecker::SpellChecker): 233 (WebCore::SpellChecker::client const): 234 (WebCore::SpellChecker::isAsynchronousEnabled const): 235 (WebCore::SpellChecker::invokeRequest): 236 (WebCore::SpellChecker::didCheck): 237 (WebCore::SpellChecker::didCheckSucceed): 238 * editing/SpellChecker.h: 239 * editing/SpellingCorrectionCommand.cpp: 240 (WebCore::SpellingCorrectionCommand::doApply): 241 * editing/TypingCommand.cpp: 242 (WebCore::TypingCommand::deleteSelection): 243 (WebCore::TypingCommand::deleteKeyPressed): 244 (WebCore::TypingCommand::forwardDeleteKeyPressed): 245 (WebCore::TypingCommand::updateSelectionIfDifferentFromCurrentSelection): 246 (WebCore::TypingCommand::insertText): 247 (WebCore::TypingCommand::insertLineBreak): 248 (WebCore::TypingCommand::insertParagraphSeparatorInQuotedContent): 249 (WebCore::TypingCommand::insertParagraphSeparator): 250 (WebCore::TypingCommand::lastTypingCommandIfStillOpenForTyping): 251 (WebCore::TypingCommand::closeTyping): 252 (WebCore::TypingCommand::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping): 253 (WebCore::TypingCommand::markMisspellingsAfterTyping): 254 (WebCore::TypingCommand::willAddTypingToOpenCommand): 255 (WebCore::TypingCommand::typingAddedToOpenCommand): 256 (WebCore::TypingCommand::insertTextAndNotifyAccessibility): 257 (WebCore::TypingCommand::insertTextRunWithoutNewlines): 258 (WebCore::TypingCommand::insertLineBreakAndNotifyAccessibility): 259 (WebCore::TypingCommand::insertParagraphSeparatorAndNotifyAccessibility): 260 (WebCore::TypingCommand::insertParagraphSeparatorInQuotedContentAndNotifyAccessibility): 261 * editing/TypingCommand.h: 262 * editing/cocoa/EditorCocoa.mm: 263 (WebCore::Editor::selectionInHTMLFormat): 264 (WebCore::Editor::writeSelectionToPasteboard): 265 (WebCore::Editor::writeSelection): 266 (WebCore::Editor::selectionInWebArchiveFormat): 267 (WebCore::Editor::replaceSelectionWithAttributedString): 268 (WebCore::Editor::webContentFromPasteboard): 269 (WebCore::Editor::takeFindStringFromSelection): 270 * editing/gtk/EditorGtk.cpp: 271 (WebCore::Editor::pasteWithPasteboard): 272 (WebCore::Editor::writeSelectionToPasteboard): 273 (WebCore::Editor::webContentFromPasteboard): 274 * editing/ios/EditorIOS.mm: 275 (WebCore::Editor::setTextAlignmentForChangedBaseWritingDirection): 276 (WebCore::Editor::removeUnchangeableStyles): 277 (WebCore::Editor::pasteWithPasteboard): 278 (WebCore::Editor::insertDictationPhrases): 279 (WebCore::Editor::setDictationPhrasesAsChildOfElement): 280 (WebCore::Editor::setTextAsChildOfElement): 281 (WebCore::Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping): 282 * editing/libwpe/EditorLibWPE.cpp: 283 (WebCore::Editor::writeSelectionToPasteboard): 284 (WebCore::Editor::pasteWithPasteboard): 285 * editing/mac/EditorMac.mm: 286 (WebCore::Editor::readSelectionFromPasteboard): 287 (WebCore::Editor::replaceNodeFromPasteboard): 288 (WebCore::Editor::selectionWillChange): 289 * editing/win/EditorWin.cpp: 290 (WebCore::Editor::pasteWithPasteboard): 291 (WebCore::Editor::webContentFromPasteboard): 292 * loader/FrameLoader.cpp: 293 (WebCore::FrameLoader::willTransitionToCommitted): 294 (WebCore::FrameLoader::closeURL): 295 (WebCore::FrameLoader::didOpenURL): 296 (WebCore::FrameLoader::clear): 297 * page/Frame.cpp: 298 (WebCore::Frame::Frame): 299 (WebCore::Frame::requestDOMPasteAccess): 300 (WebCore::Frame::setPageAndTextZoomFactors): 301 * page/Frame.h: 302 * page/TextIndicator.cpp: 303 (WebCore::TextIndicator::createWithRange): 304 1 305 2020-04-28 Antti Koivisto <antti@apple.com> 2 306 -
trunk/Source/WebCore/dom/Document.cpp
r260800 r260831 583 583 , m_identifier(DocumentIdentifier::generate()) 584 584 , m_undoManager(UndoManager::create(*this)) 585 , m_editor(makeUniqueRef<Editor>(*this)) 586 , m_selection(makeUniqueRef<FrameSelection>(this)) 585 587 { 586 588 auto addResult = allDocumentsMap().add(m_identifier, this); … … 2500 2502 } 2501 2503 2502 void Document:: prepareForDestruction()2504 void Document::willBeRemovedFromFrame() 2503 2505 { 2504 2506 if (m_hasPreparedForDestruction) … … 2593 2595 } 2594 2596 2597 editor().clear(); 2598 selection().willBeRemovedFromFrame(); 2595 2599 detachFromFrame(); 2596 2600 -
trunk/Source/WebCore/dom/Document.h
r260800 r260831 121 121 class DocumentType; 122 122 class EditingBehavior; 123 class Editor; 123 124 class EventLoop; 124 125 class EventLoopTaskGroup; … … 129 130 class FormController; 130 131 class Frame; 132 class FrameSelection; 131 133 class FrameView; 132 134 class FullscreenManager; … … 627 629 void didBecomeCurrentDocumentInFrame(); 628 630 void destroyRenderTree(); 629 void prepareForDestruction();631 void willBeRemovedFromFrame(); 630 632 631 633 // Override ScriptExecutionContext methods to do additional work … … 1579 1581 bool hasVisuallyNonEmptyCustomContent() const { return m_hasVisuallyNonEmptyCustomContent; } 1580 1582 1583 Editor& editor() { return m_editor; } 1584 const Editor& editor() const { return m_editor; } 1585 FrameSelection& selection() { return m_selection; } 1586 const FrameSelection& selection() const { return m_selection; } 1587 1581 1588 protected: 1582 1589 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 }; … … 2114 2121 2115 2122 HashMap<Element*, ElementIdentifier> m_identifiedElementsMap; 2123 2124 UniqueRef<Editor> m_editor; 2125 UniqueRef<FrameSelection> m_selection; 2116 2126 }; 2117 2127 -
trunk/Source/WebCore/editing/AlternativeTextController.cpp
r260753 r260831 83 83 } 84 84 85 AlternativeTextController::AlternativeTextController( Frame& frame)85 AlternativeTextController::AlternativeTextController(Document& document) 86 86 : m_timer(*this, &AlternativeTextController::timerFired) 87 , m_ frame(frame)87 , m_document(document) 88 88 { 89 89 } … … 116 116 { 117 117 // Make sure there's no pending autocorrection before we call markMisspellingsAndBadGrammar() below. 118 VisibleSelection currentSelection(m_ frame.selection().selection());118 VisibleSelection currentSelection(m_document.selection().selection()); 119 119 if (currentSelection == oldSelection) 120 120 return; … … 150 150 bool AlternativeTextController::isSpellingMarkerAllowed(Range& misspellingRange) const 151 151 { 152 return !m_ frame.document()->markers().hasMarkers(misspellingRange, DocumentMarker::SpellCheckingExemption);152 return !m_document.markers().hasMarkers(misspellingRange, DocumentMarker::SpellCheckingExemption); 153 153 } 154 154 … … 203 203 return false; 204 204 205 Position caretPosition = m_ frame.selection().selection().start();205 Position caretPosition = m_document.selection().selection().start(); 206 206 207 207 if (m_rangeWithAlternative->endPosition() == caretPosition) { … … 221 221 client->recordAutocorrectionResponse(AutocorrectionResponse::Reverted, corrected, correction); 222 222 223 Ref <Frame> protector(m_frame);224 m_ frame.document()->updateLayout();225 226 m_ frame.selection().setSelection(selectionOfCorrected, FrameSelection::defaultSetSelectionOptions() | FrameSelection::SpellCorrectionTriggered);227 auto range = m_ frame.selection().selection().firstRange();223 RefPtr<Frame> protector(m_document.frame()); 224 m_document.updateLayout(); 225 226 m_document.selection().setSelection(selectionOfCorrected, FrameSelection::defaultSetSelectionOptions() | FrameSelection::SpellCorrectionTriggered); 227 auto range = m_document.selection().selection().firstRange(); 228 228 if (!range) 229 229 return; 230 auto& markers = m_ frame.document()->markers();230 auto& markers = m_document.markers(); 231 231 markers.removeMarkers(*range, OptionSet<DocumentMarker::MarkerType> { DocumentMarker::Spelling, DocumentMarker::Autocorrected }, DocumentMarkerController::RemovePartiallyOverlappingMarker); 232 232 markers.addMarker(*range, DocumentMarker::Replacement); … … 239 239 switch (m_type) { 240 240 case AlternativeTextTypeCorrection: { 241 VisibleSelection selection(m_ frame.selection().selection());241 VisibleSelection selection(m_document.selection().selection()); 242 242 VisiblePosition start(selection.start(), selection.affinity()); 243 243 VisiblePosition p = startOfWord(start, LeftWordIfOnBoundary); 244 244 VisibleSelection adjacentWords = VisibleSelection(p, start); 245 245 auto adjacentWordRange = adjacentWords.toNormalizedRange(); 246 m_ frame.editor().markAllMisspellingsAndBadGrammarInRanges({ TextCheckingType::Spelling, TextCheckingType::Replacement, TextCheckingType::ShowCorrectionPanel }, createLiveRange(adjacentWordRange), createLiveRange(adjacentWordRange), nullptr);246 m_document.editor().markAllMisspellingsAndBadGrammarInRanges({ TextCheckingType::Spelling, TextCheckingType::Replacement, TextCheckingType::ShowCorrectionPanel }, createLiveRange(adjacentWordRange), createLiveRange(adjacentWordRange), nullptr); 247 247 } 248 248 break; … … 267 267 String paragraphText = plainText(TextCheckingParagraph(*m_rangeWithAlternative).paragraphRange()); 268 268 Vector<String> suggestions; 269 textChecker()->getGuessesForWord(m_originalText, paragraphText, m_ frame.selection().selection(), suggestions);269 textChecker()->getGuessesForWord(m_originalText, paragraphText, m_document.selection().selection(), suggestions); 270 270 if (suggestions.isEmpty()) { 271 271 m_rangeWithAlternative = nullptr; … … 305 305 { 306 306 Range* rangeWithAlternative = m_rangeWithAlternative.get(); 307 if (!rangeWithAlternative || m_ frame.document() != &rangeWithAlternative->ownerDocument())307 if (!rangeWithAlternative || m_document != rangeWithAlternative->ownerDocument()) 308 308 return; 309 309 … … 343 343 FloatRect AlternativeTextController::rootViewRectForRange(const SimpleRange& range) const 344 344 { 345 auto* view = m_ frame.view();345 auto* view = m_document.frame()->view(); 346 346 if (!view) 347 347 return { }; … … 351 351 void AlternativeTextController::respondToChangedSelection(const VisibleSelection& oldSelection) 352 352 { 353 VisibleSelection currentSelection(m_ frame.selection().selection());353 VisibleSelection currentSelection(m_document.selection().selection()); 354 354 // When user moves caret to the end of autocorrected word and pauses, we show the panel 355 355 // containing the original pre-correction word so that user can quickly revert the … … 386 386 { 387 387 if (command->isTopLevelCommand() && !command->shouldRetainAutocorrectionIndicator()) 388 m_ frame.document()->markers().removeMarkers(DocumentMarker::CorrectionIndicator);388 m_document.markers().removeMarkers(DocumentMarker::CorrectionIndicator); 389 389 390 390 markPrecedingWhitespaceForDeletedAutocorrectionAfterCommand(command); … … 401 401 if (!range) 402 402 return; 403 auto& markers = m_ frame.document()->markers();403 auto& markers = m_document.markers(); 404 404 markers.addMarker(*range, DocumentMarker::Replacement); 405 405 markers.addMarker(*range, DocumentMarker::SpellCheckingExemption); … … 408 408 EditorClient* AlternativeTextController::editorClient() 409 409 { 410 return m_ frame.page() ? &m_frame.page()->editorClient() : nullptr;410 return m_document.page() ? &m_document.page()->editorClient() : nullptr; 411 411 } 412 412 … … 484 484 // whitespace. So if the user types the same original word again at this position, we 485 485 // won't autocorrect it again. 486 m_ frame.document()->markers().addMarker(precedingCharacterRange, DocumentMarker::DeletedAutocorrection, m_originalStringForLastDeletedAutocorrection);486 m_document.markers().addMarker(precedingCharacterRange, DocumentMarker::DeletedAutocorrection, m_originalStringForLastDeletedAutocorrection); 487 487 } 488 488 489 489 bool AlternativeTextController::processMarkersOnTextToBeReplacedByResult(const TextCheckingResult& result, Range& rangeWithAlternative, const String& stringToBeReplaced) 490 490 { 491 auto& markers = m_ frame.document()->markers();491 auto& markers = m_document.markers(); 492 492 if (markers.hasMarkers(rangeWithAlternative, DocumentMarker::Replacement)) { 493 493 if (result.type == TextCheckingType::Correction) … … 525 525 return false; 526 526 Node* node = endOfWordPosition.containerNode(); 527 auto wordRange = Range::create( *m_frame.document(), node, marker.startOffset(), node, marker.endOffset());527 auto wordRange = Range::create(m_document, node, marker.startOffset(), node, marker.endOffset()); 528 528 String currentWord = plainText(wordRange); 529 529 if (!currentWord.length()) … … 563 563 AlternativeTextClient* AlternativeTextController::alternativeTextClient() 564 564 { 565 return m_ frame.page() ? m_frame.page()->alternativeTextClient() : nullptr;565 return m_document.frame() && m_document.page() ? m_document.page()->alternativeTextClient() : nullptr; 566 566 } 567 567 … … 600 600 // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526 601 601 auto updatedParagraphStartContainingCorrection = resolveCharacterLocation(makeRangeSelectingNodeContents(treeScopeRoot), paragraphOffsetInTreeScope); 602 auto updatedParagraphEndContainingCorrection = makeBoundaryPoint(m_ frame.selection().selection().start());602 auto updatedParagraphEndContainingCorrection = makeBoundaryPoint(m_document.selection().selection().start()); 603 603 if (!updatedParagraphEndContainingCorrection) 604 604 return; … … 622 622 target = triggeringEvent->target(); 623 623 else 624 target = eventTargetElementForDocument( m_frame.document());624 target = eventTargetElementForDocument(&m_document); 625 625 if (!target) 626 626 return false; 627 627 628 auto event = TextEvent::createForDictation(&m_ frame.windowProxy(), text, dictationAlternatives);628 auto event = TextEvent::createForDictation(&m_document.frame()->windowProxy(), text, dictationAlternatives); 629 629 event->setUnderlyingEvent(triggeringEvent); 630 630 … … 658 658 { 659 659 #if USE(DICTATION_ALTERNATIVES) 660 auto& editor = m_ frame.editor();660 auto& editor = m_document.editor(); 661 661 auto selection = editor.selectedRange(); 662 662 if (!selection || !editor.shouldInsertText(alternativeString, selection.get(), EditorInsertAction::Pasted)) -
trunk/Source/WebCore/editing/AlternativeTextController.h
r259575 r260831 36 36 37 37 class CompositeEditCommand; 38 class Document; 38 39 class EditCommand; 39 40 class EditCommandComposition; 40 41 class EditorClient; 41 42 class Event; 42 class Frame;43 43 class Range; 44 44 class TextCheckerClient; … … 62 62 WTF_MAKE_FAST_ALLOCATED; 63 63 public: 64 explicit AlternativeTextController( Frame& frame) UNLESS_ENABLED( : m_frame(frame) { })64 explicit AlternativeTextController(Document& document) UNLESS_ENABLED(: m_document(document) { }) 65 65 ~AlternativeTextController() UNLESS_ENABLED({ }) 66 66 … … 146 146 #endif 147 147 148 Frame& m_frame;148 Document& m_document; 149 149 }; 150 150 -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r260725 r260831 229 229 // Desktop handles this in -[WebHTMLView _updateSelectionForInputManager], but the phone 230 230 // goes another route. 231 frame->editor().cancelComposition();231 m_document->editor().cancelComposition(); 232 232 #endif 233 233 234 if (! frame->editor().willUnapplyEditing(*this))234 if (!m_document->editor().willUnapplyEditing(*this)) 235 235 return; 236 236 … … 239 239 m_commands[i - 1]->doUnapply(); 240 240 241 frame->editor().unappliedEditing(*this);241 m_document->editor().unappliedEditing(*this); 242 242 243 243 if (AXObjectCache::accessibilityEnabled()) … … 259 259 m_document->updateLayoutIgnorePendingStylesheets(); 260 260 261 if (! frame->editor().willReapplyEditing(*this))261 if (!m_document->editor().willReapplyEditing(*this)) 262 262 return; 263 263 … … 265 265 command->doReapply(); 266 266 267 frame->editor().reappliedEditing(*this);267 m_document->editor().reappliedEditing(*this); 268 268 269 269 if (AXObjectCache::accessibilityEnabled()) … … 320 320 bool CompositeEditCommand::willApplyCommand() 321 321 { 322 return frame().editor().willApplyEditing(*this, targetRangesForBindings());322 return document().editor().willApplyEditing(*this, targetRangesForBindings()); 323 323 } 324 324 … … 379 379 void CompositeEditCommand::didApplyCommand() 380 380 { 381 frame().editor().appliedEditing(*this);381 document().editor().appliedEditing(*this); 382 382 } 383 383 … … 385 385 { 386 386 ASSERT(!isEditingTextAreaOrTextInput()); 387 auto firstRange = frame().selection().selection().firstRange();387 auto firstRange = document().selection().selection().firstRange(); 388 388 if (!firstRange) 389 389 return { }; … … 1469 1469 1470 1470 setEndingSelection(VisibleSelection(start, end, DOWNSTREAM)); 1471 frame().editor().clearMisspellingsAndBadGrammar(endingSelection());1471 document().editor().clearMisspellingsAndBadGrammar(endingSelection()); 1472 1472 deleteSelection(false, false, false, false); 1473 1473 … … 1505 1505 applyCommandToComposite(ReplaceSelectionCommand::create(document(), WTFMove(fragment), options)); 1506 1506 1507 frame().editor().markMisspellingsAndBadGrammar(endingSelection());1507 document().editor().markMisspellingsAndBadGrammar(endingSelection()); 1508 1508 1509 1509 // If the selection is in an empty paragraph, restore styles from the old empty paragraph to the new empty paragraph. -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r260725 r260831 335 335 // position (now deleted), we need to clear that style as well. 336 336 if (m_upstreamStart.deprecatedNode() == m_downstreamEnd.deprecatedNode() && m_upstreamStart.deprecatedNode()->isTextNode()) { 337 frame().selection().clearTypingStyle();337 document().selection().clearTypingStyle(); 338 338 return; 339 339 } … … 745 745 auto range = Range::create(document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), endOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent()); 746 746 auto rangeToBeReplaced = Range::create(document(), mergeDestination.deepEquivalent().parentAnchoredEquivalent(), mergeDestination.deepEquivalent().parentAnchoredEquivalent()); 747 if (! frame().editor().client()->shouldMoveRangeAfterDelete(range.ptr(), rangeToBeReplaced.ptr()))747 if (!document().editor().client()->shouldMoveRangeAfterDelete(range.ptr(), rangeToBeReplaced.ptr())) 748 748 return; 749 749 … … 819 819 // but, if we change the selection, come back and start typing that style should be lost. Also see 820 820 // preserveTypingStyle() below. 821 frame().selection().setTypingStyle(m_typingStyle.copyRef());821 document().selection().setTypingStyle(m_typingStyle.copyRef()); 822 822 } 823 823 … … 890 890 Element* textControl = enclosingTextFormControl(m_selectionToDelete.start()); 891 891 if (textControl && textControl->focused()) 892 frame().editor().textWillBeDeletedInTextField(textControl);892 document().editor().textWillBeDeletedInTextField(textControl); 893 893 } 894 894 … … 945 945 946 946 bool shouldRebalaceWhiteSpace = true; 947 if (! frame().editor().behavior().shouldRebalanceWhiteSpacesInSecureField()) {947 if (!document().editor().behavior().shouldRebalanceWhiteSpacesInSecureField()) { 948 948 Node* node = m_endingPosition.deprecatedNode(); 949 949 if (is<Text>(node)) { … … 959 959 960 960 if (!originalString.isEmpty()) 961 frame().editor().deletedAutocorrectionAtPosition(m_endingPosition, originalString);961 document().editor().deletedAutocorrectionAtPosition(m_endingPosition, originalString); 962 962 963 963 setEndingSelection(VisibleSelection(m_endingPosition, affinity, endingSelection().isDirectional())); -
trunk/Source/WebCore/editing/EditCommand.cpp
r254945 r260831 33 33 #include "Editor.h" 34 34 #include "Element.h" 35 #include "Frame.h"36 35 #include "HTMLInputElement.h" 37 36 #include "HTMLTextAreaElement.h" … … 128 127 , m_editingAction(editingAction) 129 128 { 130 ASSERT(document.frame()); 131 setStartingSelection(m_document->frame()->selection().selection()); 129 setStartingSelection(m_document->selection().selection()); 132 130 setEndingSelection(m_startingSelection); 133 131 } … … 136 134 : m_document(document) 137 135 { 138 ASSERT(document.frame());139 136 setStartingSelection(startingSelection); 140 137 setEndingSelection(endingSelection); … … 142 139 143 140 EditCommand::~EditCommand() = default; 144 145 Frame& EditCommand::frame()146 {147 ASSERT(document().frame());148 return *document().frame();149 }150 151 const Frame& EditCommand::frame() const152 {153 ASSERT(document().frame());154 return *document().frame();155 }156 141 157 142 EditAction EditCommand::editingAction() const … … 169 154 bool EditCommand::isEditingTextAreaOrTextInput() const 170 155 { 171 auto* frame = m_document->frame(); 172 if (!frame) 173 return false; 174 175 auto* container = frame->selection().selection().start().containerNode(); 156 auto* container = m_document->selection().selection().start().containerNode(); 176 157 if (!container) 177 158 return false; … … 218 199 if (!AXObjectCache::accessibilityEnabled()) 219 200 return; 220 postTextStateChangeNotification(type, text, frame().selection().selection().start());201 postTextStateChangeNotification(type, text, m_document->selection().selection().start()); 221 202 } 222 203 -
trunk/Source/WebCore/editing/EditCommand.h
r235775 r260831 39 39 class Document; 40 40 class Element; 41 class Frame;42 41 43 42 String inputTypeNameForEditingAction(EditAction); … … 65 64 EditCommand(Document&, const VisibleSelection&, const VisibleSelection&); 66 65 67 const Frame& frame() const;68 Frame& frame();69 66 const Document& document() const { return m_document; } 70 67 Document& document() { return m_document; } -
trunk/Source/WebCore/editing/Editing.cpp
r260759 r260831 899 899 Ref<HTMLElement> createDefaultParagraphElement(Document& document) 900 900 { 901 switch (document. frame()->editor().defaultParagraphSeparator()) {901 switch (document.editor().defaultParagraphSeparator()) { 902 902 case EditorParagraphSeparatorIsDiv: 903 903 return HTMLDivElement::create(document); -
trunk/Source/WebCore/editing/EditingStyle.cpp
r260725 r260831 1687 1687 1688 1688 reconcileTextDecorationProperties(mutableStyle.get()); 1689 bool shouldStyleWithCSS = document-> frame()->editor().shouldStyleWithCSS();1689 bool shouldStyleWithCSS = document->editor().shouldStyleWithCSS(); 1690 1690 if (!shouldStyleWithCSS) 1691 1691 extractTextStyles(*document, *mutableStyle, computedStyle.useFixedFontDefaultSize()); -
trunk/Source/WebCore/editing/Editor.cpp
r260753 r260831 174 174 public: 175 175 ClearTextCommand(Document& document); 176 static void CreateAndApply( const RefPtr<Frame> frame);177 176 static void CreateAndApply(Document&); 177 178 178 private: 179 179 EditAction editingAction() const override; … … 190 190 } 191 191 192 void ClearTextCommand::CreateAndApply( const RefPtr<Frame> frame)193 { 194 if ( frame->selection().isNone())192 void ClearTextCommand::CreateAndApply(Document& document) 193 { 194 if (document.selection().isNone()) 195 195 return; 196 196 197 197 // Don't leave around stale composition state. 198 frame->editor().clear();198 document.editor().clear(); 199 199 200 const VisibleSelection oldSelection = frame->selection().selection();201 frame->selection().selectAll();202 auto clearCommand = adoptRef(*new ClearTextCommand( *frame->document()));200 const VisibleSelection oldSelection = document.selection().selection(); 201 document.selection().selectAll(); 202 auto clearCommand = adoptRef(*new ClearTextCommand(document)); 203 203 clearCommand->setStartingSelection(oldSelection); 204 204 clearCommand->apply(); … … 208 208 using namespace WTF::Unicode; 209 209 210 TemporarySelectionChange::TemporarySelectionChange( Frame& frame, Optional<VisibleSelection> temporarySelection, OptionSet<TemporarySelectionOption> options)211 : m_ frame(frame)210 TemporarySelectionChange::TemporarySelectionChange(Document& document, Optional<VisibleSelection> temporarySelection, OptionSet<TemporarySelectionOption> options) 211 : m_document(RefPtr(&document)) 212 212 , m_options(options) 213 , m_wasIgnoringSelectionChanges( frame.editor().ignoreSelectionChanges())213 , m_wasIgnoringSelectionChanges(document.editor().ignoreSelectionChanges()) 214 214 #if PLATFORM(IOS_FAMILY) 215 , m_appearanceUpdatesWereEnabled( frame.selection().isUpdateAppearanceEnabled())215 , m_appearanceUpdatesWereEnabled(document.selection().isUpdateAppearanceEnabled()) 216 216 #endif 217 217 { 218 218 #if PLATFORM(IOS_FAMILY) 219 219 if (options & TemporarySelectionOption::EnableAppearanceUpdates) 220 frame.selection().setUpdateAppearanceEnabled(true);220 document.selection().setUpdateAppearanceEnabled(true); 221 221 #endif 222 222 223 223 if (options & TemporarySelectionOption::IgnoreSelectionChanges) 224 frame.editor().setIgnoreSelectionChanges(true);224 document.editor().setIgnoreSelectionChanges(true); 225 225 226 226 if (temporarySelection) { 227 m_selectionToRestore = frame.selection().selection();227 m_selectionToRestore = document.selection().selection(); 228 228 setSelection(temporarySelection.value()); 229 229 } … … 237 237 if (m_options & TemporarySelectionOption::IgnoreSelectionChanges) { 238 238 auto revealSelection = m_options & TemporarySelectionOption::RevealSelection ? Editor::RevealSelection::Yes : Editor::RevealSelection::No; 239 m_ frame->editor().setIgnoreSelectionChanges(m_wasIgnoringSelectionChanges, revealSelection);239 m_document->editor().setIgnoreSelectionChanges(m_wasIgnoringSelectionChanges, revealSelection); 240 240 } 241 241 242 242 #if PLATFORM(IOS_FAMILY) 243 243 if (m_options & TemporarySelectionOption::EnableAppearanceUpdates) 244 m_ frame->selection().setUpdateAppearanceEnabled(m_appearanceUpdatesWereEnabled);244 m_document->selection().setUpdateAppearanceEnabled(m_appearanceUpdatesWereEnabled); 245 245 #endif 246 246 } … … 251 251 if (m_options & TemporarySelectionOption::DoNotSetFocus) 252 252 options.add(FrameSelection::DoNotSetFocus); 253 m_ frame->selection().setSelection(selection, options);253 m_document->selection().setSelection(selection, options); 254 254 } 255 255 … … 258 258 VisibleSelection Editor::selectionForCommand(Event* event) 259 259 { 260 auto selection = m_ frame.selection().selection();260 auto selection = m_document.selection().selection(); 261 261 if (!event) 262 262 return selection; … … 277 277 EditingBehavior Editor::behavior() const 278 278 { 279 return EditingBehavior(m_ frame.settings().editingBehaviorType());279 return EditingBehavior(m_document.settings().editingBehaviorType()); 280 280 } 281 281 282 282 EditorClient* Editor::client() const 283 283 { 284 if (Page* page = m_ frame.page())284 if (Page* page = m_document.page()) 285 285 return &page->editorClient(); 286 286 return nullptr; … … 345 345 bool Editor::canEdit() const 346 346 { 347 return m_ frame.selection().selection().rootEditableElement();347 return m_document.selection().selection().rootEditableElement(); 348 348 } 349 349 350 350 bool Editor::canEditRichly() const 351 351 { 352 return m_ frame.selection().selection().isContentRichlyEditable();352 return m_document.selection().selection().isContentRichlyEditable(); 353 353 } 354 354 … … 443 443 bool Editor::canDHTMLCut() 444 444 { 445 if (m_ frame.selection().selection().isInPasswordField())445 if (m_document.selection().selection().isInPasswordField()) 446 446 return false; 447 447 … … 451 451 bool Editor::canDHTMLCopy() 452 452 { 453 if (m_ frame.selection().selection().isInPasswordField())453 if (m_document.selection().selection().isInPasswordField()) 454 454 return false; 455 455 return !dispatchClipboardEvent(findEventTargetFromSelection(), ClipboardEventKind::BeforeCopy); … … 485 485 if (imageElementFromImageDocument(document())) 486 486 return true; 487 const VisibleSelection& selection = m_ frame.selection().selection();487 const VisibleSelection& selection = m_document.selection().selection(); 488 488 return selection.isRange() && !selection.isInPasswordField(); 489 489 } … … 491 491 bool Editor::canPaste() const 492 492 { 493 if (m_ frame.mainFrame().loader().shouldSuppressTextInputFromEditing())493 if (m_document.frame()->mainFrame().loader().shouldSuppressTextInputFromEditing()) 494 494 return false; 495 495 … … 499 499 bool Editor::canDelete() const 500 500 { 501 const VisibleSelection& selection = m_ frame.selection().selection();501 const VisibleSelection& selection = m_document.selection().selection(); 502 502 return selection.isRange() && selection.rootEditableElement(); 503 503 } … … 525 525 if (behavior().shouldAlwaysSmartDelete()) 526 526 return true; 527 return m_ frame.selection().granularity() == WordGranularity;527 return m_document.selection().granularity() == WordGranularity; 528 528 } 529 529 … … 548 548 return false; 549 549 550 if (m_ frame.selection().isRange()) {550 if (m_document.selection().isRange()) { 551 551 if (isTypingAction) { 552 552 TypingCommand::deleteKeyPressed(document(), canSmartCopyOrDelete() ? TypingCommand::SmartDelete : 0, granularity); … … 588 588 void Editor::deleteSelectionWithSmartDelete(bool smartDelete, EditAction editingAction) 589 589 { 590 if (m_ frame.selection().isNone())590 if (m_document.selection().isNone()) 591 591 return; 592 592 … … 596 596 void Editor::clearText() 597 597 { 598 ClearTextCommand::CreateAndApply( &m_frame);598 ClearTextCommand::CreateAndApply(m_document); 599 599 } 600 600 … … 662 662 void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, SelectReplacement selectReplacement, SmartReplace smartReplace, MatchStyle matchStyle, EditAction editingAction, MailBlockquoteHandling mailBlockquoteHandling) 663 663 { 664 VisibleSelection selection = m_ frame.selection().selection();664 VisibleSelection selection = m_document.selection().selection(); 665 665 if (selection.isNone() || !selection.isContentEditable()) 666 666 return; … … 690 690 revealSelectionAfterEditingOperation(); 691 691 692 selection = m_ frame.selection().selection();692 selection = m_document.selection().selection(); 693 693 if (selection.isInPasswordField()) 694 694 return; … … 696 696 if (AXObjectCache::accessibilityEnabled() && editingAction == EditAction::Paste) { 697 697 String text = AccessibilityObject::stringForVisiblePositionRange(command->visibleSelectionForInsertedText()); 698 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypePaste, text, m_ frame.selection().selection());698 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypePaste, text, m_document.selection().selection()); 699 699 command->composition()->setRangeDeletedByUnapply(replacedText.replacedRange()); 700 700 } … … 702 702 if (AXObjectCache::accessibilityEnabled() && editingAction == EditAction::Insert) { 703 703 String text = command->documentFragmentPlainText(); 704 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeInsert, text, m_ frame.selection().selection());704 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeInsert, text, m_document.selection().selection()); 705 705 command->composition()->setRangeDeletedByUnapply(replacedText.replacedRange()); 706 706 } … … 729 729 RefPtr<Range> Editor::selectedRange() 730 730 { 731 return createLiveRange(m_ frame.selection().selection().toNormalizedRange());731 return createLiveRange(m_document.selection().selection().toNormalizedRange()); 732 732 } 733 733 … … 745 745 bool Editor::tryDHTMLCopy() 746 746 { 747 if (m_ frame.selection().selection().isInPasswordField())747 if (m_document.selection().selection().isInPasswordField()) 748 748 return false; 749 749 … … 753 753 bool Editor::tryDHTMLCut() 754 754 { 755 if (m_ frame.selection().selection().isInPasswordField())755 if (m_document.selection().selection().isInPasswordField()) 756 756 return false; 757 757 … … 761 761 bool Editor::shouldInsertText(const String& text, Range* range, EditorInsertAction action) const 762 762 { 763 if (m_ frame.mainFrame().loader().shouldSuppressTextInputFromEditing() && action == EditorInsertAction::Typed)763 if (m_document.frame()->mainFrame().loader().shouldSuppressTextInputFromEditing() && action == EditorInsertAction::Typed) 764 764 return false; 765 765 … … 783 783 bool Editor::hasBidiSelection() const 784 784 { 785 if (m_ frame.selection().isNone())785 if (m_document.selection().isNone()) 786 786 return false; 787 787 788 788 Node* startNode; 789 if (m_ frame.selection().isRange()) {790 startNode = m_ frame.selection().selection().start().downstream().deprecatedNode();791 Node* endNode = m_ frame.selection().selection().end().upstream().deprecatedNode();789 if (m_document.selection().isRange()) { 790 startNode = m_document.selection().selection().start().downstream().deprecatedNode(); 791 Node* endNode = m_document.selection().selection().end().upstream().deprecatedNode(); 792 792 if (enclosingBlock(startNode) != enclosingBlock(endNode)) 793 793 return false; 794 794 } else 795 startNode = m_ frame.selection().selection().visibleStart().deepEquivalent().deprecatedNode();795 startNode = m_document.selection().selection().visibleStart().deepEquivalent().deprecatedNode(); 796 796 797 797 if (!startNode) … … 813 813 TriState Editor::selectionUnorderedListState() const 814 814 { 815 if (m_ frame.selection().isCaret()) {816 if (enclosingElementWithTag(m_ frame.selection().selection().start(), ulTag))815 if (m_document.selection().isCaret()) { 816 if (enclosingElementWithTag(m_document.selection().selection().start(), ulTag)) 817 817 return TrueTriState; 818 } else if (m_ frame.selection().isRange()) {819 auto* startNode = enclosingElementWithTag(m_ frame.selection().selection().start(), ulTag);820 auto* endNode = enclosingElementWithTag(m_ frame.selection().selection().end(), ulTag);818 } else if (m_document.selection().isRange()) { 819 auto* startNode = enclosingElementWithTag(m_document.selection().selection().start(), ulTag); 820 auto* endNode = enclosingElementWithTag(m_document.selection().selection().end(), ulTag); 821 821 if (startNode && endNode && startNode == endNode) 822 822 return TrueTriState; … … 828 828 TriState Editor::selectionOrderedListState() const 829 829 { 830 if (m_ frame.selection().isCaret()) {831 if (enclosingElementWithTag(m_ frame.selection().selection().start(), olTag))830 if (m_document.selection().isCaret()) { 831 if (enclosingElementWithTag(m_document.selection().selection().start(), olTag)) 832 832 return TrueTriState; 833 } else if (m_ frame.selection().isRange()) {834 auto* startNode = enclosingElementWithTag(m_ frame.selection().selection().start(), olTag);835 auto* endNode = enclosingElementWithTag(m_ frame.selection().selection().end(), olTag);833 } else if (m_document.selection().isRange()) { 834 auto* startNode = enclosingElementWithTag(m_document.selection().selection().start(), olTag); 835 auto* endNode = enclosingElementWithTag(m_document.selection().selection().end(), olTag); 836 836 if (startNode && endNode && startNode == endNode) 837 837 return TrueTriState; … … 873 873 RefPtr<Node> Editor::increaseSelectionListLevel() 874 874 { 875 if (!canEditRichly() || m_ frame.selection().isNone())875 if (!canEditRichly() || m_document.selection().isNone()) 876 876 return nullptr; 877 877 … … 883 883 RefPtr<Node> Editor::increaseSelectionListLevelOrdered() 884 884 { 885 if (!canEditRichly() || m_ frame.selection().isNone())885 if (!canEditRichly() || m_document.selection().isNone()) 886 886 return nullptr; 887 887 … … 893 893 RefPtr<Node> Editor::increaseSelectionListLevelUnordered() 894 894 { 895 if (!canEditRichly() || m_ frame.selection().isNone())895 if (!canEditRichly() || m_document.selection().isNone()) 896 896 return nullptr; 897 897 … … 903 903 void Editor::decreaseSelectionListLevel() 904 904 { 905 if (!canEditRichly() || m_ frame.selection().isNone())905 if (!canEditRichly() || m_document.selection().isNone()) 906 906 return; 907 907 … … 933 933 Element* Editor::findEventTargetFromSelection() const 934 934 { 935 return findEventTargetFrom(m_ frame.selection().selection());935 return findEventTargetFrom(m_document.selection().selection()); 936 936 } 937 937 … … 947 947 return; 948 948 949 auto selectionType = m_ frame.selection().selection().selectionType();949 auto selectionType = m_document.selection().selection().selectionType(); 950 950 if (selectionType == VisibleSelection::NoSelection) 951 951 return; … … 953 953 String inputTypeName = inputTypeNameForEditingAction(editingAction); 954 954 String inputEventData = inputEventDataForEditingStyleAndAction(*style, editingAction); 955 RefPtr<Element> element = m_ frame.selection().selection().rootEditableElement();955 RefPtr<Element> element = m_document.selection().selection().rootEditableElement(); 956 956 if (element && !dispatchBeforeInputEvent(*element, inputTypeName, inputEventData)) 957 957 return; … … 970 970 } 971 971 972 client()->didApplyStyle(); 972 if (client()) 973 client()->didApplyStyle(); 973 974 if (element) 974 975 dispatchInputEvent(*element, inputTypeName, inputEventData); … … 985 986 return; 986 987 987 auto selectionType = m_ frame.selection().selection().selectionType();988 auto selectionType = m_document.selection().selection().selectionType(); 988 989 if (selectionType == VisibleSelection::NoSelection) 989 990 return; … … 991 992 String inputTypeName = inputTypeNameForEditingAction(editingAction); 992 993 String inputEventData = inputEventDataForEditingStyleAndAction(style, editingAction); 993 RefPtr<Element> element = m_ frame.selection().selection().rootEditableElement();994 RefPtr<Element> element = m_document.selection().selection().rootEditableElement(); 994 995 if (element && !dispatchBeforeInputEvent(*element, inputTypeName, inputEventData)) 995 996 return; … … 1006 1007 return; 1007 1008 1008 if (!client() || !client()->shouldApplyStyle(style, createLiveRange(m_ frame.selection().selection().toNormalizedRange()).get()))1009 if (!client() || !client()->shouldApplyStyle(style, createLiveRange(m_document.selection().selection().toNormalizedRange()).get())) 1009 1010 return; 1010 1011 applyStyle(style, editingAction); … … 1017 1018 1018 1019 // FIXME: This is wrong for text decorations since m_mutableStyle is empty. 1019 if (!client() || !client()->shouldApplyStyle(style->styleWithResolvedTextDecorations().ptr(), createLiveRange(m_ frame.selection().selection().toNormalizedRange()).get()))1020 if (!client() || !client()->shouldApplyStyle(style->styleWithResolvedTextDecorations().ptr(), createLiveRange(m_document.selection().selection().toNormalizedRange()).get())) 1020 1021 return; 1021 1022 … … 1028 1029 return; 1029 1030 1030 if (client() && client()->shouldApplyStyle(style, createLiveRange(m_ frame.selection().selection().toNormalizedRange()).get()))1031 if (client() && client()->shouldApplyStyle(style, createLiveRange(m_document.selection().selection().toNormalizedRange()).get())) 1031 1032 applyParagraphStyle(style, editingAction); 1032 1033 } … … 1034 1035 bool Editor::selectionStartHasStyle(CSSPropertyID propertyID, const String& value) const 1035 1036 { 1036 if (auto editingStyle = EditingStyle::styleAtSelectionStart(m_ frame.selection().selection(), propertyID == CSSPropertyBackgroundColor))1037 if (auto editingStyle = EditingStyle::styleAtSelectionStart(m_document.selection().selection(), propertyID == CSSPropertyBackgroundColor)) 1037 1038 return editingStyle->hasStyle(propertyID, value); 1038 1039 return false; … … 1041 1042 TriState Editor::selectionHasStyle(CSSPropertyID propertyID, const String& value) const 1042 1043 { 1043 return EditingStyle::create(propertyID, value)->triStateOfStyle(m_ frame.selection().selection());1044 return EditingStyle::create(propertyID, value)->triStateOfStyle(m_document.selection().selection()); 1044 1045 } 1045 1046 1046 1047 String Editor::selectionStartCSSPropertyValue(CSSPropertyID propertyID) 1047 1048 { 1048 RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(m_ frame.selection().selection(),1049 RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(m_document.selection().selection(), 1049 1050 propertyID == CSSPropertyBackgroundColor); 1050 1051 if (!selectionStyle || !selectionStyle->style()) … … 1137 1138 1138 1139 if (!command.preservesTypingStyle()) 1139 m_ frame.selection().clearTypingStyle();1140 m_document.selection().clearTypingStyle(); 1140 1141 1141 1142 // Command will be equal to last edit command only in the case of typing … … 1201 1202 } 1202 1203 1203 Editor::Editor( Frame& frame)1204 : m_ frame(frame)1204 Editor::Editor(Document& document) 1205 : m_document(document) 1205 1206 , m_killRing(makeUnique<PAL::KillRing>()) 1206 , m_spellChecker(makeUnique<SpellChecker>( frame))1207 , m_alternativeTextController(makeUnique<AlternativeTextController>( frame))1207 , m_spellChecker(makeUnique<SpellChecker>(document)) 1208 , m_alternativeTextController(makeUnique<AlternativeTextController>(document)) 1208 1209 , m_editorUIUpdateTimer(*this, &Editor::editorUIUpdateTimerFired) 1209 1210 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS_FAMILY) … … 1221 1222 m_compositionNode = nullptr; 1222 1223 if (EditorClient* client = this->client()) 1223 client->discardedComposition( &m_frame);1224 client->discardedComposition(m_document.frame()); 1224 1225 } 1225 1226 m_customCompositionUnderlines.clear(); … … 1230 1231 m_oldSelectionForEditorUIUpdate = { }; 1231 1232 m_editorUIUpdateTimer.stop(); 1233 m_alternativeTextController->stopAlternativeTextUITimer(); 1232 1234 1233 1235 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS_FAMILY) … … 1239 1241 bool Editor::insertText(const String& text, Event* triggeringEvent, TextEventInputType inputType) 1240 1242 { 1241 return m_ frame.eventHandler().handleTextInputEvent(text, triggeringEvent, inputType);1243 return m_document.frame()->eventHandler().handleTextInputEvent(text, triggeringEvent, inputType); 1242 1244 } 1243 1245 1244 1246 bool Editor::insertTextForConfirmedComposition(const String& text) 1245 1247 { 1246 return m_ frame.eventHandler().handleTextInputEvent(text, 0, TextEventInputComposition);1248 return m_document.frame()->eventHandler().handleTextInputEvent(text, 0, TextEventInputComposition); 1247 1249 } 1248 1250 … … 1303 1305 // is set for the newly focused frame. 1304 1306 if (client() && client()->shouldRevealCurrentSelectionAfterInsertion()) { 1305 if (auto* editedFrame = document->frame()) { 1306 if (auto* page = editedFrame->page()) 1307 page->revealCurrentSelection(); 1308 } 1307 if (auto* page = document->page()) 1308 page->revealCurrentSelection(); 1309 1309 } 1310 1310 } … … 1319 1319 return false; 1320 1320 1321 if (!shouldInsertText("\n", createLiveRange(m_ frame.selection().selection().toNormalizedRange()).get(), EditorInsertAction::Typed))1321 if (!shouldInsertText("\n", createLiveRange(m_document.selection().selection().toNormalizedRange()).get(), EditorInsertAction::Typed)) 1322 1322 return true; 1323 1323 1324 VisiblePosition caret = m_ frame.selection().selection().visibleStart();1324 VisiblePosition caret = m_document.selection().selection().visibleStart(); 1325 1325 bool alignToEdge = isEndOfEditableOrNonEditableContent(caret); 1326 1326 bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrectionBeforeTypingIfAppropriate(); … … 1338 1338 if (!canEditRichly()) 1339 1339 return insertLineBreak(); 1340 1341 if (!shouldInsertText("\n", createLiveRange(m_ frame.selection().selection().toNormalizedRange()).get(), EditorInsertAction::Typed))1340 1341 if (!shouldInsertText("\n", createLiveRange(m_document.selection().selection().toNormalizedRange()).get(), EditorInsertAction::Typed)) 1342 1342 return true; 1343 1343 1344 VisiblePosition caret = m_ frame.selection().selection().visibleStart();1344 VisiblePosition caret = m_document.selection().selection().visibleStart(); 1345 1345 bool alignToEdge = isEndOfEditableOrNonEditableContent(caret); 1346 1346 bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrectionBeforeTypingIfAppropriate(); … … 1406 1406 } 1407 1407 1408 if (enclosingTextFormControl(m_ frame.selection().selection().start()))1408 if (enclosingTextFormControl(m_document.selection().selection().start())) 1409 1409 Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForDataTransfer(), canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace); 1410 1410 else { … … 1425 1425 #else 1426 1426 // FIXME: Delete after <http://webkit.org/b/177618> lands. 1427 Pasteboard::createForCopyAndPaste()->writeSelection(*selection, canSmartCopyOrDelete(), m_frame, IncludeImageAltTextForDataTransfer);1427 Pasteboard::createForCopyAndPaste()->writeSelection(*selection, canSmartCopyOrDelete(), *m_document.frame(), IncludeImageAltTextForDataTransfer); 1428 1428 #endif 1429 1429 } … … 1434 1434 String text; 1435 1435 if (AXObjectCache::accessibilityEnabled()) 1436 text = AccessibilityObject::stringForVisiblePositionRange(m_ frame.selection().selection());1436 text = AccessibilityObject::stringForVisiblePositionRange(m_document.selection().selection()); 1437 1437 deleteSelectionWithSmartDelete(canSmartCopyOrDelete(), EditAction::Cut); 1438 1438 if (AXObjectCache::accessibilityEnabled()) 1439 postTextStateChangeNotificationForCut(text, m_ frame.selection().selection());1439 postTextStateChangeNotificationForCut(text, m_document.selection().selection()); 1440 1440 } 1441 1441 } … … 1454 1454 updateMarkersForWordsAffectedByEditing(false); 1455 1455 ResourceCacheValidationSuppressor validationSuppressor(document().cachedResourceLoader()); 1456 if (m_ frame.selection().selection().isContentRichlyEditable())1456 if (m_document.selection().selection().isContentRichlyEditable()) 1457 1457 pasteWithPasteboard(&pasteboard, { PasteOption::AllowPlainText }); 1458 1458 else … … 1479 1479 ResourceCacheValidationSuppressor validationSuppressor(document().cachedResourceLoader()); 1480 1480 auto pasteboard = Pasteboard::createForCopyAndPaste(); 1481 if (m_ frame.selection().selection().isContentRichlyEditable())1481 if (m_document.selection().selection().isContentRichlyEditable()) 1482 1482 pasteWithPasteboard(pasteboard.get(), { PasteOption::AllowPlainText, PasteOption::AsQuotation }); 1483 1483 else … … 1617 1617 return; 1618 1618 1619 auto startContainer = makeRefPtr(m_ frame.selection().selection().start().containerNode());1619 auto startContainer = makeRefPtr(m_document.selection().selection().start().containerNode()); 1620 1620 if (!startContainer) 1621 1621 return; … … 1851 1851 { 1852 1852 #if PLATFORM(IOS_FAMILY) 1853 if (inSameParagraph(m_ frame.selection().selection().visibleStart(), m_frame.selection().selection().visibleEnd()) &&1854 baseWritingDirectionForSelectionStart() == direction)1853 if (inSameParagraph(m_document.selection().selection().visibleStart(), m_document.selection().selection().visibleEnd()) 1854 && baseWritingDirectionForSelectionStart() == direction) 1855 1855 return; 1856 1856 #endif … … 1882 1882 auto result = WritingDirection::LeftToRight; 1883 1883 1884 Position pos = m_ frame.selection().selection().visibleStart().deepEquivalent();1884 Position pos = m_document.selection().selection().visibleStart().deepEquivalent(); 1885 1885 Node* node = pos.deprecatedNode(); 1886 1886 if (!node) … … 1917 1917 VisibleSelection selection; 1918 1918 selection.setWithoutValidation(range->startPosition(), range->endPosition()); 1919 m_ frame.selection().setSelection(selection, { });1919 m_document.selection().setSelection(selection, { }); 1920 1920 } 1921 1921 … … 1952 1952 class SetCompositionScope { 1953 1953 public: 1954 SetCompositionScope( Frame& frame)1955 : m_ frame(frame)1956 , m_typingGestureIndicator( frame)1954 SetCompositionScope(Document& document) 1955 : m_document(RefPtr(&document)) 1956 , m_typingGestureIndicator(*document.frame()) 1957 1957 { 1958 m_ frame->editor().setIgnoreSelectionChanges(true);1958 m_document->editor().setIgnoreSelectionChanges(true); 1959 1959 } 1960 1960 1961 1961 ~SetCompositionScope() 1962 1962 { 1963 m_ frame->editor().setIgnoreSelectionChanges(false);1964 if (auto* editorClient = m_ frame->editor().client())1963 m_document->editor().setIgnoreSelectionChanges(false); 1964 if (auto* editorClient = m_document->editor().client()) 1965 1965 editorClient->didUpdateComposition(); 1966 1966 } 1967 1967 1968 Ref <Frame> m_frame;1968 RefPtr<Document> m_document; 1969 1969 UserTypingGestureIndicator m_typingGestureIndicator; 1970 1970 }; … … 1973 1973 { 1974 1974 ASSERT(mode == ConfirmComposition || mode == CancelComposition); 1975 SetCompositionScope setCompositionScope(m_ frame);1975 SetCompositionScope setCompositionScope(m_document); 1976 1976 1977 1977 if (mode == CancelComposition) … … 1984 1984 m_customCompositionHighlights.clear(); 1985 1985 1986 if (m_ frame.selection().isNone())1986 if (m_document.selection().isNone()) 1987 1987 return; 1988 1988 … … 2000 2000 if (mode == CancelComposition) { 2001 2001 // An open typing command that disagrees about current selection would cause issues with typing later on. 2002 TypingCommand::closeTyping( &m_frame);2002 TypingCommand::closeTyping(m_document); 2003 2003 } 2004 2004 } … … 2006 2006 void Editor::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const Vector<CompositionHighlight>& highlights, unsigned selectionStart, unsigned selectionEnd) 2007 2007 { 2008 SetCompositionScope setCompositionScope(m_ frame);2008 SetCompositionScope setCompositionScope(m_document); 2009 2009 2010 2010 // Updates styles before setting selection for composition to prevent … … 2015 2015 selectComposition(); 2016 2016 2017 if (m_ frame.selection().isNone())2017 if (m_document.selection().isNone()) 2018 2018 return; 2019 2019 … … 2023 2023 // We pass TypingCommand::TextCompositionFinal here to indicate that we are removing composition text that has been finalized. 2024 2024 TypingCommand::deleteSelection(document(), 0, TypingCommand::TextCompositionFinal); 2025 const VisibleSelection& currentSelection = m_ frame.selection().selection();2025 const VisibleSelection& currentSelection = m_document.selection().selection(); 2026 2026 if (currentSelection.isRange()) { 2027 2027 // If deletion was prevented, then we need to collapse the selection to the end so that the original text will not be recomposed. 2028 m_ frame.selection().setSelection({ currentSelection.end(), currentSelection.end() });2028 m_document.selection().setSelection({ currentSelection.end(), currentSelection.end() }); 2029 2029 } 2030 2030 } … … 2082 2082 2083 2083 // Find out what node has the composition now. 2084 Position base = m_ frame.selection().selection().base().downstream();2085 Position extent = m_ frame.selection().selection().extent();2084 Position base = m_document.selection().selection().base().downstream(); 2085 Position extent = m_document.selection().selection().extent(); 2086 2086 Node* baseNode = base.deprecatedNode(); 2087 2087 unsigned baseOffset = base.deprecatedEditingOffset(); … … 2109 2109 unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOffset); 2110 2110 auto selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end); 2111 m_ frame.selection().setSelectedRange(selectedRange.ptr(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::No);2111 m_document.selection().setSelectedRange(selectedRange.ptr(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::No); 2112 2112 } 2113 2113 } … … 2123 2123 return; 2124 2124 2125 if (auto selectedRange = m_ frame.selection().selection().toNormalizedRange())2125 if (auto selectedRange = m_document.selection().selection().toNormalizedRange()) 2126 2126 document().markers().removeMarkers(*selectedRange, DocumentMarker::Spelling); 2127 2127 … … 2138 2138 // FIXME: On Mac OS X, when use "learn" button on "Spelling and Grammar" panel, we don't call this function. It should remove misspelling markers around the learned word, see <rdar://problem/5396072>. 2139 2139 2140 if (auto selectedRange = m_ frame.selection().selection().toNormalizedRange())2140 if (auto selectedRange = m_document.selection().selection().toNormalizedRange()) 2141 2141 document().markers().removeMarkers(*selectedRange, DocumentMarker::Spelling); 2142 2142 … … 2150 2150 void Editor::advanceToNextMisspelling(bool startBeforeSelection) 2151 2151 { 2152 Ref< Frame> protection(m_frame);2152 Ref<Document> protectedDocument(m_document); 2153 2153 2154 2154 // The basic approach is to search in two phases - from the selection end to the end of the doc, and … … 2157 2157 // Start at the end of the selection, search to edge of document. Starting at the selection end makes 2158 2158 // repeated "check spelling" commands work. 2159 VisibleSelection selection(m_ frame.selection().selection());2159 VisibleSelection selection(m_document.selection().selection()); 2160 2160 Ref<Range> spellingSearchRange = rangeOfContents(document()); 2161 2161 … … 2306 2306 // FIXME 4859190: This gets confused with doubled punctuation at the end of a paragraph 2307 2307 auto badGrammarRange = resolveCharacterRange(*grammarSearchRange, { grammarPhraseOffset + grammarDetail.range.location, grammarDetail.range.length }); 2308 m_ frame.selection().setSelection(VisibleSelection(badGrammarRange, SEL_DEFAULT_AFFINITY));2309 m_ frame.selection().revealSelection();2308 m_document.selection().setSelection(VisibleSelection(badGrammarRange, SEL_DEFAULT_AFFINITY)); 2309 m_document.selection().revealSelection(); 2310 2310 2311 2311 client()->updateSpellingUIWithGrammarString(badGrammarPhrase, grammarDetail); … … 2318 2318 2319 2319 auto misspellingRange = resolveCharacterRange(spellingSearchRange, { misspellingOffset, misspelledWord.length() }); 2320 m_ frame.selection().setSelection(VisibleSelection(misspellingRange, DOWNSTREAM));2321 m_ frame.selection().revealSelection();2320 m_document.selection().setSelection(VisibleSelection(misspellingRange, DOWNSTREAM)); 2321 m_document.selection().revealSelection(); 2322 2322 2323 2323 client()->updateSpellingUIWithMisspelledWord(misspelledWord); … … 2333 2333 return String(); 2334 2334 2335 VisibleSelection selection = m_ frame.selection().selection();2335 VisibleSelection selection = m_document.selection().selection(); 2336 2336 if (!selection.isContentEditable() || selection.isNone()) 2337 2337 return String(); … … 2387 2387 { 2388 2388 #if USE(GRAMMAR_CHECKING) 2389 auto range = m_ frame.selection().selection().toNormalizedRange();2389 auto range = m_document.selection().selection().toNormalizedRange(); 2390 2390 if (!range || !client()) 2391 2391 return false; … … 2402 2402 Vector<String> guesses; 2403 2403 if (client()) 2404 textChecker()->getGuessesForWord(word, String(), m_ frame.selection().selection(), guesses);2404 textChecker()->getGuessesForWord(word, String(), m_document.selection().selection(), guesses); 2405 2405 return guesses; 2406 2406 } … … 2410 2410 if (unifiedTextCheckerEnabled()) { 2411 2411 Optional<SimpleRange> range; 2412 VisibleSelection selection = m_ frame.selection().selection();2412 VisibleSelection selection = m_document.selection().selection(); 2413 2413 if (selection.isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) { 2414 2414 VisibleSelection wordSelection = VisibleSelection(selection.base()); … … 2470 2470 void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, const VisibleSelection& selectionAfterTyping, bool doReplacement) 2471 2471 { 2472 Ref< Frame> protection(m_frame);2472 Ref<Document> protectedDocument(m_document); 2473 2473 2474 2474 if (platformDrivenTextCheckerEnabled()) … … 2592 2592 if (!autocorrectedString.isEmpty()) { 2593 2593 VisibleSelection newSelection(*misspellingRange, DOWNSTREAM); 2594 if (newSelection != m_ frame.selection().selection()) {2595 if (!m_ frame.selection().shouldChangeSelection(newSelection))2594 if (newSelection != m_document.selection().selection()) { 2595 if (!m_document.selection().shouldChangeSelection(newSelection)) 2596 2596 return; 2597 m_ frame.selection().setSelection(newSelection);2597 m_document.selection().setSelection(newSelection); 2598 2598 } 2599 2599 2600 if (!m_ frame.editor().shouldInsertText(autocorrectedString, misspellingRange.get(), EditorInsertAction::Typed))2600 if (!m_document.editor().shouldInsertText(autocorrectedString, misspellingRange.get(), EditorInsertAction::Typed)) 2601 2601 return; 2602 m_ frame.editor().replaceSelectionWithText(autocorrectedString, SelectReplacement::No, SmartReplace::No, EditAction::Insert);2602 m_document.editor().replaceSelectionWithText(autocorrectedString, SelectReplacement::No, SmartReplace::No, EditAction::Insert); 2603 2603 2604 2604 // Reset the charet one character further. 2605 m_ frame.selection().moveTo(m_frame.selection().selection().end());2606 m_ frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);2605 m_document.selection().moveTo(m_document.selection().selection().end()); 2606 m_document.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); 2607 2607 } 2608 2608 … … 2676 2676 bool Editor::isSpellCheckingEnabledInFocusedNode() const 2677 2677 { 2678 return isSpellCheckingEnabledFor(m_ frame.selection().selection().start().deprecatedNode());2678 return isSpellCheckingEnabledFor(m_document.selection().selection().start().deprecatedNode()); 2679 2679 } 2680 2680 … … 2724 2724 return; 2725 2725 2726 bool asynchronous = m_ frame.settings().asynchronousSpellCheckingEnabled() && !shouldShowCorrectionPanel;2726 bool asynchronous = m_document.settings().asynchronousSpellCheckingEnabled() && !shouldShowCorrectionPanel; 2727 2727 2728 2728 // In asynchronous mode, we intentionally check paragraph-wide sentence. … … 2739 2739 2740 2740 Vector<TextCheckingResult> results; 2741 checkTextOfParagraph(*textChecker(), paragraphToCheck.text(), resolvedOptions, results, m_ frame.selection().selection());2741 checkTextOfParagraph(*textChecker(), paragraphToCheck.text(), resolvedOptions, results, m_document.selection().selection()); 2742 2742 markAndReplaceFor(request.releaseNonNull(), results); 2743 2743 } … … 2785 2785 void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<TextCheckingResult>& results) 2786 2786 { 2787 Ref< Frame> protection(m_frame);2787 Ref<Document> protectedDocument(m_document); 2788 2788 2789 2789 auto textCheckingOptions = request.data().checkingTypes(); … … 2809 2809 2810 2810 if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) { 2811 if (m_ frame.selection().selection().selectionType() == VisibleSelection::CaretSelection) {2811 if (m_document.selection().selection().selectionType() == VisibleSelection::CaretSelection) { 2812 2812 // Attempt to save the caret position so we can restore it later if needed 2813 Position caretPosition = m_ frame.selection().selection().end();2813 Position caretPosition = m_document.selection().selection().end(); 2814 2814 selectionOffset = paragraph.offsetTo(caretPosition).releaseReturnValue(); 2815 2815 restoreSelectionAfterChange = true; … … 2893 2893 2894 2894 VisibleSelection selectionToReplace(rangeToReplace, DOWNSTREAM); 2895 if (selectionToReplace != m_ frame.selection().selection()) {2896 if (!m_ frame.selection().shouldChangeSelection(selectionToReplace))2895 if (selectionToReplace != m_document.selection().selection()) { 2896 if (!m_document.selection().shouldChangeSelection(selectionToReplace)) 2897 2897 continue; 2898 2898 } 2899 2899 2900 2900 if (resultType == TextCheckingType::Link) { 2901 m_ frame.selection().setSelection(selectionToReplace);2901 m_document.selection().setSelection(selectionToReplace); 2902 2902 selectionChanged = true; 2903 2903 restoreSelectionAfterChange = false; … … 2908 2908 2909 2909 if (AXObjectCache* cache = document().existingAXObjectCache()) { 2910 if (Element* root = m_ frame.selection().selection().rootEditableElement())2910 if (Element* root = m_document.selection().selection().rootEditableElement()) 2911 2911 cache->postNotification(root, AXObjectCache::AXAutocorrectionOccured); 2912 2912 } … … 2938 2938 if (restoreSelectionAfterChange && selectionOffset <= extendedParagraph.rangeLength()) { 2939 2939 auto selectionRange = extendedParagraph.subrange({ 0, selectionOffset }); 2940 m_ frame.selection().moveTo(selectionRange->endPosition(), DOWNSTREAM);2940 m_document.selection().moveTo(selectionRange->endPosition(), DOWNSTREAM); 2941 2941 if (adjustSelectionForParagraphBoundaries) 2942 m_ frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);2942 m_document.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); 2943 2943 } else { 2944 2944 // If this fails for any reason, the fallback is to go one position beyond the last replacement 2945 m_ frame.selection().moveTo(m_frame.selection().selection().end());2946 m_ frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);2945 m_document.selection().moveTo(m_document.selection().selection().end()); 2946 m_document.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); 2947 2947 } 2948 2948 } … … 3021 3021 // selection, and remove words between the selection boundaries. 3022 3022 // 3023 VisiblePosition startOfSelection = m_ frame.selection().selection().start();3024 VisiblePosition endOfSelection = m_ frame.selection().selection().end();3023 VisiblePosition startOfSelection = m_document.selection().selection().start(); 3024 VisiblePosition endOfSelection = m_document.selection().selection().end(); 3025 3025 if (startOfSelection.isNull()) 3026 3026 return; … … 3094 3094 RefPtr<Range> Editor::rangeForPoint(const IntPoint& windowPoint) 3095 3095 { 3096 auto document = m_ frame.documentAtPoint(windowPoint);3096 auto document = m_document.frame()->documentAtPoint(windowPoint); 3097 3097 if (!document) 3098 3098 return nullptr; 3099 3099 3100 3100 auto frame = document->frame(); 3101 3101 if (!frame) 3102 3102 return nullptr; 3103 3103 3104 3104 auto frameView = frame->view(); 3105 3105 if (!frameView) … … 3117 3117 3118 3118 SelectionRevealMode revealMode = SelectionRevealMode::Reveal; 3119 m_ frame.selection().revealSelection(revealMode, alignment, revealExtentOption);3119 m_document.selection().revealSelection(revealMode, alignment, revealExtentOption); 3120 3120 } 3121 3121 … … 3129 3129 // FIXME: Should suppress selection change notifications during a composition change <https://webkit.org/b/38830> 3130 3130 if (!ignore) 3131 respondToChangedSelection(m_ frame.selection().selection(), { });3131 respondToChangedSelection(m_document.selection().selection(), { }); 3132 3132 #endif 3133 3133 if (!ignore && shouldRevealExistingSelection == RevealSelection::Yes) … … 3152 3152 if (!m_compositionNode) 3153 3153 return false; 3154 const VisibleSelection& selection = m_ frame.selection().selection();3154 const VisibleSelection& selection = m_document.selection().selection(); 3155 3155 Position start = selection.start(); 3156 3156 if (start.deprecatedNode() != m_compositionNode) … … 3175 3175 return; 3176 3176 3177 VisibleSelection selection = m_ frame.selection().selection();3177 VisibleSelection selection = m_document.selection().selection(); 3178 3178 if (!selection.isCaret()) 3179 3179 return; … … 3200 3200 3201 3201 // Select the two characters. 3202 if (newSelection != m_ frame.selection().selection()) {3203 if (!m_ frame.selection().shouldChangeSelection(newSelection))3202 if (newSelection != m_document.selection().selection()) { 3203 if (!m_document.selection().shouldChangeSelection(newSelection)) 3204 3204 return; 3205 m_ frame.selection().setSelection(newSelection);3205 m_document.selection().setSelection(newSelection); 3206 3206 } 3207 3207 … … 3255 3255 void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection, OptionSet<FrameSelection::SetSelectionOption> options) 3256 3256 { 3257 Ref< Frame> protection(m_frame);3257 Ref<Document> protectedDocument(m_document); 3258 3258 3259 3259 // If the new selection is orphaned, then don't update the selection. … … 3265 3265 // The old selection can be invalid here and calling shouldChangeSelection can produce some strange calls. 3266 3266 // See <rdar://problem/5729315> Some shouldChangeSelectedDOMRange contain Ranges for selections that are no longer valid 3267 bool selectionDidNotChangeDOMPosition = newSelection == m_ frame.selection().selection();3268 if (selectionDidNotChangeDOMPosition || m_ frame.selection().shouldChangeSelection(newSelection))3269 m_ frame.selection().setSelection(newSelection, options);3267 bool selectionDidNotChangeDOMPosition = newSelection == m_document.selection().selection(); 3268 if (selectionDidNotChangeDOMPosition || m_document.selection().shouldChangeSelection(newSelection)) 3269 m_document.selection().setSelection(newSelection, options); 3270 3270 3271 3271 // Some editing operations change the selection visually without affecting its position within the DOM. … … 3282 3282 #endif 3283 3283 if (selectionDidNotChangeDOMPosition && client()) 3284 client()->respondToChangedSelection( &m_frame);3284 client()->respondToChangedSelection(m_document.frame()); 3285 3285 } 3286 3286 … … 3288 3288 { 3289 3289 TextIteratorBehavior behavior = TextIteratorDefaultBehavior; 3290 if (m_ frame.settings().selectionAcrossShadowBoundariesEnabled())3290 if (m_document.settings().selectionAcrossShadowBoundariesEnabled()) 3291 3291 behavior |= TextIteratorTraversesFlatTree; 3292 3292 return selectedText(behavior); … … 3296 3296 { 3297 3297 TextIteratorBehavior behavior = TextIteratorEmitsImageAltText; 3298 if (m_ frame.settings().selectionAcrossShadowBoundariesEnabled())3298 if (m_document.settings().selectionAcrossShadowBoundariesEnabled()) 3299 3299 behavior |= TextIteratorTraversesFlatTree; 3300 3300 return selectedText(behavior); … … 3304 3304 { 3305 3305 // We remove '\0' characters because they are not visibly rendered to the user. 3306 auto& selection = m_ frame.selection().selection();3306 auto& selection = m_document.selection().selection(); 3307 3307 auto start = selection.start(); 3308 3308 auto end = selection.end(); … … 3314 3314 RefPtr<TextPlaceholderElement> Editor::insertTextPlaceholder(const IntSize& size) 3315 3315 { 3316 if (m_ frame.selection().isNone() || !m_frame.selection().selection().isContentEditable())3316 if (m_document.selection().isNone() || !m_document.selection().selection().isContentEditable()) 3317 3317 return nullptr; 3318 3318 … … 3322 3322 deleteSelectionWithSmartDelete(false); 3323 3323 3324 auto range = m_ frame.selection().selection().toNormalizedRange();3324 auto range = m_document.selection().selection().toNormalizedRange(); 3325 3325 if (!range) 3326 3326 return nullptr; … … 3330 3330 3331 3331 VisibleSelection newSelection { positionBeforeNode(placeholder.ptr()), positionAfterNode(placeholder.ptr()) }; 3332 m_ frame.selection().setSelection(newSelection, FrameSelection::defaultSetSelectionOptions(UserTriggered));3332 m_document.selection().setSelection(newSelection, FrameSelection::defaultSetSelectionOptions(UserTriggered)); 3333 3333 3334 3334 return placeholder; … … 3350 3350 3351 3351 // To match the Legacy WebKit implementation, set the text insertion point to be before where the placeholder use to be. 3352 if (m_ frame.selection().isFocusedAndActive() && document->focusedElement() == savedRootEditableElement)3353 m_ frame.selection().setSelection(VisibleSelection { savedPositionBeforePlaceholder, SEL_DEFAULT_AFFINITY }, FrameSelection::defaultSetSelectionOptions(UserTriggered));3352 if (m_document.selection().isFocusedAndActive() && document->focusedElement() == savedRootEditableElement) 3353 m_document.selection().setSelection(VisibleSelection { savedPositionBeforePlaceholder, SEL_DEFAULT_AFFINITY }, FrameSelection::defaultSetSelectionOptions(UserTriggered)); 3354 3354 } 3355 3355 … … 3403 3403 { 3404 3404 #if PLATFORM(IOS_FAMILY) 3405 if (m_ frame.selectionChangeCallbacksDisabled())3405 if (m_document.frame() && m_document.frame()->selectionChangeCallbacksDisabled()) 3406 3406 return true; 3407 3407 #endif … … 3412 3412 { 3413 3413 if (style.isEmpty()) { 3414 m_ frame.selection().clearTypingStyle();3414 m_document.selection().clearTypingStyle(); 3415 3415 return; 3416 3416 } … … 3418 3418 // Calculate the current typing style. 3419 3419 RefPtr<EditingStyle> typingStyle; 3420 if (auto existingTypingStyle = m_ frame.selection().typingStyle())3420 if (auto existingTypingStyle = m_document.selection().typingStyle()) 3421 3421 typingStyle = existingTypingStyle->copy(); 3422 3422 else 3423 3423 typingStyle = EditingStyle::create(); 3424 typingStyle->overrideTypingStyleAt(style, m_ frame.selection().selection().visibleStart().deepEquivalent());3424 typingStyle->overrideTypingStyleAt(style, m_document.selection().selection().visibleStart().deepEquivalent()); 3425 3425 3426 3426 // Handle block styles, substracting these from the typing style. … … 3430 3430 3431 3431 // Set the remaining style as the typing style. 3432 m_ frame.selection().setTypingStyle(WTFMove(typingStyle));3432 m_document.selection().setTypingStyle(WTFMove(typingStyle)); 3433 3433 } 3434 3434 … … 3489 3489 bool Editor::findString(const String& target, FindOptions options) 3490 3490 { 3491 Ref< Frame> protection(m_frame);3492 3493 VisibleSelection selection = m_ frame.selection().selection();3491 Ref<Document> protectedDocument(m_document); 3492 3493 VisibleSelection selection = m_document.selection().selection(); 3494 3494 3495 3495 auto resultRange = rangeOfString(target, createLiveRange(selection.firstRange()).get(), options); … … 3497 3497 return false; 3498 3498 3499 m_ frame.selection().setSelection(VisibleSelection(*resultRange, DOWNSTREAM));3499 m_document.selection().setSelection(VisibleSelection(*resultRange, DOWNSTREAM)); 3500 3500 3501 3501 if (!(options.contains(DoNotRevealSelection))) 3502 m_ frame.selection().revealSelection();3502 m_document.selection().revealSelection(); 3503 3503 3504 3504 return true; … … 3597 3597 if (&range->ownerDocument() == &document()) 3598 3598 searchRange = range; 3599 else if (!isFrameInRange( m_frame, *range))3599 else if (!isFrameInRange(*m_document.frame(), *range)) 3600 3600 return 0; 3601 3601 } … … 3667 3667 3668 3668 if (client()) 3669 client()->respondToChangedSelection( &m_frame);3669 client()->respondToChangedSelection(m_document.frame()); 3670 3670 3671 3671 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS_FAMILY) … … 3690 3690 bool Editor::shouldDetectTelephoneNumbers() const 3691 3691 { 3692 return m_ frame.document() && document().isTelephoneNumberParsingEnabled() && TelephoneNumberDetector::isSupported();3692 return m_document.isTelephoneNumberParsingEnabled() && TelephoneNumberDetector::isSupported(); 3693 3693 } 3694 3694 … … 3733 3733 m_detectedTelephoneNumberRanges.clear(); 3734 3734 3735 auto& selection = m_ frame.selection();3735 auto& selection = m_document.selection(); 3736 3736 if (selection.isRange()) { 3737 3737 if (auto selectedRange = selection.selection().firstRange()) { … … 3750 3750 } 3751 3751 3752 if (auto* page = m_ frame.page())3752 if (auto* page = m_document.page()) 3753 3753 page->servicesOverlayController().selectedTelephoneNumberRangesChanged(); 3754 3754 } … … 3775 3775 VisibleSelection newAdjacentWords; 3776 3776 VisibleSelection newSelectedSentence; 3777 bool caretBrowsing = m_ frame.settings().caretBrowsingEnabled();3778 if (m_ frame.selection().selection().isContentEditable() || caretBrowsing) {3779 VisiblePosition newStart(m_ frame.selection().selection().visibleStart());3777 bool caretBrowsing = m_document.settings().caretBrowsingEnabled(); 3778 if (m_document.selection().selection().isContentEditable() || caretBrowsing) { 3779 VisiblePosition newStart(m_document.selection().selection().visibleStart()); 3780 3780 #if !PLATFORM(IOS_FAMILY) 3781 3781 newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary)); … … 3830 3830 m_alternativeTextController->respondToChangedSelection(oldSelection); 3831 3831 3832 m_oldSelectionForEditorUIUpdate = m_ frame.selection().selection();3832 m_oldSelectionForEditorUIUpdate = m_document.selection().selection(); 3833 3833 3834 3834 #if ENABLE(ATTACHMENT_ELEMENT) … … 3857 3857 bool Editor::selectionStartHasMarkerFor(DocumentMarker::MarkerType markerType, int from, int length) const 3858 3858 { 3859 Node* node = findFirstMarkable(m_ frame.selection().selection().start().deprecatedNode());3859 Node* node = findFirstMarkable(m_document.selection().selection().start().deprecatedNode()); 3860 3860 if (!node) 3861 3861 return false; … … 3935 3935 String Editor::stringForCandidateRequest() const 3936 3936 { 3937 auto& selection = m_ frame.selection().selection();3937 auto& selection = m_document.selection().selection(); 3938 3938 auto range = selection.isCaret() 3939 3940 3939 ? wordRangeFromPosition(selection.start()) 3940 : createLiveRange(selection.toNormalizedRange()); 3941 3941 if (!range) 3942 3942 return { }; … … 3948 3948 RefPtr<Range> Editor::contextRangeForCandidateRequest() const 3949 3949 { 3950 const VisibleSelection& selection = m_ frame.selection().selection();3950 const VisibleSelection& selection = m_document.selection().selection(); 3951 3951 return makeRange(startOfParagraph(selection.visibleStart()), endOfParagraph(selection.visibleEnd())); 3952 3952 } … … 4015 4015 FontAttributes attributes; 4016 4016 Node* nodeToRemove = nullptr; 4017 auto* style = styleForSelectionStart( &m_frame, nodeToRemove);4017 auto* style = styleForSelectionStart(m_document.frame(), nodeToRemove); 4018 4018 if (!style) { 4019 4019 if (nodeToRemove) … … 4056 4056 } 4057 4057 4058 attributes.textLists = editableTextListsAtPositionInDescendingOrder(m_ frame.selection().selection().start());4058 attributes.textLists = editableTextListsAtPositionInDescendingOrder(m_document.selection().selection().start()); 4059 4059 4060 4060 switch (style->textAlign()) { … … 4082 4082 } 4083 4083 4084 auto typingStyle = makeRefPtr(m_ frame.selection().typingStyle());4084 auto typingStyle = makeRefPtr(m_document.selection().typingStyle()); 4085 4085 if (typingStyle && typingStyle->style()) { 4086 4086 auto value = typingStyle->style()->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); … … 4170 4170 client()->didRemoveAttachmentWithIdentifier(identifier); 4171 4171 4172 auto* document = m_frame.document();4173 if (!document)4174 return;4175 4176 4172 for (auto& identifier : insertedAttachmentIdentifiers) { 4177 if (auto attachment = document->attachmentForIdentifier(identifier))4173 if (auto attachment = m_document.attachmentForIdentifier(identifier)) 4178 4174 client()->didInsertAttachmentWithIdentifier(identifier, attachment->attributeWithoutSynchronization(HTMLNames::srcAttr), attachment->hasEnclosingImage()); 4179 4175 else … … 4198 4194 void Editor::handleAcceptedCandidate(TextCheckingResult acceptedCandidate) 4199 4195 { 4200 const VisibleSelection& selection = m_ frame.selection().selection();4196 const VisibleSelection& selection = m_document.selection().selection(); 4201 4197 4202 4198 m_isHandlingAcceptedCandidate = true; … … 4217 4213 bool Editor::unifiedTextCheckerEnabled() const 4218 4214 { 4219 return WebCore::unifiedTextCheckerEnabled( &m_frame);4215 return WebCore::unifiedTextCheckerEnabled(m_document.frame()); 4220 4216 } 4221 4217 … … 4233 4229 { 4234 4230 m_overwriteModeEnabled = !m_overwriteModeEnabled; 4235 m_frame.selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 4236 } 4237 4238 Document& Editor::document() const 4239 { 4240 ASSERT(m_frame.document()); 4241 return *m_frame.document(); 4231 m_document.selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 4242 4232 } 4243 4233 … … 4292 4282 hasMultipleFonts = false; 4293 4283 4294 if (!m_ frame.selection().isRange()) {4284 if (!m_document.selection().isRange()) { 4295 4285 Node* nodeToRemove; 4296 auto* style = styleForSelectionStart( &m_frame, nodeToRemove); // sets nodeToRemove4286 auto* style = styleForSelectionStart(m_document.frame(), nodeToRemove); // sets nodeToRemove 4297 4287 4298 4288 const Font* font = nullptr; … … 4306 4296 } 4307 4297 4308 auto range = m_ frame.selection().selection().toNormalizedRange();4298 auto range = m_document.selection().selection().toNormalizedRange(); 4309 4299 if (!range) 4310 4300 return nullptr; 4311 4301 4312 4302 // FIXME: Adjusting the start may move it past the end. In that case the iterator below will go on to the end of the document. 4313 auto adjustedStart = makeBoundaryPoint(adjustedSelectionStartForStyleComputation(m_ frame.selection().selection()));4303 auto adjustedStart = makeBoundaryPoint(adjustedSelectionStartForStyleComputation(m_document.selection().selection())); 4314 4304 if (!adjustedStart) 4315 4305 return nullptr; … … 4340 4330 bool Editor::canCopyExcludingStandaloneImages() const 4341 4331 { 4342 auto& selection = m_ frame.selection().selection();4332 auto& selection = m_document.selection().selection(); 4343 4333 return selection.isRange() && !selection.isInPasswordField(); 4344 4334 } -
trunk/Source/WebCore/editing/Editor.h
r260753 r260831 34 34 #include "EditorInsertAction.h" 35 35 #include "FindOptions.h" 36 #include "Frame.h" 36 37 #include "FrameSelection.h" 37 38 #include "PasteboardWriterData.h" … … 120 121 class TemporarySelectionChange { 121 122 public: 122 WEBCORE_EXPORT TemporarySelectionChange( Frame&, Optional<VisibleSelection> = WTF::nullopt, OptionSet<TemporarySelectionOption> = { });123 WEBCORE_EXPORT TemporarySelectionChange(Document&, Optional<VisibleSelection> = WTF::nullopt, OptionSet<TemporarySelectionOption> = { }); 123 124 WEBCORE_EXPORT ~TemporarySelectionChange(); 124 125 … … 126 127 void setSelection(const VisibleSelection&); 127 128 128 Ref <Frame> m_frame;129 RefPtr<Document> m_document; 129 130 OptionSet<TemporarySelectionOption> m_options; 130 131 bool m_wasIgnoringSelectionChanges; … … 138 139 public: 139 140 IgnoreSelectionChangeForScope(Frame& frame) 140 : m_selectionChange( frame, WTF::nullopt, TemporarySelectionOption::IgnoreSelectionChanges)141 : m_selectionChange(*frame.document(), WTF::nullopt, TemporarySelectionOption::IgnoreSelectionChanges) 141 142 { 142 143 } … … 151 152 WTF_MAKE_FAST_ALLOCATED; 152 153 public: 153 explicit Editor( Frame&);154 explicit Editor(Document&); 154 155 ~Editor(); 155 156 … … 272 273 public: 273 274 WEBCORE_EXPORT Command(); 274 Command(const EditorInternalCommand*, EditorCommandSource, Frame&);275 Command(const EditorInternalCommand*, EditorCommandSource, Document&); 275 276 276 277 WEBCORE_EXPORT bool execute(const String& parameter = String(), Event* triggeringEvent = nullptr) const; … … 289 290 const EditorInternalCommand* m_command { nullptr }; 290 291 EditorCommandSource m_source; 292 RefPtr<Document> m_document; 291 293 RefPtr<Frame> m_frame; 292 294 }; … … 569 571 570 572 private: 571 Document& document() const ;573 Document& document() const { return m_document; } 572 574 573 575 bool canDeleteRange(Range*) const; … … 620 622 void postTextStateChangeNotificationForCut(const String&, const VisibleSelection&); 621 623 622 Frame& m_frame;624 Document& m_document; 623 625 RefPtr<CompositeEditCommand> m_lastEditCommand; 624 626 RefPtr<Text> m_compositionNode; -
trunk/Source/WebCore/editing/EditorCommand.cpp
r260725 r260831 1108 1108 static bool executeSwapWithMark(Frame& frame, Event*, EditorCommandSource, const String&) 1109 1109 { 1110 RefPtr<Document> protection(frame.document()); 1110 1111 Ref<Frame> protector(frame); 1111 1112 const VisibleSelection& mark = frame.editor().mark(); … … 1835 1836 Editor::Command Editor::command(const String& commandName) 1836 1837 { 1837 return Command(internalCommand(commandName), CommandFromMenuOrKeyBinding, m_ frame);1838 return Command(internalCommand(commandName), CommandFromMenuOrKeyBinding, m_document); 1838 1839 } 1839 1840 1840 1841 Editor::Command Editor::command(const String& commandName, EditorCommandSource source) 1841 1842 { 1842 return Command(internalCommand(commandName), source, m_ frame);1843 return Command(internalCommand(commandName), source, m_document); 1843 1844 } 1844 1845 … … 1852 1853 } 1853 1854 1854 Editor::Command::Command(const EditorInternalCommand* command, EditorCommandSource source, Frame& frame)1855 Editor::Command::Command(const EditorInternalCommand* command, EditorCommandSource source, Document& document) 1855 1856 : m_command(command) 1856 1857 , m_source(source) 1857 , m_frame(command ? &frame : nullptr) 1858 { 1859 ASSERT(command || !m_frame); 1858 , m_document(command ? &document : nullptr) 1859 , m_frame(command ? document.frame() : nullptr) 1860 { 1861 ASSERT(command || !m_document); 1860 1862 } 1861 1863 … … 1867 1869 return false; 1868 1870 } 1869 auto document = m_frame->document(); 1870 document->updateLayoutIgnorePendingStylesheets();1871 if (m_ frame->document() != document)1871 1872 m_document->updateLayoutIgnorePendingStylesheets(); 1873 if (m_document->frame() != m_frame) 1872 1874 return false; 1873 1875 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r260725 r260831 140 140 } 141 141 142 static inline bool shouldAlwaysUseDirectionalSelection(Frame* frame) 143 { 144 return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirectional(); 145 } 146 147 FrameSelection::FrameSelection(Frame* frame) 148 : m_frame(frame) 142 static inline bool shouldAlwaysUseDirectionalSelection(Document* document) 143 { 144 return !document || document->editor().behavior().shouldConsiderSelectionAsDirectional(); 145 } 146 147 FrameSelection::FrameSelection(Document* document) 148 : m_document(document) 149 , m_frame(document? document->frame() : nullptr) 149 150 , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()) 150 151 , m_granularity(CharacterGranularity) … … 157 158 , m_caretPaint(true) 158 159 , m_isCaretBlinkingSuspended(false) 159 , m_focused( frame && frame->page() && frame->page()->focusController().focusedFrame() ==frame)160 , m_focused(m_frame && m_frame->page() && m_frame->page()->focusController().focusedFrame() == m_frame) 160 161 , m_shouldShowBlockCursor(false) 161 162 , m_pendingSelectionUpdate(false) … … 166 167 #endif 167 168 { 168 if (shouldAlwaysUseDirectionalSelection(m_ frame))169 if (shouldAlwaysUseDirectionalSelection(m_document)) 169 170 m_selection.setIsDirectional(true); 171 172 bool activeAndFocused = isFocusedAndActive(); 173 if (activeAndFocused) 174 setSelectionFromNone(); 175 #if USE(UIKIT_EDITING) 176 // Caret blinking (blinks | does not blink) 177 setCaretVisible(activeAndFocused); 178 #else 179 setCaretVisibility(activeAndFocused ? Visible : Hidden); 180 #endif 170 181 } 171 182 … … 173 184 { 174 185 Element* selectionRoot = m_selection.rootEditableElement(); 175 return selectionRoot ? selectionRoot : m_ frame->document()->documentElement();186 return selectionRoot ? selectionRoot : m_document->documentElement(); 176 187 } 177 188 … … 285 296 { 286 297 VisibleSelection newSelection = passedNewSelection; 287 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_ frame) || newSelection.isDirectional();298 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_document) || newSelection.isDirectional(); 288 299 289 300 VisiblePosition base = m_originalBase.isNotNull() ? m_originalBase : newSelection.visibleBase(); … … 323 334 324 335 VisibleSelection newSelection = newSelectionPossiblyWithoutDirection; 325 if (shouldAlwaysUseDirectionalSelection(m_ frame))336 if (shouldAlwaysUseDirectionalSelection(m_document)) 326 337 newSelection.setIsDirectional(true); 327 338 … … 335 346 if (Document* newSelectionDocument = newSelection.base().document()) { 336 347 if (RefPtr<Frame> newSelectionFrame = newSelectionDocument->frame()) { 337 if (newSelectionFrame != m_frame && newSelectionDocument != m_ frame->document()) {348 if (newSelectionFrame != m_frame && newSelectionDocument != m_document) { 338 349 newSelectionFrame->selection().setSelection(newSelection, options, AXTextStateChangeIntent(), align, granularity); 339 350 // It's possible that during the above set selection, this FrameSelection has been modified by … … 350 361 351 362 if (closeTyping) 352 TypingCommand::closeTyping( m_frame);363 TypingCommand::closeTyping(*m_document); 353 364 354 365 if (shouldClearTypingStyle) … … 358 369 bool didMutateSelection = oldSelection != newSelection; 359 370 if (didMutateSelection) 360 m_ frame->editor().selectionWillChange();371 m_document->editor().selectionWillChange(); 361 372 362 373 m_selection = newSelection; … … 372 383 373 384 if (!newSelection.isNone() && !(options & DoNotSetFocus)) { 374 auto* oldFocusedElement = m_ frame->document()->focusedElement();385 auto* oldFocusedElement = m_document->focusedElement(); 375 386 setFocusedElementIfNeeded(); 376 387 // FIXME: Should not be needed. 377 if (m_ frame->document()->focusedElement() != oldFocusedElement)378 m_ frame->document()->updateStyleIfNeeded();388 if (m_document->focusedElement() != oldFocusedElement) 389 m_document->updateStyleIfNeeded(); 379 390 } 380 391 … … 383 394 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); 384 395 selectFrameElementInParentIfFullySelected(); 385 m_ frame->editor().respondToChangedSelection(oldSelection, options);396 m_document->editor().respondToChangedSelection(oldSelection, options); 386 397 // https://www.w3.org/TR/selection-api/#selectionchange-event 387 398 // FIXME: Spec doesn't specify which task source to use. 388 m_ frame->document()->queueTaskToDispatchEvent(TaskSource::UserInteraction, Event::create(eventNames().selectionchangeEvent, Event::CanBubble::No, Event::IsCancelable::No));399 m_document->queueTaskToDispatchEvent(TaskSource::UserInteraction, Event::create(eventNames().selectionchangeEvent, Event::CanBubble::No, Event::IsCancelable::No)); 389 400 390 401 return true; … … 393 404 void FrameSelection::setSelection(const VisibleSelection& selection, OptionSet<SetSelectionOption> options, AXTextStateChangeIntent intent, CursorAlignOnScroll align, TextGranularity granularity) 394 405 { 395 RefPtr< Frame> protectedFrame(m_frame);406 RefPtr<Document> protector(m_document); 396 407 if (!setSelectionWithoutUpdatingAppearance(selection, options, align, granularity)) 397 return;398 399 Document* document = m_frame->document();400 if (!document)401 408 return; 402 409 … … 412 419 m_pendingSelectionUpdate = true; 413 420 414 if ( document->hasPendingStyleRecalc())415 return; 416 417 FrameView* frameView = document->view();421 if (m_document->hasPendingStyleRecalc()) 422 return; 423 424 FrameView* frameView = m_document->view(); 418 425 if (frameView && frameView->layoutContext().isLayoutPending()) 419 426 return; … … 422 429 423 430 if (options & IsUserTriggered) { 424 if (auto* client = m_ frame->editor().client())431 if (auto* client = m_document->editor().client()) 425 432 client->didEndUserTriggeredSelectionChanges(); 426 433 } 427 434 } 428 435 429 static void updateSelectionByUpdatingLayoutOrStyle( Frame& frame)436 static void updateSelectionByUpdatingLayoutOrStyle(Document& document) 430 437 { 431 438 #if ENABLE(TEXT_CARET) 432 frame.document()->updateLayoutIgnorePendingStylesheets();439 document.updateLayoutIgnorePendingStylesheets(); 433 440 #else 434 frame.document()->updateStyleIfNeeded();441 document.updateStyleIfNeeded(); 435 442 #endif 436 443 } … … 442 449 m_selectionRevealMode = SelectionRevealMode::Reveal; 443 450 m_pendingSelectionUpdate = true; 444 if (RenderView* view = m_ frame->contentRenderer())451 if (RenderView* view = m_document->renderView()) 445 452 view->selection().clearSelection(); 446 453 } … … 458 465 ScrollAlignment alignment; 459 466 460 if (m_ frame->editor().behavior().shouldCenterAlignWhenSelectionIsRevealed())467 if (m_document->editor().behavior().shouldCenterAlignWhenSelectionIsRevealed()) 461 468 alignment = m_alwaysAlignCursorOnScrollWhenRevealingSelection ? ScrollAlignment::alignCenterAlways : ScrollAlignment::alignCenterIfNeeded; 462 469 else … … 472 479 { 473 480 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS_FAMILY) 474 m_ frame->editor().scanSelectionForTelephoneNumbers();481 m_document->editor().scanSelectionForTelephoneNumbers(); 475 482 #endif 476 483 } … … 704 711 // to which depends on the value of isBaseFirst. Then this can be changed 705 712 // to just return m_sel.extent(). 706 if (m_ frame && m_frame->editor().behavior().shouldAlwaysExtendSelectionFromExtentEndpoint())713 if (m_document && m_document->editor().behavior().shouldAlwaysExtendSelectionFromExtentEndpoint()) 707 714 return m_selection.isBaseFirst() ? m_selection.visibleEnd() : m_selection.visibleStart(); 708 715 … … 724 731 VisiblePosition positionAfterCurrentWord = nextWordPosition(originalPosition); 725 732 726 if (m_ frame && m_frame->editor().behavior().shouldSkipSpaceWhenMovingRight()) {733 if (m_document && m_document->editor().behavior().shouldSkipSpaceWhenMovingRight()) { 727 734 // In order to skip spaces when moving right, we advance one 728 735 // word further and then move one word back. Given the … … 856 863 break; 857 864 case WordGranularity: { 858 bool skipsSpaceWhenMovingRight = m_ frame && m_frame->editor().behavior().shouldSkipSpaceWhenMovingRight();865 bool skipsSpaceWhenMovingRight = m_document && m_document->editor().behavior().shouldSkipSpaceWhenMovingRight(); 859 866 VisiblePosition currentPosition(m_selection.extent(), m_selection.affinity()); 860 867 pos = rightWordPosition(currentPosition, skipsSpaceWhenMovingRight); … … 1077 1084 break; 1078 1085 case WordGranularity: { 1079 bool skipsSpaceWhenMovingRight = m_ frame && m_frame->editor().behavior().shouldSkipSpaceWhenMovingRight();1086 bool skipsSpaceWhenMovingRight = m_document && m_document->editor().behavior().shouldSkipSpaceWhenMovingRight(); 1080 1087 VisiblePosition currentPosition(m_selection.extent(), m_selection.affinity()); 1081 1088 pos = leftWordPosition(currentPosition, skipsSpaceWhenMovingRight); … … 1363 1370 } 1364 1371 1365 if (reachedBoundary && !isRange() && userTriggered == UserTriggered && m_ frame&& AXObjectCache::accessibilityEnabled()) {1372 if (reachedBoundary && !isRange() && userTriggered == UserTriggered && m_document && AXObjectCache::accessibilityEnabled()) { 1366 1373 notifyAccessibilityForSelectionChange({ AXTextStateChangeTypeSelectionBoundary, textSelectionWithDirectionAndGranularity(direction, granularity) }); 1367 1374 return true; … … 1375 1382 return false; 1376 1383 1377 if (m_ frame&& AXObjectCache::accessibilityEnabled()) {1378 if (AXObjectCache* cache = m_ frame->document()->existingAXObjectCache())1384 if (m_document && AXObjectCache::accessibilityEnabled()) { 1385 if (AXObjectCache* cache = m_document->existingAXObjectCache()) 1379 1386 cache->setTextSelectionIntent(textSelectionIntent(alter, direction, granularity)); 1380 1387 } … … 1385 1392 // the requested position type if there were no xPosForVerticalArrowNavigation set. 1386 1393 LayoutUnit x = lineDirectionPointForBlockDirectionNavigation(START); 1387 m_selection.setIsDirectional(shouldAlwaysUseDirectionalSelection(m_ frame) || alter == AlterationExtend);1394 m_selection.setIsDirectional(shouldAlwaysUseDirectionalSelection(m_document) || alter == AlterationExtend); 1388 1395 1389 1396 switch (alter) { … … 1395 1402 if (!m_selection.isCaret() 1396 1403 && (granularity == WordGranularity || granularity == ParagraphGranularity || granularity == LineGranularity) 1397 && m_ frame && !m_frame->editor().behavior().shouldExtendSelectionByWordOrLineAcrossCaret()) {1404 && m_document && !m_document->editor().behavior().shouldExtendSelectionByWordOrLineAcrossCaret()) { 1398 1405 // Don't let the selection go across the base position directly. Needed to match mac 1399 1406 // behavior when, for instance, word-selecting backwards starting with the caret in … … 1408 1415 // Standard Mac behavior when extending to a boundary is grow the selection rather than leaving the 1409 1416 // base in place and moving the extent. Matches NSTextView. 1410 if (!m_ frame || !m_frame->editor().behavior().shouldAlwaysGrowSelectionWhenExtendingToBoundary() || m_selection.isCaret() || !isBoundary(granularity))1417 if (!m_document || !m_document->editor().behavior().shouldAlwaysGrowSelectionWhenExtendingToBoundary() || m_selection.isCaret() || !isBoundary(granularity)) 1411 1418 setExtent(position, userTriggered); 1412 1419 else { … … 1518 1525 m_granularity = CharacterGranularity; 1519 1526 1520 m_selection.setIsDirectional(shouldAlwaysUseDirectionalSelection(m_ frame) || alter == AlterationExtend);1527 m_selection.setIsDirectional(shouldAlwaysUseDirectionalSelection(m_document) || alter == AlterationExtend); 1521 1528 1522 1529 return true; … … 1568 1575 } 1569 1576 1570 void FrameSelection:: prepareForDestruction()1577 void FrameSelection::willBeRemovedFromFrame() 1571 1578 { 1572 1579 m_granularity = CharacterGranularity; … … 1576 1583 #endif 1577 1584 1578 if (auto* view = m_ frame->contentRenderer())1585 if (auto* view = m_document->renderView()) 1579 1586 view->selection().clearSelection(); 1580 1587 … … 1656 1663 IntRect FrameSelection::absoluteCaretBounds(bool* insideFixed) 1657 1664 { 1658 if (!m_ frame)1665 if (!m_document) 1659 1666 return IntRect(); 1660 updateSelectionByUpdatingLayoutOrStyle(*m_ frame);1667 updateSelectionByUpdatingLayoutOrStyle(*m_document); 1661 1668 recomputeCaretRect(); 1662 1669 if (insideFixed) … … 1676 1683 return false; 1677 1684 1678 if (!m_ frame)1685 if (!m_document) 1679 1686 return false; 1680 1687 1681 FrameView* v = m_ frame->document()->view();1688 FrameView* v = m_document->view(); 1682 1689 if (!v) 1683 1690 return false; … … 1691 1698 else { 1692 1699 VisiblePosition visibleStart = m_selection.visibleStart(); 1693 if (updateCaretRect(m_ frame->document(), visibleStart)) {1700 if (updateCaretRect(m_document, visibleStart)) { 1694 1701 caretNode = visibleStart.deepEquivalent().deprecatedNode(); 1695 1702 m_absCaretBoundsDirty = true; … … 1716 1723 1717 1724 #if ENABLE(TEXT_CARET) 1718 if (RenderView* view = m_ frame->document()->renderView()) {1725 if (RenderView* view = m_document->renderView()) { 1719 1726 bool previousOrNewCaretNodeIsContentEditable = m_selection.isContentEditable() || (m_previousCaretNode && m_previousCaretNode->isContentEditable()); 1720 1727 if (shouldRepaintCaret(view, previousOrNewCaretNodeIsContentEditable)) { … … 1895 1902 return false; 1896 1903 1897 auto* document = m_frame->document(); 1898 if (!document) 1904 if (!m_document) 1899 1905 return false; 1900 1906 1901 1907 HitTestResult result(point); 1902 document->hitTest(HitTestRequest(), result);1908 m_document->hitTest(HitTestRequest(), result); 1903 1909 Node* innerNode = result.innerNode(); 1904 1910 if (!innerNode || !innerNode->renderer()) … … 1969 1975 void FrameSelection::selectAll() 1970 1976 { 1971 Document* document = m_frame->document(); 1972 1973 Element* focusedElement = document->focusedElement(); 1977 Element* focusedElement = m_document->focusedElement(); 1974 1978 if (is<HTMLSelectElement>(focusedElement)) { 1975 1979 HTMLSelectElement& selectElement = downcast<HTMLSelectElement>(*focusedElement); … … 2001 2005 selectStartTarget = root->shadowHost(); 2002 2006 else { 2003 root = document->documentElement();2004 selectStartTarget = document->bodyOrFrameset();2007 root = m_document->documentElement(); 2008 selectStartTarget = m_document->bodyOrFrameset(); 2005 2009 } 2006 2010 } … … 2059 2063 { 2060 2064 bool activeAndFocused = isFocusedAndActive(); 2061 Ref<Document> document(*m_frame->document()); 2062 2063 document->updateStyleIfNeeded(); 2065 2066 m_document->updateStyleIfNeeded(); 2064 2067 2065 2068 #if USE(UIKIT_EDITING) … … 2072 2075 // RenderObject::selectionForegroundColor() check if the frame is active, 2073 2076 // we have to update places those colors were painted. 2074 if (RenderView* view = document->renderView())2077 if (RenderView* view = m_document->renderView()) 2075 2078 view->selection().repaint(); 2076 2079 … … 2083 2086 // RenderTheme::isFocused() check if the frame is active, we have to 2084 2087 // update style and theme state that depended on those. 2085 if (Element* element = document->focusedElement()) {2088 if (Element* element = m_document->focusedElement()) { 2086 2089 element->invalidateStyleForSubtree(); 2087 2090 if (RenderObject* renderer = element->renderer()) … … 2108 2111 bool FrameSelection::isFocusedAndActive() const 2109 2112 { 2110 return m_focused && m_ frame->page() && m_frame->page()->focusController().isActive();2113 return m_focused && m_document->page() && m_document->page()->focusController().isActive(); 2111 2114 } 2112 2115 2113 2116 #if ENABLE(TEXT_CARET) 2114 inline static bool shouldStopBlinkingDueToTypingCommand( Frame* frame)2115 { 2116 return frame->editor().lastEditCommand() && frame->editor().lastEditCommand()->shouldStopCaretBlinking();2117 inline static bool shouldStopBlinkingDueToTypingCommand(Document* document) 2118 { 2119 return document->editor().lastEditCommand() && document->editor().lastEditCommand()->shouldStopCaretBlinking(); 2117 2120 } 2118 2121 #endif … … 2133 2136 bool caretRectChangedOrCleared = recomputeCaretRect(); 2134 2137 2135 bool caretBrowsing = m_ frame->settings().caretBrowsingEnabled();2138 bool caretBrowsing = m_document->settings().caretBrowsingEnabled(); 2136 2139 bool shouldBlink = !paintBlockCursor && caretIsVisible() && isCaret() && (oldSelection.isContentEditable() || caretBrowsing); 2137 2140 2138 2141 // If the caret moved, stop the blink timer so we can restart with a 2139 2142 // black caret in the new location. 2140 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypingCommand(m_ frame))2143 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypingCommand(m_document)) 2141 2144 m_caretBlinkTimer.stop(); 2142 2145 … … 2154 2157 #endif 2155 2158 2156 RenderView* view = m_ frame->contentRenderer();2159 RenderView* view = m_document->renderView(); 2157 2160 if (!view) 2158 2161 return; … … 2203 2206 2204 2207 // FIXME: We shouldn't trigger a synchronous layout here. 2205 if (m_ frame)2206 updateSelectionByUpdatingLayoutOrStyle(*m_ frame);2208 if (m_document) 2209 updateSelectionByUpdatingLayoutOrStyle(*m_document); 2207 2210 2208 2211 #if ENABLE(TEXT_CARET) … … 2248 2251 return; 2249 2252 2250 bool caretBrowsing = m_ frame->settings().caretBrowsingEnabled();2253 bool caretBrowsing = m_document->settings().caretBrowsingEnabled(); 2251 2254 if (caretBrowsing) { 2252 2255 if (Element* anchor = enclosingAnchorElement(m_selection.base())) { 2253 m_ frame->page()->focusController().setFocusedElement(anchor, *m_frame);2256 m_document->page()->focusController().setFocusedElement(anchor, *m_frame); 2254 2257 return; 2255 2258 } … … 2263 2266 // work in the long term, but this is the safest fix at this time. 2264 2267 if (target->isMouseFocusable() && !isFrameElement(target)) { 2265 m_ frame->page()->focusController().setFocusedElement(target, *m_frame);2268 m_document->page()->focusController().setFocusedElement(target, *m_frame); 2266 2269 return; 2267 2270 } 2268 2271 target = target->parentOrShadowHostElement(); 2269 2272 } 2270 m_ frame->document()->setFocusedElement(nullptr);2273 m_document->setFocusedElement(nullptr); 2271 2274 } 2272 2275 2273 2276 if (caretBrowsing) 2274 m_ frame->page()->focusController().setFocusedElement(nullptr, *m_frame);2277 m_document->page()->focusController().setFocusedElement(nullptr, *m_frame); 2275 2278 } 2276 2279 … … 2301 2304 return true; 2302 2305 #endif 2303 return m_ frame->editor().client()->shouldDeleteRange(createLiveRange(selection.toNormalizedRange()).get());2306 return m_document->editor().client()->shouldDeleteRange(createLiveRange(selection.toNormalizedRange()).get()); 2304 2307 } 2305 2308 2306 2309 FloatRect FrameSelection::selectionBounds(ClipToVisibleContent clipToVisibleContent) const 2307 2310 { 2308 if (!m_ frame->document())2311 if (!m_document) 2309 2312 return LayoutRect(); 2310 2313 2311 updateSelectionByUpdatingLayoutOrStyle(*m_ frame);2312 auto* renderView = m_ frame->contentRenderer();2314 updateSelectionByUpdatingLayoutOrStyle(*m_document); 2315 auto* renderView = m_document->renderView(); 2313 2316 if (!renderView) 2314 2317 return LayoutRect(); … … 2326 2329 void FrameSelection::getClippedVisibleTextRectangles(Vector<FloatRect>& rectangles, TextRectangleHeight textRectHeight) const 2327 2330 { 2328 if (!m_ frame->contentRenderer())2331 if (!m_document->renderView()) 2329 2332 return; 2330 2333 … … 2333 2336 return; 2334 2337 2335 auto visibleContentRect = m_ frame->view()->visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);2338 auto visibleContentRect = m_document->view()->visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect); 2336 2339 for (auto& rect : boundingBoxes(RenderObject::absoluteTextQuads(*range, textRectHeight == TextRectangleHeight::SelectionHeight))) { 2337 2340 auto intersectionRect = intersection(rect, visibleContentRect); … … 2365 2368 { 2366 2369 // Start looking either at the active (first responder) node, or where the selection is. 2367 Element* start = m_ frame->document()->focusedElement();2370 Element* start = m_document->focusedElement(); 2368 2371 if (!start) 2369 2372 start = m_selection.start().element(); … … 2408 2411 layer->setAdjustForIOSCaretWhenScrolling(false); 2409 2412 updateAppearance(); 2410 if (m_ frame->page())2411 m_ frame->page()->chrome().client().notifyRevealedSelectionByScrollingFrame(*m_frame);2413 if (m_document->page()) 2414 m_document->page()->chrome().client().notifyRevealedSelectionByScrollingFrame(*m_frame); 2412 2415 } 2413 2416 } … … 2427 2430 // entire WebView is editable or designMode is on for this document). 2428 2431 2429 Document* document = m_frame->document();2430 2432 #if !PLATFORM(IOS_FAMILY) 2431 bool caretBrowsing = m_ frame->settings().caretBrowsingEnabled();2432 if (!isNone() || !( document->hasEditableStyle() || caretBrowsing))2433 bool caretBrowsing = m_document->settings().caretBrowsingEnabled(); 2434 if (!isNone() || !(m_document->hasEditableStyle() || caretBrowsing)) 2433 2435 return; 2434 2436 #else 2435 if (! document || !(isNone() || isStartOfDocument(VisiblePosition(m_selection.start(), m_selection.affinity()))) || !document->hasEditableStyle())2436 return; 2437 #endif 2438 2439 if (auto* body = document->body())2437 if (!m_document || !(isNone() || isStartOfDocument(VisiblePosition(m_selection.start(), m_selection.affinity()))) || !m_document->hasEditableStyle()) 2438 return; 2439 #endif 2440 2441 if (auto* body = m_document->body()) 2440 2442 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), DOWNSTREAM)); 2441 2443 } … … 2447 2449 return true; 2448 2450 #endif 2449 return m_ frame->editor().shouldChangeSelection(selection(), newSelection, newSelection.affinity(), false);2451 return m_document->editor().shouldChangeSelection(selection(), newSelection, newSelection.affinity(), false); 2450 2452 } 2451 2453 … … 2465 2467 m_shouldShowBlockCursor = shouldShowBlockCursor; 2466 2468 2467 m_ frame->document()->updateLayoutIgnorePendingStylesheets();2469 m_document->updateLayoutIgnorePendingStylesheets(); 2468 2470 2469 2471 updateAppearance(); … … 2483 2485 void FrameSelection::appearanceUpdateTimerFired() 2484 2486 { 2485 Ref< Frame> protectedFrame(*m_frame);2487 Ref<Document> protector(*m_document); 2486 2488 updateAppearanceAfterLayoutOrStyleChange(); 2487 2489 } … … 2489 2491 void FrameSelection::updateAppearanceAfterLayoutOrStyleChange() 2490 2492 { 2491 if (auto* client = m_ frame->editor().client())2493 if (auto* client = m_document->editor().client()) 2492 2494 client->updateEditorStateAfterLayoutIfEditabilityChanged(); 2493 2495 … … 2709 2711 void FrameSelection::selectRangeOnElement(unsigned location, unsigned length, Node& node) 2710 2712 { 2711 RefPtr<Range> resultRange = m_ frame->document()->createRange();2713 RefPtr<Range> resultRange = m_document->createRange(); 2712 2714 resultRange->setStart(node, location); 2713 2715 resultRange->setEnd(node, location + length); … … 2890 2892 return; 2891 2893 #if ENABLE(TEXT_CARET) 2892 m_ frame->document()->updateLayoutIgnorePendingStylesheets();2894 m_document->updateLayoutIgnorePendingStylesheets(); 2893 2895 if (m_caretPaint) { 2894 2896 m_caretPaint = false; -
trunk/Source/WebCore/editing/FrameSelection.h
r260725 r260831 141 141 } 142 142 143 WEBCORE_EXPORT explicit FrameSelection( Frame* = nullptr);143 WEBCORE_EXPORT explicit FrameSelection(Document* = nullptr); 144 144 145 145 WEBCORE_EXPORT Element* rootEditableElementOrDocumentElement() const; … … 159 159 WEBCORE_EXPORT void selectAll(); 160 160 WEBCORE_EXPORT void clear(); 161 void prepareForDestruction();161 void willBeRemovedFromFrame(); 162 162 163 163 void updateAppearanceAfterLayout(); … … 337 337 #endif 338 338 339 Document* m_document; 339 340 Frame* m_frame; 340 341 -
trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp
r242117 r260831 51 51 void InsertIntoTextNodeCommand::doApply() 52 52 { 53 bool passwordEchoEnabled = frame().settings().passwordEchoEnabled();53 bool passwordEchoEnabled = document().settings().passwordEchoEnabled(); 54 54 if (passwordEchoEnabled) 55 55 document().updateLayoutIgnorePendingStylesheets(); -
trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp
r216233 r260831 143 143 // Handle the case where there is a typing style. 144 144 145 RefPtr<EditingStyle> typingStyle = frame().selection().typingStyle();145 RefPtr<EditingStyle> typingStyle = document().selection().typingStyle(); 146 146 147 147 if (typingStyle && !typingStyle->isEmpty()) { -
trunk/Source/WebCore/editing/InsertTextCommand.cpp
r249854 r260831 147 147 if (endingSelection().isNone()) 148 148 return; 149 } else if ( frame().editor().isOverwriteModeEnabled()) {149 } else if (document().editor().isOverwriteModeEnabled()) { 150 150 if (performOverwrite(m_text, m_selectInsertedText)) 151 151 return; … … 223 223 224 224 // Handle the case where there is a typing style. 225 if (RefPtr<EditingStyle> typingStyle = frame().selection().typingStyle()) {225 if (RefPtr<EditingStyle> typingStyle = document().selection().typingStyle()) { 226 226 typingStyle->prepareToApplyAt(endPosition, EditingStyle::PreserveWritingDirection); 227 227 if (!typingStyle->isEmpty()) -
trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp
r259401 r260831 61 61 return; 62 62 63 if (! frame().selection().shouldChangeSelection(selection))63 if (!document().selection().shouldChangeSelection(selection)) 64 64 return; 65 65 -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r260725 r260831 1182 1182 // FIXME: Can this wait until after the operation has been performed? There doesn't seem to be 1183 1183 // any work performed after this that queries or uses the typing style. 1184 frame().selection().clearTypingStyle();1184 document().selection().clearTypingStyle(); 1185 1185 1186 1186 // We don't want the destination to end up inside nodes that weren't selected. To avoid that, we move the -
trunk/Source/WebCore/editing/SetSelectionCommand.cpp
r234801 r260831 41 41 void SetSelectionCommand::doApply() 42 42 { 43 FrameSelection& selection = frame().selection();43 FrameSelection& selection = document().selection(); 44 44 45 45 if (selection.shouldChangeSelection(m_selectionToSet) && !m_selectionToSet.isNoneOrOrphaned()) { … … 51 51 void SetSelectionCommand::doUnapply() 52 52 { 53 FrameSelection& selection = frame().selection();53 FrameSelection& selection = document().selection(); 54 54 55 55 if (selection.shouldChangeSelection(startingSelection()) && !startingSelection().isNoneOrOrphaned()) -
trunk/Source/WebCore/editing/SpellChecker.cpp
r258182 r260831 99 99 } 100 100 101 SpellChecker::SpellChecker( Frame& frame)102 : m_ frame(frame)101 SpellChecker::SpellChecker(Document& document) 102 : m_document(document) 103 103 , m_timerToProcessQueuedRequest(*this, &SpellChecker::timerFiredToProcessQueuedRequest) 104 104 { … … 115 115 TextCheckerClient* SpellChecker::client() const 116 116 { 117 Page* page = m_ frame.page();117 Page* page = m_document.page(); 118 118 if (!page) 119 119 return nullptr; … … 132 132 bool SpellChecker::isAsynchronousEnabled() const 133 133 { 134 return m_ frame.settings().asynchronousSpellCheckingEnabled();134 return m_document.settings().asynchronousSpellCheckingEnabled(); 135 135 } 136 136 … … 175 175 return; 176 176 m_processingRequest = WTFMove(request); 177 client()->requestCheckingOfString(*m_processingRequest, m_ frame.selection().selection());177 client()->requestCheckingOfString(*m_processingRequest, m_document.selection().selection()); 178 178 } 179 179 … … 200 200 } 201 201 202 m_ frame.editor().markAndReplaceFor(*m_processingRequest, results);202 m_document.editor().markAndReplaceFor(*m_processingRequest, results); 203 203 204 204 if (m_lastProcessedIdentifier.toUInt64() < identifier.toUInt64()) … … 220 220 markerTypes.add(DocumentMarker::Grammar); 221 221 if (!markerTypes.isEmpty()) 222 m_ frame.document()->markers().removeMarkers(m_processingRequest->checkingRange(), markerTypes);222 m_document.markers().removeMarkers(m_processingRequest->checkingRange(), markerTypes); 223 223 } 224 224 didCheck(identifier, results); -
trunk/Source/WebCore/editing/SpellChecker.h
r258182 r260831 77 77 friend class SpellCheckRequest; 78 78 79 explicit SpellChecker( Frame&);79 explicit SpellChecker(Document&); 80 80 ~SpellChecker(); 81 81 … … 107 107 void didCheck(TextCheckingRequestIdentifier, const Vector<TextCheckingResult>&); 108 108 109 Frame& m_frame;109 Document& m_document; 110 110 TextCheckingRequestIdentifier m_lastRequestIdentifier; 111 111 TextCheckingRequestIdentifier m_lastProcessedIdentifier; -
trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp
r259401 r260831 66 66 { 67 67 if (!m_hasBeenUndone) { 68 frame().editor().unappliedSpellCorrection(startingSelection(), m_corrected, m_correction);68 document().editor().unappliedSpellCorrection(startingSelection(), m_corrected, m_correction); 69 69 m_hasBeenUndone = true; 70 70 } … … 104 104 return; 105 105 106 if (! frame().selection().shouldChangeSelection(m_selectionToBeCorrected))106 if (!document().selection().shouldChangeSelection(m_selectionToBeCorrected)) 107 107 return; 108 108 -
trunk/Source/WebCore/editing/TypingCommand.cpp
r260725 r260831 164 164 void TypingCommand::deleteSelection(Document& document, Options options, TextCompositionType compositionType) 165 165 { 166 Frame* frame = document.frame(); 167 ASSERT(frame); 168 169 if (!frame->selection().isRange()) 170 return; 171 172 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(*frame)) { 166 if (!document.selection().isRange()) 167 return; 168 169 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 173 170 lastTypingCommand->setIsAutocompletion(options & IsAutocompletion); 174 171 lastTypingCommand->setCompositionType(compositionType); … … 184 181 { 185 182 if (granularity == CharacterGranularity) { 186 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *document.frame())) {187 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), document .frame());183 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 184 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), document); 188 185 lastTypingCommand->setIsAutocompletion(options & IsAutocompletion); 189 186 lastTypingCommand->setCompositionType(TextCompositionNone); … … 200 197 { 201 198 // FIXME: Forward delete in TextEdit appears to open and close a new typing command. 202 Frame* frame = document.frame();203 199 if (granularity == CharacterGranularity) { 204 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *frame)) {205 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), frame);200 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 201 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), document); 206 202 lastTypingCommand->setIsAutocompletion(options & IsAutocompletion); 207 203 lastTypingCommand->setCompositionType(TextCompositionNone); … … 215 211 } 216 212 217 void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand* typingCommand, Frame* frame) 218 { 219 ASSERT(frame); 220 VisibleSelection currentSelection = frame->selection().selection(); 213 void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand* typingCommand, Document& document) 214 { 215 VisibleSelection currentSelection = document.selection().selection(); 221 216 if (currentSelection == typingCommand->endingSelection()) 222 217 return; … … 228 223 void TypingCommand::insertText(Document& document, const String& text, Options options, TextCompositionType composition) 229 224 { 230 Frame* frame = document.frame();231 ASSERT(frame);232 233 225 if (!text.isEmpty()) 234 frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));226 document.editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0])); 235 227 236 insertText(document, text, frame->selection().selection(), options, composition);228 insertText(document, text, document.selection().selection(), options, composition); 237 229 } 238 230 … … 240 232 void TypingCommand::insertText(Document& document, const String& text, const VisibleSelection& selectionForInsertion, Options options, TextCompositionType compositionType) 241 233 { 242 RefPtr<Frame> frame = document.frame();243 ASSERT(frame);244 245 234 LOG(Editing, "TypingCommand::insertText (text %s)", text.utf8().data()); 246 235 247 VisibleSelection currentSelection = frame->selection().selection();236 VisibleSelection currentSelection = document.selection().selection(); 248 237 249 238 String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, compositionType == TextCompositionPending); … … 252 241 // that is different from the current selection. In the future, we should change EditCommand 253 242 // to deal with custom selections in a general way that can be used by all of the commands. 254 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *frame)) {243 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 255 244 if (lastTypingCommand->endingSelection() != selectionForInsertion) { 256 245 lastTypingCommand->setStartingSelection(selectionForInsertion); … … 267 256 268 257 auto cmd = TypingCommand::create(document, InsertText, newText, options, compositionType); 269 applyTextInsertionCommand( frame.get(), cmd.get(), selectionForInsertion, currentSelection);258 applyTextInsertionCommand(document.frame(), cmd.get(), selectionForInsertion, currentSelection); 270 259 } 271 260 272 261 void TypingCommand::insertLineBreak(Document& document, Options options) 273 262 { 274 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *document.frame())) {263 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 275 264 lastTypingCommand->setIsAutocompletion(options & IsAutocompletion); 276 265 lastTypingCommand->setCompositionType(TextCompositionNone); … … 285 274 void TypingCommand::insertParagraphSeparatorInQuotedContent(Document& document) 286 275 { 287 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *document.frame())) {276 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 288 277 lastTypingCommand->setIsAutocompletion(false); 289 278 lastTypingCommand->setCompositionType(TextCompositionNone); … … 297 286 void TypingCommand::insertParagraphSeparator(Document& document, Options options) 298 287 { 299 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *document.frame())) {288 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 300 289 lastTypingCommand->setIsAutocompletion(options & IsAutocompletion); 301 290 lastTypingCommand->setCompositionType(TextCompositionNone); … … 308 297 } 309 298 310 RefPtr<TypingCommand> TypingCommand::lastTypingCommandIfStillOpenForTyping( Frame& frame)311 { 312 RefPtr<CompositeEditCommand> lastEditCommand = frame.editor().lastEditCommand();299 RefPtr<TypingCommand> TypingCommand::lastTypingCommandIfStillOpenForTyping(Document& document) 300 { 301 RefPtr<CompositeEditCommand> lastEditCommand = document.editor().lastEditCommand(); 313 302 if (!lastEditCommand || !lastEditCommand->isTypingCommand() || !static_cast<TypingCommand*>(lastEditCommand.get())->isOpenForMoreTyping()) 314 303 return nullptr; … … 322 311 } 323 312 324 void TypingCommand::closeTyping( Frame* frame)325 { 326 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *frame))313 void TypingCommand::closeTyping(Document& document) 314 { 315 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) 327 316 lastTypingCommand->closeTyping(); 328 317 } 329 318 330 319 #if PLATFORM(IOS_FAMILY) 331 void TypingCommand::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping( Frame* frame, const VisibleSelection& newSelection)332 { 333 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping( *frame)) {320 void TypingCommand::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping(Document& document, const VisibleSelection& newSelection) 321 { 322 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) { 334 323 lastTypingCommand->setEndingSelection(newSelection); 335 324 lastTypingCommand->setEndingSelectionOnLastInsertCommand(newSelection); … … 437 426 void TypingCommand::markMisspellingsAfterTyping(ETypingCommand commandType) 438 427 { 439 Frame& frame = this->frame();440 441 428 #if PLATFORM(MAC) 442 if (! frame.editor().isContinuousSpellCheckingEnabled()443 && ! frame.editor().isAutomaticQuoteSubstitutionEnabled()444 && ! frame.editor().isAutomaticLinkDetectionEnabled()445 && ! frame.editor().isAutomaticDashSubstitutionEnabled()446 && ! frame.editor().isAutomaticTextReplacementEnabled())429 if (!document().editor().isContinuousSpellCheckingEnabled() 430 && !document().editor().isAutomaticQuoteSubstitutionEnabled() 431 && !document().editor().isAutomaticLinkDetectionEnabled() 432 && !document().editor().isAutomaticDashSubstitutionEnabled() 433 && !document().editor().isAutomaticTextReplacementEnabled()) 447 434 return; 448 if ( frame.editor().isHandlingAcceptedCandidate())435 if (document().editor().isHandlingAcceptedCandidate()) 449 436 return; 450 437 #else 451 if (! frame.editor().isContinuousSpellCheckingEnabled())438 if (!document().editor().isContinuousSpellCheckingEnabled()) 452 439 return; 453 440 #endif … … 467 454 if (range && (commandType == TypingCommand::InsertText || commandType == TypingCommand::InsertLineBreak || commandType == TypingCommand::InsertParagraphSeparator || commandType == TypingCommand::InsertParagraphSeparatorInQuotedContent)) 468 455 strippedPreviousWord = plainText(*range).stripWhiteSpace(); 469 frame.editor().markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty());456 document().editor().markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty()); 470 457 } else if (commandType == TypingCommand::InsertText) 471 frame.editor().startAlternativeTextUITimer();458 document().editor().startAlternativeTextUITimer(); 472 459 #else 473 460 UNUSED_PARAM(commandType); … … 484 471 VisiblePosition p2 = startOfWord(start, startWordSide); 485 472 if (p1 != p2) 486 frame.editor().markMisspellingsAfterTypingToWord(p1, endingSelection(), false);473 document().editor().markMisspellingsAfterTypingToWord(p1, endingSelection(), false); 487 474 #endif // !PLATFORM(IOS_FAMILY) 488 475 } … … 498 485 499 486 if (!range || isEditingTextAreaOrTextInput()) 500 return frame().editor().willApplyEditing(*this, CompositeEditCommand::targetRangesForBindings());501 502 return frame().editor().willApplyEditing(*this, { 1, StaticRange::create(*range) });487 return document().editor().willApplyEditing(*this, CompositeEditCommand::targetRangesForBindings()); 488 489 return document().editor().willApplyEditing(*this, { 1, StaticRange::create(*range) }); 503 490 } 504 491 505 492 void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedTyping) 506 493 { 507 Frame& frame = this->frame();494 RefPtr<Frame> protector(document().frame()); 508 495 509 496 updatePreservesTypingStyle(commandTypeForAddedTyping); 510 497 511 498 #if PLATFORM(COCOA) 512 frame.editor().appliedEditing(*this);499 document().editor().appliedEditing(*this); 513 500 // Since the spellchecking code may also perform corrections and other replacements, it should happen after the typing changes. 514 501 if (!m_shouldPreventSpellChecking) … … 517 504 // The old spellchecking code requires that checking be done first, to prevent issues like that in 6864072, where <doesn't> is marked as misspelled. 518 505 markMisspellingsAfterTyping(commandTypeForAddedTyping); 519 frame.editor().appliedEditing(*this);506 document().editor().appliedEditing(*this); 520 507 #endif 521 508 } … … 536 523 LOG(Editing, "TypingCommand %p insertTextAndNotifyAccessibility (text %s, selectInsertedText %d)", this, text.utf8().data(), selectInsertedText); 537 524 538 AccessibilityReplacedText replacedText( frame().selection().selection());525 AccessibilityReplacedText replacedText(document().selection().selection()); 539 526 insertText(text, selectInsertedText); 540 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, text, frame().selection().selection());527 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, text, document().selection().selection()); 541 528 composition()->setRangeDeletedByUnapply(replacedText.replacedRange()); 542 529 } … … 551 538 552 539 applyCommandToComposite(WTFMove(command), endingSelection()); 553 554 Frame& frame = this->frame();555 Ref<Frame> protector(frame);556 540 typingAddedToOpenCommand(InsertText); 557 541 } … … 566 550 567 551 applyCommandToComposite(InsertLineBreakCommand::create(document())); 568 569 Frame& frame = this->frame();570 Ref<Frame> protector(frame);571 552 typingAddedToOpenCommand(InsertLineBreak); 572 553 } … … 574 555 void TypingCommand::insertLineBreakAndNotifyAccessibility() 575 556 { 576 AccessibilityReplacedText replacedText( frame().selection().selection());557 AccessibilityReplacedText replacedText(document().selection().selection()); 577 558 insertLineBreak(); 578 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, "\n", frame().selection().selection());559 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, "\n", document().selection().selection()); 579 560 composition()->setRangeDeletedByUnapply(replacedText.replacedRange()); 580 561 } … … 589 570 590 571 applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditAction::TypingInsertParagraph)); 591 592 Frame& frame = this->frame();593 Ref<Frame> protector(frame);594 572 typingAddedToOpenCommand(InsertParagraphSeparator); 595 573 } … … 597 575 void TypingCommand::insertParagraphSeparatorAndNotifyAccessibility() 598 576 { 599 AccessibilityReplacedText replacedText( frame().selection().selection());577 AccessibilityReplacedText replacedText(document().selection().selection()); 600 578 insertParagraphSeparator(); 601 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, "\n", frame().selection().selection());579 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, "\n", document().selection().selection()); 602 580 composition()->setRangeDeletedByUnapply(replacedText.replacedRange()); 603 581 } … … 616 594 617 595 applyCommandToComposite(BreakBlockquoteCommand::create(document())); 618 619 Frame& frame = this->frame();620 Ref<Frame> protector(frame);621 596 typingAddedToOpenCommand(InsertParagraphSeparatorInQuotedContent); 622 597 } … … 624 599 void TypingCommand::insertParagraphSeparatorInQuotedContentAndNotifyAccessibility() 625 600 { 626 AccessibilityReplacedText replacedText( frame().selection().selection());601 AccessibilityReplacedText replacedText(document().selection().selection()); 627 602 insertParagraphSeparatorInQuotedContent(); 628 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, "\n", frame().selection().selection());603 replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypeTyping, "\n", document().selection().selection()); 629 604 composition()->setRangeDeletedByUnapply(replacedText.replacedRange()); 630 605 } … … 653 628 void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing) 654 629 { 655 Frame& frame = this->frame(); 656 Ref<Frame> protector(frame); 657 658 frame.editor().updateMarkersForWordsAffectedByEditing(false); 630 RefPtr<Frame> protector(document().frame()); 631 632 document().editor().updateMarkersForWordsAffectedByEditing(false); 659 633 660 634 VisibleSelection selectionToDelete; … … 749 723 // Workaround for this bug: 750 724 // <rdar://problem/4653755> UIKit text widgets should use WebKit editing API to manipulate text 751 setEndingSelection( frame.selection().selection());752 closeTyping( &frame);725 setEndingSelection(document().selection().selection()); 726 closeTyping(document()); 753 727 #endif 754 728 return; 755 729 } 756 730 757 if (selectionToDelete.isCaret() || ! frame.selection().shouldDeleteSelection(selectionToDelete))731 if (selectionToDelete.isCaret() || !document().selection().shouldDeleteSelection(selectionToDelete)) 758 732 return; 759 733 … … 762 736 763 737 if (shouldAddToKillRing) 764 frame.editor().addRangeToKillRing(createLiveRange(*selectionToDelete.toNormalizedRange()), Editor::KillRingInsertionMode::PrependText);738 document().editor().addRangeToKillRing(createLiveRange(*selectionToDelete.toNormalizedRange()), Editor::KillRingInsertionMode::PrependText); 765 739 766 740 // Post the accessibility notification before actually deleting the content while selectionToDelete is still valid … … 779 753 void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing) 780 754 { 781 Frame& frame = this->frame(); 782 Ref<Frame> protector(frame); 783 784 frame.editor().updateMarkersForWordsAffectedByEditing(false); 755 RefPtr<Frame> protector(document().frame()); 756 757 document().editor().updateMarkersForWordsAffectedByEditing(false); 785 758 786 759 VisibleSelection selectionToDelete; … … 858 831 // Workaround for this bug: 859 832 // <rdar://problem/4653755> UIKit text widgets should use WebKit editing API to manipulate text 860 setEndingSelection( frame.selection().selection());861 closeTyping( &frame);833 setEndingSelection(document().selection().selection()); 834 closeTyping(document()); 862 835 #endif 863 836 return; 864 837 } 865 838 866 if (selectionToDelete.isCaret() || ! frame.selection().shouldDeleteSelection(selectionToDelete))839 if (selectionToDelete.isCaret() || !document().selection().shouldDeleteSelection(selectionToDelete)) 867 840 return; 868 841 … … 874 847 875 848 if (shouldAddToKillRing) 876 frame.editor().addRangeToKillRing(createLiveRange(*selectionToDelete.toNormalizedRange()), Editor::KillRingInsertionMode::AppendText);849 document().editor().addRangeToKillRing(createLiveRange(*selectionToDelete.toNormalizedRange()), Editor::KillRingInsertionMode::AppendText); 877 850 // make undo select what was deleted 878 851 setStartingSelection(selectionAfterUndo); -
trunk/Source/WebCore/editing/TypingCommand.h
r237266 r260831 66 66 static void insertParagraphSeparator(Document&, Options); 67 67 static void insertParagraphSeparatorInQuotedContent(Document&); 68 static void closeTyping( Frame*);68 static void closeTyping(Document&); 69 69 #if PLATFORM(IOS_FAMILY) 70 static void ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping( Frame*, const VisibleSelection&);70 static void ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping(Document&, const VisibleSelection&); 71 71 #endif 72 72 … … 104 104 void closeTyping() { m_openForMoreTyping = false; } 105 105 106 static RefPtr<TypingCommand> lastTypingCommandIfStillOpenForTyping( Frame&);106 static RefPtr<TypingCommand> lastTypingCommandIfStillOpenForTyping(Document&); 107 107 108 108 void doApply() final; … … 123 123 bool isBeforeInputEventCancelable() const final; 124 124 125 static void updateSelectionIfDifferentFromCurrentSelection(TypingCommand*, Frame*);125 static void updateSelectionIfDifferentFromCurrentSelection(TypingCommand*, Document&); 126 126 127 127 void updatePreservesTypingStyle(ETypingCommand); -
trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm
r260753 r260831 81 81 String Editor::selectionInHTMLFormat() 82 82 { 83 return serializePreservingVisualAppearance(m_ frame.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy,84 m_ frame.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No);83 return serializePreservingVisualAppearance(m_document.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy, 84 m_document.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No); 85 85 } 86 86 … … 106 106 #endif 107 107 108 static RetainPtr<NSAttributedString> selectionAsAttributedString(const Frame& frame)109 { 110 auto range = frame.selection().selection().firstRange();108 static RetainPtr<NSAttributedString> selectionAsAttributedString(const Document& document) 109 { 110 auto range = document.selection().selection().firstRange(); 111 111 return range ? attributedString(*range).string : adoptNS([[NSAttributedString alloc] init]); 112 112 } … … 114 114 void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard) 115 115 { 116 auto string = selectionAsAttributedString(m_ frame);116 auto string = selectionAsAttributedString(m_document); 117 117 118 118 PasteboardWebContent content; 119 content.contentOrigin = m_ frame.document()->originIdentifierForPasteboard();119 content.contentOrigin = m_document.originIdentifierForPasteboard(); 120 120 content.canSmartCopyOrDelete = canSmartCopyOrDelete(); 121 121 content.dataInWebArchiveFormat = selectionInWebArchiveFormat(); … … 132 132 void Editor::writeSelection(PasteboardWriterData& pasteboardWriterData) 133 133 { 134 auto string = selectionAsAttributedString(m_ frame);134 auto string = selectionAsAttributedString(m_document); 135 135 136 136 PasteboardWriterData::WebContent webContent; 137 webContent.contentOrigin = m_ frame.document()->originIdentifierForPasteboard();137 webContent.contentOrigin = m_document.originIdentifierForPasteboard(); 138 138 webContent.canSmartCopyOrDelete = canSmartCopyOrDelete(); 139 139 webContent.dataInWebArchiveFormat = selectionInWebArchiveFormat(); … … 150 150 RefPtr<SharedBuffer> Editor::selectionInWebArchiveFormat() 151 151 { 152 auto archive = LegacyWebArchive::createFromSelection( &m_frame);152 auto archive = LegacyWebArchive::createFromSelection(m_document.frame()); 153 153 if (!archive) 154 154 return nullptr; … … 178 178 void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling) 179 179 { 180 if (m_ frame.selection().isNone())180 if (m_document.selection().isNone()) 181 181 return; 182 182 183 if (m_ frame.selection().selection().isContentRichlyEditable()) {184 if (auto fragment = createFragmentAndAddResources( m_frame, attributedString)) {183 if (m_document.selection().selection().isContentRichlyEditable()) { 184 if (auto fragment = createFragmentAndAddResources(*m_document.frame(), attributedString)) { 185 185 if (shouldInsertFragment(*fragment, selectedRange().get(), EditorInsertAction::Pasted)) 186 186 pasteAsFragment(fragment.releaseNonNull(), false, false, mailBlockquoteHandling); … … 228 228 RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, const SimpleRange& context, bool allowPlainText, bool& chosePlainText) 229 229 { 230 WebContentReader reader( m_frame, context, allowPlainText);230 WebContentReader reader(*m_document.frame(), context, allowPlainText); 231 231 pasteboard.read(reader); 232 232 chosePlainText = reader.madeFragmentFromPlainText; … … 241 241 } 242 242 243 auto stringFromSelection = m_ frame.displayStringModifiedByEncoding(selectedTextForDataTransfer());243 auto stringFromSelection = m_document.frame()->displayStringModifiedByEncoding(selectedTextForDataTransfer()); 244 244 #if PLATFORM(MAC) 245 245 Vector<String> types; -
trunk/Source/WebCore/editing/gtk/EditorGtk.cpp
r260753 r260831 95 95 96 96 bool chosePlainText; 97 RefPtr<DocumentFragment> fragment = createFragmentFromPasteboardData(*pasteboard, m_frame, *range, options.contains(PasteOption::AllowPlainText), chosePlainText);97 RefPtr<DocumentFragment> fragment = createFragmentFromPasteboardData(*pasteboard, *m_document.frame(), *range, options.contains(PasteOption::AllowPlainText), chosePlainText); 98 98 99 99 if (fragment && options.contains(PasteOption::AsQuotation)) … … 148 148 pasteboardContent.canSmartCopyOrDelete = canSmartCopyOrDelete(); 149 149 pasteboardContent.text = selectedTextForDataTransfer(); 150 pasteboardContent.markup = serializePreservingVisualAppearance(m_ frame.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy,151 m_ frame.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No);150 pasteboardContent.markup = serializePreservingVisualAppearance(m_document.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy, 151 m_document.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No); 152 152 pasteboard.write(pasteboardContent); 153 153 } … … 155 155 RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, const SimpleRange& context, bool allowPlainText, bool& chosePlainText) 156 156 { 157 return createFragmentFromPasteboardData(pasteboard, m_frame, context, allowPlainText, chosePlainText);157 return createFragmentFromPasteboardData(pasteboard, *m_document.frame(), context, allowPlainText, chosePlainText); 158 158 } 159 159 -
trunk/Source/WebCore/editing/ios/EditorIOS.mm
r260739 r260831 83 83 // Otherwise, do nothing. 84 84 85 auto selectionStyle = EditingStyle::styleAtSelectionStart(m_ frame.selection().selection());85 auto selectionStyle = EditingStyle::styleAtSelectionStart(m_document.selection().selection()); 86 86 if (!selectionStyle || !selectionStyle->style()) 87 87 return; … … 127 127 return; 128 128 129 Element* focusedElement = m_ frame.document()->focusedElement();129 Element* focusedElement = m_document.focusedElement(); 130 130 if (focusedElement && (is<HTMLTextAreaElement>(*focusedElement) || (is<HTMLInputElement>(*focusedElement) 131 131 && (downcast<HTMLInputElement>(*focusedElement).isTextField() … … 134 134 return; 135 135 downcast<HTMLElement>(*focusedElement).setAttributeWithoutSynchronization(alignAttr, newValue); 136 m_ frame.document()->updateStyleIfNeeded();136 m_document.updateStyleIfNeeded(); 137 137 return; 138 138 } … … 147 147 // This function removes styles that the user cannot modify by applying their default values. 148 148 149 auto editingStyle = EditingStyle::create(m_ frame.document()->bodyOrFrameset());149 auto editingStyle = EditingStyle::create(m_document.bodyOrFrameset()); 150 150 auto defaultStyle = editingStyle->style()->mutableCopy(); 151 151 … … 219 219 RefPtr<Range> range = selectedRange(); 220 220 bool allowPlainText = options.contains(PasteOption::AllowPlainText); 221 WebContentReader reader( m_frame, *range, allowPlainText);221 WebContentReader reader(*m_document.frame(), *range, allowPlainText); 222 222 int numberOfPasteboardItems = client()->getPasteboardItemsCount(); 223 223 for (int i = 0; i < numberOfPasteboardItems; ++i) { … … 243 243 void Editor::insertDictationPhrases(Vector<Vector<String>>&& dictationPhrases, id metadata) 244 244 { 245 if (m_ frame.selection().isNone())245 if (m_document.selection().isNone()) 246 246 return; 247 247 … … 261 261 clearUndoRedoOperations(); 262 262 263 m_ frame.selection().clear();263 m_document.selection().clear(); 264 264 265 265 element.removeChildren(); … … 339 339 // As a side effect this function sets a caret selection after the inserted content. Much of what 340 340 // follows is more expensive if there is a selection, so clear it since it's going to change anyway. 341 m_ frame.selection().clear();341 m_document.selection().clear(); 342 342 343 343 // clear out all current children of element … … 380 380 selection.setExtent(visiblePos); 381 381 382 m_ frame.selection().setSelection(selection);382 m_document.selection().setSelection(selection); 383 383 384 384 client()->respondToChangedContents(); … … 389 389 void Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping() 390 390 { 391 TypingCommand::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping( &m_frame, m_frame.selection().selection());391 TypingCommand::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping(m_document, m_document.selection().selection()); 392 392 } 393 393 -
trunk/Source/WebCore/editing/libwpe/EditorLibWPE.cpp
r238317 r260831 68 68 PasteboardWebContent pasteboardContent; 69 69 pasteboardContent.text = selectedTextForDataTransfer(); 70 pasteboardContent.markup = serializePreservingVisualAppearance(m_ frame.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy,71 m_ frame.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No);70 pasteboardContent.markup = serializePreservingVisualAppearance(m_document.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy, 71 m_document.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No); 72 72 pasteboard.write(pasteboardContent); 73 73 } … … 85 85 86 86 bool chosePlainText; 87 RefPtr<DocumentFragment> fragment = createFragmentFromPasteboardData(*pasteboard, m_frame, *range, options.contains(PasteOption::AllowPlainText), chosePlainText);87 RefPtr<DocumentFragment> fragment = createFragmentFromPasteboardData(*pasteboard, *m_document.frame(), *range, options.contains(PasteOption::AllowPlainText), chosePlainText); 88 88 89 89 if (fragment && options.contains(PasteOption::AsQuotation)) -
trunk/Source/WebCore/editing/mac/EditorMac.mm
r260753 r260831 103 103 { 104 104 Pasteboard pasteboard(pasteboardName); 105 if (m_ frame.selection().selection().isContentRichlyEditable())105 if (m_document.selection().selection().isContentRichlyEditable()) 106 106 pasteWithPasteboard(&pasteboard, { PasteOption::AllowPlainText }); 107 107 else … … 137 137 ASSERT(node); 138 138 139 if ( &node->document() != m_frame.document())140 return; 141 142 Ref< Frame> protector(m_frame);139 if (node->document() != m_document) 140 return; 141 142 Ref<Document> protector(m_document); 143 143 144 144 auto range = makeRangeSelectingNodeContents(*node); 145 m_ frame.selection().setSelection(VisibleSelection(range), FrameSelection::DoNotSetFocus);145 m_document.selection().setSelection(VisibleSelection(range), FrameSelection::DoNotSetFocus); 146 146 147 147 Pasteboard pasteboard(pasteboardName); 148 148 149 if (!m_ frame.selection().selection().isContentRichlyEditable()) {149 if (!m_document.selection().selection().isContentRichlyEditable()) { 150 150 pasteAsPlainTextWithPasteboard(pasteboard); 151 151 return; … … 221 221 void Editor::selectionWillChange() 222 222 { 223 if (!hasComposition() || ignoreSelectionChanges() || m_ frame.selection().isNone())223 if (!hasComposition() || ignoreSelectionChanges() || m_document.selection().isNone()) 224 224 return; 225 225 -
trunk/Source/WebCore/editing/win/EditorWin.cpp
r260753 r260831 43 43 44 44 bool chosePlainText; 45 RefPtr<DocumentFragment> fragment = pasteboard->documentFragment( m_frame, *range, options.contains(PasteOption::AllowPlainText), chosePlainText);45 RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(*m_document.frame(), *range, options.contains(PasteOption::AllowPlainText), chosePlainText); 46 46 47 47 if (fragment && options.contains(PasteOption::AsQuotation)) … … 70 70 { 71 71 if (COMPtr<IDataObject> platformDragData = pasteboard.dataObject()) 72 return createFragmentFromPlatformData(*platformDragData, m_frame);72 return createFragmentFromPlatformData(*platformDragData, *m_document.frame()); 73 73 74 return createFragmentFromPlatformData(pasteboard.dragDataMap(), m_frame);74 return createFragmentFromPlatformData(pasteboard.dragDataMap(), *m_document.frame()); 75 75 } 76 76 -
trunk/Source/WebCore/history/CachedFrame.cpp
r260774 r260831 287 287 288 288 m_document->setBackForwardCacheState(Document::NotInBackForwardCache); 289 m_document-> prepareForDestruction();289 m_document->willBeRemovedFromFrame(); 290 290 291 291 clear(); -
trunk/Source/WebCore/loader/FrameLoader.cpp
r260753 r260831 549 549 { 550 550 // This function is called when a frame is still fully in place (not cached, not detached), but will be replaced. 551 552 if (m_frame.editor().hasComposition()) { 551 Document* document = m_frame.document(); 552 if (!document) 553 return; 554 555 if (document->editor().hasComposition()) { 553 556 // The text was already present in DOM, so it's better to confirm than to cancel the composition. 554 m_frame.editor().confirmComposition();555 if (EditorClient* editorClient = m_frame.editor().client()) {557 document->editor().confirmComposition(); 558 if (EditorClient* editorClient = document->editor().client()) { 556 559 editorClient->respondToChangedSelection(&m_frame); 557 560 editorClient->discardedComposition(&m_frame); … … 564 567 history().saveDocumentState(); 565 568 566 Document*currentDocument = m_frame.document();569 RefPtr<Document> currentDocument = m_frame.document(); 567 570 UnloadEventPolicy unloadEventPolicy; 568 571 if (m_frame.page() && m_frame.page()->chrome().client().isSVGImageChromeClient()) { … … 576 579 stopLoading(unloadEventPolicy); 577 580 578 m_frame.editor().clearUndoRedoOperations(); 581 if (currentDocument) 582 currentDocument->editor().clearUndoRedoOperations(); 579 583 } 580 584 … … 588 592 589 593 m_frame.navigationScheduler().cancel(); 590 m_frame.editor().clearLastEditCommand();591 594 592 595 m_isComplete = false; … … 651 654 void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView, WTF::Function<void()>&& handleDOMWindowCreation) 652 655 { 653 m_frame.editor().clear();654 655 656 bool neededClear = m_needsClear; 656 657 m_needsClear = false; … … 660 661 m_frame.document()->stopActiveDOMObjects(); 661 662 bool hadLivingRenderTree = m_frame.document()->hasLivingRenderTree(); 662 m_frame.document()-> prepareForDestruction();663 m_frame.document()->willBeRemovedFromFrame(); 663 664 if (hadLivingRenderTree) 664 665 m_frame.document()->adjustFocusedNodeOnNodeRemoval(*m_frame.document()); … … 681 682 } 682 683 683 m_frame.selection().prepareForDestruction();684 684 m_frame.eventHandler().clear(); 685 685 -
trunk/Source/WebCore/page/Frame.cpp
r260774 r260831 157 157 , m_ownerElement(ownerElement) 158 158 , m_script(makeUniqueRef<ScriptController>(*this)) 159 , m_editor(makeUniqueRef<Editor>(*this))160 , m_selection(makeUniqueRef<FrameSelection>(this))161 159 , m_animationController(makeUniqueRef<CSSAnimationController>(*this)) 162 160 , m_pageZoomFactor(parentPageZoomFactor(this)) … … 235 233 // these calls to work. 236 234 if (!view && m_doc && m_doc->backForwardCacheState() != Document::InBackForwardCache) 237 m_doc-> prepareForDestruction();235 m_doc->willBeRemovedFromFrame(); 238 236 239 237 if (m_view) … … 280 278 281 279 if (m_doc && m_doc->backForwardCacheState() != Document::InBackForwardCache) 282 m_doc-> prepareForDestruction();280 m_doc->willBeRemovedFromFrame(); 283 281 284 282 m_doc = newDocument.copyRef(); … … 555 553 return false; 556 554 case DOMPasteAccessPolicy::NotRequestedYet: { 557 auto* client = m_editor->client();555 auto* client = editor().client(); 558 556 if (!client) 559 557 return false; … … 938 936 return; 939 937 940 m_editor->dismissCorrectionPanelAsIgnored();938 editor().dismissCorrectionPanelAsIgnored(); 941 939 942 940 // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents. -
trunk/Source/WebCore/page/Frame.h
r260774 r260831 30 30 #include "AbstractFrame.h" 31 31 #include "AdjustViewSizeOrNot.h" 32 #include "Document.h" 32 33 #include "FrameIdentifier.h" 33 34 #include "FrameTree.h" … … 164 165 FrameView* view() const; 165 166 166 Editor& editor() { return m_editor; }167 const Editor& editor() const { return m_editor; }167 Editor& editor() { return document()->editor(); } 168 const Editor& editor() const { return document()->editor(); } 168 169 EventHandler& eventHandler() { return m_eventHandler; } 169 170 const EventHandler& eventHandler() const { return m_eventHandler; } 170 171 FrameLoader& loader() const; 171 172 NavigationScheduler& navigationScheduler() const; 172 FrameSelection& selection() { return m_selection; }173 const FrameSelection& selection() const { return m_selection; }173 FrameSelection& selection() { return document()->selection(); } 174 const FrameSelection& selection() const { return document()->selection(); } 174 175 FrameTree& tree() const; 175 176 CSSAnimationController& legacyAnimation() { return m_animationController; } … … 339 340 340 341 UniqueRef<ScriptController> m_script; 341 UniqueRef<Editor> m_editor;342 UniqueRef<FrameSelection> m_selection;343 342 UniqueRef<CSSAnimationController> m_animationController; 344 343 -
trunk/Source/WebCore/page/TextIndicator.cpp
r260753 r260831 73 73 return nullptr; 74 74 75 bool indicatesCurrentSelection = range == frame->selection().selection().toNormalizedRange(); 75 auto document = makeRefPtr(frame->document()); 76 if (!document) 77 return nullptr; 78 79 bool indicatesCurrentSelection = range == document->selection().selection().toNormalizedRange(); 76 80 77 81 OptionSet<TemporarySelectionOption> temporarySelectionOptions; … … 81 85 temporarySelectionOptions.add(TemporarySelectionOption::EnableAppearanceUpdates); 82 86 #endif 83 TemporarySelectionChange selectionChange(* frame, { range }, temporarySelectionOptions);87 TemporarySelectionChange selectionChange(*document, { range }, temporarySelectionOptions); 84 88 85 89 TextIndicatorData data;
Note: See TracChangeset
for help on using the changeset viewer.