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 28 matching lines...) Expand all Loading... |
39 #include "core/css/resolver/ViewportStyleResolver.h" | 39 #include "core/css/resolver/ViewportStyleResolver.h" |
40 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
41 #include "core/dom/StyleEngine.h" | 41 #include "core/dom/StyleEngine.h" |
42 #include "core/dom/shadow/ElementShadow.h" | 42 #include "core/dom/shadow/ElementShadow.h" |
43 #include "core/dom/shadow/ShadowRoot.h" | 43 #include "core/dom/shadow/ShadowRoot.h" |
44 #include "core/html/HTMLStyleElement.h" | 44 #include "core/html/HTMLStyleElement.h" |
45 #include "core/svg/SVGStyleElement.h" | 45 #include "core/svg/SVGStyleElement.h" |
46 | 46 |
47 namespace blink { | 47 namespace blink { |
48 | 48 |
| 49 ScopedStyleResolver::~ScopedStyleResolver() |
| 50 { |
| 51 if (m_treeBoundaryCrossingRuleSet) |
| 52 treeScope().document().styleEngine().removeTreeBoundaryCrossingScope(); |
| 53 } |
| 54 |
49 TreeScope* ScopedStyleResolver::treeScopeFor(Document& document, const CSSStyleS
heet* sheet) | 55 TreeScope* ScopedStyleResolver::treeScopeFor(Document& document, const CSSStyleS
heet* sheet) |
50 { | 56 { |
51 ASSERT(sheet); | 57 ASSERT(sheet); |
52 | 58 |
53 if (!sheet->ownerDocument()) | 59 if (!sheet->ownerDocument()) |
54 return 0; | 60 return 0; |
55 | 61 |
56 Node* ownerNode = sheet->ownerNode(); | 62 Node* ownerNode = sheet->ownerNode(); |
57 if (!isHTMLStyleElement(ownerNode) && !isSVGStyleElement(ownerNode)) | 63 if (!isHTMLStyleElement(ownerNode) && !isSVGStyleElement(ownerNode)) |
58 return &document; | 64 return &document; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 130 |
125 for (const auto& rules : *m_treeBoundaryCrossingRuleSet) | 131 for (const auto& rules : *m_treeBoundaryCrossingRuleSet) |
126 features.add(rules->m_ruleSet->features()); | 132 features.add(rules->m_ruleSet->features()); |
127 } | 133 } |
128 | 134 |
129 void ScopedStyleResolver::resetAuthorStyle() | 135 void ScopedStyleResolver::resetAuthorStyle() |
130 { | 136 { |
131 m_authorStyleSheets.clear(); | 137 m_authorStyleSheets.clear(); |
132 m_keyframesRuleMap.clear(); | 138 m_keyframesRuleMap.clear(); |
133 m_treeBoundaryCrossingRuleSet = nullptr; | 139 m_treeBoundaryCrossingRuleSet = nullptr; |
| 140 treeScope().document().styleEngine().removeTreeBoundaryCrossingScope(); |
134 } | 141 } |
135 | 142 |
136 StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const String
Impl* animationName) | 143 StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const String
Impl* animationName) |
137 { | 144 { |
138 if (m_keyframesRuleMap.isEmpty()) | 145 if (m_keyframesRuleMap.isEmpty()) |
139 return nullptr; | 146 return nullptr; |
140 | 147 |
141 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName); | 148 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName); |
142 if (it == m_keyframesRuleMap.end()) | 149 if (it == m_keyframesRuleMap.end()) |
143 return nullptr; | 150 return nullptr; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { | 188 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { |
182 ASSERT(m_authorStyleSheets[i]->ownerNode()); | 189 ASSERT(m_authorStyleSheets[i]->ownerNode()); |
183 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i); | 190 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i); |
184 collector.collectMatchingShadowHostRules(matchRequest, ruleRange, cascad
eOrder); | 191 collector.collectMatchingShadowHostRules(matchRequest, ruleRange, cascad
eOrder); |
185 } | 192 } |
186 collector.setScopeContainsLastMatchedElement(false); | 193 collector.setScopeContainsLastMatchedElement(false); |
187 } | 194 } |
188 | 195 |
189 void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCo
llector& collector, bool includeEmptyRules, CascadeOrder cascadeOrder) | 196 void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCo
llector& collector, bool includeEmptyRules, CascadeOrder cascadeOrder) |
190 { | 197 { |
| 198 if (!m_treeBoundaryCrossingRuleSet) |
| 199 return; |
| 200 |
| 201 ASSERT(!collector.scopeContainsLastMatchedElement()); |
| 202 collector.setScopeContainsLastMatchedElement(true); |
| 203 |
191 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); | 204 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); |
192 for (const auto& rules : *m_treeBoundaryCrossingRuleSet) { | 205 for (const auto& rules : *m_treeBoundaryCrossingRuleSet) { |
193 MatchRequest request(rules->m_ruleSet.get(), includeEmptyRules, &treeSco
pe().rootNode(), rules->m_parentStyleSheet, rules->m_parentIndex); | 206 MatchRequest request(rules->m_ruleSet.get(), includeEmptyRules, &treeSco
pe().rootNode(), rules->m_parentStyleSheet, rules->m_parentIndex); |
194 collector.collectMatchingRules(request, ruleRange, cascadeOrder, true); | 207 collector.collectMatchingRules(request, ruleRange, cascadeOrder, true); |
195 } | 208 } |
| 209 |
| 210 collector.setScopeContainsLastMatchedElement(false); |
196 } | 211 } |
197 | 212 |
198 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector) | 213 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector) |
199 { | 214 { |
200 // Only consider the global author RuleSet for @page rules, as per the HTML5
spec. | 215 // Only consider the global author RuleSet for @page rules, as per the HTML5
spec. |
201 ASSERT(m_scope->rootNode().isDocumentNode()); | 216 ASSERT(m_scope->rootNode().isDocumentNode()); |
202 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) | 217 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) |
203 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet())
; | 218 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet())
; |
204 } | 219 } |
205 | 220 |
(...skipping 30 matching lines...) Expand all Loading... |
236 return; | 251 return; |
237 | 252 |
238 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); | 253 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); |
239 addRules(ruleSetForScope.get(), authorRules.treeBoundaryCrossingRules()); | 254 addRules(ruleSetForScope.get(), authorRules.treeBoundaryCrossingRules()); |
240 | 255 |
241 if (!isDocumentScope) | 256 if (!isDocumentScope) |
242 addRules(ruleSetForScope.get(), authorRules.shadowDistributedRules()); | 257 addRules(ruleSetForScope.get(), authorRules.shadowDistributedRules()); |
243 | 258 |
244 if (!m_treeBoundaryCrossingRuleSet) { | 259 if (!m_treeBoundaryCrossingRuleSet) { |
245 m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRule
SubSet()); | 260 m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRule
SubSet()); |
246 treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(tre
eScope().rootNode()); | 261 treeScope().document().styleEngine().addTreeBoundaryCrossingScope(); |
247 } | 262 } |
248 | 263 |
249 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s
heetIndex, ruleSetForScope.release())); | 264 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s
heetIndex, ruleSetForScope.release())); |
250 } | 265 } |
251 | 266 |
252 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) | 267 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) |
253 { | 268 { |
254 visitor->trace(m_ruleSet); | 269 visitor->trace(m_ruleSet); |
255 } | 270 } |
256 | 271 |
257 } // namespace blink | 272 } // namespace blink |
OLD | NEW |