Source/WebCore/ChangeLog

 12016-02-25 Antti Koivisto <antti@apple.com>
 2
 3 Implement ::slotted pseudo element
 4 https://bugs.webkit.org/show_bug.cgi?id=149441
 5 <rdar://problem/22731987>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Based on latest in https://github.com/w3c/webcomponents/issues/331
 10
 11 * css/CSSGrammar.y.in:
 12
 13 Parse ::slotted.
 14
 15 * css/CSSParser.cpp:
 16 (WebCore::CSSParser::detectFunctionTypeToken):
 17 * css/CSSParserValues.cpp:
 18 (WebCore::CSSParserSelector::parsePseudoElementCueFunctionSelector):
 19 (WebCore::CSSParserSelector::parsePseudoElementSlottedFunctionSelector):
 20
 21 Tokenize ::slotted.
 22
 23 (WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector):
 24 * css/CSSParserValues.h:
 25 * css/CSSSelector.cpp:
 26 (WebCore::CSSSelector::pseudoId):
 27 * css/CSSSelector.h:
 28 * css/ElementRuleCollector.cpp:
 29 (WebCore::ElementRuleCollector::matchAuthorRules):
 30 (WebCore::ElementRuleCollector::matchHostPseudoClassRules):
 31 (WebCore::ElementRuleCollector::matchSlottedPseudoElementRules):
 32
 33 Match ::slotted selector.
 34
 35 (WebCore::ElementRuleCollector::collectSlottedPseudoElementRulesForSlot):
 36
 37 Collect ::slotted rules that may apply to an element in a slot.
 38
 39 (WebCore::ElementRuleCollector::matchUserRules):
 40 (WebCore::ElementRuleCollector::matchUARules):
 41 (WebCore::findSlottedPseudoElementSelector):
 42 (WebCore::ElementRuleCollector::ruleMatches):
 43 * css/ElementRuleCollector.h:
 44 * css/RuleSet.cpp:
 45 (WebCore::RuleSet::addRule):
 46
 47 Collect ::slotted rules.
 48
 49 (WebCore::RuleSet::shrinkToFit):
 50 * css/RuleSet.h:
 51 (WebCore::RuleSet::hostPseudoClassRules):
 52 (WebCore::RuleSet::slottedPseudoElementRules):
 53 (WebCore::RuleSet::focusPseudoClassRules):
 54 (WebCore::RuleSet::universalRules):
 55 * css/SelectorChecker.cpp:
 56 (WebCore::SelectorChecker::checkOne):
 57 * style/StyleSharingResolver.cpp:
 58 (WebCore::Style::SharingResolver::resolve):
 59
 60 Disable style sharing for children of shadow host. They may be affected by the shadow tree style
 61 which is not considered in style sharing checks.
 62
1632016-02-25 Said Abou-Hallawa <sabouhallawa@apple.com>
264
365 REGRESSION (r196268): Many assertion failures and crashes on SVG path animation tests when JS garbage collection happens quickly
197127

Source/WebCore/css/CSSGrammar.y.in

@@static bool selectorListDoesNotMatchAnyP
365365
366366#endif
367367
 368#if ENABLE_SHADOW_DOM
 369
 370%token <string> SLOTTEDFUNCTION
 371
 372#endif
 373
368374%%
369375
370376stylesheet:

@@pseudo:
13571363 $$ = CSSParserSelector::parsePseudoElementCueFunctionSelector($3, $5);
13581364 }
13591365#endif
 1366#if ENABLE_SHADOW_DOM
 1367 | ':' ':' SLOTTEDFUNCTION maybe_space compound_selector maybe_space ')' {
 1368 $$ = CSSParserSelector::parsePseudoElementSlottedFunctionSelector($3, $5);
 1369 }
 1370#endif
13601371 // use by :-webkit-any.
13611372 // FIXME: should we support generic selectors here or just simple_selectors?
13621373 // Use simple_selector_list for now to match -moz-any.
197027

Source/WebCore/css/CSSParser.cpp

@@inline bool CSSParser::detectFunctionTyp
1189411894 m_token = MATCHESFUNCTION;
1189511895 return true;
1189611896 }
 11897#if ENABLE(SHADOW_DOM)
 11898 if (isEqualToCSSIdentifier(name, "slotted")) {
 11899 m_token = SLOTTEDFUNCTION;
 11900 return true;
 11901 }
 11902#endif
1189711903 return false;
1189811904
1189911905 case 9:
197027

Source/WebCore/css/CSSParserValues.cpp

@@CSSParserSelector* CSSParserSelector::pa
231231}
232232#endif
233233
 234#if ENABLE(SHADOW_DOM)
 235CSSParserSelector* CSSParserSelector::parsePseudoElementSlottedFunctionSelector(const CSSParserString& functionIdentifier, CSSParserSelector* parsedSelector)
 236{
 237 ASSERT_UNUSED(functionIdentifier, String(functionIdentifier) == "slotted(");
 238
 239 if (!parsedSelector)
 240 return nullptr;
 241
 242 std::unique_ptr<CSSParserSelector> ownedParsedSelector(parsedSelector);
 243
 244 for (auto* component = parsedSelector; component; component = component->tagHistory()) {
 245 if (component->matchesPseudoElement())
 246 return nullptr;
 247 }
 248
 249 auto selectorVector = std::make_unique<Vector<std::unique_ptr<CSSParserSelector>>>();
 250 selectorVector->append(WTFMove(ownedParsedSelector));
 251
 252 auto selector = std::make_unique<CSSParserSelector>();
 253 selector->m_selector->setMatch(CSSSelector::PseudoElement);
 254 selector->m_selector->setPseudoElementType(CSSSelector::PseudoElementSlotted);
 255 selector->adoptSelectorVector(*selectorVector);
 256 return selector.release();
 257}
 258#endif
 259
234260CSSParserSelector* CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector(CSSParserString& pseudoTypeString)
235261{
236262 if (pseudoTypeString.length() && pseudoTypeString[pseudoTypeString.length() - 1] == '(')
197027

Source/WebCore/css/CSSParserValues.h

@@class CSSParserSelector {
203203public:
204204 static CSSParserSelector* parsePagePseudoSelector(const CSSParserString& pseudoTypeString);
205205 static CSSParserSelector* parsePseudoElementSelector(CSSParserString& pseudoTypeString);
206  static CSSParserSelector* parsePseudoElementCueFunctionSelector(const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* selectorVector);
 206 static CSSParserSelector* parsePseudoElementCueFunctionSelector(const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>*);
 207#if ENABLE(SHADOW_DOM)
 208 static CSSParserSelector* parsePseudoElementSlottedFunctionSelector(const CSSParserString& functionIdentifier, CSSParserSelector*);
 209#endif
207210 static CSSParserSelector* parsePseudoClassAndCompatibilityElementSelector(CSSParserString& pseudoTypeString);
208211
209212 CSSParserSelector();
197027

Source/WebCore/css/CSSSelector.cpp

@@PseudoId CSSSelector::pseudoId(PseudoEle
299299#if ENABLE(VIDEO_TRACK)
300300 case PseudoElementCue:
301301#endif
 302#if ENABLE(SHADOW_DOM)
 303 case PseudoElementSlotted:
 304#endif
302305 case PseudoElementUnknown:
303306 case PseudoElementUserAgentCustom:
304307 case PseudoElementWebKitCustom:

@@String CSSSelector::selectorText(const S
644647 ASSERT_NOT_REACHED();
645648 }
646649 } else if (cs->match() == CSSSelector::PseudoElement) {
647  str.appendLiteral("::");
648  str.append(cs->value());
 650 switch (cs->pseudoElementType()) {
 651#if ENABLE(SHADOW_DOM)
 652 case CSSSelector::PseudoElementSlotted:
 653 str.appendLiteral("::slotted(");
 654 cs->selectorList()->buildSelectorsText(str);
 655 str.append(')');
 656 break;
 657#endif
 658 default:
 659 str.appendLiteral("::");
 660 str.append(cs->value());
 661 }
649662 } else if (cs->isAttributeSelector()) {
650663 str.append('[');
651664 const AtomicString& prefix = cs->attribute().prefix();
197027

Source/WebCore/css/CSSSelector.h

@@namespace WebCore {
181181 PseudoElementScrollbarTrack,
182182 PseudoElementScrollbarTrackPiece,
183183 PseudoElementSelection,
 184#if ENABLE(SHADOW_DOM)
 185 PseudoElementSlotted,
 186#endif
184187 PseudoElementUserAgentCustom,
185188 PseudoElementWebKitCustom,
186189 };
197027

Source/WebCore/css/ElementRuleCollector.cpp

3636#include "CSSSelectorList.h"
3737#include "CSSValueKeywords.h"
3838#include "HTMLElement.h"
 39#include "HTMLSlotElement.h"
3940#include "InspectorInstrumentation.h"
4041#include "NodeRenderStyle.h"
4142#include "RenderRegion.h"

@@void ElementRuleCollector::matchAuthorRu
206207#if ENABLE(SHADOW_DOM)
207208 if (m_element.shadowRoot())
208209 matchHostPseudoClassRules(includeEmptyRules);
 210
 211 auto* parent = m_element.parentNode();
 212 if (parent && parent->shadowRoot())
 213 matchSlottedPseudoElementRules(includeEmptyRules);
209214#endif
210215
211216 clearMatchedRules();

@@void ElementRuleCollector::matchHostPseu
241246 // FIXME: Match the spec when it is finalized.
242247 sortAndTransferMatchedRules();
243248}
 249
 250void ElementRuleCollector::matchSlottedPseudoElementRules(bool includeEmptyRules)
 251{
 252 auto* hostShadowRoot = m_element.parentNode()->shadowRoot();
 253 ASSERT(hostShadowRoot);
 254 auto* slot = hostShadowRoot->findAssignedSlot(m_element);
 255 if (!slot)
 256 return;
 257 auto* shadowAuthorStyle = hostShadowRoot->styleResolver().ruleSets().authorStyle();
 258 if (!shadowAuthorStyle)
 259 return;
 260 // Find out if there are any ::slotted rules in the shadow tree matching the current slot.
 261 // FIXME: This is really part of the slot style and could be cached when resolving it.
 262 ElementRuleCollector collector(*slot, *shadowAuthorStyle, nullptr);
 263 auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(includeEmptyRules);
 264 if (slottedPseudoElementRules.isEmpty())
 265 return;
 266
 267
 268 clearMatchedRules();
 269 m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1;
 270
 271 {
 272 // Match in the current scope.
 273 TemporaryChange<bool> change(m_isMatchingSlottedPseudoElement, true);
 274
 275 MatchRequest matchRequest(nullptr, includeEmptyRules);
 276 auto ruleRange = m_result.ranges.authorRuleRange();
 277 collectMatchingRulesForList(&slottedPseudoElementRules, matchRequest, ruleRange);
 278 }
 279
 280 // FIXME: What is the correct order?
 281 sortAndTransferMatchedRules();
 282}
 283
 284RuleSet::RuleDataVector ElementRuleCollector::collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules)
 285{
 286 ASSERT(is<HTMLSlotElement>(m_element));
 287
 288 clearMatchedRules();
 289
 290 m_mode = SelectorChecker::Mode::CollectingRules;
 291
 292 // Match global author rules.
 293 MatchRequest matchRequest(&m_authorStyle, includeEmptyRules);
 294 StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange();
 295 collectMatchingRulesForList(&m_authorStyle.slottedPseudoElementRules(), matchRequest, ruleRange);
 296
 297 if (m_matchedRules.isEmpty())
 298 return { };
 299
 300 RuleSet::RuleDataVector ruleDataVector;
 301 for (auto& matchedRule : m_matchedRules)
 302 ruleDataVector.append(*matchedRule.ruleData);
 303 return ruleDataVector;
 304}
244305#endif
245306
246307void ElementRuleCollector::matchUserRules(bool includeEmptyRules)

@@void ElementRuleCollector::matchUARules(
284345 sortAndTransferMatchedRules();
285346}
286347
 348#if ENABLE(SHADOW_DOM)
 349static const CSSSelector* findSlottedPseudoElementSelector(const CSSSelector* selector)
 350{
 351 for (; selector; selector = selector->tagHistory()) {
 352 if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementSlotted) {
 353 if (auto* list = selector->selectorList())
 354 return list->first();
 355 break;
 356 }
 357 };
 358 return nullptr;
 359}
 360#endif
 361
287362inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, unsigned& specificity)
288363{
289364 // We know a sufficiently simple single part selector matches simply because we found it from the rule hash when filtering the RuleSet.

@@inline bool ElementRuleCollector::ruleMa
356431 } else
357432#endif // ENABLE(CSS_SELECTOR_JIT)
358433 {
 434 auto* selector = ruleData.selector();
 435#if ENABLE(SHADOW_DOM)
 436 if (m_isMatchingSlottedPseudoElement) {
 437 selector = findSlottedPseudoElementSelector(ruleData.selector());
 438 if (!selector)
 439 return false;
 440 }
 441
 442#endif
359443 // Slow path.
360444 SelectorChecker selectorChecker(m_element.document());
361  selectorMatches = selectorChecker.match(*ruleData.selector(), m_element, context, specificity);
 445 selectorMatches = selectorChecker.match(*selector, m_element, context, specificity);
362446 }
363447
364448 commitStyleRelations(context.styleRelations);
197027

Source/WebCore/css/ElementRuleCollector.h

@@private:
7373 void matchUARules(RuleSet*);
7474#if ENABLE(SHADOW_DOM)
7575 void matchHostPseudoClassRules(bool includeEmptyRules);
 76 void matchSlottedPseudoElementRules(bool includeEmptyRules);
 77 RuleSet::RuleDataVector collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules);
7678#endif
7779
7880 void collectMatchingRules(const MatchRequest&, StyleResolver::RuleRange&);

@@private:
98100 PseudoStyleRequest m_pseudoStyleRequest { NOPSEUDO };
99101 bool m_sameOriginOnly { false };
100102 SelectorChecker::Mode m_mode { SelectorChecker::Mode::ResolvingStyle };
 103#if ENABLE(SHADOW_DOM)
 104 bool m_isMatchingSlottedPseudoElement { false };
 105#endif
101106
102107 Vector<MatchedRule, 64> m_matchedRules;
103108
197027

Source/WebCore/css/RuleSet.cpp

@@void RuleSet::addRule(StyleRule* rule, u
266266 m_hostPseudoClassRules.append(ruleData);
267267 return;
268268 }
 269 if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementSlotted) {
 270 // ::slotted pseudo elements work accross shadow boundary making filtering difficult.
 271 ruleData.disableSelectorFiltering();
 272 m_slottedPseudoElementRules.append(ruleData);
 273 return;
 274 }
269275#endif
270276 if (selector->relation() != CSSSelector::SubSelector)
271277 break;

@@void RuleSet::shrinkToFit()
422428#if ENABLE(VIDEO_TRACK)
423429 m_cuePseudoRules.shrinkToFit();
424430#endif
 431#if ENABLE(SHADOW_DOM)
 432 m_hostPseudoClassRules.shrinkToFit();
 433 m_slottedPseudoElementRules.shrinkToFit();
 434#endif
425435 m_focusPseudoClassRules.shrinkToFit();
426436 m_universalRules.shrinkToFit();
427437 m_pageRules.shrinkToFit();
197027

Source/WebCore/css/RuleSet.h

@@public:
184184#endif
185185#if ENABLE(SHADOW_DOM)
186186 const RuleDataVector& hostPseudoClassRules() const { return m_hostPseudoClassRules; }
 187 const RuleDataVector& slottedPseudoElementRules() const { return m_slottedPseudoElementRules; }
187188#endif
188189 const RuleDataVector* focusPseudoClassRules() const { return &m_focusPseudoClassRules; }
189190 const RuleDataVector* universalRules() const { return &m_universalRules; }

@@private:
210211#endif
211212#if ENABLE(SHADOW_DOM)
212213 RuleDataVector m_hostPseudoClassRules;
 214 RuleDataVector m_slottedPseudoElementRules;
213215#endif
214216 RuleDataVector m_focusPseudoClassRules;
215217 RuleDataVector m_universalRules;
197027

Source/WebCore/css/SelectorChecker.cpp

4444#include "HTMLOptionElement.h"
4545#include "HTMLParserIdioms.h"
4646#include "HTMLProgressElement.h"
 47#include "HTMLSlotElement.h"
4748#include "HTMLStyleElement.h"
4849#include "InspectorInstrumentation.h"
4950#include "Page.h"

@@bool SelectorChecker::checkOne(CheckingC
10381039 return false;
10391040 }
10401041#endif
1041  // ### add the rest of the checks...
 1042#if ENABLE(SHADOW_DOM)
 1043 if (selector.match() == CSSSelector::PseudoElement && selector.pseudoElementType() == CSSSelector::PseudoElementSlotted) {
 1044 // We see ::slotted() pseudo elements when collecting slotted rules from the slot shadow tree only.
 1045 ASSERT(checkingContext.resolvingMode == Mode::CollectingRules);
 1046 return is<HTMLSlotElement>(element);
 1047 }
 1048#endif
10421049 return true;
10431050}
10441051
197027

Source/WebCore/style/StyleSharingResolver.cpp

@@const Element* SharingResolver::resolve(
7676 if (!element.parentElement())
7777 return nullptr;
7878 auto& parentElement = *element.parentElement();
 79 if (parentElement.shadowRoot())
 80 return nullptr;
7981 if (!parentElement.renderStyle())
8082 return nullptr;
8183 // If the element has inline style it is probably unique.
197027

LayoutTests/ChangeLog

 12016-02-26 Antti Koivisto <antti@apple.com>
 2
 3 Implement ::slotted pseudo element
 4 https://bugs.webkit.org/show_bug.cgi?id=149441
 5 <rdar://problem/22731987>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 * fast/shadow-dom/css-scoping-shadow-slotted-rule.html:
 10
 11 Enable the test, fix it and update it to the current spec.
 12
 13 * fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt: Added.
 14 * fast/shadow-dom/slotted-pseudo-element-css-text.html: Added.
 15
 16 Add parsing/cssText test based on a Blink test.
 17 There are a few failures due to * not rountripping and the parser being slightly too lenient.
 18
 19 * platform/mac/TestExpectations:
 20
1212016-02-25 Myles C. Maxfield <mmaxfield@apple.com>
222
323 Font size computed style is innaccurate
197161

LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html

11<!DOCTYPE html>
22<html>
33<head>
4  <title>CSS Scoping - :slotted pesudo element must allow selecting elements assigned to a slot element</title>
 4 <title>CSS Scoping - :slotted pseudo element must allow selecting elements assigned to a slot element</title>
55 <link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"/>
66 <link rel="help" href="http://www.w3.org/TR/css-scoping-1/#selectors-data-model">
77 <link rel="match" href="reference/green-box.html"/>

1212 display: block;
1313 width: 100px;
1414 height: 100px;
15  background: red;
 15 color: red;
 16 background: green;
1617 }
1718 my-host > div, nested-host {
1819 display: block;

2324 <p>Test passes if you see a single 100px by 100px green box below.</p>
2425 <my-host>
2526 <div class="green">FAIL1</div>
26  <div><span>FAIL2</span></div>
 27 <myelem><span>FAIL2</span></myelem>
2728 <nested-host>
2829 <span>FAIL3</span>
2930 </nested-host>

3637 try {
3738 var shadowHost = document.querySelector('my-host');
3839 shadowRoot = shadowHost.attachShadow({mode: 'open'});
39  shadowRoot.innerHTML = '<slot></slot><style> ::slotted > .green, ::slotted span { color:green; } </style>';
 40 shadowRoot.innerHTML = '<slot></slot><style> ::slotted(.green), ::slotted(myelem) { color:green; } </style>';
4041
4142 shadowHost = document.querySelector('nested-host');
4243 shadowRoot = shadowHost.attachShadow({mode: 'open'});
43  shadowRoot.innerHTML = '<slot></slot>';
 44 shadowRoot.innerHTML = '<style> .mydiv ::slotted(*) { color:green; } </style><div class=mydiv><slot></slot></div>';
4445
4546 shadowHost = document.querySelector('another-host');
4647 shadowRoot = shadowHost.attachShadow({mode: 'open'});
47  shadowRoot.innerHTML = '<style> ::slotted { color:green; } </style><slot></slot>';
 48 shadowRoot.innerHTML = '<style> ::slotted(*) { color:green; } </style><slot></slot>';
4849 } catch (exception) {
4950 document.body.appendChild(document.createTextNode(exception));
5051 }
197027

LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt

 1Test for cssText of '::slotted' rule.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6Rule ::slotted { display: block; }
 7PASS cssText is ""
 8Rule ::slotted() { display: block; }
 9PASS cssText is ""
 10Rule ::slotted(*) { display: block; }
 11PASS cssText is "::slotted(*) { display: block; }"
 12Rule *::slotted(*) { display: block; }
 13FAIL cssText should be *::slotted(*) { display: block; }. Was ::slotted(*) { display: block; }.
 14Rule ::slotted(div) { display: block; }
 15PASS cssText is "::slotted(div) { display: block; }"
 16Rule ::slotted( div) { display: block; }
 17PASS cssText is "::slotted(div) { display: block; }"
 18Rule ::slotted(div ) { display: block; }
 19PASS cssText is "::slotted(div) { display: block; }"
 20Rule ::slotted(div::before) { display: block; }
 21PASS cssText is ""
 22Rule .foo::slotted(div) { color: blue; }
 23PASS cssText is ".foo::slotted(div) { color: blue; }"
 24Rule #id::slotted(*) { color: blue; }
 25PASS cssText is "#id::slotted(*) { color: blue; }"
 26Rule [attr=foo]::slotted(*) { color: blue; }
 27PASS cssText is "[attr=\"foo\"]::slotted(*) { color: blue; }"
 28Rule .foo .bar::slotted(div) { color: blue; }
 29PASS cssText is ".foo .bar::slotted(div) { color: blue; }"
 30Rule .foo::before .bar::slotted(div) { color: blue; }
 31FAIL cssText should be . Was .foo::before .bar::slotted(div) { color: blue; }.
 32Rule .foo::slotted(div) .bar { color: blue; }
 33FAIL cssText should be . Was .foo::slotted(div) .bar { color: blue; }.
 34Rule ::slotted(div, div) { color: blue; }
 35PASS cssText is ""
 36Rule ::slotted(div div) { color: blue; }
 37PASS cssText is ""
 38Rule slot::slotted(.green) { color: green; }
 39PASS cssText is "slot::slotted(.green) { color: green; }"
 40Rule slot::slotted(#green) { color: green; }
 41PASS cssText is "slot::slotted(#green) { color: green; }"
 42Rule slot::slotted([green=green]) { color: green; }
 43PASS cssText is "slot::slotted([green=\"green\"]) { color: green; }"
 44Rule slot::slotted(div.green) { color: green; }
 45PASS cssText is "slot::slotted(div.green) { color: green; }"
 46Rule div ::slotted(div) { color: red; }
 47PASS cssText is "div ::slotted(div) { color: red; }"
 48Rule div + slot::slotted(div) { color: red; }
 49PASS cssText is "div + slot::slotted(div) { color: red; }"
 50Rule span::slotted(*) { color: red; }
 51PASS cssText is "span::slotted(*) { color: red; }"
 52Rule ::slotted(span)::slotted(span) { color: red; }
 53FAIL cssText should be . Was ::slotted(span)::slotted(span) { color: red; }.
 54Rule ::slotted(::slotted(div)) { color: red; }
 55PASS cssText is ""
 56PASS successfullyParsed is true
 57
 58TEST COMPLETE
 59
0

LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text.html

 1<!DOCTYPE html>
 2<script src='../../resources/js-test-pre.js'></script>
 3<script>
 4description("Test for cssText of '::slotted' rule.");
 5
 6var rules = [
 7"::slotted { display: block; }", /* invalid - no parameter */
 8"::slotted() { display: block; }", /* invalid - empty parameter */
 9"::slotted(*) { display: block; }",
 10"*::slotted(*) { display: block; }",
 11"::slotted(div) { display: block; }", /* expects universal selector (*) on the left in cssText */
 12"::slotted( div) { display: block; }", /* allow a space on left */
 13"::slotted(div ) { display: block; }", /* allow a space on right */
 14"::slotted(div::before) { display: block; }", /* having a pseudo element in () is invalid */
 15".foo::slotted(div) { color: blue; }",
 16"#id::slotted(*) { color: blue; }",
 17"[attr=foo]::slotted(*) { color: blue; }",
 18".foo .bar::slotted(div) { color: blue; }",
 19".foo::before .bar::slotted(div) { color: blue; }", /* invalid, only one pseudo element is allowed at the rightmost compound */
 20".foo::slotted(div) .bar { color: blue; }", /* invalid, same as above */
 21"::slotted(div, div) { color: blue; }", /* invalid - selector list */
 22"::slotted(div div) { color: blue; }", /* invalid - complex selector (combinator is used) */
 23"slot::slotted(.green) { color: green; }",
 24"slot::slotted(#green) { color: green; }",
 25"slot::slotted([green=green]) { color: green; }",
 26"slot::slotted(div.green) { color: green; }",
 27"div ::slotted(div) { color: red; }",
 28"div + slot::slotted(div) { color: red; }",
 29"span::slotted(*) { color: red; }", /* never matches, but valid as a selector */
 30"::slotted(span)::slotted(span) { color: red; }", /* invalid */
 31"::slotted(::slotted(div)) { color: red; }" /* invalid */
 32];
 33
 34var expectedCSSTexts = [
 35"",
 36"",
 37"::slotted(*) { display: block; }",
 38"*::slotted(*) { display: block; }",
 39"::slotted(div) { display: block; }",
 40"::slotted(div) { display: block; }",
 41"::slotted(div) { display: block; }",
 42"",
 43".foo::slotted(div) { color: blue; }",
 44"#id::slotted(*) { color: blue; }",
 45"[attr=\"foo\"]::slotted(*) { color: blue; }",
 46".foo .bar::slotted(div) { color: blue; }",
 47"",
 48"",
 49"",
 50"",
 51"slot::slotted(.green) { color: green; }",
 52"slot::slotted(#green) { color: green; }",
 53"slot::slotted([green=\"green\"]) { color: green; }",
 54"slot::slotted(div.green) { color: green; }",
 55"div ::slotted(div) { color: red; }",
 56"div + slot::slotted(div) { color: red; }",
 57"span::slotted(*) { color: red; }",
 58"",
 59"",
 60];
 61
 62function ruleCSSText(rule)
 63{
 64 var style = document.createElement("style");
 65 style.innerText = rule;
 66 document.head.appendChild(style);
 67 if (style.sheet.cssRules.length == 0)
 68 return "";
 69 return style.sheet.cssRules.item(0).cssText;
 70}
 71
 72for (var i = 0; i < rules.length; ++i) {
 73 debug("Rule " + rules[i]);
 74 cssText = ruleCSSText(rules[i]);
 75 expectedCSSText = expectedCSSTexts[i]
 76 shouldBeEqualToString("cssText", expectedCSSText);
 77}
 78</script>
 79<script src='../../resources/js-test-post.js'></script>
0

LayoutTests/platform/mac/TestExpectations

@@webkit.org/b/149128 fast/text/control-ch
12501250
12511251webkit.org/b/148695 fast/shadow-dom [ Pass ]
12521252webkit.org/b/149440 fast/shadow-dom/css-scoping-shadow-host-functional-rule.html [ ImageOnlyFailure ]
1253 webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slotted-rule.html [ ImageOnlyFailure ]
12541253webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slot-display-override.html [ ImageOnlyFailure ]
12551254
12561255# Touch events is not enabled on Mac
197027