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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 void ScopedStyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, const Media
QueryEvaluator& medium, StyleResolver* resolver) | 70 void ScopedStyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, const Media
QueryEvaluator& medium, StyleResolver* resolver) |
71 { | 71 { |
72 m_authorStyleSheets.append(cssSheet); | 72 m_authorStyleSheets.append(cssSheet); |
73 StyleSheetContents* sheet = cssSheet->contents(); | 73 StyleSheetContents* sheet = cssSheet->contents(); |
74 | 74 |
75 AddRuleFlags addRuleFlags = resolver->document().securityOrigin()->canReques
t(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState; | 75 AddRuleFlags addRuleFlags = resolver->document().securityOrigin()->canReques
t(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState; |
76 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); | 76 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); |
77 resolver->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults())
; | 77 resolver->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults())
; |
78 resolver->processScopedRules(ruleSet, sheet->baseURL(), &m_scopingNode); | 78 resolver->processScopedRules(ruleSet, cssSheet, m_scopingNode); |
79 } | 79 } |
80 | 80 |
81 void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HashSet<co
nst StyleSheetContents*>& visitedSharedStyleSheetContents) | 81 void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HashSet<co
nst StyleSheetContents*>& visitedSharedStyleSheetContents) |
82 { | 82 { |
83 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { | 83 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { |
84 StyleSheetContents* contents = m_authorStyleSheets[i]->contents(); | 84 StyleSheetContents* contents = m_authorStyleSheets[i]->contents(); |
85 if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(cont
ents).isNewEntry) | 85 if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(cont
ents).isNewEntry) |
86 features.add(contents->ruleSet().features()); | 86 features.add(contents->ruleSet().features()); |
87 } | 87 } |
88 } | 88 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 if (!applyAuthorStyles) | 127 if (!applyAuthorStyles) |
128 behaviorAtBoundary |= SelectorChecker::ScopeContainsLastMatchedElement; | 128 behaviorAtBoundary |= SelectorChecker::ScopeContainsLastMatchedElement; |
129 | 129 |
130 if (m_scopingNode.isShadowRoot()) { | 130 if (m_scopingNode.isShadowRoot()) { |
131 scopingNode = toShadowRoot(m_scopingNode).host(); | 131 scopingNode = toShadowRoot(m_scopingNode).host(); |
132 behaviorAtBoundary |= SelectorChecker::ScopeIsShadowHost; | 132 behaviorAtBoundary |= SelectorChecker::ScopeIsShadowHost; |
133 } | 133 } |
134 | 134 |
135 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { | 135 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { |
136 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, includeEmptyRules, scopingNode, applyAuthorStyles, i, m_authorStyleSheets[i]); | 136 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, includeEmptyRules, scopingNode, m_authorStyleSheets[i], applyAuthorStyles, i); |
137 collector.collectMatchingRules(matchRequest, collector.matchedResult().r
anges.authorRuleRange(), static_cast<SelectorChecker::BehaviorAtBoundary>(behavi
orAtBoundary), cascadeScope, cascadeOrder); | 137 collector.collectMatchingRules(matchRequest, collector.matchedResult().r
anges.authorRuleRange(), static_cast<SelectorChecker::BehaviorAtBoundary>(behavi
orAtBoundary), cascadeScope, cascadeOrder); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector) | 141 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector) |
142 { | 142 { |
143 // Only consider the global author RuleSet for @page rules, as per the HTML5
spec. | 143 // Only consider the global author RuleSet for @page rules, as per the HTML5
spec. |
144 ASSERT(m_scopingNode.isDocumentNode()); | 144 ASSERT(m_scopingNode.isDocumentNode()); |
145 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) | 145 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) |
146 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet())
; | 146 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet())
; |
147 } | 147 } |
148 | 148 |
149 void ScopedStyleResolver::collectViewportRulesTo(StyleResolver* resolver) const | 149 void ScopedStyleResolver::collectViewportRulesTo(StyleResolver* resolver) const |
150 { | 150 { |
151 if (!m_scopingNode.isDocumentNode()) | 151 if (!m_scopingNode.isDocumentNode()) |
152 return; | 152 return; |
153 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) | 153 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) |
154 resolver->viewportStyleResolver()->collectViewportRules(&m_authorStyleSh
eets[i]->contents()->ruleSet(), ViewportStyleResolver::AuthorOrigin); | 154 resolver->viewportStyleResolver()->collectViewportRules(&m_authorStyleSh
eets[i]->contents()->ruleSet(), ViewportStyleResolver::AuthorOrigin); |
155 } | 155 } |
156 | 156 |
157 } // namespace WebCore | 157 } // namespace WebCore |
OLD | NEW |