Changeset 224034 in webkit
- Timestamp:
- Oct 26, 2017 11:51:33 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r224033 r224034 1 2017-10-26 Antti Koivisto <antti@apple.com> 2 3 Remove unnecessary whitespace invalidation logic from RenderTreeUpdater 4 https://bugs.webkit.org/show_bug.cgi?id=178786 5 6 Reviewed by Zalan Bujtas. 7 8 RenderTreeUpdater::invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded is a somewhat complex 9 and confusing function for figuring out if some whitespace-only text node might need to have its 10 rendering status recomputed. However actually computing if a text renderer is needed is not expensive. 11 We can simply do it for all whitespace nodes after a sibling mutation. 12 13 This also removes a set that could have stale renderer pointers in it (they were never dereferenced). 14 15 * rendering/RenderBlock.cpp: 16 (WebCore::RenderBlock::addChildIgnoringContinuation): 17 18 Fix a display:contents bug exposed by this change. With display:contents a text renderer may have an anonymous 19 inline wrapper and we need to take it into account when the text renderer is the beforeChild. 20 21 Tested by imported/w3c/web-platform-tests/css/css-display-3/display-contents-state-change-001.html 22 23 * style/RenderTreeUpdater.cpp: 24 (WebCore::RenderTreeUpdater::updateRenderTree): 25 26 Call updateTextRenderer() for all whitespace-only text nodes after a change in siblings. 27 In normal update case it just figures out quickly (by calling textRendererIsNeeded) 28 that there are no changes and bails out. 29 30 (WebCore::RenderTreeUpdater::updateElementRenderer): 31 (WebCore::RenderTreeUpdater::updateTextRenderer): 32 (WebCore::RenderTreeUpdater::invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded): Deleted. 33 34 No longer needed. Just mark that there have been changes to siblings instead. 35 36 * style/RenderTreeUpdater.h: 37 1 38 2017-10-26 Myles C. Maxfield <mmaxfield@apple.com> 2 39 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r223476 r224034 555 555 556 556 if (beforeChildContainer->isAnonymous()) { 557 if (beforeChildContainer->isInline()) { 558 ASSERT(RenderText::findByDisplayContentsInlineWrapperCandidate(*beforeChildContainer) == beforeChild); 559 addChild(WTFMove(newChild), beforeChildContainer); 560 return; 561 } 557 562 // If the requested beforeChild is not one of our children, then this is because 558 563 // there is an anonymous container within this object that contains the beforeChild. -
trunk/Source/WebCore/style/RenderTreeUpdater.cpp
r223848 r224034 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 175 175 auto& text = downcast<Text>(node); 176 176 auto* textUpdate = m_styleUpdate->textUpdate(text); 177 if ((parent().updates && parent().updates->update.change == Style::Detach) || textUpdate || m_invalidatedWhitespaceOnlyTextSiblings.contains(&text)) 177 bool didCreateParent = parent().updates && parent().updates->update.change == Style::Detach; 178 bool mayNeedUpdateWhitespaceOnlyRenderer = parent().didCreateOrDestroyChildRenderer && text.containsOnlyWhitespace(); 179 if (didCreateParent || textUpdate || mayNeedUpdateWhitespaceOnlyRenderer) 178 180 updateTextRenderer(text, textUpdate); 179 181 … … 212 214 213 215 popParentsToDepth(0); 214 215 m_invalidatedWhitespaceOnlyTextSiblings.clear();216 216 } 217 217 … … 314 314 auto teardownType = update.style->display() == NONE ? TeardownType::RendererUpdateCancelingAnimations : TeardownType::RendererUpdate; 315 315 tearDownRenderers(element, teardownType); 316 317 parent().didCreateOrDestroyChildRenderer = true; 316 318 } 317 319 … … 327 329 element.willAttachRenderers(); 328 330 createRenderer(element, RenderStyle::clone(*update.style)); 329 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(element); 331 332 parent().didCreateOrDestroyChildRenderer = true; 330 333 return; 331 334 } … … 481 484 } 482 485 tearDownRenderer(text); 483 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text);486 parent().didCreateOrDestroyChildRenderer = true; 484 487 return; 485 488 } … … 487 490 return; 488 491 createTextRenderer(text, renderTreePosition(), textUpdate); 489 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text); 490 } 491 492 void RenderTreeUpdater::invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node& current) 493 { 494 // FIXME: This needs to traverse in composed tree order. 495 496 // This function finds sibling text renderers where the results of textRendererIsNeeded may have changed as a result of 497 // the current node gaining or losing the renderer. This can only affect white space text nodes. 498 for (Node* sibling = current.nextSibling(); sibling; sibling = sibling->nextSibling()) { 499 if (is<Element>(*sibling)) { 500 if (m_styleUpdate->elementUpdates(downcast<Element>(*sibling))) 501 return; 502 // Text renderers beyond rendered elements can't be affected. 503 if (sibling->renderer()) 504 return; 505 continue; 506 } 507 if (!is<Text>(*sibling)) 508 continue; 509 Text& textSibling = downcast<Text>(*sibling); 510 if (m_styleUpdate->textUpdate(textSibling)) 511 return; 512 if (!textSibling.containsOnlyWhitespace()) 513 continue; 514 m_invalidatedWhitespaceOnlyTextSiblings.add(&textSibling); 515 } 492 parent().didCreateOrDestroyChildRenderer = true; 516 493 } 517 494 -
trunk/Source/WebCore/style/RenderTreeUpdater.h
r223848 r224034 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 62 62 void updateElementRenderer(Element&, const Style::ElementUpdate&); 63 63 void createRenderer(Element&, RenderStyle&&); 64 void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node&);65 64 void updateBeforeDescendants(Element&, const Style::ElementUpdates*); 66 65 void updateAfterDescendants(Element&, const Style::ElementUpdates*); … … 72 71 const Style::ElementUpdates* updates { nullptr }; 73 72 std::optional<RenderTreePosition> renderTreePosition; 73 74 bool didCreateOrDestroyChildRenderer { false }; 74 75 RenderObject* previousChildRenderer { nullptr }; 75 76 … … 96 97 Vector<Parent> m_parentStack; 97 98 98 HashSet<Text*> m_invalidatedWhitespaceOnlyTextSiblings;99 100 99 std::unique_ptr<GeneratedContent> m_generatedContent; 101 100 };
Note: See TracChangeset
for help on using the changeset viewer.