Diff
Modified: trunk/LayoutTests/ChangeLog (228496 => 228497)
--- trunk/LayoutTests/ChangeLog 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/LayoutTests/ChangeLog 2018-02-15 01:27:52 UTC (rev 228497)
@@ -1,3 +1,19 @@
+2018-02-14 Antti Koivisto <[email protected]>
+
+ Do sibling invalidation on mutation
+ https://bugs.webkit.org/show_bug.cgi?id=182809
+
+ Reviewed by Zalan Bujtas.
+
+ Sibling invalidation now happens on mutation. Update the tests.
+
+ * fast/css/indirect-adjacent-style-invalidation-1-expected.txt:
+ * fast/css/indirect-adjacent-style-invalidation-1.html:
+ * fast/css/indirect-adjacent-style-invalidation-2-expected.txt:
+ * fast/css/indirect-adjacent-style-invalidation-2.html:
+ * fast/css/indirect-adjacent-style-invalidation-3-expected.txt:
+ * fast/css/indirect-adjacent-style-invalidation-3.html:
+
2018-02-14 Daniel Bates <[email protected]>
Disallow cross-origin subresources from asking for credentials
Modified: trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1-expected.txt (228496 => 228497)
--- trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1-expected.txt 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1-expected.txt 2018-02-15 01:27:52 UTC (rev 228497)
@@ -11,8 +11,8 @@
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)"
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is false
@@ -21,8 +21,8 @@
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is false
Modified: trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1.html (228496 => 228497)
--- trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1.html 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-1.html 2018-02-15 01:27:52 UTC (rev 228497)
@@ -49,8 +49,8 @@
var testFunction = expected ? shouldBeTrue : shouldBeFalse;
testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[0])");
testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[1])");
- shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");
- shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");
+ testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");
+ testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");
}
function setId(name) {
Modified: trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2-expected.txt (228496 => 228497)
--- trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2-expected.txt 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2-expected.txt 2018-02-15 01:27:52 UTC (rev 228497)
@@ -11,8 +11,8 @@
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)"
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is false
@@ -21,8 +21,8 @@
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is false
Modified: trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2.html (228496 => 228497)
--- trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2.html 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-2.html 2018-02-15 01:27:52 UTC (rev 228497)
@@ -49,8 +49,8 @@
var testFunction = expected ? shouldBeTrue : shouldBeFalse;
testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[0])");
testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[1])");
- shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");
- shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");
+ testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");
+ testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");
}
function setId(name) {
Modified: trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3-expected.txt (228496 => 228497)
--- trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3-expected.txt 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3-expected.txt 2018-02-15 01:27:52 UTC (rev 228497)
@@ -11,8 +11,8 @@
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)"
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is false
@@ -21,8 +21,8 @@
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is true
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[1]) is true
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is false
-PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll("target")[1]) is true
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)"
PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(".activator")[0]) is false
Modified: trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3.html (228496 => 228497)
--- trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3.html 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/LayoutTests/fast/css/indirect-adjacent-style-invalidation-3.html 2018-02-15 01:27:52 UTC (rev 228497)
@@ -49,8 +49,8 @@
var testFunction = expected ? shouldBeTrue : shouldBeFalse;
testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[0])");
testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\".activator\")[1])");
- shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");
- shouldBeFalse("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");
+ testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[0])");
+ testFunction("window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\"target\")[1])");
}
function setId(name) {
Modified: trunk/Source/WebCore/ChangeLog (228496 => 228497)
--- trunk/Source/WebCore/ChangeLog 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/Source/WebCore/ChangeLog 2018-02-15 01:27:52 UTC (rev 228497)
@@ -1,3 +1,48 @@
+2018-02-14 Antti Koivisto <[email protected]>
+
+ Do sibling invalidation on mutation
+ https://bugs.webkit.org/show_bug.cgi?id=182809
+
+ Reviewed by Zalan Bujtas.
+
+ We used to invalidate siblings for sibling combinators and nth-pseudo classes during style resolution tree walk.
+ This would consider any element with invalid style a reason to invalidate siblings too. However we now do
+ accurate invalidation on class and attribute changes and this approach ends up invalidating too much.
+
+ This patch sibling style invalidation to mutation time and removes invalidation code from style resolution tree walk.
+
+ * dom/Element.cpp:
+ (WebCore::invalidateSiblingsIfNeeded):
+
+ Helper to invalidate siblings.
+
+ (WebCore::Element::invalidateStyle):
+ (WebCore::Element::invalidateStyleAndLayerComposition):
+ (WebCore::Element::invalidateStyleForSubtree):
+ (WebCore::Element::invalidateStyleAndRenderersForSubtree):
+
+ Invalidate siblings if needed based on affectsNextSibling/affectedByPreviousSibling bits.
+
+ (WebCore::Element::invalidateStyleInternal):
+ (WebCore::Element::invalidateStyleForSubtreeInternal):
+
+ Add "internal" versions that don't invalidate siblings. These are used by StyleInvalidator for accurate invalidation.
+
+ * dom/Element.h:
+ * style/StyleInvalidator.cpp:
+ (WebCore::Style::Invalidator::invalidateIfNeeded):
+ (WebCore::Style::Invalidator::invalidateStyle):
+
+ Use internal invalidation functions.
+
+ * style/StyleTreeResolver.cpp:
+ (WebCore::Style::resetStyleForNonRenderedDescendants):
+ (WebCore::Style::TreeResolver::resolveComposedTree):
+
+ Remove sibling invalidation.
+
+ * style/StyleTreeResolver.h:
+
2018-02-14 John Wilander <[email protected]>
Resource Load Statistics: Make sure WebResourceLoadStatisticsStore::mergeWithDataFromDecoder() can ingest older plist versions and not reset the database
Modified: trunk/Source/WebCore/dom/Element.cpp (228496 => 228497)
--- trunk/Source/WebCore/dom/Element.cpp 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/Source/WebCore/dom/Element.cpp 2018-02-15 01:27:52 UTC (rev 228497)
@@ -1481,26 +1481,56 @@
return styleResolver().styleForElement(*this, parentStyle);
}
+static void invalidateSiblingsIfNeeded(Element& element)
+{
+ if (!element.affectsNextSiblingElementStyle())
+ return;
+ auto* parent = element.parentElement();
+ if (parent && parent->styleValidity() >= Style::Validity::SubtreeInvalid)
+ return;
+
+ for (auto* sibling = element.nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) {
+ if (sibling->styleIsAffectedByPreviousSibling())
+ sibling->invalidateStyleForSubtreeInternal();
+ if (!sibling->affectsNextSiblingElementStyle())
+ return;
+ }
+}
+
void Element::invalidateStyle()
{
Node::invalidateStyle(Style::Validity::ElementInvalid);
+ invalidateSiblingsIfNeeded(*this);
}
void Element::invalidateStyleAndLayerComposition()
{
Node::invalidateStyle(Style::Validity::ElementInvalid, Style::InvalidationMode::RecompositeLayer);
+ invalidateSiblingsIfNeeded(*this);
}
void Element::invalidateStyleForSubtree()
{
Node::invalidateStyle(Style::Validity::SubtreeInvalid);
+ invalidateSiblingsIfNeeded(*this);
}
void Element::invalidateStyleAndRenderersForSubtree()
{
Node::invalidateStyle(Style::Validity::SubtreeAndRenderersInvalid);
+ invalidateSiblingsIfNeeded(*this);
}
+void Element::invalidateStyleInternal()
+{
+ Node::invalidateStyle(Style::Validity::ElementInvalid);
+}
+
+void Element::invalidateStyleForSubtreeInternal()
+{
+ Node::invalidateStyle(Style::Validity::SubtreeInvalid);
+}
+
bool Element::hasDisplayContents() const
{
if (!hasRareData())
Modified: trunk/Source/WebCore/dom/Element.h (228496 => 228497)
--- trunk/Source/WebCore/dom/Element.h 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/Source/WebCore/dom/Element.h 2018-02-15 01:27:52 UTC (rev 228497)
@@ -545,6 +545,9 @@
// Elements newly added to the tree are also in this state.
void invalidateStyleAndRenderersForSubtree();
+ void invalidateStyleInternal();
+ void invalidateStyleForSubtreeInternal();
+
bool hasDisplayContents() const;
void storeDisplayContentsStyle(std::unique_ptr<RenderStyle>);
Modified: trunk/Source/WebCore/style/StyleInvalidator.cpp (228496 => 228497)
--- trunk/Source/WebCore/style/StyleInvalidator.cpp 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/Source/WebCore/style/StyleInvalidator.cpp 2018-02-15 01:27:52 UTC (rev 228497)
@@ -103,7 +103,7 @@
if (m_hasShadowPseudoElementRulesInAuthorSheet) {
// FIXME: This could do actual rule matching too.
if (element.shadowRoot())
- element.invalidateStyleForSubtree();
+ element.invalidateStyleForSubtreeInternal();
}
bool shouldCheckForSlots = !m_ruleSet.slottedPseudoElementRules().isEmpty() && !m_didInvalidateHostChildren;
@@ -111,7 +111,7 @@
auto* containingShadowRoot = element.containingShadowRoot();
if (containingShadowRoot && containingShadowRoot->host()) {
for (auto& possiblySlotted : childrenOfType<Element>(*containingShadowRoot->host()))
- possiblySlotted.invalidateStyle();
+ possiblySlotted.invalidateStyleInternal();
}
// No need to do this again.
m_didInvalidateHostChildren = true;
@@ -124,7 +124,7 @@
ruleCollector.matchAuthorRules(false);
if (ruleCollector.hasMatchedRules())
- element.invalidateStyle();
+ element.invalidateStyleInternal();
return CheckDescendants::Yes;
}
case Style::Validity::ElementInvalid:
@@ -193,7 +193,7 @@
ASSERT(!m_dirtiesAllStyle);
if (!m_ruleSet.hostPseudoClassRules().isEmpty() && shadowRoot.host())
- shadowRoot.host()->invalidateStyle();
+ shadowRoot.host()->invalidateStyleInternal();
for (auto& child : childrenOfType<Element>(shadowRoot)) {
SelectorFilter filter;
Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (228496 => 228497)
--- trunk/Source/WebCore/style/StyleTreeResolver.cpp 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp 2018-02-15 01:27:52 UTC (rev 228497)
@@ -137,14 +137,8 @@
static void resetStyleForNonRenderedDescendants(Element& current)
{
- // FIXME: This is not correct with shadow trees. This should be done with ComposedTreeIterator.
- bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
for (auto& child : childrenOfType<Element>(current)) {
- bool affectedByPreviousSibling = child.styleIsAffectedByPreviousSibling() && elementNeedingStyleRecalcAffectsNextSiblingElementStyle;
- if (child.needsStyleRecalc() || elementNeedingStyleRecalcAffectsNextSiblingElementStyle)
- elementNeedingStyleRecalcAffectsNextSiblingElementStyle = child.affectsNextSiblingElementStyle();
-
- if (child.needsStyleRecalc() || affectedByPreviousSibling) {
+ if (child.needsStyleRecalc()) {
child.resetComputedStyle();
child.resetStyleRelations();
child.setHasValidStyle();
@@ -471,16 +465,11 @@
continue;
}
- // FIXME: We should deal with this during style invalidation.
- bool affectedByPreviousSibling = element.styleIsAffectedByPreviousSibling() && parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle;
- if (element.needsStyleRecalc() || parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle)
- parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle = element.affectsNextSiblingElementStyle();
-
auto* style = renderOrDisplayContentsStyle(element);
auto change = NoChange;
auto descendantsToResolve = DescendantsToResolve::None;
- bool shouldResolve = shouldResolveElement(element, parent.descendantsToResolve) || affectedByPreviousSibling;
+ bool shouldResolve = shouldResolveElement(element, parent.descendantsToResolve);
if (shouldResolve) {
if (!element.hasDisplayContents())
element.resetComputedStyle();
@@ -498,9 +487,6 @@
change = elementUpdates.update.change;
descendantsToResolve = elementUpdates.descendantsToResolve;
- if (affectedByPreviousSibling)
- descendantsToResolve = DescendantsToResolve::All;
-
if (elementUpdates.update.style)
m_update->addElement(element, parent.element, WTFMove(elementUpdates));
Modified: trunk/Source/WebCore/style/StyleTreeResolver.h (228496 => 228497)
--- trunk/Source/WebCore/style/StyleTreeResolver.h 2018-02-15 01:02:41 UTC (rev 228496)
+++ trunk/Source/WebCore/style/StyleTreeResolver.h 2018-02-15 01:27:52 UTC (rev 228497)
@@ -79,7 +79,6 @@
Change change { NoChange };
DescendantsToResolve descendantsToResolve { DescendantsToResolve::None };
bool didPushScope { false };
- bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle { false };
Parent(Document&);
Parent(Element&, const RenderStyle&, Change, DescendantsToResolve);