OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 if (!styleElement->scoped()) | 58 if (!styleElement->scoped()) |
59 return styleElement->isInShadowTree() ? styleElement->containingShadowRo
ot() : 0; | 59 return styleElement->isInShadowTree() ? styleElement->containingShadowRo
ot() : 0; |
60 | 60 |
61 ContainerNode* parent = styleElement->parentNode(); | 61 ContainerNode* parent = styleElement->parentNode(); |
62 if (!parent) | 62 if (!parent) |
63 return 0; | 63 return 0; |
64 | 64 |
65 return (parent->isElementNode() || parent->isShadowRoot()) ? parent : 0; | 65 return (parent->isElementNode() || parent->isShadowRoot()) ? parent : 0; |
66 } | 66 } |
67 | 67 |
68 void ScopedStyleResolver::addRulesFromSheet(StyleSheetContents* sheet, const Med
iaQueryEvaluator& medium, StyleResolver* resolver) | 68 inline RuleSet* ScopedStyleResolver::ensureAuthorStyle() |
69 { | 69 { |
70 if (!m_authorStyle) | 70 if (!m_authorStyle) |
71 m_authorStyle = RuleSet::create(); | 71 m_authorStyle = RuleSet::create(); |
| 72 return m_authorStyle.get(); |
| 73 } |
72 | 74 |
73 bool hasDocumentSecurityOrigin = resolver->document().securityOrigin()->canR
equest(sheet->baseURL()); | 75 void ScopedStyleResolver::addRulesFromSheet(StyleSheetContents* sheet, const Med
iaQueryEvaluator& medium, StyleResolver* resolver, bool viewportRuleIsProcessed) |
74 m_authorStyle->addRulesFromSheet(sheet, medium, hasDocumentSecurityOrigin); | 76 { |
| 77 AddRuleFlags addRuleFlags = resolver->document().securityOrigin()->canReques
t(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState; |
| 78 |
| 79 if (viewportRuleIsProcessed) |
| 80 addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | ViewportRuleIsPr
ocessed); |
| 81 |
| 82 ensureAuthorStyle()->addRulesFromSheet(sheet, medium, addRuleFlags); |
75 resolver->addMediaQueryResults(m_authorStyle->viewportDependentMediaQueryRes
ults()); | 83 resolver->addMediaQueryResults(m_authorStyle->viewportDependentMediaQueryRes
ults()); |
76 resolver->processScopedRules(*m_authorStyle, sheet->baseURL(), &m_scopingNod
e); | 84 resolver->processScopedRules(*m_authorStyle, sheet->baseURL(), &m_scopingNod
e); |
77 } | 85 } |
78 | 86 |
| 87 void ScopedStyleResolver::addViewportRule(StyleRuleViewport* rule) |
| 88 { |
| 89 ensureAuthorStyle()->addViewportRule(rule); |
| 90 } |
| 91 |
79 inline RuleSet* ScopedStyleResolver::ensureAtHostRuleSetFor(const ShadowRoot* sh
adowRoot) | 92 inline RuleSet* ScopedStyleResolver::ensureAtHostRuleSetFor(const ShadowRoot* sh
adowRoot) |
80 { | 93 { |
81 HashMap<const ShadowRoot*, OwnPtr<RuleSet> >::AddResult addResult = m_atHost
Rules.add(shadowRoot, nullptr); | 94 HashMap<const ShadowRoot*, OwnPtr<RuleSet> >::AddResult addResult = m_atHost
Rules.add(shadowRoot, nullptr); |
82 if (addResult.isNewEntry) | 95 if (addResult.isNewEntry) |
83 addResult.iterator->value = RuleSet::create(); | 96 addResult.iterator->value = RuleSet::create(); |
84 return addResult.iterator->value.get(); | 97 return addResult.iterator->value.get(); |
85 } | 98 } |
86 | 99 |
87 void ScopedStyleResolver::addHostRule(StyleRuleHost* hostRule, bool hasDocumentS
ecurityOrigin, const ContainerNode* scopingNode) | 100 void ScopedStyleResolver::addHostRule(StyleRuleHost* hostRule, bool hasDocumentS
ecurityOrigin, const ContainerNode* scopingNode) |
88 { | 101 { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 262 |
250 void ScopedStyleResolver::collectViewportRulesTo(StyleResolver* resolver) const | 263 void ScopedStyleResolver::collectViewportRulesTo(StyleResolver* resolver) const |
251 { | 264 { |
252 // Only consider the global author RuleSet for @viewport rules. | 265 // Only consider the global author RuleSet for @viewport rules. |
253 if (!m_scopingNode.isDocumentNode() || !m_authorStyle) | 266 if (!m_scopingNode.isDocumentNode() || !m_authorStyle) |
254 return; | 267 return; |
255 resolver->viewportStyleResolver()->collectViewportRules(m_authorStyle.get(),
ViewportStyleResolver::AuthorOrigin); | 268 resolver->viewportStyleResolver()->collectViewportRules(m_authorStyle.get(),
ViewportStyleResolver::AuthorOrigin); |
256 } | 269 } |
257 | 270 |
258 } // namespace WebCore | 271 } // namespace WebCore |
OLD | NEW |