Changeset 209352 in webkit
- Timestamp:
- Dec 5, 2016 2:42:28 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r209349 r209352 1 2016-12-05 Antti Koivisto <antti@apple.com> 2 3 keyframes do not work when defined inside a style in a shadowRoot 4 https://bugs.webkit.org/show_bug.cgi?id=164608 5 <rdar://problem/29210251> 6 7 Reviewed by Darin Adler. 8 9 * fast/shadow-dom/shadow-host-animation-expected.html: Added. 10 * fast/shadow-dom/shadow-host-animation.html: Added. 11 1 12 2016-12-05 Ryan Haddad <ryanhaddad@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r209351 r209352 1 2016-12-05 Antti Koivisto <antti@apple.com> 2 3 keyframes do not work when defined inside a style in a shadowRoot 4 https://bugs.webkit.org/show_bug.cgi?id=164608 5 <rdar://problem/29210251> 6 7 Reviewed by Darin Adler. 8 9 With :host and ::slotted rules a keyframe animation affecting an element can be 10 defined in a style scope different from the element's own scope. Style resolver 11 loses the scope information when building the RenderStyle so there is no way 12 to find out the correct scope. 13 14 Fix by passing style scope through to style builder and including a scope association 15 with the animation name. Find the correct scope when resolving keyframes. 16 17 Test: fast/shadow-dom/shadow-host-animation.html 18 19 * css/CSSToStyleMap.cpp: 20 (WebCore::CSSToStyleMap::mapAnimationName): 21 22 Include scope with the name. 23 24 * css/ElementRuleCollector.cpp: 25 (WebCore::MatchRequest::MatchRequest): 26 (WebCore::ElementRuleCollector::addMatchedRule): 27 (WebCore::ElementRuleCollector::sortAndTransferMatchedRules): 28 (WebCore::ElementRuleCollector::matchAuthorRules): 29 (WebCore::ElementRuleCollector::matchAuthorShadowPseudoElementRules): 30 (WebCore::ElementRuleCollector::matchHostPseudoClassRules): 31 (WebCore::ElementRuleCollector::matchSlottedPseudoElementRules): 32 (WebCore::ElementRuleCollector::collectMatchingRulesForList): 33 34 Replace treeContextOrdinal int with Style::ScopeOrdinal enum carrying the same information. 35 Simplify the code removing unnecessary use of MatchRequest struct. 36 37 (WebCore::compareRules): 38 * css/ElementRuleCollector.h: 39 * css/StyleResolver.cpp: 40 (WebCore::StyleResolver::MatchResult::addMatchedProperties): 41 (WebCore::StyleResolver::CascadedProperties::setPropertyInternal): 42 (WebCore::StyleResolver::CascadedProperties::set): 43 (WebCore::StyleResolver::CascadedProperties::setDeferred): 44 45 Pass styleScopeOrdinal through the cascade mechanism 46 47 (WebCore::cascadeLevelForIndex): 48 (WebCore::StyleResolver::CascadedProperties::addMatch): 49 (WebCore::StyleResolver::CascadedProperties::addImportantMatches): 50 (WebCore::StyleResolver::CascadedProperties::Property::apply): 51 52 Set styleScopeOrdinal in State when applying style. 53 54 (WebCore::StyleResolver::CascadedProperties::addStyleProperties): Deleted. 55 56 Move the code to the only caller. 57 58 * css/StyleResolver.h: 59 (WebCore::StyleResolver::State::styleScopeOrdinal): 60 (WebCore::StyleResolver::State::setStyleScopeOrdinal): 61 * page/animation/CompositeAnimation.cpp: 62 (WebCore::KeyframeAnimation::KeyframeAnimation): 63 (WebCore::KeyframeAnimation::resolveKeyframeStyles): 64 65 Find the correct scope for resolving keyframes based on the scope ordinal. 66 67 * platform/animation/Animation.cpp: 68 * platform/animation/Animation.h: 69 70 Add m_nameStyleScopeOrdinal that tells the scope where the name is defined. 71 72 * style/StyleScope.cpp: 73 (WebCore::Style::Scope::forOrdinal): 74 75 Find the scope for ordinal. 76 77 * style/StyleScope.h: 78 79 Define ScopeOrdinal types. 80 81 (WebCore::Style::operator++): 82 1 83 2016-12-05 Dave Hyatt <hyatt@apple.com> 2 84 -
trunk/Source/WebCore/css/CSSToStyleMap.cpp
r209325 r209352 413 413 layer.setIsNoneAnimation(true); 414 414 else 415 layer.setName(primitiveValue.stringValue() );415 layer.setName(primitiveValue.stringValue(), m_resolver->state().styleScopeOrdinal()); 416 416 } 417 417 -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r208841 r209352 69 69 class MatchRequest { 70 70 public: 71 MatchRequest(const RuleSet* ruleSet, bool includeEmptyRules = false, int treeContextOrdinal = 0)71 MatchRequest(const RuleSet* ruleSet, bool includeEmptyRules = false, Style::ScopeOrdinal styleScopeOrdinal = Style::ScopeOrdinal::Element) 72 72 : ruleSet(ruleSet) 73 73 , includeEmptyRules(includeEmptyRules) 74 , treeContextOrdinal(treeContextOrdinal)74 , styleScopeOrdinal(styleScopeOrdinal) 75 75 { 76 76 } 77 77 const RuleSet* ruleSet; 78 78 const bool includeEmptyRules; 79 int treeContextOrdinal;79 Style::ScopeOrdinal styleScopeOrdinal; 80 80 }; 81 81 … … 109 109 } 110 110 111 inline void ElementRuleCollector::addMatchedRule(const RuleData& ruleData, unsigned specificity, int treeContextOrdinal, StyleResolver::RuleRange& ruleRange)111 inline void ElementRuleCollector::addMatchedRule(const RuleData& ruleData, unsigned specificity, Style::ScopeOrdinal styleScopeOrdinal, StyleResolver::RuleRange& ruleRange) 112 112 { 113 113 // Update our first/last rule indices in the matched rules array. … … 116 116 ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; 117 117 118 m_matchedRules.append({ &ruleData, specificity, treeContextOrdinal });118 m_matchedRules.append({ &ruleData, specificity, styleScopeOrdinal }); 119 119 } 120 120 … … 194 194 195 195 for (const MatchedRule& matchedRule : m_matchedRules) { 196 m_result.addMatchedProperties(matchedRule.ruleData->rule()->properties(), matchedRule.ruleData->rule(), matchedRule.ruleData->linkMatchType(), matchedRule.ruleData->propertyWhitelistType(), matchedRule. treeContextOrdinal);196 m_result.addMatchedProperties(matchedRule.ruleData->rule()->properties(), matchedRule.ruleData->rule(), matchedRule.ruleData->linkMatchType(), matchedRule.ruleData->propertyWhitelistType(), matchedRule.styleScopeOrdinal); 197 197 } 198 198 } … … 205 205 StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); 206 206 207 // Match global author rules. 208 MatchRequest matchRequest(&m_authorStyle, includeEmptyRules); 209 collectMatchingRules(matchRequest, ruleRange); 210 collectMatchingRulesForRegion(matchRequest, ruleRange); 207 { 208 MatchRequest matchRequest(&m_authorStyle, includeEmptyRules); 209 collectMatchingRules(matchRequest, ruleRange); 210 collectMatchingRulesForRegion(matchRequest, ruleRange); 211 } 211 212 212 213 auto* parent = m_element.parentElement(); 213 214 if (parent && parent->shadowRoot()) 214 matchSlottedPseudoElementRules( matchRequest, ruleRange);215 matchSlottedPseudoElementRules(includeEmptyRules, ruleRange); 215 216 216 217 if (m_element.shadowRoot() && m_pseudoStyleRequest.pseudoId == NOPSEUDO) 217 matchHostPseudoClassRules( matchRequest, ruleRange);218 matchHostPseudoClassRules(includeEmptyRules, ruleRange); 218 219 219 220 if (m_element.isInShadowTree()) 220 matchAuthorShadowPseudoElementRules( matchRequest, ruleRange);221 matchAuthorShadowPseudoElementRules(includeEmptyRules, ruleRange); 221 222 222 223 sortAndTransferMatchedRules(); 223 224 } 224 225 225 void ElementRuleCollector::matchAuthorShadowPseudoElementRules( const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)226 void ElementRuleCollector::matchAuthorShadowPseudoElementRules(bool includeEmptyRules, StyleResolver::RuleRange& ruleRange) 226 227 { 227 228 ASSERT(m_element.isInShadowTree()); … … 231 232 // Look up shadow pseudo elements also from the host scope author style as they are web-exposed. 232 233 auto& hostAuthorRules = Style::Scope::forNode(*shadowRoot.host()).resolver().ruleSets().authorStyle(); 233 MatchRequest hostAuthorRequest { &hostAuthorRules, matchRequest.includeEmptyRules, matchRequest.treeContextOrdinal - 1};234 MatchRequest hostAuthorRequest { &hostAuthorRules, includeEmptyRules, Style::ScopeOrdinal::ContainingHost }; 234 235 collectMatchingShadowPseudoElementRules(hostAuthorRequest, ruleRange); 235 236 } 236 237 237 void ElementRuleCollector::matchHostPseudoClassRules( MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)238 void ElementRuleCollector::matchHostPseudoClassRules(bool includeEmptyRules, StyleResolver::RuleRange& ruleRange) 238 239 { 239 240 ASSERT(m_element.shadowRoot()); 240 241 matchRequest.treeContextOrdinal++;242 241 243 242 auto& shadowAuthorStyle = m_element.shadowRoot()->styleScope().resolver().ruleSets().authorStyle(); … … 250 249 251 250 for (auto& ruleData : shadowHostRules) { 252 if (ruleData.rule()->properties().isEmpty() && ! matchRequest.includeEmptyRules)251 if (ruleData.rule()->properties().isEmpty() && !includeEmptyRules) 253 252 continue; 254 253 auto& selector = *ruleData.selector(); … … 256 255 if (!selectorChecker.matchHostPseudoClass(selector, m_element, context, specificity)) 257 256 continue; 258 addMatchedRule(ruleData, specificity, matchRequest.treeContextOrdinal, ruleRange); 259 } 260 } 261 262 void ElementRuleCollector::matchSlottedPseudoElementRules(MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) 263 { 264 auto* maybeSlotted = &m_element; 265 for (auto* hostShadowRoot = m_element.parentNode()->shadowRoot(); hostShadowRoot; hostShadowRoot = maybeSlotted->parentNode()->shadowRoot()) { 266 auto* slot = hostShadowRoot->findAssignedSlot(*maybeSlotted); 267 if (!slot) 268 return; 269 270 matchRequest.treeContextOrdinal++; 271 272 // In nested case the slot may itself be assigned to a slot. Collect ::slotted rules from all the nested trees. 273 maybeSlotted = slot; 274 if (!hostShadowRoot->styleScope().resolver().ruleSets().isAuthorStyleDefined()) 257 addMatchedRule(ruleData, specificity, Style::ScopeOrdinal::Shadow, ruleRange); 258 } 259 } 260 261 void ElementRuleCollector::matchSlottedPseudoElementRules(bool includeEmptyRules, StyleResolver::RuleRange& ruleRange) 262 { 263 auto* slot = m_element.assignedSlot(); 264 auto styleScopeOrdinal = Style::ScopeOrdinal::FirstSlot; 265 266 for (; slot; slot = slot->assignedSlot(), ++styleScopeOrdinal) { 267 auto& styleScope = Style::Scope::forNode(*slot); 268 if (!styleScope.resolver().ruleSets().isAuthorStyleDefined()) 275 269 continue; 276 270 // Find out if there are any ::slotted rules in the shadow tree matching the current slot. 277 271 // FIXME: This is really part of the slot style and could be cached when resolving it. 278 ElementRuleCollector collector(*slot, hostShadowRoot->styleScope().resolver().ruleSets().authorStyle(), nullptr);279 auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot( matchRequest.includeEmptyRules);272 ElementRuleCollector collector(*slot, styleScope.resolver().ruleSets().authorStyle(), nullptr); 273 auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(includeEmptyRules); 280 274 if (!slottedPseudoElementRules) 281 275 continue; … … 283 277 SetForScope<bool> change(m_isMatchingSlottedPseudoElements, true); 284 278 285 MatchRequest scopeMatchRequest(nullptr, matchRequest.includeEmptyRules, matchRequest.treeContextOrdinal);279 MatchRequest scopeMatchRequest(nullptr, includeEmptyRules, styleScopeOrdinal); 286 280 collectMatchingRulesForList(slottedPseudoElementRules.get(), scopeMatchRequest, ruleRange); 287 281 … … 508 502 unsigned specificity; 509 503 if (ruleMatches(ruleData, specificity)) 510 addMatchedRule(ruleData, specificity, matchRequest. treeContextOrdinal, ruleRange);504 addMatchedRule(ruleData, specificity, matchRequest.styleScopeOrdinal, ruleRange); 511 505 } 512 506 } … … 514 508 static inline bool compareRules(MatchedRule r1, MatchedRule r2) 515 509 { 516 // For normal properties the earlier tree wins. This may be reversed by !important which is handled when resolving cascade.517 if (r1. treeContextOrdinal != r2.treeContextOrdinal)518 return r1. treeContextOrdinal > r2.treeContextOrdinal;510 // For normal properties the earlier scope wins. This may be reversed by !important which is handled when resolving cascade. 511 if (r1.styleScopeOrdinal != r2.styleScopeOrdinal) 512 return r1.styleScopeOrdinal > r2.styleScopeOrdinal; 519 513 520 514 if (r1.specificity != r2.specificity) -
trunk/Source/WebCore/css/ElementRuleCollector.h
r208668 r209352 41 41 const RuleData* ruleData; 42 42 unsigned specificity; 43 int treeContextOrdinal;43 Style::ScopeOrdinal styleScopeOrdinal; 44 44 }; 45 45 … … 76 76 77 77 void matchUARules(RuleSet*); 78 void matchAuthorShadowPseudoElementRules( const MatchRequest&, StyleResolver::RuleRange&);79 void matchHostPseudoClassRules( MatchRequest&, StyleResolver::RuleRange&);80 void matchSlottedPseudoElementRules( MatchRequest&, StyleResolver::RuleRange&);78 void matchAuthorShadowPseudoElementRules(bool includeEmptyRules, StyleResolver::RuleRange&); 79 void matchHostPseudoClassRules(bool includeEmptyRules, StyleResolver::RuleRange&); 80 void matchSlottedPseudoElementRules(bool includeEmptyRules, StyleResolver::RuleRange&); 81 81 82 82 void collectMatchingShadowPseudoElementRules(const MatchRequest&, StyleResolver::RuleRange&); … … 91 91 void sortAndTransferMatchedRules(); 92 92 93 void addMatchedRule(const RuleData&, unsigned specificity, int treeContextOrdinal, StyleResolver::RuleRange&);93 void addMatchedRule(const RuleData&, unsigned specificity, Style::ScopeOrdinal, StyleResolver::RuleRange&); 94 94 95 95 const Element& m_element; -
trunk/Source/WebCore/css/StyleResolver.cpp
r209001 r209352 188 188 } 189 189 190 void StyleResolver::MatchResult::addMatchedProperties(const StyleProperties& properties, StyleRule* rule, unsigned linkMatchType, PropertyWhitelistType propertyWhitelistType, int treeContextOrdinal)190 void StyleResolver::MatchResult::addMatchedProperties(const StyleProperties& properties, StyleRule* rule, unsigned linkMatchType, PropertyWhitelistType propertyWhitelistType, Style::ScopeOrdinal styleScopeOrdinal) 191 191 { 192 192 m_matchedProperties.grow(m_matchedProperties.size() + 1); … … 195 195 newProperties.linkMatchType = linkMatchType; 196 196 newProperties.whitelistType = propertyWhitelistType; 197 newProperties. treeContextOrdinal = treeContextOrdinal;197 newProperties.styleScopeOrdinal = styleScopeOrdinal; 198 198 matchedRules.append(rule); 199 199 200 // Ordinal is relative to the currently matched element 201 if (treeContextOrdinal) 200 if (styleScopeOrdinal != Style::ScopeOrdinal::Element) 202 201 isCacheable = false; 203 202 … … 2061 2060 } 2062 2061 2063 void StyleResolver::CascadedProperties::setPropertyInternal(Property& property, CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel )2062 void StyleResolver::CascadedProperties::setPropertyInternal(Property& property, CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel, Style::ScopeOrdinal styleScopeOrdinal) 2064 2063 { 2065 2064 ASSERT(linkMatchType <= SelectorChecker::MatchAll); 2066 2065 property.id = id; 2067 2066 property.level = cascadeLevel; 2067 property.styleScopeOrdinal = styleScopeOrdinal; 2068 2068 if (linkMatchType == SelectorChecker::MatchAll) { 2069 2069 property.cssValue[0] = &cssValue; … … 2074 2074 } 2075 2075 2076 void StyleResolver::CascadedProperties::set(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel )2076 void StyleResolver::CascadedProperties::set(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel, Style::ScopeOrdinal styleScopeOrdinal) 2077 2077 { 2078 2078 if (CSSProperty::isDirectionAwareProperty(id)) … … 2091 2091 property.id = id; 2092 2092 memset(property.cssValue, 0, sizeof(property.cssValue)); 2093 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel );2093 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel, styleScopeOrdinal); 2094 2094 customProperties().set(customValue.name(), property); 2095 2095 } else { 2096 2096 Property property = customProperties().get(customValue.name()); 2097 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel );2097 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel, styleScopeOrdinal); 2098 2098 customProperties().set(customValue.name(), property); 2099 2099 } … … 2104 2104 memset(property.cssValue, 0, sizeof(property.cssValue)); 2105 2105 m_propertyIsPresent.set(id); 2106 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel );2107 } 2108 2109 void StyleResolver::CascadedProperties::setDeferred(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel )2106 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel, styleScopeOrdinal); 2107 } 2108 2109 void StyleResolver::CascadedProperties::setDeferred(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel, Style::ScopeOrdinal styleScopeOrdinal) 2110 2110 { 2111 2111 ASSERT(!CSSProperty::isDirectionAwareProperty(id)); … … 2114 2114 Property property; 2115 2115 memset(property.cssValue, 0, sizeof(property.cssValue)); 2116 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel );2116 setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel, styleScopeOrdinal); 2117 2117 m_deferredProperties.append(property); 2118 2118 } 2119 2119 2120 void StyleResolver::CascadedProperties::addStyleProperties(const StyleProperties& properties, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType, unsigned linkMatchType, CascadeLevel cascadeLevel) 2121 { 2122 for (unsigned i = 0, count = properties.propertyCount(); i < count; ++i) { 2123 auto current = properties.propertyAt(i); 2120 static CascadeLevel cascadeLevelForIndex(const StyleResolver::MatchResult& matchResult, int index) 2121 { 2122 if (index >= matchResult.ranges.firstUARule && index <= matchResult.ranges.lastUARule) 2123 return UserAgentLevel; 2124 if (index >= matchResult.ranges.firstUserRule && index <= matchResult.ranges.lastUserRule) 2125 return UserLevel; 2126 return AuthorLevel; 2127 } 2128 2129 void StyleResolver::CascadedProperties::addMatch(const MatchResult& matchResult, unsigned index, bool isImportant, bool inheritedOnly) 2130 { 2131 auto& matchedProperties = matchResult.matchedProperties()[index]; 2132 auto& styleProperties = *matchedProperties.properties; 2133 2134 auto propertyWhitelistType = static_cast<PropertyWhitelistType>(matchedProperties.whitelistType); 2135 auto cascadeLevel = cascadeLevelForIndex(matchResult, index); 2136 2137 for (unsigned i = 0, count = styleProperties.propertyCount(); i < count; ++i) { 2138 auto current = styleProperties.propertyAt(i); 2124 2139 if (isImportant != current.isImportant()) 2125 2140 continue; … … 2140 2155 2141 2156 if (shouldApplyPropertyInParseOrder(propertyID)) 2142 setDeferred(propertyID, *current.value(), linkMatchType, cascadeLevel);2157 setDeferred(propertyID, *current.value(), matchedProperties.linkMatchType, cascadeLevel, matchedProperties.styleScopeOrdinal); 2143 2158 else 2144 set(propertyID, *current.value(), linkMatchType, cascadeLevel); 2145 } 2146 } 2147 2148 static CascadeLevel cascadeLevelForIndex(const StyleResolver::MatchResult& matchResult, int index) 2149 { 2150 if (index >= matchResult.ranges.firstUARule && index <= matchResult.ranges.lastUARule) 2151 return UserAgentLevel; 2152 if (index >= matchResult.ranges.firstUserRule && index <= matchResult.ranges.lastUserRule) 2153 return UserLevel; 2154 return AuthorLevel; 2155 } 2156 2157 void StyleResolver::CascadedProperties::addMatch(const MatchResult& matchResult, unsigned index, bool isImportant, bool inheritedOnly) 2158 { 2159 const MatchedProperties& matchedProperties = matchResult.matchedProperties()[index]; 2160 2161 auto propertyWhitelistType = static_cast<PropertyWhitelistType>(matchedProperties.whitelistType); 2162 auto cascadeLevel = cascadeLevelForIndex(matchResult, index); 2163 2164 addStyleProperties(*matchedProperties.properties, isImportant, inheritedOnly, propertyWhitelistType, matchedProperties.linkMatchType, cascadeLevel); 2159 set(propertyID, *current.value(), matchedProperties.linkMatchType, cascadeLevel, matchedProperties.styleScopeOrdinal); 2160 } 2165 2161 } 2166 2162 … … 2190 2186 struct IndexAndOrdinal { 2191 2187 int index; 2192 intordinal;2188 Style::ScopeOrdinal ordinal; 2193 2189 }; 2194 2190 Vector<IndexAndOrdinal> shadowTreeMatches; … … 2200 2196 continue; 2201 2197 2202 if (matchedProperties. treeContextOrdinal) {2203 shadowTreeMatches.append({ i, matchedProperties. treeContextOrdinal });2198 if (matchedProperties.styleScopeOrdinal != Style::ScopeOrdinal::Element) { 2199 shadowTreeMatches.append({ i, matchedProperties.styleScopeOrdinal }); 2204 2200 continue; 2205 2201 } … … 2231 2227 State& state = resolver.state(); 2232 2228 state.setCascadeLevel(level); 2229 state.setStyleScopeOrdinal(styleScopeOrdinal); 2233 2230 2234 2231 if (cssValue[SelectorChecker::MatchDefault]) { -
trunk/Source/WebCore/css/StyleResolver.h
r208915 r209352 33 33 #include "SelectorChecker.h" 34 34 #include "StylePendingResources.h" 35 #include "StyleScope.h" 35 36 #include <bitset> 36 37 #include <memory> … … 251 252 uint16_t linkMatchType; 252 253 uint16_t whitelistType; 253 int treeContextOrdinal;254 Style::ScopeOrdinal styleScopeOrdinal; 254 255 }; 255 256 … … 262 263 const Vector<MatchedProperties, 64>& matchedProperties() const { return m_matchedProperties; } 263 264 264 void addMatchedProperties(const StyleProperties&, StyleRule* = nullptr, unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType = PropertyWhitelistNone, int treeContextOrdinal = 0);265 void addMatchedProperties(const StyleProperties&, StyleRule* = nullptr, unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType = PropertyWhitelistNone, Style::ScopeOrdinal = Style::ScopeOrdinal::Element); 265 266 private: 266 267 Vector<MatchedProperties, 64> m_matchedProperties; … … 277 278 CSSPropertyID id; 278 279 CascadeLevel level; 280 Style::ScopeOrdinal styleScopeOrdinal; 279 281 CSSValue* cssValue[3]; 280 282 }; … … 285 287 void addNormalMatches(const MatchResult&, int startIndex, int endIndex, bool inheritedOnly = false); 286 288 void addImportantMatches(const MatchResult&, int startIndex, int endIndex, bool inheritedOnly = false); 287 288 void set(CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel);289 void setDeferred(CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel);290 289 291 290 void applyDeferredProperties(StyleResolver&, const MatchResult*); … … 297 296 private: 298 297 void addMatch(const MatchResult&, unsigned index, bool isImportant, bool inheritedOnly); 299 void addStyleProperties(const StyleProperties&, bool isImportant, bool inheritedOnly, PropertyWhitelistType, unsigned linkMatchType, CascadeLevel); 300 static void setPropertyInternal(Property&, CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel); 298 void set(CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel, Style::ScopeOrdinal); 299 void setDeferred(CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel, Style::ScopeOrdinal); 300 static void setPropertyInternal(Property&, CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel, Style::ScopeOrdinal); 301 301 302 302 Property m_properties[numCSSProperties + 2]; … … 405 405 CascadeLevel cascadeLevel() const { return m_cascadeLevel; } 406 406 void setCascadeLevel(CascadeLevel level) { m_cascadeLevel = level; } 407 407 Style::ScopeOrdinal styleScopeOrdinal() const { return m_styleScopeOrdinal; } 408 void setStyleScopeOrdinal(Style::ScopeOrdinal styleScopeOrdinal) { m_styleScopeOrdinal = styleScopeOrdinal; } 409 408 410 CascadedProperties* authorRollback() const { return m_authorRollback.get(); } 409 411 CascadedProperties* userRollback() const { return m_userRollback.get(); } … … 440 442 441 443 CascadeLevel m_cascadeLevel { UserAgentLevel }; 444 Style::ScopeOrdinal m_styleScopeOrdinal { Style::ScopeOrdinal::Element }; 442 445 std::unique_ptr<CascadedProperties> m_authorRollback; 443 446 std::unique_ptr<CascadedProperties> m_userRollback; -
trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp
r208314 r209352 40 40 #include "StylePendingResources.h" 41 41 #include "StyleResolver.h" 42 #include "StyleScope.h" 42 43 #include "WillChangeData.h" 43 44 … … 364 365 auto& element = *m_object->element(); 365 366 366 element.styleResolver().keyframeStylesForAnimation(*m_object->element(), m_unanimatedStyle.get(), m_keyframes); 367 if (auto* styleScope = Style::Scope::forOrdinal(element, m_animation->nameStyleScopeOrdinal())) 368 styleScope->resolver().keyframeStylesForAnimation(*m_object->element(), m_unanimatedStyle.get(), m_keyframes); 367 369 368 370 // Ensure resource loads for all the frames. -
trunk/Source/WebCore/platform/animation/Animation.cpp
r194819 r209352 60 60 : RefCounted<Animation>() 61 61 , m_name(o.m_name) 62 , m_nameStyleScopeOrdinal(o.m_nameStyleScopeOrdinal) 62 63 , m_property(o.m_property) 63 64 , m_mode(o.m_mode) … … 91 92 { 92 93 m_name = o.m_name; 94 m_nameStyleScopeOrdinal = o.m_nameStyleScopeOrdinal; 93 95 m_property = o.m_property; 94 96 m_mode = o.m_mode; … … 131 133 { 132 134 bool result = m_name == other.m_name 135 && m_nameStyleScopeOrdinal == other.m_nameStyleScopeOrdinal 133 136 && m_property == other.m_property 134 137 && m_mode == other.m_mode -
trunk/Source/WebCore/platform/animation/Animation.h
r186894 r209352 33 33 #include "CSSPropertyNames.h" 34 34 #include "RenderStyleConstants.h" 35 #include "StyleScope.h" 35 36 #include "TimingFunction.h" 36 37 #include <wtf/PassRefPtr.h> … … 136 137 double iterationCount() const { return m_iterationCount; } 137 138 const String& name() const { return m_name; } 139 Style::ScopeOrdinal nameStyleScopeOrdinal() const { return m_nameStyleScopeOrdinal; } 138 140 EAnimPlayState playState() const { return static_cast<EAnimPlayState>(m_playState); } 139 141 CSSPropertyID property() const { return m_property; } … … 149 151 void setFillMode(unsigned f) { m_fillMode = f; m_fillModeSet = true; } 150 152 void setIterationCount(double c) { m_iterationCount = c; m_iterationCountSet = true; } 151 void setName(const String& n) { m_name = n; m_nameSet = true; } 153 void setName(const String& name, Style::ScopeOrdinal scope = Style::ScopeOrdinal::Element) 154 { 155 m_name = name; 156 m_nameStyleScopeOrdinal = scope; 157 m_nameSet = true; 158 } 152 159 void setPlayState(EAnimPlayState d) { m_playState = d; m_playStateSet = true; } 153 160 void setProperty(CSSPropertyID t) { m_property = t; m_propertySet = true; } … … 177 184 178 185 String m_name; 186 Style::ScopeOrdinal m_nameStyleScopeOrdinal { Style::ScopeOrdinal::Element }; 179 187 CSSPropertyID m_property; 180 188 AnimationMode m_mode; -
trunk/Source/WebCore/style/StyleScope.cpp
r208982 r209352 35 35 #include "HTMLIFrameElement.h" 36 36 #include "HTMLLinkElement.h" 37 #include "HTMLSlotElement.h" 37 38 #include "HTMLStyleElement.h" 38 39 #include "InspectorInstrumentation.h" … … 125 126 return shadowRoot->styleScope(); 126 127 return node.document().styleScope(); 128 } 129 130 Scope* Scope::forOrdinal(Element& element, ScopeOrdinal ordinal) 131 { 132 switch (ordinal) { 133 case ScopeOrdinal::Element: 134 return &forNode(element); 135 case ScopeOrdinal::ContainingHost: { 136 auto* containingShadowRoot = element.containingShadowRoot(); 137 if (!containingShadowRoot) 138 return nullptr; 139 return &forNode(*containingShadowRoot->host()); 140 } 141 case ScopeOrdinal::Shadow: { 142 auto* shadowRoot = element.shadowRoot(); 143 if (!shadowRoot) 144 return nullptr; 145 return &shadowRoot->styleScope(); 146 } 147 default: { 148 ASSERT(ordinal >= ScopeOrdinal::FirstSlot); 149 auto slotIndex = ScopeOrdinal::FirstSlot; 150 for (auto* slot = element.assignedSlot(); slot; slot = slot->assignedSlot(), ++slotIndex) { 151 if (slotIndex == ordinal) 152 return &forNode(*slot); 153 } 154 return nullptr; 155 } 156 } 127 157 } 128 158 -
trunk/Source/WebCore/style/StyleScope.h
r208985 r209352 41 41 class CSSStyleSheet; 42 42 class Document; 43 class Element; 43 44 class Node; 44 45 class StyleResolver; … … 50 51 51 52 namespace Style { 53 54 // This is used to identify style scopes that can affect an element. 55 // Scopes are in tree-of-trees order. Styles from earlier scopes win over later ones (modulo !important). 56 enum class ScopeOrdinal : int { 57 ContainingHost = -1, // Author-exposed UA pseudo classes from the host tree scope. 58 Element = 0, // Normal rules in the same tree where the element is. 59 FirstSlot = 1, // ::slotted rules in the parent's shadow tree. Values greater than FirstSlot indicate subsequent slots in the chain. 60 Shadow = std::numeric_limits<int>::max(), // :host rules in element's own shadow tree. 61 }; 52 62 53 63 class Scope { … … 103 113 104 114 static Scope& forNode(Node&); 115 static Scope* forOrdinal(Element&, ScopeOrdinal); 105 116 106 117 private: … … 165 176 } 166 177 178 inline ScopeOrdinal& operator++(ScopeOrdinal& ordinal) 179 { 180 ASSERT(ordinal < ScopeOrdinal::Shadow); 181 return ordinal = static_cast<ScopeOrdinal>(static_cast<int>(ordinal) + 1); 182 } 183 167 184 } 168 185 }
Note: See TracChangeset
for help on using the changeset viewer.