Diff
Modified: trunk/LayoutTests/ChangeLog (250860 => 250861)
--- trunk/LayoutTests/ChangeLog 2019-10-08 21:23:14 UTC (rev 250860)
+++ trunk/LayoutTests/ChangeLog 2019-10-08 21:40:25 UTC (rev 250861)
@@ -1,3 +1,13 @@
+2019-10-08 Antti Koivisto <an...@apple.com>
+
+ [CSS Shadow Parts] Fix style invalidation with class selector and ::before and ::after
+ https://bugs.webkit.org/show_bug.cgi?id=202694
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/css/shadow-parts/invalidation-class-before-after-expected.txt: Added.
+ * fast/css/shadow-parts/invalidation-class-before-after.html: Added.
+
2019-10-08 youenn fablet <you...@apple.com>
MediaStreamTrack should be a PlatformMediaSessionClient instead of MediaStream
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-before-after-expected.txt (0 => 250861)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-before-after-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-before-after-expected.txt 2019-10-08 21:40:25 UTC (rev 250861)
@@ -0,0 +1,6 @@
+The following text should be green:
+
+PASS Part in selected host changed color
+PASS Before pseudo element of part in selected host changed color
+PASS After pseudo element of part in selected host changed color
+
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-before-after.html (0 => 250861)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-before-after.html (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-before-after.html 2019-10-08 21:40:25 UTC (rev 250861)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>CSS Shadow Parts - Invalidation of before/after with class selector</title>
+ <link href="" rel="author" title="Apple">
+ <link href="" rel="help">
+ <script src=""
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <style>
+ .enable-self::part(partp) { color: green; }
+ .enable-before::part(partp)::before { color: green; }
+ .enable-after::part(partp)::after { color: green; }
+ </style>
+ <script>installCustomElement("custom-element", "custom-element-template");</script>
+ <template id="custom-element-template">
+ <style>
+ span::before { content: "Before text"; color: red; }
+ span::after { content: "After text"; color: red; }
+ </style>
+ <span id="part" part="partp">Main text</span>
+ </template>
+ The following text should be green:
+ <div><custom-element id="c-e"></custom-element></div>
+ <script>
+ "use strict";
+ test(function() {
+ const part = getElementByShadowIds(document, ["c-e", "part"]);
+ const oldColor = window.getComputedStyle(part).color;
+ document.querySelector("#c-e").classList.add("enable-self");
+ const newColor = window.getComputedStyle(part).color;
+ assert_not_equals(oldColor, newColor);
+ }, "Part in selected host changed color");
+ test(function() {
+ const part = getElementByShadowIds(document, ["c-e", "part"]);
+ const oldColor = window.getComputedStyle(part, "::before").color;
+ document.querySelector("#c-e").classList.add("enable-before");
+ const newColor = window.getComputedStyle(part, "::before").color;
+ assert_not_equals(oldColor, newColor);
+ }, "Before pseudo element of part in selected host changed color");
+ test(function() {
+ const part = getElementByShadowIds(document, ["c-e", "part"]);
+ const oldColor = window.getComputedStyle(part, "::after").color;
+ document.querySelector("#c-e").classList.add("enable-after");
+ const newColor = window.getComputedStyle(part, "::after").color;
+ assert_not_equals(oldColor, newColor);
+ }, "After pseudo element of part in selected host changed color");
+ </script>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (250860 => 250861)
--- trunk/Source/WebCore/ChangeLog 2019-10-08 21:23:14 UTC (rev 250860)
+++ trunk/Source/WebCore/ChangeLog 2019-10-08 21:40:25 UTC (rev 250861)
@@ -1,3 +1,24 @@
+2019-10-08 Antti Koivisto <an...@apple.com>
+
+ [CSS Shadow Parts] Fix style invalidation with class selector and ::before and ::after
+ https://bugs.webkit.org/show_bug.cgi?id=202694
+
+ Reviewed by Ryosuke Niwa.
+
+ Test: fast/css/shadow-parts/invalidation-class-before-after.html
+
+ * style/StyleInvalidator.cpp:
+ (WebCore::Style::Invalidator::invalidateIfNeeded):
+ (WebCore::Style::Invalidator::invalidateStyleWithMatchElement):
+
+ Invalidate in the shadow tree if the computed match element is host.
+
+ (WebCore::Style::Invalidator::invalidateInShadowTreeIfNeeded):
+
+ Factor into a function.
+
+ * style/StyleInvalidator.h:
+
2019-10-08 Adrian Perez de Castro <ape...@igalia.com>
[GTK][WPE] Fix non-unified builds after r250486
Modified: trunk/Source/WebCore/style/StyleInvalidator.cpp (250860 => 250861)
--- trunk/Source/WebCore/style/StyleInvalidator.cpp 2019-10-08 21:23:14 UTC (rev 250860)
+++ trunk/Source/WebCore/style/StyleInvalidator.cpp 2019-10-08 21:40:25 UTC (rev 250861)
@@ -98,16 +98,8 @@
Invalidator::CheckDescendants Invalidator::invalidateIfNeeded(Element& element, const SelectorFilter* filter)
{
- if (m_ruleSet.hasShadowPseudoElementRules()) {
- // FIXME: This could do actual rule matching too.
- if (element.shadowRoot())
- element.invalidateStyleForSubtreeInternal();
- }
+ invalidateInShadowTreeIfNeeded(element);
- // FIXME: More fine-grained invalidation for ::part()
- if (!m_ruleSet.partPseudoElementRules().isEmpty() && element.shadowRoot())
- invalidateShadowParts(*element.shadowRoot());
-
bool shouldCheckForSlots = !m_ruleSet.slottedPseudoElementRules().isEmpty() && !m_didInvalidateHostChildren;
if (shouldCheckForSlots && is<HTMLSlotElement>(element)) {
auto* containingShadowRoot = element.containingShadowRoot();
@@ -259,7 +251,7 @@
break;
}
case MatchElement::Host:
- // FIXME: Handle this here as well.
+ invalidateInShadowTreeIfNeeded(element);
break;
}
}
@@ -283,5 +275,22 @@
}
}
+void Invalidator::invalidateInShadowTreeIfNeeded(Element& element)
+{
+ auto* shadowRoot = element.shadowRoot();
+ if (!shadowRoot)
+ return;
+
+ if (m_ruleSet.hasShadowPseudoElementRules()) {
+ // FIXME: This could do actual rule matching too.
+ element.invalidateStyleForSubtreeInternal();
+ }
+
+ // FIXME: More fine-grained invalidation for ::part()
+ if (!m_ruleSet.partPseudoElementRules().isEmpty())
+ invalidateShadowParts(*shadowRoot);
}
+
+
}
+}
Modified: trunk/Source/WebCore/style/StyleInvalidator.h (250860 => 250861)
--- trunk/Source/WebCore/style/StyleInvalidator.h 2019-10-08 21:23:14 UTC (rev 250860)
+++ trunk/Source/WebCore/style/StyleInvalidator.h 2019-10-08 21:40:25 UTC (rev 250861)
@@ -58,6 +58,7 @@
CheckDescendants invalidateIfNeeded(Element&, const SelectorFilter*);
void invalidateStyleForTree(Element&, SelectorFilter*);
void invalidateStyleForDescendants(Element&, SelectorFilter*);
+ void invalidateInShadowTreeIfNeeded(Element&);
std::unique_ptr<RuleSet> m_ownedRuleSet;
const RuleSet& m_ruleSet;