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