| 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 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (current->isAttributeSelector()) | 104 if (current->isAttributeSelector()) |
| 105 return true; | 105 return true; |
| 106 if (selectorListContainsUncommonAttributeSelector(current)) | 106 if (selectorListContainsUncommonAttributeSelector(current)) |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) | 112 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) |
| 113 { | 113 { |
| 114 if (addRuleFlags & RuleIsInRegionRule) | |
| 115 return PropertyWhitelistRegion; | |
| 116 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { | 114 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { |
| 117 if (component->pseudoType() == CSSSelector::PseudoCue || (component->m_m
atch == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha
dowPseudoId())) | 115 if (component->pseudoType() == CSSSelector::PseudoCue || (component->m_m
atch == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha
dowPseudoId())) |
| 118 return PropertyWhitelistCue; | 116 return PropertyWhitelistCue; |
| 119 } | 117 } |
| 120 return PropertyWhitelistNone; | 118 return PropertyWhitelistNone; |
| 121 } | 119 } |
| 122 | 120 |
| 123 namespace { | 121 namespace { |
| 124 | 122 |
| 125 // FIXME: Should we move this class to WTF? | 123 // FIXME: Should we move this class to WTF? |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. | 321 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. |
| 324 m_fontFaceRules.append(rule); | 322 m_fontFaceRules.append(rule); |
| 325 } | 323 } |
| 326 | 324 |
| 327 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule) | 325 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule) |
| 328 { | 326 { |
| 329 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called. | 327 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called. |
| 330 m_keyframesRules.append(rule); | 328 m_keyframesRules.append(rule); |
| 331 } | 329 } |
| 332 | 330 |
| 333 void RuleSet::addRegionRule(StyleRuleRegion* regionRule, bool hasDocumentSecurit
yOrigin) | |
| 334 { | |
| 335 ensurePendingRules(); // So that m_regionSelectorsAndRuleSets.shrinkToFit()
gets called. | |
| 336 OwnPtr<RuleSet> regionRuleSet = RuleSet::create(); | |
| 337 // The region rule set should take into account the position inside the pare
nt rule set. | |
| 338 // Otherwise, the rules inside region block might be incorrectly positioned
before other similar rules from | |
| 339 // the stylesheet that contains the region block. | |
| 340 regionRuleSet->m_ruleCount = m_ruleCount; | |
| 341 | |
| 342 // Collect the region rules into a rule set | |
| 343 // FIXME: Should this add other types of rules? (i.e. use addChildRules() di
rectly?) | |
| 344 const Vector<RefPtr<StyleRuleBase> >& childRules = regionRule->childRules(); | |
| 345 AddRuleFlags addRuleFlags = hasDocumentSecurityOrigin ? RuleHasDocumentSecur
ityOrigin : RuleHasNoSpecialState; | |
| 346 addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | RuleIsInRegionRule |
RuleCanUseFastCheckSelector); | |
| 347 for (unsigned i = 0; i < childRules.size(); ++i) { | |
| 348 StyleRuleBase* regionStylingRule = childRules[i].get(); | |
| 349 if (regionStylingRule->isStyleRule()) | |
| 350 regionRuleSet->addStyleRule(toStyleRule(regionStylingRule), addRuleF
lags); | |
| 351 } | |
| 352 // Update the "global" rule count so that proper order is maintained | |
| 353 m_ruleCount = regionRuleSet->m_ruleCount; | |
| 354 | |
| 355 m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selector
List().first(), regionRuleSet.release())); | |
| 356 } | |
| 357 | |
| 358 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
ediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) | 331 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
ediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) |
| 359 { | 332 { |
| 360 for (unsigned i = 0; i < rules.size(); ++i) { | 333 for (unsigned i = 0; i < rules.size(); ++i) { |
| 361 StyleRuleBase* rule = rules[i].get(); | 334 StyleRuleBase* rule = rules[i].get(); |
| 362 | 335 |
| 363 if (rule->isStyleRule()) { | 336 if (rule->isStyleRule()) { |
| 364 StyleRule* styleRule = toStyleRule(rule); | 337 StyleRule* styleRule = toStyleRule(rule); |
| 365 | 338 |
| 366 const CSSSelectorList& selectorList = styleRule->selectorList(); | 339 const CSSSelectorList& selectorList = styleRule->selectorList(); |
| 367 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { | 340 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { |
| 368 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd
ex)) { | 341 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd
ex)) { |
| 369 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule
, selectorIndex, addRuleFlags)); | 342 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule
, selectorIndex, addRuleFlags)); |
| 370 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { | 343 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { |
| 371 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s
electorIndex, addRuleFlags)); | 344 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s
electorIndex, addRuleFlags)); |
| 372 } else { | 345 } else { |
| 373 addRule(styleRule, selectorIndex, addRuleFlags); | 346 addRule(styleRule, selectorIndex, addRuleFlags); |
| 374 } | 347 } |
| 375 } | 348 } |
| 376 } else if (rule->isPageRule()) { | 349 } else if (rule->isPageRule()) { |
| 377 addPageRule(toStyleRulePage(rule)); | 350 addPageRule(toStyleRulePage(rule)); |
| 378 } else if (rule->isMediaRule()) { | 351 } else if (rule->isMediaRule()) { |
| 379 StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); | 352 StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); |
| 380 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), &m_viewportDependentMediaQueryResults))) | 353 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), &m_viewportDependentMediaQueryResults))) |
| 381 addChildRules(mediaRule->childRules(), medium, addRuleFlags); | 354 addChildRules(mediaRule->childRules(), medium, addRuleFlags); |
| 382 } else if (rule->isFontFaceRule()) { | 355 } else if (rule->isFontFaceRule()) { |
| 383 addFontFaceRule(toStyleRuleFontFace(rule)); | 356 addFontFaceRule(toStyleRuleFontFace(rule)); |
| 384 } else if (rule->isKeyframesRule()) { | 357 } else if (rule->isKeyframesRule()) { |
| 385 addKeyframesRule(toStyleRuleKeyframes(rule)); | 358 addKeyframesRule(toStyleRuleKeyframes(rule)); |
| 386 } else if (rule->isRegionRule()) { | |
| 387 addRegionRule(toStyleRuleRegion(rule), addRuleFlags & RuleHasDocumen
tSecurityOrigin); | |
| 388 } else if (rule->isViewportRule()) { | 359 } else if (rule->isViewportRule()) { |
| 389 addViewportRule(toStyleRuleViewport(rule)); | 360 addViewportRule(toStyleRuleViewport(rule)); |
| 390 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio
nIsSupported()) { | 361 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio
nIsSupported()) { |
| 391 addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRu
leFlags); | 362 addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRu
leFlags); |
| 392 } | 363 } |
| 393 } | 364 } |
| 394 } | 365 } |
| 395 | 366 |
| 396 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, AddRuleFlags addRuleFlags) | 367 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, AddRuleFlags addRuleFlags) |
| 397 { | 368 { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 m_universalRules.shrinkToFit(); | 417 m_universalRules.shrinkToFit(); |
| 447 m_pageRules.shrinkToFit(); | 418 m_pageRules.shrinkToFit(); |
| 448 m_viewportRules.shrinkToFit(); | 419 m_viewportRules.shrinkToFit(); |
| 449 m_fontFaceRules.shrinkToFit(); | 420 m_fontFaceRules.shrinkToFit(); |
| 450 m_keyframesRules.shrinkToFit(); | 421 m_keyframesRules.shrinkToFit(); |
| 451 m_treeBoundaryCrossingRules.shrinkToFit(); | 422 m_treeBoundaryCrossingRules.shrinkToFit(); |
| 452 m_shadowDistributedRules.shrinkToFit(); | 423 m_shadowDistributedRules.shrinkToFit(); |
| 453 } | 424 } |
| 454 | 425 |
| 455 } // namespace WebCore | 426 } // namespace WebCore |
| OLD | NEW |