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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/css/resolver/StyleResolver.h" | 44 #include "core/css/resolver/StyleResolver.h" |
45 #include "core/html/track/TextTrackCue.h" | 45 #include "core/html/track/TextTrackCue.h" |
46 #include "weborigin/SecurityOrigin.h" | 46 #include "weborigin/SecurityOrigin.h" |
47 | 47 |
48 namespace WebCore { | 48 namespace WebCore { |
49 | 49 |
50 using namespace HTMLNames; | 50 using namespace HTMLNames; |
51 | 51 |
52 // ----------------------------------------------------------------- | 52 // ----------------------------------------------------------------- |
53 | 53 |
54 static inline bool isDocumentScope(const ContainerNode* scope) | |
55 { | |
56 return !scope || scope->isDocumentNode(); | |
57 } | |
58 | |
59 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector* sele
ctor) | 54 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector* sele
ctor) |
60 { | 55 { |
61 ASSERT(selector); | 56 ASSERT(selector); |
62 if (selector->m_match == CSSSelector::Tag) { | 57 if (selector->m_match == CSSSelector::Tag) { |
63 const AtomicString& selectorNamespace = selector->tagQName().namespaceUR
I(); | 58 const AtomicString& selectorNamespace = selector->tagQName().namespaceUR
I(); |
64 if (selectorNamespace != starAtom && selectorNamespace != xhtmlNamespace
URI) | 59 if (selectorNamespace != starAtom && selectorNamespace != xhtmlNamespace
URI) |
65 return false; | 60 return false; |
66 if (selector->relation() == CSSSelector::SubSelector) | 61 if (selector->relation() == CSSSelector::SubSelector) |
67 return isSelectorMatchingHTMLBasedOnRuleHash(selector->tagHistory())
; | 62 return isSelectorMatchingHTMLBasedOnRuleHash(selector->tagHistory())
; |
68 return true; | 63 return true; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), resolver->viewportDependentMediaQueryResults()))) | 392 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri
es(), resolver->viewportDependentMediaQueryResults()))) |
398 addChildRules(mediaRule->childRules(), medium, resolver, scope,
hasDocumentSecurityOrigin, addRuleFlags); | 393 addChildRules(mediaRule->childRules(), medium, resolver, scope,
hasDocumentSecurityOrigin, addRuleFlags); |
399 } else if (rule->isFontFaceRule()) { | 394 } else if (rule->isFontFaceRule()) { |
400 addFontFaceRule(static_cast<StyleRuleFontFace*>(rule)); | 395 addFontFaceRule(static_cast<StyleRuleFontFace*>(rule)); |
401 } else if (rule->isKeyframesRule()) { | 396 } else if (rule->isKeyframesRule()) { |
402 addKeyframesRule(static_cast<StyleRuleKeyframes*>(rule)); | 397 addKeyframesRule(static_cast<StyleRuleKeyframes*>(rule)); |
403 } else if (rule->isRegionRule()) { | 398 } else if (rule->isRegionRule()) { |
404 addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecuri
tyOrigin); | 399 addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecuri
tyOrigin); |
405 } else if (rule->isHostRule()) { | 400 } else if (rule->isHostRule()) { |
406 addHostRule(static_cast<StyleRuleHost*>(rule)); | 401 addHostRule(static_cast<StyleRuleHost*>(rule)); |
407 } else if (rule->isViewportRule()) { | 402 } else if (rule->isViewportRule() && !(addRuleFlags & ViewportRuleIsProc
essed)) { |
408 addViewportRule(static_cast<StyleRuleViewport*>(rule)); | 403 addViewportRule(static_cast<StyleRuleViewport*>(rule)); |
409 } else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rul
e)->conditionIsSupported()) { | 404 } else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rul
e)->conditionIsSupported()) { |
410 addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), m
edium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags); | 405 addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), m
edium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags); |
411 } | 406 } |
412 } | 407 } |
413 } | 408 } |
414 | 409 |
415 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, StyleResolver* resolver, const ContainerNode* scope) | 410 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
ator& medium, StyleResolver* resolver, const ContainerNode* scope, bool viewport
RuleIsProcessed) |
416 { | 411 { |
417 ASSERT(sheet); | 412 ASSERT(sheet); |
418 | 413 |
419 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules(); | 414 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules(); |
420 for (unsigned i = 0; i < importRules.size(); ++i) { | 415 for (unsigned i = 0; i < importRules.size(); ++i) { |
421 StyleRuleImport* importRule = importRules[i].get(); | 416 StyleRuleImport* importRule = importRules[i].get(); |
422 if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.e
val(importRule->mediaQueries(), resolver->viewportDependentMediaQueryResults()))
) | 417 if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.e
val(importRule->mediaQueries(), resolver->viewportDependentMediaQueryResults()))
) |
423 addRulesFromSheet(importRule->styleSheet(), medium, resolver, scope)
; | 418 addRulesFromSheet(importRule->styleSheet(), medium, resolver, scope,
viewportRuleIsProcessed); |
424 } | 419 } |
425 | 420 |
426 bool hasDocumentSecurityOrigin = resolver && resolver->document().securityOr
igin()->canRequest(sheet->baseURL()); | 421 bool hasDocumentSecurityOrigin = resolver && resolver->document().securityOr
igin()->canRequest(sheet->baseURL()); |
427 AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOr
igin ? RuleHasDocumentSecurityOrigin : 0) | (!scope ? RuleCanUseFastCheckSelecto
r : 0)); | 422 AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOr
igin ? RuleHasDocumentSecurityOrigin : 0) | (!scope ? RuleCanUseFastCheckSelecto
r : 0) | (viewportRuleIsProcessed ? ViewportRuleIsProcessed : 0)); |
428 | 423 |
429 addChildRules(sheet->childRules(), medium, resolver, scope, hasDocumentSecur
ityOrigin, addRuleFlags); | 424 addChildRules(sheet->childRules(), medium, resolver, scope, hasDocumentSecur
ityOrigin, addRuleFlags); |
430 } | 425 } |
431 | 426 |
432 void RuleSet::addStyleRule(StyleRule* rule, AddRuleFlags addRuleFlags) | 427 void RuleSet::addStyleRule(StyleRule* rule, AddRuleFlags addRuleFlags) |
433 { | 428 { |
434 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = r
ule->selectorList().indexOfNextSelectorAfter(selectorIndex)) | 429 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = r
ule->selectorList().indexOfNextSelectorAfter(selectorIndex)) |
435 addRule(rule, selectorIndex, addRuleFlags); | 430 addRule(rule, selectorIndex, addRuleFlags); |
436 } | 431 } |
437 | 432 |
(...skipping 26 matching lines...) Expand all Loading... |
464 m_linkPseudoClassRules.shrinkToFit(); | 459 m_linkPseudoClassRules.shrinkToFit(); |
465 m_cuePseudoRules.shrinkToFit(); | 460 m_cuePseudoRules.shrinkToFit(); |
466 m_focusPseudoClassRules.shrinkToFit(); | 461 m_focusPseudoClassRules.shrinkToFit(); |
467 m_universalRules.shrinkToFit(); | 462 m_universalRules.shrinkToFit(); |
468 m_pageRules.shrinkToFit(); | 463 m_pageRules.shrinkToFit(); |
469 m_viewportRules.shrinkToFit(); | 464 m_viewportRules.shrinkToFit(); |
470 m_fontFaceRules.shrinkToFit(); | 465 m_fontFaceRules.shrinkToFit(); |
471 } | 466 } |
472 | 467 |
473 } // namespace WebCore | 468 } // namespace WebCore |
OLD | NEW |