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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. | 294 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. |
297 m_fontFaceRules.append(rule); | 295 m_fontFaceRules.append(rule); |
298 } | 296 } |
299 | 297 |
300 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule) | 298 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule) |
301 { | 299 { |
302 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called. | 300 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called. |
303 m_keyframesRules.append(rule); | 301 m_keyframesRules.append(rule); |
304 } | 302 } |
305 | 303 |
306 void RuleSet::addRegionRule(StyleRuleRegion* regionRule, bool hasDocumentSecurit
yOrigin) | |
307 { | |
308 ensurePendingRules(); // So that m_regionSelectorsAndRuleSets.shrinkToFit()
gets called. | |
309 OwnPtr<RuleSet> regionRuleSet = RuleSet::create(); | |
310 // The region rule set should take into account the position inside the pare
nt rule set. | |
311 // Otherwise, the rules inside region block might be incorrectly positioned
before other similar rules from | |
312 // the stylesheet that contains the region block. | |
313 regionRuleSet->m_ruleCount = m_ruleCount; | |
314 | |
315 // Collect the region rules into a rule set | |
316 // FIXME: Should this add other types of rules? (i.e. use addChildRules() di
rectly?) | |
317 const Vector<RefPtr<StyleRuleBase> >& childRules = regionRule->childRules(); | |
318 AddRuleFlags addRuleFlags = hasDocumentSecurityOrigin ? RuleHasDocumentSecur
ityOrigin : RuleHasNoSpecialState; | |
319 addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | RuleIsInRegionRule |
RuleCanUseFastCheckSelector); | |
320 for (unsigned i = 0; i < childRules.size(); ++i) { | |
321 StyleRuleBase* regionStylingRule = childRules[i].get(); | |
322 if (regionStylingRule->isStyleRule()) | |
323 regionRuleSet->addStyleRule(toStyleRule(regionStylingRule), addRuleF
lags); | |
324 } | |
325 // Update the "global" rule count so that proper order is maintained | |
326 m_ruleCount = regionRuleSet->m_ruleCount; | |
327 | |
328 m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selector
List().first(), regionRuleSet.release())); | |
329 } | |
330 | |
331 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
ediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) | 304 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
ediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) |
332 { | 305 { |
333 for (unsigned i = 0; i < rules.size(); ++i) { | 306 for (unsigned i = 0; i < rules.size(); ++i) { |
334 StyleRuleBase* rule = rules[i].get(); | 307 StyleRuleBase* rule = rules[i].get(); |
335 | 308 |
336 if (rule->isStyleRule()) { | 309 if (rule->isStyleRule()) { |
337 StyleRule* styleRule = toStyleRule(rule); | 310 StyleRule* styleRule = toStyleRule(rule); |
338 | 311 |
339 const CSSSelectorList& selectorList = styleRule->selectorList(); | 312 const CSSSelectorList& selectorList = styleRule->selectorList(); |
340 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { | 313 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { |
341 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd
ex)) { | 314 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd
ex)) { |
342 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule
, selectorIndex, addRuleFlags)); | 315 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule
, selectorIndex, addRuleFlags)); |
343 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { | 316 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { |
344 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s
electorIndex, addRuleFlags)); | 317 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s
electorIndex, addRuleFlags)); |
345 } else { | 318 } else { |
346 addRule(styleRule, selectorIndex, addRuleFlags); | 319 addRule(styleRule, selectorIndex, addRuleFlags); |
347 } | 320 } |
348 } | 321 } |
349 } else if (rule->isPageRule()) { | 322 } else if (rule->isPageRule()) { |
350 addPageRule(toStyleRulePage(rule)); | 323 addPageRule(toStyleRulePage(rule)); |
351 } else if (rule->isMediaRule()) { | 324 } else if (rule->isMediaRule()) { |
352 StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); | 325 StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); |
353 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), &m_viewportDependentMediaQueryResults))) | 326 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), &m_viewportDependentMediaQueryResults))) |
354 addChildRules(mediaRule->childRules(), medium, addRuleFlags); | 327 addChildRules(mediaRule->childRules(), medium, addRuleFlags); |
355 } else if (rule->isFontFaceRule()) { | 328 } else if (rule->isFontFaceRule()) { |
356 addFontFaceRule(toStyleRuleFontFace(rule)); | 329 addFontFaceRule(toStyleRuleFontFace(rule)); |
357 } else if (rule->isKeyframesRule()) { | 330 } else if (rule->isKeyframesRule()) { |
358 addKeyframesRule(toStyleRuleKeyframes(rule)); | 331 addKeyframesRule(toStyleRuleKeyframes(rule)); |
359 } else if (rule->isRegionRule()) { | |
360 addRegionRule(toStyleRuleRegion(rule), addRuleFlags & RuleHasDocumen
tSecurityOrigin); | |
361 } else if (rule->isViewportRule()) { | 332 } else if (rule->isViewportRule()) { |
362 addViewportRule(toStyleRuleViewport(rule)); | 333 addViewportRule(toStyleRuleViewport(rule)); |
363 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio
nIsSupported()) { | 334 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio
nIsSupported()) { |
364 addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRu
leFlags); | 335 addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRu
leFlags); |
365 } | 336 } |
366 } | 337 } |
367 } | 338 } |
368 | 339 |
369 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, AddRuleFlags addRuleFlags) | 340 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, AddRuleFlags addRuleFlags) |
370 { | 341 { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 m_universalRules.shrinkToFit(); | 390 m_universalRules.shrinkToFit(); |
420 m_pageRules.shrinkToFit(); | 391 m_pageRules.shrinkToFit(); |
421 m_viewportRules.shrinkToFit(); | 392 m_viewportRules.shrinkToFit(); |
422 m_fontFaceRules.shrinkToFit(); | 393 m_fontFaceRules.shrinkToFit(); |
423 m_keyframesRules.shrinkToFit(); | 394 m_keyframesRules.shrinkToFit(); |
424 m_treeBoundaryCrossingRules.shrinkToFit(); | 395 m_treeBoundaryCrossingRules.shrinkToFit(); |
425 m_shadowDistributedRules.shrinkToFit(); | 396 m_shadowDistributedRules.shrinkToFit(); |
426 } | 397 } |
427 | 398 |
428 } // namespace WebCore | 399 } // namespace WebCore |
OLD | NEW |