Diff
Modified: trunk/LayoutTests/ChangeLog (250820 => 250821)
--- trunk/LayoutTests/ChangeLog 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/LayoutTests/ChangeLog 2019-10-08 12:22:21 UTC (rev 250821)
@@ -1,5 +1,23 @@
2019-10-08 Antti Koivisto <[email protected]>
+ [CSS Shadow Parts] Implement style invalidation
+ https://bugs.webkit.org/show_bug.cgi?id=202632
+
+ Reviewed by Ryosuke Niwa.
+
+ Add some tests to verify class mutations and combinators with ::part and exportpart.
+
+ * fast/css/shadow-parts/invalidation-class-descendant-combinator-expected.txt: Added.
+ * fast/css/shadow-parts/invalidation-class-descendant-combinator-export-expected.txt: Added.
+ * fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html: Added.
+ * fast/css/shadow-parts/invalidation-class-descendant-combinator.html: Added.
+ * fast/css/shadow-parts/invalidation-class-sibling-combinator-expected.txt: Added.
+ * fast/css/shadow-parts/invalidation-class-sibling-combinator-export-expected.txt: Added.
+ * fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html: Added.
+ * fast/css/shadow-parts/invalidation-class-sibling-combinator.html: Added.
+
+2019-10-08 Antti Koivisto <[email protected]>
+
[CSS Shadow Parts] Internal shadow pseudo elements should work with ::part
https://bugs.webkit.org/show_bug.cgi?id=202620
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-expected.txt (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-expected.txt 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,4 @@
+The following text should be green:
+
+PASS Part in selected host changed color
+
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-export-expected.txt (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-export-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-export-expected.txt 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,4 @@
+The following text should be green:
+
+PASS Part in selected host changed color
+
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>CSS Shadow Parts - Invalidation with with class in descendant combinator and part forward</title>
+ <link href="" rel="author" title="Apple">
+ <link href="" rel="help">
+ <script src=""
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <style>.ancestor #c-e-outer::part(part-forwarded) { color: green; }</style>
+ <script>installCustomElement("custom-element-inner", "custom-element-inner-template");</script>
+ <template id="custom-element-inner-template">
+ <style>span { color: red; }</style>
+ <span id="part" part="partp">This text</span>
+ </template>
+ <script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
+ <template id="custom-element-outer-template"><custom-element-inner id="c-e-inner" exportparts="partp: part-forwarded"></custom-element-inner></template>
+ The following text should be green:
+ <div id="target">
+ <div><custom-element-outer id="c-e-outer"></custom-element-outer></div>
+ </div>
+ <script>
+ "use strict";
+ test(function() {
+ const part = getElementByShadowIds(document, ["c-e-outer", "c-e-inner", "part"]);
+ const before = window.getComputedStyle(part).color;
+ document.querySelector("#target").classList.add("ancestor");
+ const after = window.getComputedStyle(part).color;
+ assert_not_equals(before, after);
+ }, "Part in selected host changed color");
+ </script>
+ </body>
+</html>
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator.html (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator.html (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-descendant-combinator.html 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>CSS Shadow Parts - Invalidation with class in descendant combinator</title>
+ <link href="" rel="author" title="Apple">
+ <link href="" rel="help">
+ <script src=""
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <style>.ancestor #c-e::part(partp) { color: green; }</style>
+ <script>installCustomElement("custom-element", "custom-element-template");</script>
+ <template id="custom-element-template">
+ <style>span { color: red; }</style>
+ <span id="part" part="partp">This text</span>
+ </template>
+ The following text should be green:
+ <div id="target">
+ <div><custom-element id="c-e"></custom-element></div>
+ </div>
+ <script>
+ "use strict";
+ test(function() {
+ const part = getElementByShadowIds(document, ["c-e", "part"]);
+ const before = window.getComputedStyle(part).color;
+ document.querySelector("#target").classList.add("ancestor");
+ const after = window.getComputedStyle(part).color;
+ assert_not_equals(before, after);
+ }, "Part in selected host changed color");
+ </script>
+ </body>
+</html>
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-expected.txt (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-expected.txt 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,4 @@
+The following text should be green:
+
+PASS Part in selected host changed color
+
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-export-expected.txt (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-export-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-export-expected.txt 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,4 @@
+The following text should be green:
+
+PASS Part in selected host changed color
+
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>CSS Shadow Parts - Invalidation with with class in descendant combinator and part forward</title>
+ <link href="" rel="author" title="Apple">
+ <link href="" rel="help">
+ <script src=""
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <style>.sibling ~ #c-e-outer::part(part-forwarded) { color: green; }</style>
+ <script>installCustomElement("custom-element-inner", "custom-element-inner-template");</script>
+ <template id="custom-element-inner-template">
+ <style>span { color: red; }</style>
+ <span id="part" part="partp">This text</span>
+ </template>
+ <script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
+ <template id="custom-element-outer-template"><custom-element-inner id="c-e-inner" exportparts="partp: part-forwarded"></custom-element-inner></template>
+ The following text should be green:
+ <div>
+ <div id="target"></div>
+ <div></div>
+ <custom-element-outer id="c-e-outer"></custom-element-outer>
+ </div>
+ <script>
+ "use strict";
+ test(function() {
+ const part = getElementByShadowIds(document, ["c-e-outer", "c-e-inner", "part"]);
+ const before = window.getComputedStyle(part).color;
+ document.querySelector("#target").classList.add("sibling");
+ const after = window.getComputedStyle(part).color;
+ assert_not_equals(before, after);
+ }, "Part in selected host changed color");
+ </script>
+ </body>
+</html>
Added: trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator.html (0 => 250821)
--- trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator.html (rev 0)
+++ trunk/LayoutTests/fast/css/shadow-parts/invalidation-class-sibling-combinator.html 2019-10-08 12:22:21 UTC (rev 250821)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>CSS Shadow Parts - Invalidation with class in descendant combinator</title>
+ <link href="" rel="author" title="Apple">
+ <link href="" rel="help">
+ <script src=""
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <style>.sibling ~ #c-e::part(partp) { color: green; }</style>
+ <script>installCustomElement("custom-element", "custom-element-template");</script>
+ <template id="custom-element-template">
+ <style>span { color: red; }</style>
+ <span id="part" part="partp">This text</span>
+ </template>
+ The following text should be green:
+ <div>
+ <div id="target"></div>
+ <div></div>
+ <custom-element id="c-e"></custom-element>
+ </div>
+ <script>
+ "use strict";
+ test(function() {
+ const part = getElementByShadowIds(document, ["c-e", "part"]);
+ const before = window.getComputedStyle(part).color;
+ document.querySelector("#target").classList.add("sibling");
+ const after = window.getComputedStyle(part).color;
+ assert_not_equals(before, after);
+ }, "Part in selected host changed color");
+ </script>
+ </body>
+</html>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (250820 => 250821)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2019-10-08 12:22:21 UTC (rev 250821)
@@ -1,3 +1,14 @@
+2019-10-08 Antti Koivisto <[email protected]>
+
+ [CSS Shadow Parts] Implement style invalidation
+ https://bugs.webkit.org/show_bug.cgi?id=202632
+
+ Reviewed by Ryosuke Niwa.
+
+ * web-platform-tests/css/css-shadow-parts/invalidation-change-exportparts-forward-expected.txt:
+ * web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-expected.txt:
+ * web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-forward-expected.txt:
+
2019-10-07 Rob Buis <[email protected]>
Change Response's statusText's default
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-exportparts-forward-expected.txt (250820 => 250821)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-exportparts-forward-expected.txt 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-exportparts-forward-expected.txt 2019-10-08 12:22:21 UTC (rev 250821)
@@ -1,4 +1,4 @@
The following text should be green:
-FAIL Part in selected host changed color assert_not_equals: got disallowed value "rgb(255, 0, 0)"
+PASS Part in selected host changed color
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-expected.txt (250820 => 250821)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-expected.txt 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-expected.txt 2019-10-08 12:22:21 UTC (rev 250821)
@@ -1,4 +1,4 @@
The following text should be green:
-FAIL Part in selected host changed color assert_not_equals: got disallowed value "rgb(255, 0, 0)"
+PASS Part in selected host changed color
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-forward-expected.txt (250820 => 250821)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-forward-expected.txt 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-forward-expected.txt 2019-10-08 12:22:21 UTC (rev 250821)
@@ -1,4 +1,4 @@
The following text should be green:
-FAIL Part in selected host changed color assert_not_equals: got disallowed value "rgb(255, 0, 0)"
+PASS Part in selected host changed color
Modified: trunk/Source/WebCore/ChangeLog (250820 => 250821)
--- trunk/Source/WebCore/ChangeLog 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/Source/WebCore/ChangeLog 2019-10-08 12:22:21 UTC (rev 250821)
@@ -1,3 +1,43 @@
+2019-10-08 Antti Koivisto <[email protected]>
+
+ [CSS Shadow Parts] Implement style invalidation
+ https://bugs.webkit.org/show_bug.cgi?id=202632
+
+ Reviewed by Ryosuke Niwa.
+
+ Tests: fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html
+ fast/css/shadow-parts/invalidation-class-descendant-combinator.html
+ fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html
+ fast/css/shadow-parts/invalidation-class-sibling-combinator.html
+
+ * css/RuleFeature.cpp:
+ (WebCore::isSiblingOrSubject):
+
+ Don't treat crossing to host as moving to ancestor when computing elements impacted by a selector.
+ StyleInvalidator expects these relations to be about the host element, shadow tree invalidation in handled separately.
+
+ * dom/Element.cpp:
+ (WebCore::Element::attributeChanged):
+
+ Invalidate parts in shadow tree on 'exportparts' attribute mutation.
+
+ (WebCore::Element::partAttributeChanged):
+
+ Invalidate element on 'part' attribute mutation.
+
+ * style/StyleInvalidator.cpp:
+ (WebCore::Style::Invalidator::Invalidator):
+ (WebCore::Style::Invalidator::invalidateIfNeeded):
+
+ Invalidate parts in shadow tree during class and attribute mutation invalidation.
+
+ (WebCore::Style::Invalidator::invalidateShadowParts):
+ * style/StyleInvalidator.h:
+ (WebCore::Style::Invalidator::dirtiesAllStyle const):
+ (WebCore::Style::Invalidator::hasShadowPseudoElementRulesInAuthorSheet const): Deleted.
+
+ Remove an unncessary bool.
+
2019-10-08 Carlos Garcia Campos <[email protected]>
Unreviewed. Remove unused WebKitSoupRequestGeneric after r250597
Modified: trunk/Source/WebCore/css/RuleFeature.cpp (250820 => 250821)
--- trunk/Source/WebCore/css/RuleFeature.cpp 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/Source/WebCore/css/RuleFeature.cpp 2019-10-08 12:22:21 UTC (rev 250821)
@@ -42,12 +42,12 @@
case MatchElement::IndirectSibling:
case MatchElement::DirectSibling:
case MatchElement::AnySibling:
+ case MatchElement::Host:
return true;
case MatchElement::Parent:
case MatchElement::Ancestor:
case MatchElement::ParentSibling:
case MatchElement::AncestorSibling:
- case MatchElement::Host:
return false;
}
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/dom/Element.cpp (250820 => 250821)
--- trunk/Source/WebCore/dom/Element.cpp 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/Source/WebCore/dom/Element.cpp 2019-10-08 12:22:21 UTC (rev 250821)
@@ -103,6 +103,7 @@
#include "Settings.h"
#include "SimulatedClick.h"
#include "SlotAssignment.h"
+#include "StyleInvalidator.h"
#include "StyleProperties.h"
#include "StyleResolver.h"
#include "StyleScope.h"
@@ -1750,8 +1751,10 @@
} else if (name == HTMLNames::partAttr)
partAttributeChanged(newValue);
else if (name == HTMLNames::exportpartsAttr) {
- if (auto* shadowRoot = this->shadowRoot())
+ if (auto* shadowRoot = this->shadowRoot()) {
shadowRoot->invalidatePartMappings();
+ Style::Invalidator::invalidateShadowParts(*shadowRoot);
+ }
}
}
@@ -1835,6 +1838,9 @@
if (auto* partList = elementRareData()->partList())
partList->associatedAttributeValueChanged(newValue);
}
+
+ if (needsStyleInvalidation() && isInShadowTree())
+ invalidateStyleInternal();
}
URL Element::absoluteLinkURL() const
Modified: trunk/Source/WebCore/style/StyleInvalidator.cpp (250820 => 250821)
--- trunk/Source/WebCore/style/StyleInvalidator.cpp 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/Source/WebCore/style/StyleInvalidator.cpp 2019-10-08 12:22:21 UTC (rev 250821)
@@ -31,6 +31,7 @@
#include "ElementIterator.h"
#include "ElementRuleCollector.h"
#include "HTMLSlotElement.h"
+#include "RuntimeEnabledFeatures.h"
#include "SelectorFilter.h"
#include "ShadowRoot.h"
#include "StyleRuleImport.h"
@@ -88,24 +89,25 @@
m_ownedRuleSet->disableAutoShrinkToFit();
for (auto& sheet : sheets)
m_ownedRuleSet->addRulesFromSheet(*sheet, mediaQueryEvaluator);
-
- m_hasShadowPseudoElementRulesInAuthorSheet = m_ruleSet.hasShadowPseudoElementRules();
}
Invalidator::Invalidator(const RuleSet& ruleSet)
: m_ruleSet(ruleSet)
- , m_hasShadowPseudoElementRulesInAuthorSheet(ruleSet.hasShadowPseudoElementRules())
{
}
Invalidator::CheckDescendants Invalidator::invalidateIfNeeded(Element& element, const SelectorFilter* filter)
{
- if (m_hasShadowPseudoElementRulesInAuthorSheet) {
+ if (m_ruleSet.hasShadowPseudoElementRules()) {
// FIXME: This could do actual rule matching too.
if (element.shadowRoot())
element.invalidateStyleForSubtreeInternal();
}
+ // 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();
@@ -262,5 +264,24 @@
}
}
+void Invalidator::invalidateShadowParts(ShadowRoot& shadowRoot)
+{
+ if (!RuntimeEnabledFeatures::sharedFeatures().cssShadowPartsEnabled())
+ return;
+
+ if (shadowRoot.mode() == ShadowRootMode::UserAgent)
+ return;
+
+ for (auto& descendant : descendantsOfType<Element>(shadowRoot)) {
+ // FIXME: We could only invalidate part names that actually show up in rules.
+ if (!descendant.partNames().isEmpty())
+ descendant.invalidateStyleInternal();
+
+ auto* nestedShadowRoot = descendant.shadowRoot();
+ if (nestedShadowRoot && !nestedShadowRoot->partMappings().isEmpty())
+ invalidateShadowParts(*nestedShadowRoot);
+ }
}
+
}
+}
Modified: trunk/Source/WebCore/style/StyleInvalidator.h (250820 => 250821)
--- trunk/Source/WebCore/style/StyleInvalidator.h 2019-10-08 10:03:38 UTC (rev 250820)
+++ trunk/Source/WebCore/style/StyleInvalidator.h 2019-10-08 12:22:21 UTC (rev 250821)
@@ -46,12 +46,13 @@
Invalidator(const RuleSet&);
bool dirtiesAllStyle() const { return m_dirtiesAllStyle; }
- bool hasShadowPseudoElementRulesInAuthorSheet() const { return m_hasShadowPseudoElementRulesInAuthorSheet; }
void invalidateStyle(Document&);
void invalidateStyle(ShadowRoot&);
void invalidateStyle(Element&);
void invalidateStyleWithMatchElement(Element&, MatchElement);
+ static void invalidateShadowParts(ShadowRoot&);
+
private:
enum class CheckDescendants { Yes, No };
CheckDescendants invalidateIfNeeded(Element&, const SelectorFilter*);
@@ -61,7 +62,6 @@
std::unique_ptr<RuleSet> m_ownedRuleSet;
const RuleSet& m_ruleSet;
bool m_dirtiesAllStyle { false };
- bool m_hasShadowPseudoElementRulesInAuthorSheet { false };
bool m_didInvalidateHostChildren { false };
};