Changeset 283311 in webkit
- Timestamp:
- Sep 30, 2021, 7:53:33 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/editing/text-iterator/text-iterator-document-mutation-expected.txt (added)
-
LayoutTests/editing/text-iterator/text-iterator-document-mutation.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp (modified) (1 diff)
-
Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h (modified) (3 diffs)
-
Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (modified) (3 diffs)
-
Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebCore/testing/Internals.h (modified) (3 diffs)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r283310 r283311 1 2021-09-30 Antti Koivisto <antti@apple.com> 2 3 Having unused TextIterator instance shouldn't crash if document is mutated 4 https://bugs.webkit.org/show_bug.cgi?id=231013 5 rdar://83690985 6 7 Reviewed by Alan Bujtas. 8 9 * editing/text-iterator/text-iterator-document-mutation-expected.txt: Added. 10 * editing/text-iterator/text-iterator-document-mutation.html: Added. 11 1 12 2021-09-30 Lauro Moura <lmoura@igalia.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r283309 r283311 1 2021-09-30 Antti Koivisto <antti@apple.com> 2 3 Regression (283158): Having unused TextIterator instance shouldn't crash if document is mutated 4 https://bugs.webkit.org/show_bug.cgi?id=231013 5 rdar://83690985 6 7 Reviewed by Alan Bujtas. 8 9 By using bundle APIs it is possible to create a retained TextIterator and hit CheckedPtr assertion because layout 10 is torn down while iterator still exists. This is not dangerous in itself so can be supported. 11 12 This patch ensures LineLayout disconnects cleanly from (refcounted) InlineContent. 13 14 Test: editing/text-iterator/text-iterator-document-mutation.html 15 16 * layout/integration/LayoutIntegrationInlineContent.cpp: 17 (WebCore::LayoutIntegration::InlineContent::clearAndDetach): 18 19 Remove all content and clear the LineLayout pointer. 20 21 This is safe since iterators refer to content via indexes and any attempt to access 22 via them will hit nullptrs or vector asserts. 23 24 * layout/integration/LayoutIntegrationInlineContent.h: 25 (WebCore::LayoutIntegration::InlineContent::lineLayout const): 26 * layout/integration/LayoutIntegrationLineLayout.cpp: 27 (WebCore::LayoutIntegration::LineLayout::~LineLayout): 28 (WebCore::LayoutIntegration::LineLayout::layout): 29 (WebCore::LayoutIntegration::LineLayout::hitTest): 30 (WebCore::LayoutIntegration::LineLayout::clearInlineContent): 31 32 Clear InlineContent before nulling it as it can still be kept alive by iterators. 33 34 * layout/integration/LayoutIntegrationLineLayout.h: 35 * testing/Internals.cpp: 36 (WebCore::Internals::retainTextIteratorForDocumentContent): 37 * testing/Internals.h: 38 * testing/Internals.idl: 39 1 40 2021-09-30 Enrique Ocaña González <eocanha@igalia.com> 2 41 -
trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp
r283158 r283311 144 144 } 145 145 146 void InlineContent::clearAndDetach() 147 { 148 releaseCaches(); 149 boxes.clear(); 150 lines.clear(); 151 m_lineLayout = nullptr; 152 } 153 146 154 void InlineContent::releaseCaches() 147 155 { -
trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h
r283158 r283311 69 69 void shrinkToFit(); 70 70 71 const LineLayout& lineLayout() const { return m_lineLayout; }71 const LineLayout& lineLayout() const { return *m_lineLayout; } 72 72 const RenderObject& rendererForLayoutBox(const Layout::Box&) const; 73 73 const RenderBlockFlow& containingBlock() const; … … 81 81 const Vector<size_t>& nonRootInlineBoxIndexesForLayoutBox(const Layout::Box&) const; 82 82 83 void clearAndDetach(); 83 84 void releaseCaches(); 84 85 … … 86 87 InlineContent(const LineLayout&); 87 88 88 Checked Ref<const LineLayout> m_lineLayout;89 CheckedPtr<const LineLayout> m_lineLayout; 89 90 90 91 using FirstBoxIndexCache = HashMap<CheckedRef<const Layout::Box>, size_t>; -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp
r283158 r283311 68 68 } 69 69 70 LineLayout::~LineLayout() = default; 70 LineLayout::~LineLayout() 71 { 72 clearInlineContent(); 73 } 71 74 72 75 RenderBlockFlow* LineLayout::blockContainer(RenderObject& renderer) … … 219 222 220 223 // FIXME: Do not clear the lines and boxes here unconditionally, but consult with the damage object instead. 221 m_inlineContent = nullptr; 224 clearInlineContent(); 225 222 226 auto& rootGeometry = m_layoutState.geometryForBox(rootLayoutBox); 223 227 auto inlineFormattingContext = Layout::InlineFormattingContext { rootLayoutBox, m_inlineFormattingState, m_lineDamage.get() }; … … 573 577 } 574 578 579 void LineLayout::clearInlineContent() 580 { 581 if (!m_inlineContent) 582 return; 583 m_inlineContent->clearAndDetach(); 584 m_inlineContent = nullptr; 585 } 586 575 587 void LineLayout::paintTextBoxUsingPhysicalCoordinates(PaintInfo& paintInfo, const LayoutPoint& paintOffset, const InlineDisplay::Box& textBox) 576 588 { -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h
r283158 r283311 130 130 const Layout::ContainerBox& rootLayoutBox() const; 131 131 Layout::ContainerBox& rootLayoutBox(); 132 void clearInlineContent(); 132 133 void releaseCaches(); 133 134 -
trunk/Source/WebCore/testing/Internals.cpp
r283033 r283311 6538 6538 #endif 6539 6539 6540 void Internals::retainTextIteratorForDocumentContent() 6541 { 6542 auto* document = contextDocument(); 6543 if (!document) 6544 return; 6545 6546 auto range = makeRangeSelectingNodeContents(*document); 6547 m_textIterator = makeUnique<TextIterator>(range); 6548 } 6549 6550 6540 6551 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r283033 r283311 103 103 class StringCallback; 104 104 class StyleSheet; 105 class TextIterator; 105 106 class TextTrack; 106 107 class TimeRanges; … … 1191 1192 ExceptionOr<void> setDocumentAutoplayPolicy(Document&, AutoplayPolicy); 1192 1193 1194 void retainTextIteratorForDocumentContent(); 1195 1193 1196 private: 1194 1197 explicit Internals(Document&); … … 1220 1223 HashMap<unsigned, std::unique_ptr<WebCore::SleepDisabler>> m_sleepDisablers; 1221 1224 1225 std::unique_ptr<TextIterator> m_textIterator; 1226 1222 1227 #if ENABLE(WEBXR) 1223 1228 RefPtr<WebXRTest> m_xrTest; -
trunk/Source/WebCore/testing/Internals.idl
r282686 r283311 1064 1064 1065 1065 undefined setDocumentAutoplayPolicy(Document document, AutoplayPolicy policy); 1066 }; 1066 1067 undefined retainTextIteratorForDocumentContent(); 1068 };
Note:
See TracChangeset
for help on using the changeset viewer.