Title: [208390] trunk
- Revision
- 208390
- Author
- [email protected]
- Date
- 2016-11-04 11:32:45 -0700 (Fri, 04 Nov 2016)
Log Message
slotted() pseudo does not work with ID selector
https://bugs.webkit.org/show_bug.cgi?id=160538
<rdar://problem/28534529>
Reviewed by Andreas Kling.
Source/WebCore:
When we saw an id selector while addin rules we immediately threw it into the m_idRules
optimization bucket and bailed out. However selectors containing ::slotted must always end
up in m_slottedPseudoElementRules list no matter what else is there.
Fix by treating id like other selectors and only choosing the bucket after analysing all
the selector components.
Test: fast/shadow-dom/css-scoping-slot-with-id.html
* css/RuleSet.cpp:
(WebCore::RuleSet::addRule): Also made this use switch instead of a series of ifs.
LayoutTests:
* fast/shadow-dom/css-scoping-slot-with-id-expected.html: Added.
* fast/shadow-dom/css-scoping-slot-with-id.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (208389 => 208390)
--- trunk/LayoutTests/ChangeLog 2016-11-04 18:10:24 UTC (rev 208389)
+++ trunk/LayoutTests/ChangeLog 2016-11-04 18:32:45 UTC (rev 208390)
@@ -1,3 +1,14 @@
+2016-11-04 Antti Koivisto <[email protected]>
+
+ slotted() pseudo does not work with ID selector
+ https://bugs.webkit.org/show_bug.cgi?id=160538
+ <rdar://problem/28534529>
+
+ Reviewed by Andreas Kling.
+
+ * fast/shadow-dom/css-scoping-slot-with-id-expected.html: Added.
+ * fast/shadow-dom/css-scoping-slot-with-id.html: Added.
+
2016-11-04 Brady Eidson <[email protected]>
IndexedDB 2.0: Use IDB-specific exceptions in places where the generic exceptions are currently used.
Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-with-id-expected.html (0 => 208390)
--- trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-with-id-expected.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-with-id-expected.html 2016-11-04 18:32:45 UTC (rev 208390)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <p>Test passes if you see a single 100px by 100px green box below.</p>
+ <div style="width: 100px; height: 100px; background: green;"></div>
+ </body>
+</html>
Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-with-id.html (0 => 208390)
--- trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-with-id.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-with-id.html 2016-11-04 18:32:45 UTC (rev 208390)
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+my-host {
+ display: block;
+ width: 100px;
+ height: 25px;
+ background: red;
+}
+</style>
+</head>
+<body>
+<p>Test passes if you see a single 100px by 100px green box below.</p>
+<my-host id="t1"><div id="host-child">text</div></my-host>
+<my-host id="t2"><div>text</div></my-host>
+<my-host id="t3"><div>text</div></my-host>
+<my-host id="t4"><div>text</div></my-host>
+
+<script>
+var host = document.querySelector('#t1');
+host.attachShadow({ mode: 'open' }).innerHTML = `
+ <style>
+ #myslot::slotted(#host-child) {
+ background-color: green; width: 100%; height: 100%;
+ }
+ </style>
+ <slot id="myslot" style="color:green"></slot>
+`;
+
+var host = document.querySelector('#t2');
+host.attachShadow({ mode: 'open' }).innerHTML = `
+ <style>
+ .myclass#myslot[style]::slotted(*) {
+ background-color: green; width: 100%; height: 100%;
+ }
+ #myslot::slotted(#not-my-host-child) {
+ background-color: red; width: 100%; height: 100%;
+ }
+ #notmyslot::slotted(*) {
+ background-color: red; width: 100%; height: 100%;
+ }
+ </style>
+ <slot class="myclass" id="myslot" style="color:green"></slot>
+`;
+
+var host = document.querySelector('#t3');
+host.attachShadow({ mode: 'open' }).innerHTML = `
+ <style>
+ ::slotted(*)#myslot {
+ background-color: green; width: 100%; height: 100%;
+ }
+ </style>
+ <slot id="myslot" style="color:green"></slot>
+`;
+
+var host = document.querySelector('#t4');
+var shadow = host.attachShadow({ mode: 'open' });
+shadow.innerHTML = `
+ <style>
+ #myslot::slotted(*) {
+ background-color: green; width: 100%; height: 100%;
+ }
+ </style>
+ <slot id="notmyslot" style="color:green"></slot>
+`;
+var slot = shadow.querySelector("#notmyslot");
+slot.offsetWidth;
+slot.setAttribute("id", "myslot");
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (208389 => 208390)
--- trunk/Source/WebCore/ChangeLog 2016-11-04 18:10:24 UTC (rev 208389)
+++ trunk/Source/WebCore/ChangeLog 2016-11-04 18:32:45 UTC (rev 208390)
@@ -1,3 +1,23 @@
+2016-11-04 Antti Koivisto <[email protected]>
+
+ slotted() pseudo does not work with ID selector
+ https://bugs.webkit.org/show_bug.cgi?id=160538
+ <rdar://problem/28534529>
+
+ Reviewed by Andreas Kling.
+
+ When we saw an id selector while addin rules we immediately threw it into the m_idRules
+ optimization bucket and bailed out. However selectors containing ::slotted must always end
+ up in m_slottedPseudoElementRules list no matter what else is there.
+
+ Fix by treating id like other selectors and only choosing the bucket after analysing all
+ the selector components.
+
+ Test: fast/shadow-dom/css-scoping-slot-with-id.html
+
+ * css/RuleSet.cpp:
+ (WebCore::RuleSet::addRule): Also made this use switch instead of a series of ifs.
+
2016-11-04 Brady Eidson <[email protected]>
IndexedDB 2.0: Handle IDBObjectStore rename behavior properly when version change transaction aborts.
Modified: trunk/Source/WebCore/css/RuleSet.cpp (208389 => 208390)
--- trunk/Source/WebCore/css/RuleSet.cpp 2016-11-04 18:10:24 UTC (rev 208389)
+++ trunk/Source/WebCore/css/RuleSet.cpp 2016-11-04 18:32:45 UTC (rev 208390)
@@ -200,33 +200,22 @@
m_features.collectFeatures(ruleData);
unsigned classBucketSize = 0;
+ const CSSSelector* idSelector = nullptr;
const CSSSelector* tagSelector = nullptr;
const CSSSelector* classSelector = nullptr;
const CSSSelector* linkSelector = nullptr;
const CSSSelector* focusSelector = nullptr;
+ const CSSSelector* customPseudoElementSelector = nullptr;
+ const CSSSelector* slottedPseudoElementSelector = nullptr;
+ const CSSSelector* cuePseudoElementSelector = nullptr;
const CSSSelector* selector = ruleData.selector();
do {
- if (selector->match() == CSSSelector::Id) {
- addToRuleSet(selector->value().impl(), m_idRules, ruleData);
- return;
- }
-
-#if ENABLE(VIDEO_TRACK)
- if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementCue) {
- m_cuePseudoRules.append(ruleData);
- return;
- }
-#endif
-
- if (selector->isCustomPseudoElement()) {
- // FIXME: Custom pseudo elements are handled by the shadow tree's selector filter. It doesn't know about the main DOM.
- ruleData.disableSelectorFiltering();
- addToRuleSet(selector->value().impl(), m_shadowPseudoElementRules, ruleData);
- return;
- }
-
- if (selector->match() == CSSSelector::Class) {
- AtomicStringImpl* className = selector->value().impl();
+ switch (selector->match()) {
+ case CSSSelector::Id:
+ idSelector = selector;
+ break;
+ case CSSSelector::Class: {
+ auto* className = selector->value().impl();
if (!classSelector) {
classSelector = selector;
classBucketSize = rulesCountForName(m_classRules, className);
@@ -237,12 +226,32 @@
classBucketSize = newClassBucketSize;
}
}
+ break;
}
-
- if (selector->match() == CSSSelector::Tag && selector->tagQName().localName() != starAtom)
- tagSelector = selector;
-
- if (SelectorChecker::isCommonPseudoClassSelector(selector)) {
+ case CSSSelector::Tag:
+ if (selector->tagQName().localName() != starAtom)
+ tagSelector = selector;
+ break;
+ case CSSSelector::PseudoElement:
+ switch (selector->pseudoElementType()) {
+ case CSSSelector::PseudoElementUserAgentCustom:
+ case CSSSelector::PseudoElementWebKitCustom:
+ case CSSSelector::PseudoElementWebKitCustomLegacyPrefixed:
+ customPseudoElementSelector = selector;
+ break;
+ case CSSSelector::PseudoElementSlotted:
+ slottedPseudoElementSelector = selector;
+ break;
+#if ENABLE(VIDEO_TRACK)
+ case CSSSelector::PseudoElementCue:
+ cuePseudoElementSelector = selector;
+ break;
+#endif
+ default:
+ break;
+ }
+ break;
+ case CSSSelector::PseudoClass:
switch (selector->pseudoClassType()) {
case CSSSelector::PseudoClassLink:
case CSSSelector::PseudoClassVisited:
@@ -253,26 +262,53 @@
case CSSSelector::PseudoClassFocus:
focusSelector = selector;
break;
+ case CSSSelector::PseudoClassHost:
+ m_hostPseudoClassRules.append(ruleData);
+ return;
default:
- ASSERT_NOT_REACHED();
+ break;
}
+ break;
+ case CSSSelector::Unknown:
+ case CSSSelector::Exact:
+ case CSSSelector::Set:
+ case CSSSelector::List:
+ case CSSSelector::Hyphen:
+ case CSSSelector::Contain:
+ case CSSSelector::Begin:
+ case CSSSelector::End:
+ case CSSSelector::PagePseudoClass:
+ break;
}
-
- if (selector->match() == CSSSelector::PseudoClass && selector->pseudoClassType() == CSSSelector::PseudoClassHost) {
- m_hostPseudoClassRules.append(ruleData);
- return;
- }
- if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementSlotted) {
- // ::slotted pseudo elements work accross shadow boundary making filtering difficult.
- ruleData.disableSelectorFiltering();
- m_slottedPseudoElementRules.append(ruleData);
- return;
- }
if (selector->relation() != CSSSelector::Subselector)
break;
selector = selector->tagHistory();
} while (selector);
+ if (cuePseudoElementSelector) {
+ m_cuePseudoRules.append(ruleData);
+ return;
+ }
+
+ if (slottedPseudoElementSelector) {
+ // ::slotted pseudo elements work accross shadow boundary making filtering difficult.
+ ruleData.disableSelectorFiltering();
+ m_slottedPseudoElementRules.append(ruleData);
+ return;
+ }
+
+ if (customPseudoElementSelector) {
+ // FIXME: Custom pseudo elements are handled by the shadow tree's selector filter. It doesn't know about the main DOM.
+ ruleData.disableSelectorFiltering();
+ addToRuleSet(customPseudoElementSelector->value().impl(), m_shadowPseudoElementRules, ruleData);
+ return;
+ }
+
+ if (idSelector) {
+ addToRuleSet(idSelector->value().impl(), m_idRules, ruleData);
+ return;
+ }
+
if (classSelector) {
addToRuleSet(classSelector->value().impl(), m_classRules, ruleData);
return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes