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

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

Issue 789403005: Keep a separate list of :host(-context) rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added tests Created 6 years 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); 121 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange();
122 ASSERT(!collector.scopeContainsLastMatchedElement()); 122 ASSERT(!collector.scopeContainsLastMatchedElement());
123 collector.setScopeContainsLastMatchedElement(true); 123 collector.setScopeContainsLastMatchedElement(true);
124 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 124 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
125 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i); 125 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i);
126 collector.collectMatchingRules(matchRequest, ruleRange, cascadeScope, ca scadeOrder); 126 collector.collectMatchingRules(matchRequest, ruleRange, cascadeScope, ca scadeOrder);
127 } 127 }
128 collector.setScopeContainsLastMatchedElement(false); 128 collector.setScopeContainsLastMatchedElement(false);
129 } 129 }
130 130
131 void ScopedStyleResolver::collectMatchingShadowHostRules(ElementRuleCollector& c ollector, bool includeEmptyRules, CascadeScope cascadeScope, CascadeOrder cascad eOrder)
132 {
133 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange();
134 ASSERT(!collector.scopeContainsLastMatchedElement());
135 collector.setScopeContainsLastMatchedElement(true);
136 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
137 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i);
138 collector.collectMatchingShadowHostRules(matchRequest, ruleRange, cascad eScope, cascadeOrder);
139 }
140 collector.setScopeContainsLastMatchedElement(false);
141 }
142
131 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector) 143 void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector)
132 { 144 {
133 // Only consider the global author RuleSet for @page rules, as per the HTML5 spec. 145 // Only consider the global author RuleSet for @page rules, as per the HTML5 spec.
134 ASSERT(m_scope->rootNode().isDocumentNode()); 146 ASSERT(m_scope->rootNode().isDocumentNode());
135 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) 147 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i)
136 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet()) ; 148 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet()) ;
137 } 149 }
138 150
139 void ScopedStyleResolver::collectViewportRulesTo(StyleResolver* resolver) const 151 void ScopedStyleResolver::collectViewportRulesTo(StyleResolver* resolver) const
140 { 152 {
141 if (!m_scope->rootNode().isDocumentNode()) 153 if (!m_scope->rootNode().isDocumentNode())
142 return; 154 return;
143 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) 155 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i)
144 resolver->viewportStyleResolver()->collectViewportRules(&m_authorStyleSh eets[i]->contents()->ruleSet(), ViewportStyleResolver::AuthorOrigin); 156 resolver->viewportStyleResolver()->collectViewportRules(&m_authorStyleSh eets[i]->contents()->ruleSet(), ViewportStyleResolver::AuthorOrigin);
145 } 157 }
146 158
147 void ScopedStyleResolver::trace(Visitor* visitor) 159 void ScopedStyleResolver::trace(Visitor* visitor)
148 { 160 {
149 #if ENABLE(OILPAN) 161 #if ENABLE(OILPAN)
150 visitor->trace(m_scope); 162 visitor->trace(m_scope);
151 visitor->trace(m_authorStyleSheets); 163 visitor->trace(m_authorStyleSheets);
152 visitor->trace(m_keyframesRuleMap); 164 visitor->trace(m_keyframesRuleMap);
153 #endif 165 #endif
154 } 166 }
155 167
156 } // namespace blink 168 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/ScopedStyleResolver.h ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698