Changeset 273621 in webkit
- Timestamp:
- Feb 27, 2021, 12:24:02 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/text/splitText-dirty-lines-expected.txt (modified) (1 diff)
-
LayoutTests/fast/text/text-combine-surroundContents-crash-expected.txt (modified) (1 diff)
-
LayoutTests/imported/blink/fast/css/first-letter-range-insert-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/CharacterData.cpp (modified) (2 diffs)
-
Source/WebCore/dom/Document.cpp (modified) (4 diffs)
-
Source/WebCore/dom/Document.h (modified) (1 diff)
-
Source/WebCore/dom/Text.cpp (modified) (2 diffs)
-
Source/WebCore/editing/CompositeEditCommand.cpp (modified) (1 diff)
-
Source/WebCore/editing/markup.cpp (modified) (1 diff)
-
Source/WebCore/rendering/updating/RenderTreeUpdater.cpp (modified) (1 diff)
-
Source/WebCore/style/StyleTreeResolver.cpp (modified) (2 diffs)
-
Source/WebCore/style/StyleTreeResolver.h (modified) (1 diff)
-
Source/WebCore/style/StyleUpdate.cpp (modified) (2 diffs)
-
Source/WebCore/style/StyleUpdate.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r273616 r273621 1 2021-02-27 Antti Koivisto <antti@apple.com> 2 3 Render tree updates for Text node content mutations should happen during rendering update 4 https://bugs.webkit.org/show_bug.cgi?id=222406 5 6 Reviewed by Simon Fraser. 7 8 These are progressions. 9 10 * fast/text/splitText-dirty-lines-expected.txt: 11 * imported/blink/fast/css/first-letter-range-insert-expected.txt: 12 13 Here we were actually drawing text that didn't exist in DOM anymore. 14 1 15 2021-02-26 Peng Liu <peng.liu6@apple.com> 2 16 -
trunk/LayoutTests/fast/text/splitText-dirty-lines-expected.txt
r62134 r273621 16 16 layer at (8,8) size 200x160 17 17 RenderBlock (positioned) {DIV} at (0,0) size 200x160 [color=#008000] 18 RenderText {#text} at (0,0) size 0x019 18 RenderText {#text} at (0,0) size 160x160 20 19 text run at (0,0) width 160: "AAAA" -
trunk/LayoutTests/fast/text/text-combine-surroundContents-crash-expected.txt
r235615 r273621 1 1 layer at (0,0) size 800x600 2 2 RenderView at (0,0) size 800x600 3 layer at (0,0) size 800x76 4 RenderBlock {HTML} at (0,0) size 800x76 5 RenderBody {BODY} at (8,8) size 784x60 6 RenderBlock {DIV} at (0,0) size 20x40 7 RenderCombineText {#text} at (0,0) size 0x0 8 RenderInline {SPAN} at (0,0) size 20x0 9 RenderCombineText {#text} at (0,20) size 20x20 10 text run at (0,20) width 20: "\x{FFFC}" 11 RenderBlock (anonymous) at (0,40) size 784x0 3 layer at (0,0) size 800x56 4 RenderBlock {HTML} at (0,0) size 800x56 5 RenderBody {BODY} at (8,8) size 784x40 6 RenderBlock {DIV} at (0,0) size 20x20 7 RenderInline {SPAN} at (0,0) size 0x0 8 RenderCombineText {#text} at (0,0) size 20x20 9 text run at (0,0) width 20: "\x{FFFC}" 10 RenderBlock (anonymous) at (0,20) size 784x0 12 11 RenderText {#text} at (0,0) size 0x0 13 12 RenderText {#text} at (0,0) size 0x0 14 RenderBlock {DIV} at (0, 40) size 784x2013 RenderBlock {DIV} at (0,20) size 784x20 15 14 RenderText {#text} at (0,0) size 400x20 16 15 text run at (0,0) width 400: "PASS, did not crash." -
trunk/LayoutTests/imported/blink/fast/css/first-letter-range-insert-expected.txt
r220646 r273621 1 B2 1 -
trunk/Source/WebCore/ChangeLog
r273620 r273621 1 2021-02-27 Antti Koivisto <antti@apple.com> 2 3 Render tree updates for Text node content mutations should happen during rendering update 4 https://bugs.webkit.org/show_bug.cgi?id=222406 5 6 Reviewed by Simon Fraser. 7 8 Calls to Text.insertData and similar should not mutate render tree synchronously. 9 Instead render tree should be updated during the next rendering update along with 10 any style changes. 11 12 These updates already go via RenderTreeUpdater. We just need to save the information 13 about which nodes need updating so the next rendering update can pick them up. 14 15 This seems to help with some performance benchmarks. 16 17 * dom/CharacterData.cpp: 18 (WebCore::CharacterData::parserAppendData): 19 (WebCore::CharacterData::setDataAndUpdate): 20 21 Move in-tree check to the updateRendererAfterContentChange and make it use isConnected(). 22 23 * dom/Document.cpp: 24 (WebCore::Document::removedLastRef): 25 (WebCore::Document::resolveStyle): 26 27 Include the text update when updating the render tree. 28 29 (WebCore::Document::updateTextRenderer): 30 31 Create a text update that will get flushed during the next rendering update. 32 33 (WebCore::Document::needsStyleRecalc const): 34 35 We need to recalc if there are pending text updates. 36 37 * dom/Document.h: 38 * dom/Text.cpp: 39 (WebCore::Text::splitText): 40 41 Use updateRendererAfterContentChange instead of poking render tree directly. 42 43 (WebCore::Text::updateRendererAfterContentChange): 44 * rendering/updating/RenderTreeUpdater.cpp: 45 * style/StyleTreeResolver.cpp: 46 (WebCore::Style::TreeResolver::TreeResolver): 47 (WebCore::Style::TreeResolver::resolve): 48 * style/StyleTreeResolver.h: 49 (WebCore::Style::TreeResolver::TreeResolver): 50 * style/StyleUpdate.cpp: 51 (WebCore::Style::Update::addText): 52 53 Merge text updates. 54 55 (WebCore::Style::Update::addPossibleRoot): 56 * style/StyleUpdate.h: 57 (WebCore::Style::Update::roots const): 58 (WebCore::Style::Update:: const): Deleted. 59 60 Refcount the nodes since this now has longer lifetime. 61 62 * editing/CompositeEditCommand.cpp: 63 (WebCore::CompositeEditCommand::deleteInsignificantText): 64 65 Ensure we leave deleteInsignificantText with updated render tree. Clients expect that. 66 Do layout (instead of just style update) for consistency, deleteInsignificantText does one anyway in beginning. 67 68 * editing/markup.cpp: 69 (WebCore::replaceChildrenWithFragment): 70 71 Pending text update may ref the node so this refcount assert is not correct. 72 73 * style/StyleUpdate.cpp: 74 (WebCore::Style::Update::addText): 75 1 76 2021-02-27 Megan Gardner <megan_gardner@apple.com> 2 77 -
trunk/Source/WebCore/dom/CharacterData.cpp
r269161 r273621 103 103 104 104 ASSERT(!renderer() || is<Text>(*this)); 105 if (is<Text>(*this) && parentNode())105 if (is<Text>(*this)) 106 106 downcast<Text>(*this).updateRendererAfterContentChange(oldLength, 0); 107 107 … … 183 183 184 184 ASSERT(!renderer() || is<Text>(*this)); 185 if (is<Text>(*this) && parentNode())185 if (is<Text>(*this)) 186 186 downcast<Text>(*this).updateRendererAfterContentChange(offsetOfReplacedData, oldLength); 187 187 -
trunk/Source/WebCore/dom/Document.cpp
r273415 r273621 808 808 #endif 809 809 m_associatedFormControls.clear(); 810 m_pendingRenderTreeTextUpdate = { }; 810 811 811 812 m_fontSelector->stopLoadingAndClearFonts(); … … 2053 2054 } 2054 2055 2055 Style::TreeResolver resolver(*this );2056 Style::TreeResolver resolver(*this, WTFMove(m_pendingRenderTreeTextUpdate)); 2056 2057 auto styleUpdate = resolver.resolve(); 2057 2058 … … 2101 2102 void Document::updateTextRenderer(Text& text, unsigned offsetOfReplacedText, unsigned lengthOfReplacedText) 2102 2103 { 2103 auto textUpdate = makeUnique<Style::Update>(*this); 2104 textUpdate->addText(text, { offsetOfReplacedText, lengthOfReplacedText, WTF::nullopt }); 2105 2106 updateRenderTree(WTFMove(textUpdate)); 2104 if (!m_pendingRenderTreeTextUpdate) 2105 m_pendingRenderTreeTextUpdate = makeUnique<Style::Update>(*this); 2106 2107 m_pendingRenderTreeTextUpdate->addText(text, { offsetOfReplacedText, lengthOfReplacedText, WTF::nullopt }); 2108 2109 scheduleRenderingUpdate({ }); 2107 2110 } 2108 2111 … … 2116 2119 2117 2120 if (childNeedsStyleRecalc()) 2121 return true; 2122 2123 if (m_pendingRenderTreeTextUpdate) 2118 2124 return true; 2119 2125 -
trunk/Source/WebCore/dom/Document.h
r272707 r273621 1804 1804 Timer m_styleRecalcTimer; 1805 1805 1806 std::unique_ptr<Style::Update> m_pendingRenderTreeTextUpdate; 1807 1806 1808 Element* m_cssTarget { nullptr }; 1807 1809 -
trunk/Source/WebCore/dom/Text.cpp
r267220 r273621 77 77 document().textNodeSplit(*this); 78 78 79 if (renderer()) 80 renderer()->setTextWithOffset(data(), 0, oldData.length()); 79 updateRendererAfterContentChange(0, oldData.length()); 81 80 82 81 return newText; … … 216 215 void Text::updateRendererAfterContentChange(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData) 217 216 { 218 ASSERT(parentNode()); 217 if (!isConnected()) 218 return; 219 219 220 if (styleValidity() >= Style::Validity::SubtreeAndRenderersInvalid) 220 221 return; -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r273468 r273621 1059 1059 deleteInsignificantText(textNode, startOffset, endOffset); 1060 1060 } 1061 if (!nodes.isEmpty()) { 1062 // Callers expect render tree to be in sync. 1063 document().updateLayoutIgnorePendingStylesheets(); 1064 } 1061 1065 } 1062 1066 -
trunk/Source/WebCore/editing/markup.cpp
r273375 r273621 1386 1386 if (containerChild && !containerChild->nextSibling()) { 1387 1387 if (is<Text>(*containerChild) && hasOneTextChild(fragment) && canUseSetDataOptimization(downcast<Text>(*containerChild), mutation)) { 1388 ASSERT(!fragment->firstChild()->refCount());1389 1388 downcast<Text>(*containerChild).setData(downcast<Text>(*fragment->firstChild()).data()); 1390 1389 return { }; -
trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp
r269813 r273621 103 103 { 104 104 ListHashSet<ContainerNode*> renderingRoots; 105 for (auto *root : update.roots()) {105 for (auto& root : update.roots()) { 106 106 auto* renderingRoot = findRenderingRoot(*root); 107 107 if (!renderingRoot) -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r273003 r273621 63 63 DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(TreeResolverScope); 64 64 65 TreeResolver::TreeResolver(Document& document )65 TreeResolver::TreeResolver(Document& document, std::unique_ptr<Update> update) 66 66 : m_document(document) 67 , m_update(WTFMove(update)) 67 68 { 68 69 } … … 577 578 } 578 579 if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc()) 579 return nullptr;580 return WTFMove(m_update); 580 581 581 582 m_didSeePendingStylesheet = m_document.styleScope().hasPendingSheetsBeforeBody(); 582 583 583 m_update = makeUnique<Update>(m_document); 584 if (!m_update) 585 m_update = makeUnique<Update>(m_document); 584 586 m_scopeStack.append(adoptRef(*new Scope(m_document))); 585 587 m_parentStack.append(Parent(m_document)); -
trunk/Source/WebCore/style/StyleTreeResolver.h
r270837 r273621 50 50 class TreeResolver { 51 51 public: 52 TreeResolver(Document& );52 TreeResolver(Document&, std::unique_ptr<Update> = { }); 53 53 ~TreeResolver(); 54 54 -
trunk/Source/WebCore/style/StyleUpdate.cpp
r223604 r273621 97 97 void Update::addText(Text& text, Element* parent, TextUpdate&& textUpdate) 98 98 { 99 ASSERT(!m_texts.contains(&text));100 99 ASSERT(composedTreeAncestors(text).first() == parent); 101 100 102 101 addPossibleRoot(parent); 103 m_texts.add(&text, WTFMove(textUpdate)); 102 auto result = m_texts.ensure(&text, [&] { 103 return WTFMove(textUpdate); 104 }); 105 if (!result.isNewEntry) { 106 auto& entry = result.iterator->value; 107 auto startOffset = std::min(entry.offset, textUpdate.offset); 108 auto endOffset = std::max(entry.offset + entry.length, textUpdate.offset + textUpdate.length); 109 entry.offset = startOffset; 110 entry.length = endOffset - startOffset; 111 112 ASSERT(!entry.inheritedDisplayContentsStyle || !textUpdate.inheritedDisplayContentsStyle); 113 if (!entry.inheritedDisplayContentsStyle) 114 entry.inheritedDisplayContentsStyle = WTFMove(textUpdate.inheritedDisplayContentsStyle); 115 } 104 116 } 105 117 … … 112 124 { 113 125 if (!element) { 114 m_roots.add( &m_document);126 m_roots.add(m_document.ptr()); 115 127 return; 116 128 } -
trunk/Source/WebCore/style/StyleUpdate.h
r269813 r273621 70 70 Update(Document&); 71 71 72 const ListHashSet< ContainerNode*>& roots() const { return m_roots; }72 const ListHashSet<RefPtr<ContainerNode>>& roots() const { return m_roots; } 73 73 74 74 const ElementUpdates* elementUpdates(const Element&) const; … … 91 91 void addPossibleRoot(Element*); 92 92 93 Document&m_document;94 ListHashSet< ContainerNode*> m_roots;95 HashMap< const Element*, ElementUpdates> m_elements;96 HashMap< const Text*, TextUpdate> m_texts;93 Ref<Document> m_document; 94 ListHashSet<RefPtr<ContainerNode>> m_roots; 95 HashMap<RefPtr<const Element>, ElementUpdates> m_elements; 96 HashMap<RefPtr<const Text>, TextUpdate> m_texts; 97 97 }; 98 98
Note:
See TracChangeset
for help on using the changeset viewer.