Changeset 274862 in webkit
- Timestamp:
- Mar 23, 2021, 6:36:58 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
editing/CompositeEditCommand.cpp (modified) (2 diffs)
-
editing/FrameSelection.cpp (modified) (2 diffs)
-
editing/FrameSelection.h (modified) (1 diff)
-
editing/VisibleSelection.cpp (modified) (1 diff)
-
editing/VisibleSelection.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r274861 r274862 1 2021-03-23 Frédéric Wang <fwang@igalia.com> 2 3 Nullptr crash in HTMLConverter::convert 4 https://bugs.webkit.org/show_bug.cgi?id=221719 5 6 Reviewed by Ryosuke Niwa. 7 8 When the "Undo" command is called after DOM changes, one of the selection's position anchors 9 may have been moved to a new document. In that case, just clear the selection. Also add 10 asserts to ensure the selection is in good state after unapply and reapply commands. 11 12 * editing/CompositeEditCommand.cpp: 13 (WebCore::EditCommandComposition::unapply): Add security assert to ensure selection is in 14 good state. 15 (WebCore::EditCommandComposition::reapply): Ditto. 16 * editing/FrameSelection.cpp: 17 (WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance): If the selection's 18 position anchors have been moved to a new document then just clear the selection. 19 (WebCore::FrameSelection::isConnectedToDocument const): New method to verify that all the 20 positions of the visible selection are in m_document. 21 * editing/FrameSelection.h: Declare new method. 22 * editing/VisibleSelection.cpp: 23 (WebCore::VisibleSelection::document const): New method that returns a common document for 24 all positions or nullptr otherwise. 25 * editing/VisibleSelection.h: Declare new method. 26 1 27 2021-03-23 Kimmo Kinnunen <kkinnunen@apple.com> 2 28 -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r274626 r274862 244 244 if (AXObjectCache::accessibilityEnabled()) 245 245 m_replacedText.postTextStateChangeNotificationForUnapply(m_document->existingAXObjectCache()); 246 247 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_document->selection().isNone() || m_document->selection().isConnectedToDocument()); 246 248 } 247 249 … … 271 273 if (AXObjectCache::accessibilityEnabled()) 272 274 m_replacedText.postTextStateChangeNotificationForReapply(m_document->existingAXObjectCache()); 275 276 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_document->selection().isNone() || m_document->selection().isConnectedToDocument()); 273 277 } 274 278 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r274526 r274862 370 370 } 371 371 372 bool selectionEndpointsBelongToMultipleDocuments = newSelection.base().document() && !newSelection.document(); 373 bool selectionIsInAnotherDocument = newSelection.document() && newSelection.document() != m_document.get(); 374 if (selectionEndpointsBelongToMultipleDocuments || selectionIsInAnotherDocument) { 375 clear(); 376 return false; 377 } 378 372 379 if (closeTyping) 373 380 TypingCommand::closeTyping(*m_document); … … 2795 2802 } 2796 2803 2804 bool FrameSelection::isConnectedToDocument() const 2805 { 2806 return selection().document() == m_document.get(); 2807 } 2808 2797 2809 RefPtr<Range> FrameSelection::associatedLiveRange() 2798 2810 { -
trunk/Source/WebCore/editing/FrameSelection.h
r274526 r274862 253 253 254 254 bool isInDocumentTree() const; 255 bool isConnectedToDocument() const; 256 255 257 RefPtr<Range> associatedLiveRange(); 256 258 void associateLiveRange(Range&); -
trunk/Source/WebCore/editing/VisibleSelection.cpp
r272928 r274862 143 143 return true; 144 144 return false; 145 } 146 147 RefPtr<Document> VisibleSelection::document() const 148 { 149 auto baseDocument = makeRefPtr(m_base.document()); 150 if (!baseDocument) 151 return nullptr; 152 153 if (m_extent.document() != baseDocument.get() || m_start.document() != baseDocument.get() || m_end.document() != baseDocument.get()) 154 return nullptr; 155 156 if (baseDocument->settings().liveRangeSelectionEnabled() && (m_anchor.document() != baseDocument.get() || m_focus.document() != baseDocument.get())) 157 return nullptr; 158 159 return baseDocument; 145 160 } 146 161 -
trunk/Source/WebCore/editing/VisibleSelection.h
r272928 r274862 88 88 bool isNoneOrOrphaned() const { return isNone() || start().isOrphan() || end().isOrphan(); } 89 89 bool isOrphan() const; 90 RefPtr<Document> document() const; 90 91 91 92 bool isBaseFirst() const { return m_anchorIsFirst; }
Note:
See TracChangeset
for help on using the changeset viewer.