Changeset 228497 in webkit
- Timestamp:
- Feb 14, 2018, 5:27:52 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r228486 r228497 1 2018-02-14 Antti Koivisto <antti@apple.com> 2 3 Do sibling invalidation on mutation 4 https://bugs.webkit.org/show_bug.cgi?id=182809 5 6 Reviewed by Zalan Bujtas. 7 8 Sibling invalidation now happens on mutation. Update the tests. 9 10 * fast/css/indirect-adjacent-style-invalidation-1-expected.txt: 11 * fast/css/indirect-adjacent-style-invalidation-1.html: 12 * fast/css/indirect-adjacent-style-invalidation-2-expected.txt: 13 * fast/css/indirect-adjacent-style-invalidation-2.html: 14 * fast/css/indirect-adjacent-style-invalidation-3-expected.txt: 15 * fast/css/indirect-adjacent-style-invalidation-3.html: 16 1 17 2018-02-14 Daniel Bates <dabates@apple.com> 2 18 -
trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1-expected.txt
r189560 r228497 12 12 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true 13 13 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true 14 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false15 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false14 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true 15 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true 16 16 PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)" 17 17 PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)" … … 22 22 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true 23 23 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true 24 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false25 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false24 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true 25 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true 26 26 PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" 27 27 PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" -
trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1.html
r189560 r228497 50 50 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[0])"); 51 51 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[1])"); 52 shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");53 shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");52 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])"); 53 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])"); 54 54 } 55 55 -
trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2-expected.txt
r189560 r228497 12 12 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true 13 13 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true 14 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false15 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false14 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true 15 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true 16 16 PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)" 17 17 PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)" … … 22 22 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true 23 23 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true 24 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false25 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false24 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true 25 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true 26 26 PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" 27 27 PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" -
trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2.html
r189560 r228497 50 50 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[0])"); 51 51 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[1])"); 52 shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");53 shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");52 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])"); 53 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])"); 54 54 } 55 55 -
trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3-expected.txt
r189560 r228497 12 12 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true 13 13 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true 14 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false15 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false14 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true 15 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true 16 16 PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)" 17 17 PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)" … … 22 22 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true 23 23 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true 24 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false25 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false24 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true 25 PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true 26 26 PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" 27 27 PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" -
trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3.html
r189560 r228497 50 50 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[0])"); 51 51 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[1])"); 52 shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");53 shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");52 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])"); 53 testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])"); 54 54 } 55 55 -
trunk/Source/WebCore/ChangeLog
r228495 r228497 1 2018-02-14 Antti Koivisto <antti@apple.com> 2 3 Do sibling invalidation on mutation 4 https://bugs.webkit.org/show_bug.cgi?id=182809 5 6 Reviewed by Zalan Bujtas. 7 8 We used to invalidate siblings for sibling combinators and nth-pseudo classes during style resolution tree walk. 9 This would consider any element with invalid style a reason to invalidate siblings too. However we now do 10 accurate invalidation on class and attribute changes and this approach ends up invalidating too much. 11 12 This patch sibling style invalidation to mutation time and removes invalidation code from style resolution tree walk. 13 14 * dom/Element.cpp: 15 (WebCore::invalidateSiblingsIfNeeded): 16 17 Helper to invalidate siblings. 18 19 (WebCore::Element::invalidateStyle): 20 (WebCore::Element::invalidateStyleAndLayerComposition): 21 (WebCore::Element::invalidateStyleForSubtree): 22 (WebCore::Element::invalidateStyleAndRenderersForSubtree): 23 24 Invalidate siblings if needed based on affectsNextSibling/affectedByPreviousSibling bits. 25 26 (WebCore::Element::invalidateStyleInternal): 27 (WebCore::Element::invalidateStyleForSubtreeInternal): 28 29 Add "internal" versions that don't invalidate siblings. These are used by StyleInvalidator for accurate invalidation. 30 31 * dom/Element.h: 32 * style/StyleInvalidator.cpp: 33 (WebCore::Style::Invalidator::invalidateIfNeeded): 34 (WebCore::Style::Invalidator::invalidateStyle): 35 36 Use internal invalidation functions. 37 38 * style/StyleTreeResolver.cpp: 39 (WebCore::Style::resetStyleForNonRenderedDescendants): 40 (WebCore::Style::TreeResolver::resolveComposedTree): 41 42 Remove sibling invalidation. 43 44 * style/StyleTreeResolver.h: 45 1 46 2018-02-14 John Wilander <wilander@apple.com> 2 47 -
trunk/Source/WebCore/dom/Element.cpp
r228446 r228497 1482 1482 } 1483 1483 1484 static void invalidateSiblingsIfNeeded(Element& element) 1485 { 1486 if (!element.affectsNextSiblingElementStyle()) 1487 return; 1488 auto* parent = element.parentElement(); 1489 if (parent && parent->styleValidity() >= Style::Validity::SubtreeInvalid) 1490 return; 1491 1492 for (auto* sibling = element.nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) { 1493 if (sibling->styleIsAffectedByPreviousSibling()) 1494 sibling->invalidateStyleForSubtreeInternal(); 1495 if (!sibling->affectsNextSiblingElementStyle()) 1496 return; 1497 } 1498 } 1499 1484 1500 void Element::invalidateStyle() 1485 1501 { 1486 1502 Node::invalidateStyle(Style::Validity::ElementInvalid); 1503 invalidateSiblingsIfNeeded(*this); 1487 1504 } 1488 1505 … … 1490 1507 { 1491 1508 Node::invalidateStyle(Style::Validity::ElementInvalid, Style::InvalidationMode::RecompositeLayer); 1509 invalidateSiblingsIfNeeded(*this); 1492 1510 } 1493 1511 … … 1495 1513 { 1496 1514 Node::invalidateStyle(Style::Validity::SubtreeInvalid); 1515 invalidateSiblingsIfNeeded(*this); 1497 1516 } 1498 1517 … … 1500 1519 { 1501 1520 Node::invalidateStyle(Style::Validity::SubtreeAndRenderersInvalid); 1521 invalidateSiblingsIfNeeded(*this); 1522 } 1523 1524 void Element::invalidateStyleInternal() 1525 { 1526 Node::invalidateStyle(Style::Validity::ElementInvalid); 1527 } 1528 1529 void Element::invalidateStyleForSubtreeInternal() 1530 { 1531 Node::invalidateStyle(Style::Validity::SubtreeInvalid); 1502 1532 } 1503 1533 -
trunk/Source/WebCore/dom/Element.h
r228446 r228497 546 546 void invalidateStyleAndRenderersForSubtree(); 547 547 548 void invalidateStyleInternal(); 549 void invalidateStyleForSubtreeInternal(); 550 548 551 bool hasDisplayContents() const; 549 552 void storeDisplayContentsStyle(std::unique_ptr<RenderStyle>); -
trunk/Source/WebCore/style/StyleInvalidator.cpp
r227956 r228497 104 104 // FIXME: This could do actual rule matching too. 105 105 if (element.shadowRoot()) 106 element.invalidateStyleForSubtree ();106 element.invalidateStyleForSubtreeInternal(); 107 107 } 108 108 … … 112 112 if (containingShadowRoot && containingShadowRoot->host()) { 113 113 for (auto& possiblySlotted : childrenOfType<Element>(*containingShadowRoot->host())) 114 possiblySlotted.invalidateStyle ();114 possiblySlotted.invalidateStyleInternal(); 115 115 } 116 116 // No need to do this again. … … 125 125 126 126 if (ruleCollector.hasMatchedRules()) 127 element.invalidateStyle ();127 element.invalidateStyleInternal(); 128 128 return CheckDescendants::Yes; 129 129 } … … 194 194 195 195 if (!m_ruleSet.hostPseudoClassRules().isEmpty() && shadowRoot.host()) 196 shadowRoot.host()->invalidateStyle ();196 shadowRoot.host()->invalidateStyleInternal(); 197 197 198 198 for (auto& child : childrenOfType<Element>(shadowRoot)) { -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r226809 r228497 138 138 static void resetStyleForNonRenderedDescendants(Element& current) 139 139 { 140 // FIXME: This is not correct with shadow trees. This should be done with ComposedTreeIterator.141 bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;142 140 for (auto& child : childrenOfType<Element>(current)) { 143 bool affectedByPreviousSibling = child.styleIsAffectedByPreviousSibling() && elementNeedingStyleRecalcAffectsNextSiblingElementStyle; 144 if (child.needsStyleRecalc() || elementNeedingStyleRecalcAffectsNextSiblingElementStyle) 145 elementNeedingStyleRecalcAffectsNextSiblingElementStyle = child.affectsNextSiblingElementStyle(); 146 147 if (child.needsStyleRecalc() || affectedByPreviousSibling) { 141 if (child.needsStyleRecalc()) { 148 142 child.resetComputedStyle(); 149 143 child.resetStyleRelations(); … … 472 466 } 473 467 474 // FIXME: We should deal with this during style invalidation.475 bool affectedByPreviousSibling = element.styleIsAffectedByPreviousSibling() && parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle;476 if (element.needsStyleRecalc() || parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle)477 parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle = element.affectsNextSiblingElementStyle();478 479 468 auto* style = renderOrDisplayContentsStyle(element); 480 469 auto change = NoChange; 481 470 auto descendantsToResolve = DescendantsToResolve::None; 482 471 483 bool shouldResolve = shouldResolveElement(element, parent.descendantsToResolve) || affectedByPreviousSibling;472 bool shouldResolve = shouldResolveElement(element, parent.descendantsToResolve); 484 473 if (shouldResolve) { 485 474 if (!element.hasDisplayContents()) … … 498 487 change = elementUpdates.update.change; 499 488 descendantsToResolve = elementUpdates.descendantsToResolve; 500 501 if (affectedByPreviousSibling)502 descendantsToResolve = DescendantsToResolve::All;503 489 504 490 if (elementUpdates.update.style) -
trunk/Source/WebCore/style/StyleTreeResolver.h
r226809 r228497 80 80 DescendantsToResolve descendantsToResolve { DescendantsToResolve::None }; 81 81 bool didPushScope { false }; 82 bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle { false };83 82 84 83 Parent(Document&);
Note:
See TracChangeset
for help on using the changeset viewer.