| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 void StyleResolver::resetRuleFeatures() | 240 void StyleResolver::resetRuleFeatures() |
| 241 { | 241 { |
| 242 // Need to recreate RuleFeatureSet. | 242 // Need to recreate RuleFeatureSet. |
| 243 m_features.clear(); | 243 m_features.clear(); |
| 244 m_siblingRuleSet.clear(); | 244 m_siblingRuleSet.clear(); |
| 245 m_uncommonAttributeRuleSet.clear(); | 245 m_uncommonAttributeRuleSet.clear(); |
| 246 m_needCollectFeatures = true; | 246 m_needCollectFeatures = true; |
| 247 } | 247 } |
| 248 | 248 |
| 249 void StyleResolver::addTreeBoundaryCrossingRules(const WillBeHeapVector<MinimalR
uleData>& rules, ContainerNode* scope) | 249 void StyleResolver::addTreeBoundaryCrossingRules(const WillBeHeapVector<MinimalR
uleData>& rules, ContainerNode* scope, CSSStyleSheet* parentStyleSheet) |
| 250 { | 250 { |
| 251 for (unsigned i = 0; i < rules.size(); ++i) { | 251 for (unsigned i = 0; i < rules.size(); ++i) { |
| 252 const MinimalRuleData& info = rules[i]; | 252 const MinimalRuleData& info = rules[i]; |
| 253 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s
cope, info.m_flags); | 253 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s
cope, parentStyleSheet, info.m_flags); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 void StyleResolver::processScopedRules(const RuleSet& authorRules, const KURL& s
heetBaseURL, ContainerNode* scope) | 257 void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet
* parentStyleSheet, ContainerNode* scope) |
| 258 { | 258 { |
| 259 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes> > keyframesRul
es = authorRules.keyframesRules(); | 259 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes> > keyframesRul
es = authorRules.keyframesRules(); |
| 260 for (unsigned i = 0; i < keyframesRules.size(); ++i) | 260 for (unsigned i = 0; i < keyframesRules.size(); ++i) |
| 261 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); | 261 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); |
| 262 | 262 |
| 263 addTreeBoundaryCrossingRules(authorRules.treeBoundaryCrossingRules(), scope)
; | 263 addTreeBoundaryCrossingRules(authorRules.treeBoundaryCrossingRules(), scope,
parentStyleSheet); |
| 264 | 264 |
| 265 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. | 265 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. |
| 266 if (!scope || scope->isDocumentNode()) { | 266 if (!scope || scope->isDocumentNode()) { |
| 267 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace> > fontFaceR
ules = authorRules.fontFaceRules(); | 267 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace> > fontFaceR
ules = authorRules.fontFaceRules(); |
| 268 for (unsigned i = 0; i < fontFaceRules.size(); ++i) | 268 for (unsigned i = 0; i < fontFaceRules.size(); ++i) |
| 269 addFontFaceRule(&m_document, document().styleEngine()->fontSelector(
), fontFaceRules[i]); | 269 addFontFaceRule(&m_document, document().styleEngine()->fontSelector(
), fontFaceRules[i]); |
| 270 if (fontFaceRules.size()) | 270 if (fontFaceRules.size()) |
| 271 invalidateMatchedPropertiesCache(); | 271 invalidateMatchedPropertiesCache(); |
| 272 } else { | 272 } else { |
| 273 addTreeBoundaryCrossingRules(authorRules.shadowDistributedRules(), scope
); | 273 addTreeBoundaryCrossingRules(authorRules.shadowDistributedRules(), scope
, parentStyleSheet); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) | 277 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) |
| 278 { | 278 { |
| 279 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh
ild has been already modified. | 279 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh
ild has been already modified. |
| 280 // So we cannot use hasScopedHTMLStyleChild flag here. | 280 // So we cannot use hasScopedHTMLStyleChild flag here. |
| 281 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR
esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | 281 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR
esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); |
| 282 if (!resolver) | 282 if (!resolver) |
| 283 return; | 283 return; |
| 284 | 284 |
| 285 treeBoundaryCrossingRules().reset(scopingNode); | 285 m_treeBoundaryCrossingRules.reset(scopingNode); |
| 286 | 286 |
| 287 resolver->resetAuthorStyle(); | 287 resolver->resetAuthorStyle(); |
| 288 resetRuleFeatures(); | 288 resetRuleFeatures(); |
| 289 if (!scopingNode) | 289 if (!scopingNode) |
| 290 return; | 290 return; |
| 291 | 291 |
| 292 m_styleTree.remove(scopingNode); | 292 m_styleTree.remove(scopingNode); |
| 293 } | 293 } |
| 294 | 294 |
| 295 static PassOwnPtrWillBeRawPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& ru
les) | 295 static PassOwnPtrWillBeRawPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& ru
les) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 CascadeOrder innerCascadeOrder = m_treeBoundaryCrossingRules.size(); | 413 CascadeOrder innerCascadeOrder = m_treeBoundaryCrossingRules.size(); |
| 414 | 414 |
| 415 for (DocumentOrderedList::iterator it = m_treeBoundaryCrossingRules.begin();
it != m_treeBoundaryCrossingRules.end(); ++it) { | 415 for (DocumentOrderedList::iterator it = m_treeBoundaryCrossingRules.begin();
it != m_treeBoundaryCrossingRules.end(); ++it) { |
| 416 const ContainerNode* scopingNode = toContainerNode(*it); | 416 const ContainerNode* scopingNode = toContainerNode(*it); |
| 417 | 417 |
| 418 if (ShadowRoot* shadowRoot = scopingNode->containingShadowRoot()) { | 418 if (ShadowRoot* shadowRoot = scopingNode->containingShadowRoot()) { |
| 419 if (!shadowRoot->isActiveForStyling()) | 419 if (!shadowRoot->isActiveForStyling()) |
| 420 continue; | 420 continue; |
| 421 } | 421 } |
| 422 | 422 |
| 423 RuleSet* ruleSet = m_treeBoundaryCrossingRules.ruleSetScopedBy(scopingNo
de); | 423 TreeBoundaryCrossingRules::CSSStyleSheetRuleSubSet* styleSheetsRuleSubSe
ts = m_treeBoundaryCrossingRules.ruleSetScopedBy(scopingNode); |
| 424 unsigned boundaryBehavior = SelectorChecker::ScopeContainsLastMatchedEle
ment; | 424 unsigned boundaryBehavior = SelectorChecker::ScopeContainsLastMatchedEle
ment; |
| 425 bool isInnerTreeScope = element->treeScope().isInclusiveAncestorOf(scopi
ngNode->treeScope()); | 425 bool isInnerTreeScope = element->treeScope().isInclusiveAncestorOf(scopi
ngNode->treeScope()); |
| 426 | 426 |
| 427 // If a given scoping node is a shadow root and a given element is in a
descendant tree of tree hosted by | 427 // If a given scoping node is a shadow root and a given element is in a
descendant tree of tree hosted by |
| 428 // the scoping node's shadow host, we should use ScopeIsShadowHost. | 428 // the scoping node's shadow host, we should use ScopeIsShadowHost. |
| 429 if (scopingNode && scopingNode->isShadowRoot()) { | 429 if (scopingNode && scopingNode->isShadowRoot()) { |
| 430 if (element->isInDescendantTreeOf(toShadowRoot(scopingNode)->host())
) | 430 if (element->isInDescendantTreeOf(toShadowRoot(scopingNode)->host())
) |
| 431 boundaryBehavior |= SelectorChecker::ScopeIsShadowHost; | 431 boundaryBehavior |= SelectorChecker::ScopeIsShadowHost; |
| 432 scopingNode = toShadowRoot(scopingNode)->host(); | 432 scopingNode = toShadowRoot(scopingNode)->host(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 CascadeOrder cascadeOrder = isInnerTreeScope ? innerCascadeOrder : outer
CascadeOrder; | 435 CascadeOrder cascadeOrder = isInnerTreeScope ? innerCascadeOrder : outer
CascadeOrder; |
| 436 | 436 for (TreeBoundaryCrossingRules::CSSStyleSheetRuleSubSet::iterator it = s
tyleSheetsRuleSubSets->begin(); it != styleSheetsRuleSubSets->end(); ++it) { |
| 437 collector.collectMatchingRules(MatchRequest(ruleSet, includeEmptyRules,
scopingNode), ruleRange, static_cast<SelectorChecker::BehaviorAtBoundary>(bounda
ryBehavior), ignoreCascadeScope, cascadeOrder); | 437 RuleSet* ruleSet = it->value.get(); |
| 438 collector.collectMatchingRules(MatchRequest(ruleSet, includeEmptyRul
es, scopingNode, it->key), ruleRange, static_cast<SelectorChecker::BehaviorAtBou
ndary>(boundaryBehavior), ignoreCascadeScope, cascadeOrder); |
| 439 } |
| 438 ++innerCascadeOrder; | 440 ++innerCascadeOrder; |
| 439 --outerCascadeOrder; | 441 --outerCascadeOrder; |
| 440 } | 442 } |
| 441 } | 443 } |
| 442 | 444 |
| 443 static inline bool applyAuthorStylesOf(const Element* element) | 445 static inline bool applyAuthorStylesOf(const Element* element) |
| 444 { | 446 { |
| 445 return element->treeScope().applyAuthorStyles() || (element->shadow() && ele
ment->shadow()->applyAuthorStyles()); | 447 return element->treeScope().applyAuthorStyles() || (element->shadow() && ele
ment->shadow()->applyAuthorStyles()); |
| 446 } | 448 } |
| 447 | 449 |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 bool StyleResolver::mediaQueryAffectedByViewportChange() const | 1421 bool StyleResolver::mediaQueryAffectedByViewportChange() const |
| 1420 { | 1422 { |
| 1421 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1423 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
| 1422 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1424 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
| 1423 return true; | 1425 return true; |
| 1424 } | 1426 } |
| 1425 return false; | 1427 return false; |
| 1426 } | 1428 } |
| 1427 | 1429 |
| 1428 } // namespace WebCore | 1430 } // namespace WebCore |
| OLD | NEW |