Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: Source/core/css/resolver/ScopedStyleResolver.cpp

Issue 1134173002: Get rid of TreeBoundaryCrossingRules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Missing important UA rules. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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;
144 151
145 return it->value.get(); 152 return it->value.get();
146 } 153 }
147 154
148 void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyfr ames> rule) 155 void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyfr ames> rule)
149 { 156 {
150 AtomicString s(rule->name()); 157 AtomicString s(rule->name());
151 158
152 if (rule->isVendorPrefixed()) { 159 if (rule->isVendorPrefixed()) {
153 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl()); 160 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl());
154 if (it == m_keyframesRuleMap.end()) 161 if (it == m_keyframesRuleMap.end())
155 m_keyframesRuleMap.set(s.impl(), rule); 162 m_keyframesRuleMap.set(s.impl(), rule);
156 else if (it->value->isVendorPrefixed()) 163 else if (it->value->isVendorPrefixed())
157 m_keyframesRuleMap.set(s.impl(), rule); 164 m_keyframesRuleMap.set(s.impl(), rule);
158 } else { 165 } else {
159 m_keyframesRuleMap.set(s.impl(), rule); 166 m_keyframesRuleMap.set(s.impl(), rule);
160 } 167 }
161 } 168 }
162 169
163 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle ctor, bool includeEmptyRules, CascadeOrder cascadeOrder) 170 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle ctor, bool includeEmptyRules)
164 { 171 {
165 ASSERT(!collector.scopeContainsLastMatchedElement()); 172 ASSERT(!collector.scopeContainsLastMatchedElement());
166 collector.setScopeContainsLastMatchedElement(true); 173 collector.setScopeContainsLastMatchedElement(true);
167 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 174 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
168 ASSERT(m_authorStyleSheets[i]->ownerNode()); 175 ASSERT(m_authorStyleSheets[i]->ownerNode());
169 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i); 176 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i);
170 collector.collectMatchingRules(matchRequest, cascadeOrder); 177 collector.collectMatchingRules(matchRequest);
171 } 178 }
172 collector.setScopeContainsLastMatchedElement(false); 179 collector.setScopeContainsLastMatchedElement(false);
173 } 180 }
174 181
175 void ScopedStyleResolver::collectMatchingShadowHostRules(ElementRuleCollector& c ollector, bool includeEmptyRules, CascadeOrder cascadeOrder) 182 void ScopedStyleResolver::collectMatchingShadowHostRules(ElementRuleCollector& c ollector, bool includeEmptyRules)
176 { 183 {
177 ASSERT(!collector.scopeContainsLastMatchedElement()); 184 ASSERT(!collector.scopeContainsLastMatchedElement());
178 collector.setScopeContainsLastMatchedElement(true); 185 collector.setScopeContainsLastMatchedElement(true);
179 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 186 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
180 ASSERT(m_authorStyleSheets[i]->ownerNode()); 187 ASSERT(m_authorStyleSheets[i]->ownerNode());
181 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i); 188 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i);
182 collector.collectMatchingShadowHostRules(matchRequest, cascadeOrder); 189 collector.collectMatchingShadowHostRules(matchRequest);
183 } 190 }
184 collector.setScopeContainsLastMatchedElement(false); 191 collector.setScopeContainsLastMatchedElement(false);
185 } 192 }
186 193
187 void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCo llector& collector, bool includeEmptyRules, CascadeOrder cascadeOrder) 194 void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCo llector& collector, bool includeEmptyRules)
188 { 195 {
196 if (!m_treeBoundaryCrossingRuleSet)
197 return;
198
199 ASSERT(!collector.scopeContainsLastMatchedElement());
200 collector.setScopeContainsLastMatchedElement(true);
201
189 for (const auto& rules : *m_treeBoundaryCrossingRuleSet) { 202 for (const auto& rules : *m_treeBoundaryCrossingRuleSet) {
190 MatchRequest request(rules->m_ruleSet.get(), includeEmptyRules, &treeSco pe().rootNode(), rules->m_parentStyleSheet, rules->m_parentIndex); 203 MatchRequest request(rules->m_ruleSet.get(), includeEmptyRules, &treeSco pe().rootNode(), rules->m_parentStyleSheet, rules->m_parentIndex);
191 collector.collectMatchingRules(request, cascadeOrder, true); 204 collector.collectMatchingRules(request, true);
192 } 205 }
206
207 collector.setScopeContainsLastMatchedElement(false);
193 } 208 }
194 209
195 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector) 210 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector)
196 { 211 {
197 // Only consider the global author RuleSet for @page rules, as per the HTML5 spec. 212 // Only consider the global author RuleSet for @page rules, as per the HTML5 spec.
198 ASSERT(m_scope->rootNode().isDocumentNode()); 213 ASSERT(m_scope->rootNode().isDocumentNode());
199 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) 214 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i)
200 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet()) ; 215 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet()) ;
201 } 216 }
202 217
(...skipping 30 matching lines...) Expand all
233 return; 248 return;
234 249
235 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); 250 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create();
236 addRules(ruleSetForScope.get(), authorRules.treeBoundaryCrossingRules()); 251 addRules(ruleSetForScope.get(), authorRules.treeBoundaryCrossingRules());
237 252
238 if (!isDocumentScope) 253 if (!isDocumentScope)
239 addRules(ruleSetForScope.get(), authorRules.shadowDistributedRules()); 254 addRules(ruleSetForScope.get(), authorRules.shadowDistributedRules());
240 255
241 if (!m_treeBoundaryCrossingRuleSet) { 256 if (!m_treeBoundaryCrossingRuleSet) {
242 m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRule SubSet()); 257 m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRule SubSet());
243 treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(tre eScope().rootNode()); 258 treeScope().document().styleEngine().addTreeBoundaryCrossingScope();
244 } 259 }
245 260
246 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release())); 261 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release()));
247 } 262 }
248 263
249 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) 264 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet)
250 { 265 {
251 visitor->trace(m_ruleSet); 266 visitor->trace(m_ruleSet);
252 } 267 }
253 268
254 } // namespace blink 269 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/ScopedStyleResolver.h ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698