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

Side by Side Diff: sky/engine/core/css/resolver/StyleResolver.cpp

Issue 864693002: Treat UA rules like author rules when matching. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 void StyleResolver::clearStyleSharingList() 140 void StyleResolver::clearStyleSharingList()
141 { 141 {
142 m_styleSharingList.clear(); 142 m_styleSharingList.clear();
143 } 143 }
144 144
145 StyleResolver::~StyleResolver() 145 StyleResolver::~StyleResolver()
146 { 146 {
147 } 147 }
148 148
149 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col lector) 149 void StyleResolver::matchRules(Element& element, ElementRuleCollector& collector )
150 { 150 {
151 collector.clearMatchedRules(); 151 collector.clearMatchedRules();
152 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult(). matchedProperties.size() - 1; 152 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult(). matchedProperties.size() - 1;
153 153
154 // TODO(esprehn): Eliminate CascadeOrder.
155 CascadeOrder cascadeOrder = 0; 154 CascadeOrder cascadeOrder = 0;
156 155
157 if (ShadowRoot* shadowRoot = element->shadowRoot()) 156 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange();
158 shadowRoot->scopedStyleResolver().collectMatchingHostRules(collector, ca scadeOrder++); 157 collector.collectMatchingRules(MatchRequest(&defaultStyles()), ruleRange, ++ cascadeOrder);
159 158
160 ScopedStyleResolver& resolver = element->treeScope().scopedStyleResolver(); 159 if (ShadowRoot* shadowRoot = element.shadowRoot())
161 resolver.collectMatchingAuthorRules(collector, cascadeOrder); 160 shadowRoot->scopedStyleResolver().collectMatchingHostRules(collector, ++ cascadeOrder);
161
162 ScopedStyleResolver& resolver = element.treeScope().scopedStyleResolver();
163 resolver.collectMatchingAuthorRules(collector, ++cascadeOrder);
162 164
163 collector.sortAndTransferMatchedRules(); 165 collector.sortAndTransferMatchedRules();
164 }
165 166
166 void StyleResolver::matchUARules(ElementRuleCollector& collector) 167 if (const StylePropertySet* inlineStyle = element.inlineStyle()) {
167 { 168 // Inline style is immutable as long as there is no CSSOM wrapper.
168 collector.clearMatchedRules(); 169 bool isInlineStyleCacheable = !inlineStyle->isMutable();
169 collector.matchedResult().ranges.lastUARule = collector.matchedResult().matc hedProperties.size() - 1; 170 collector.addElementStyleProperties(inlineStyle, isInlineStyleCacheable) ;
170
171 RuleRange ruleRange = collector.matchedResult().ranges.UARuleRange();
172 collector.collectMatchingRules(MatchRequest(&defaultStyles()), ruleRange);
173
174 collector.sortAndTransferMatchedRules();
175 }
176
177 void StyleResolver::matchAllRules(StyleResolverState& state, ElementRuleCollecto r& collector)
178 {
179 matchUARules(collector);
180 matchAuthorRules(state.element(), collector);
181
182 if (state.element()->isStyledElement()) {
183 if (state.element()->inlineStyle()) {
184 // Inline style is immutable as long as there is no CSSOM wrapper.
185 bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMut able();
186 collector.addElementStyleProperties(state.element()->inlineStyle(), isInlineStyleCacheable);
187 }
188 } 171 }
189 } 172 }
190 173
191 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(Document& document) 174 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(Document& document)
192 { 175 {
193 RefPtr<RenderStyle> documentStyle = RenderStyle::create(); 176 RefPtr<RenderStyle> documentStyle = RenderStyle::create();
194 documentStyle->setDisplay(BLOCK); 177 documentStyle->setDisplay(BLOCK);
195 documentStyle->setRTLOrdering(LogicalOrder); 178 documentStyle->setRTLOrdering(LogicalOrder);
196 documentStyle->setLocale(document.contentLanguage()); 179 documentStyle->setLocale(document.contentLanguage());
197 documentStyle->setZIndex(0); 180 documentStyle->setZIndex(0);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) 223 if (RenderStyle* styleOfShadowHost = parent->renderStyle())
241 state.style()->setUserModify(styleOfShadowHost->userModify()); 224 state.style()->setUserModify(styleOfShadowHost->userModify());
242 } 225 }
243 } 226 }
244 227
245 state.fontBuilder().initForStyleResolve(state.document(), state.style()); 228 state.fontBuilder().initForStyleResolve(state.document(), state.style());
246 229
247 { 230 {
248 ElementRuleCollector collector(state.elementContext(), state.style()); 231 ElementRuleCollector collector(state.elementContext(), state.style());
249 232
250 matchAllRules(state, collector); 233 matchRules(*element, collector);
251 234
252 applyMatchedProperties(state, collector.matchedResult()); 235 applyMatchedProperties(state, collector.matchedResult());
253 } 236 }
254 237
255 // Cache our original display. 238 // Cache our original display.
256 state.style()->setOriginalDisplay(state.style()->display()); 239 state.style()->setOriginalDisplay(state.style()->display());
257 240
258 StyleAdjuster adjuster; 241 StyleAdjuster adjuster;
259 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), *element); 242 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), *element);
260 243
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 break; 672 break;
690 default: 673 default:
691 break; 674 break;
692 } 675 }
693 StyleBuilder::applyProperty(properties[i].property, state, propertie s[i].value); 676 StyleBuilder::applyProperty(properties[i].property, state, propertie s[i].value);
694 } 677 }
695 } 678 }
696 } 679 }
697 680
698 } // namespace blink 681 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698