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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 StyleRuleBase* regionStylingRule = childRules[i].get(); | 358 StyleRuleBase* regionStylingRule = childRules[i].get(); |
359 if (regionStylingRule->isStyleRule()) | 359 if (regionStylingRule->isStyleRule()) |
360 regionRuleSet->addStyleRule(static_cast<StyleRule*>(regionStylingRul
e), addRuleFlags); | 360 regionRuleSet->addStyleRule(static_cast<StyleRule*>(regionStylingRul
e), addRuleFlags); |
361 } | 361 } |
362 // Update the "global" rule count so that proper order is maintained | 362 // Update the "global" rule count so that proper order is maintained |
363 m_ruleCount = regionRuleSet->m_ruleCount; | 363 m_ruleCount = regionRuleSet->m_ruleCount; |
364 | 364 |
365 m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selector
List().first(), regionRuleSet.release())); | 365 m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selector
List().first(), regionRuleSet.release())); |
366 } | 366 } |
367 | 367 |
368 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
ediaQueryEvaluator& medium, bool hasDocumentSecurityOrigin, AddRuleFlags addRule
Flags) | 368 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
ediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) |
369 { | 369 { |
370 for (unsigned i = 0; i < rules.size(); ++i) { | 370 for (unsigned i = 0; i < rules.size(); ++i) { |
371 StyleRuleBase* rule = rules[i].get(); | 371 StyleRuleBase* rule = rules[i].get(); |
372 | 372 |
373 if (rule->isStyleRule()) { | 373 if (rule->isStyleRule()) { |
374 StyleRule* styleRule = static_cast<StyleRule*>(rule); | 374 StyleRule* styleRule = static_cast<StyleRule*>(rule); |
375 | 375 |
376 const CSSSelectorList& selectorList = styleRule->selectorList(); | 376 const CSSSelectorList& selectorList = styleRule->selectorList(); |
377 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { | 377 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { |
378 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd
ex)) { | 378 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd
ex)) { |
379 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule
, selectorIndex, addRuleFlags)); | 379 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule
, selectorIndex, addRuleFlags)); |
380 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { | 380 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { |
381 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s
electorIndex, addRuleFlags)); | 381 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s
electorIndex, addRuleFlags)); |
382 } else { | 382 } else { |
383 addRule(styleRule, selectorIndex, addRuleFlags); | 383 addRule(styleRule, selectorIndex, addRuleFlags); |
384 } | 384 } |
385 } | 385 } |
386 } else if (rule->isPageRule()) { | 386 } else if (rule->isPageRule()) { |
387 addPageRule(static_cast<StyleRulePage*>(rule)); | 387 addPageRule(static_cast<StyleRulePage*>(rule)); |
388 } else if (rule->isMediaRule()) { | 388 } else if (rule->isMediaRule()) { |
389 StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule); | 389 StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule); |
390 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), &m_viewportDependentMediaQueryResults))) | 390 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), &m_viewportDependentMediaQueryResults))) |
391 addChildRules(mediaRule->childRules(), medium, hasDocumentSecuri
tyOrigin, addRuleFlags); | 391 addChildRules(mediaRule->childRules(), medium, addRuleFlags); |
392 } else if (rule->isFontFaceRule()) { | 392 } else if (rule->isFontFaceRule()) { |
393 addFontFaceRule(static_cast<StyleRuleFontFace*>(rule)); | 393 addFontFaceRule(static_cast<StyleRuleFontFace*>(rule)); |
394 } else if (rule->isKeyframesRule()) { | 394 } else if (rule->isKeyframesRule()) { |
395 addKeyframesRule(static_cast<StyleRuleKeyframes*>(rule)); | 395 addKeyframesRule(static_cast<StyleRuleKeyframes*>(rule)); |
396 } else if (rule->isRegionRule()) { | 396 } else if (rule->isRegionRule()) { |
397 addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecuri
tyOrigin); | 397 addRegionRule(static_cast<StyleRuleRegion*>(rule), addRuleFlags & Ru
leHasDocumentSecurityOrigin); |
398 } else if (rule->isHostRule()) { | 398 } else if (rule->isHostRule()) { |
399 addHostRule(static_cast<StyleRuleHost*>(rule)); | 399 addHostRule(static_cast<StyleRuleHost*>(rule)); |
400 } else if (rule->isViewportRule()) { | 400 } else if (rule->isViewportRule() && !(addRuleFlags & ViewportRuleIsProc
essed)) { |
401 addViewportRule(static_cast<StyleRuleViewport*>(rule)); | 401 addViewportRule(static_cast<StyleRuleViewport*>(rule)); |
402 } else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rul
e)->conditionIsSupported()) { | 402 } else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rul
e)->conditionIsSupported()) { |
403 addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), m
edium, hasDocumentSecurityOrigin, addRuleFlags); | 403 addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), m
edium, addRuleFlags); |
404 } | 404 } |
405 } | 405 } |
406 } | 406 } |
407 | 407 |
408 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, bool hasDocumentSecurityOrigin) | 408 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, AddRuleFlags addRuleFlags) |
409 { | 409 { |
410 ASSERT(sheet); | 410 ASSERT(sheet); |
411 | 411 |
412 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules(); | 412 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules(); |
413 for (unsigned i = 0; i < importRules.size(); ++i) { | 413 for (unsigned i = 0; i < importRules.size(); ++i) { |
414 StyleRuleImport* importRule = importRules[i].get(); | 414 StyleRuleImport* importRule = importRules[i].get(); |
415 if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.e
val(importRule->mediaQueries(), &m_viewportDependentMediaQueryResults))) | 415 if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.e
val(importRule->mediaQueries(), &m_viewportDependentMediaQueryResults))) |
416 addRulesFromSheet(importRule->styleSheet(), medium); | 416 addRulesFromSheet(importRule->styleSheet(), medium, addRuleFlags); |
417 } | 417 } |
418 | 418 |
419 AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOr
igin ? RuleHasDocumentSecurityOrigin : 0) | RuleCanUseFastCheckSelector); | 419 addChildRules(sheet->childRules(), medium, static_cast<AddRuleFlags>(addRule
Flags | RuleCanUseFastCheckSelector)); |
420 addChildRules(sheet->childRules(), medium, hasDocumentSecurityOrigin, addRul
eFlags); | |
421 } | 420 } |
422 | 421 |
423 void RuleSet::addStyleRule(StyleRule* rule, AddRuleFlags addRuleFlags) | 422 void RuleSet::addStyleRule(StyleRule* rule, AddRuleFlags addRuleFlags) |
424 { | 423 { |
425 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = r
ule->selectorList().indexOfNextSelectorAfter(selectorIndex)) | 424 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = r
ule->selectorList().indexOfNextSelectorAfter(selectorIndex)) |
426 addRule(rule, selectorIndex, addRuleFlags); | 425 addRule(rule, selectorIndex, addRuleFlags); |
427 } | 426 } |
428 | 427 |
429 void RuleSet::compactPendingRules(PendingRuleMap& pendingMap, CompactRuleMap& co
mpactMap) | 428 void RuleSet::compactPendingRules(PendingRuleMap& pendingMap, CompactRuleMap& co
mpactMap) |
430 { | 429 { |
(...skipping 28 matching lines...) Expand all Loading... |
459 m_pageRules.shrinkToFit(); | 458 m_pageRules.shrinkToFit(); |
460 m_viewportRules.shrinkToFit(); | 459 m_viewportRules.shrinkToFit(); |
461 m_fontFaceRules.shrinkToFit(); | 460 m_fontFaceRules.shrinkToFit(); |
462 m_keyframesRules.shrinkToFit(); | 461 m_keyframesRules.shrinkToFit(); |
463 m_hostRules.shrinkToFit(); | 462 m_hostRules.shrinkToFit(); |
464 m_treeBoundaryCrossingRules.shrinkToFit(); | 463 m_treeBoundaryCrossingRules.shrinkToFit(); |
465 m_shadowDistributedRules.shrinkToFit(); | 464 m_shadowDistributedRules.shrinkToFit(); |
466 } | 465 } |
467 | 466 |
468 } // namespace WebCore | 467 } // namespace WebCore |
OLD | NEW |