Changeset 190680 in webkit
- Timestamp:
- Oct 7, 2015, 12:59:32 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/LayoutTests/ChangeLog ¶
r190677 r190680 1 2015-10-07 Antti Koivisto <antti@apple.com> 2 3 Implement :host pseudo class 4 https://bugs.webkit.org/show_bug.cgi?id=149440 5 6 Reviewed by Ryosuke Niwa. 7 8 * fast/shadow-dom/css-scoping-shadow-host-rule.html: 9 10 Fix and expand the test case. 11 12 * platform/mac/TestExpectations: 13 1 14 2015-10-07 Brian Burg <bburg@apple.com> 2 15 -
TabularUnified trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-host-rule.html ¶
r190098 r190680 9 9 <body> 10 10 <style> 11 my-host, good-host, other-host, other-good-host{11 my-host, my-host2, my-host3, my-host4 { 12 12 display: block; 13 13 width: 100px; 14 height: 50px; 14 height: 25px; 15 } 16 my-host2 { 17 background: green; 18 } 19 my-host3 { 15 20 background: red; 21 color: green; 16 22 } 17 good-host, other-good-host{23 my-host4 { 18 24 background: green; 25 color: green; 19 26 } 20 27 </style> … … 23 30 <div>FAIL</div> 24 31 </my-host> 32 <my-host2> 33 <div>FAIL</div> 34 </my-host2> 35 <my-host3> 36 <div>FAIL</div> 37 </my-host3> 25 38 <div class="container"> 26 < good-host>39 <my-host4> 27 40 <div>FAIL</div> 28 </ good-host>41 </my-host4> 29 42 </div> 30 <other-host id="bar" class="foo" name="baz">31 <div>FAIL</div>32 </other-host>33 <other-good-host>34 <div class="child">FAIL</div>35 </other-good-host>36 43 <script> 37 44 38 45 try { 39 46 var shadowHost = document.querySelector('my-host'); 47 var shadowRoot = shadowHost.attachShadow({mode: 'open'}); 48 shadowRoot.innerHTML = '<style> :host { color: green; background: green; } </style><div>FAIL</div>'; 49 50 shadowHost = document.querySelector('my-host2'); 40 51 shadowRoot = shadowHost.attachShadow({mode: 'open'}); 41 shadowRoot.innerHTML = '<style> :host { background: green; } </style>';52 shadowRoot.innerHTML = '<style> :host { color: red; background: red; } div { color: green }</style><div>FAIL</div>'; 42 53 43 shadowHost = document.querySelector(' good-host');54 shadowHost = document.querySelector('my-host3'); 44 55 shadowRoot = shadowHost.attachShadow({mode: 'open'}); 45 shadowRoot.innerHTML = '<style> .container :host { background: red; } </style>'; 56 shadowRoot.innerHTML = '<style> :host { background: green !important; color: green !important; } </style><div>FAIL</div>'; 57 58 shadowHost = document.querySelector('my-host4'); 59 shadowRoot = shadowHost.attachShadow({mode: 'open'}); 60 shadowRoot.innerHTML = '<style> .container :host { background: red !important; } </style><div>FAIL</div>'; 46 61 } catch (exception) { 47 62 document.body.appendChild(document.createTextNode(exception)); -
TabularUnified trunk/LayoutTests/platform/mac/TestExpectations ¶
r190667 r190680 1326 1326 1327 1327 webkit.org/b/148695 fast/shadow-dom [ Pass ] 1328 webkit.org/b/149440 fast/shadow-dom/css-scoping-shadow-host-rule.html [ ImageOnlyFailure ]1329 1328 webkit.org/b/149440 fast/shadow-dom/css-scoping-shadow-host-functional-rule.html [ ImageOnlyFailure ] 1330 1329 webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slotted-rule.html [ ImageOnlyFailure ] -
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r190674 r190680 1 2015-10-07 Antti Koivisto <antti@apple.com> 2 3 Implement :host pseudo class 4 https://bugs.webkit.org/show_bug.cgi?id=149440 5 rdar://problem/22731953 6 7 Reviewed by Ryosuke Niwa. 8 9 This implements the basic non-function :host syntax. 10 11 * css/CSSSelector.cpp: 12 (WebCore::CSSSelector::selectorText): 13 * css/CSSSelector.h: 14 * css/ElementRuleCollector.cpp: 15 (WebCore::ElementRuleCollector::matchAuthorRules): 16 (WebCore::ElementRuleCollector::matchHostPseudoClassRules): 17 (WebCore::ElementRuleCollector::matchUserRules): 18 * css/ElementRuleCollector.h: 19 * css/RuleSet.cpp: 20 (WebCore::computeMatchBasedOnRuleHash): 21 (WebCore::RuleSet::addRule): 22 * css/RuleSet.h: 23 (WebCore::RuleSet::cuePseudoRules): 24 (WebCore::RuleSet::hostPseudoClassRules): 25 (WebCore::RuleSet::focusPseudoClassRules): 26 (WebCore::RuleSet::universalRules): 27 * css/SelectorChecker.cpp: 28 (WebCore::SelectorChecker::checkOne): 29 * css/SelectorPseudoClassAndCompatibilityElementMap.in: 30 * cssjit/SelectorCompiler.cpp: 31 (WebCore::SelectorCompiler::addPseudoClassType): 32 1 33 2015-10-07 Nan Wang <n_wang@apple.com> 2 34 -
TabularUnified trunk/Source/WebCore/css/CSSSelector.cpp ¶
r187149 r190680 633 633 str.appendLiteral(":window-inactive"); 634 634 break; 635 #if ENABLE(SHADOW_DOM) 636 case CSSSelector::PseudoClassHost: 637 str.appendLiteral(":host"); 638 break; 639 #endif 635 640 case CSSSelector::PseudoClassUnknown: 636 641 ASSERT_NOT_REACHED(); -
TabularUnified trunk/Source/WebCore/css/CSSSelector.h ¶
r187353 r190680 160 160 PseudoClassRole, 161 161 #endif 162 #if ENABLE(SHADOW_DOM) 163 PseudoClassHost, 164 #endif 162 165 }; 163 166 -
TabularUnified trunk/Source/WebCore/css/ElementRuleCollector.cpp ¶
r190347 r190680 189 189 void ElementRuleCollector::matchAuthorRules(bool includeEmptyRules) 190 190 { 191 #if ENABLE(SHADOW_DOM) 192 if (m_element.shadowRoot()) 193 matchHostPseudoClassRules(includeEmptyRules); 194 #endif 195 191 196 clearMatchedRules(); 192 197 m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1; … … 200 205 sortAndTransferMatchedRules(); 201 206 } 207 208 #if ENABLE(SHADOW_DOM) 209 void ElementRuleCollector::matchHostPseudoClassRules(bool includeEmptyRules) 210 { 211 ASSERT(m_element.shadowRoot()); 212 auto& shadowAuthorStyle = *m_element.shadowRoot()->styleResolver().ruleSets().authorStyle(); 213 auto& shadowHostRules = shadowAuthorStyle.hostPseudoClassRules(); 214 if (shadowHostRules.isEmpty()) 215 return; 216 217 clearMatchedRules(); 218 m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1; 219 220 auto ruleRange = m_result.ranges.authorRuleRange(); 221 MatchRequest matchRequest(&shadowAuthorStyle, includeEmptyRules); 222 collectMatchingRulesForList(&shadowHostRules, matchRequest, ruleRange); 223 224 // We just sort the host rules before other author rules. This matches the current vague spec language 225 // but is not necessarily exactly what is needed. 226 // FIXME: Match the spec when it is finalized. 227 sortAndTransferMatchedRules(); 228 } 229 #endif 202 230 203 231 void ElementRuleCollector::matchUserRules(bool includeEmptyRules) -
TabularUnified trunk/Source/WebCore/css/ElementRuleCollector.h ¶
r190347 r190680 78 78 79 79 void matchUARules(RuleSet*); 80 #if ENABLE(SHADOW_DOM) 81 void matchHostPseudoClassRules(bool includeEmptyRules); 82 #endif 80 83 81 84 void collectMatchingRules(const MatchRequest&, StyleResolver::RuleRange&); -
TabularUnified trunk/Source/WebCore/css/RuleSet.cpp ¶
r190347 r190680 71 71 if (SelectorChecker::isCommonPseudoClassSelector(&selector)) 72 72 return MatchBasedOnRuleHash::ClassB; 73 #if ENABLE(SHADOW_DOM) 74 if (selector.match() == CSSSelector::PseudoClass && selector.pseudoClassType() == CSSSelector::PseudoClassHost) 75 return MatchBasedOnRuleHash::ClassB; 76 #endif 73 77 if (selector.match() == CSSSelector::Id) 74 78 return MatchBasedOnRuleHash::ClassA; … … 259 263 } 260 264 265 #if ENABLE(SHADOW_DOM) 266 if (selector->match() == CSSSelector::PseudoClass && selector->pseudoClassType() == CSSSelector::PseudoClassHost) { 267 m_hostPseudoClassRules.append(ruleData); 268 return; 269 } 270 #endif 261 271 if (selector->relation() != CSSSelector::SubSelector) 262 272 break; -
TabularUnified trunk/Source/WebCore/css/RuleSet.h ¶
r190347 r190680 180 180 const RuleDataVector* cuePseudoRules() const { return &m_cuePseudoRules; } 181 181 #endif 182 #if ENABLE(SHADOW_DOM) 183 const RuleDataVector& hostPseudoClassRules() const { return m_hostPseudoClassRules; } 184 #endif 182 185 const RuleDataVector* focusPseudoClassRules() const { return &m_focusPseudoClassRules; } 183 186 const RuleDataVector* universalRules() const { return &m_universalRules; } … … 202 205 #if ENABLE(VIDEO_TRACK) 203 206 RuleDataVector m_cuePseudoRules; 207 #endif 208 #if ENABLE(SHADOW_DOM) 209 RuleDataVector m_hostPseudoClassRules; 204 210 #endif 205 211 RuleDataVector m_focusPseudoClassRules; -
TabularUnified trunk/Source/WebCore/css/SelectorChecker.cpp ¶
r189841 r190680 1014 1014 break; 1015 1015 } 1016 1016 #if ENABLE(SHADOW_DOM) 1017 case CSSSelector::PseudoClassHost: 1018 // :host matches based on context. Cases that reach selector checker don't match. 1019 return false; 1020 #endif 1017 1021 case CSSSelector::PseudoClassWindowInactive: 1018 1022 return isWindowInactive(element); -
TabularUnified trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in ¶
r182129 r190680 75 75 past 76 76 #endif 77 78 #if ENABLE(SHADOW_DOM) 79 host 80 #endif -
TabularUnified trunk/Source/WebCore/cssjit/SelectorCompiler.cpp ¶
r186268 r190680 820 820 return functionType; 821 821 } 822 822 #if ENABLE(SHADOW_DOM) 823 case CSSSelector::PseudoClassHost: 824 // :host matches based on context. Cases that reach selector checker don't match. 825 return FunctionType::CannotMatchAnything; 826 #endif 823 827 case CSSSelector::PseudoClassUnknown: 824 828 ASSERT_NOT_REACHED();
Note:
See TracChangeset
for help on using the changeset viewer.