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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/css/resolver/StyleResolver.cpp
diff --git a/sky/engine/core/css/resolver/StyleResolver.cpp b/sky/engine/core/css/resolver/StyleResolver.cpp
index 2b2f43701c6383e2ef90eb565d142aa1dc766bab..0db9cbcd49b36570edcb327180f9c4343e4e0ee8 100644
--- a/sky/engine/core/css/resolver/StyleResolver.cpp
+++ b/sky/engine/core/css/resolver/StyleResolver.cpp
@@ -146,45 +146,28 @@ StyleResolver::~StyleResolver()
{
}
-void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& collector)
+void StyleResolver::matchRules(Element& element, ElementRuleCollector& collector)
{
collector.clearMatchedRules();
collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().matchedProperties.size() - 1;
- // TODO(esprehn): Eliminate CascadeOrder.
CascadeOrder cascadeOrder = 0;
- if (ShadowRoot* shadowRoot = element->shadowRoot())
- shadowRoot->scopedStyleResolver().collectMatchingHostRules(collector, cascadeOrder++);
-
- ScopedStyleResolver& resolver = element->treeScope().scopedStyleResolver();
- resolver.collectMatchingAuthorRules(collector, cascadeOrder);
+ RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange();
+ collector.collectMatchingRules(MatchRequest(&defaultStyles()), ruleRange, ++cascadeOrder);
- collector.sortAndTransferMatchedRules();
-}
+ if (ShadowRoot* shadowRoot = element.shadowRoot())
+ shadowRoot->scopedStyleResolver().collectMatchingHostRules(collector, ++cascadeOrder);
-void StyleResolver::matchUARules(ElementRuleCollector& collector)
-{
- collector.clearMatchedRules();
- collector.matchedResult().ranges.lastUARule = collector.matchedResult().matchedProperties.size() - 1;
-
- RuleRange ruleRange = collector.matchedResult().ranges.UARuleRange();
- collector.collectMatchingRules(MatchRequest(&defaultStyles()), ruleRange);
+ ScopedStyleResolver& resolver = element.treeScope().scopedStyleResolver();
+ resolver.collectMatchingAuthorRules(collector, ++cascadeOrder);
collector.sortAndTransferMatchedRules();
-}
-void StyleResolver::matchAllRules(StyleResolverState& state, ElementRuleCollector& collector)
-{
- matchUARules(collector);
- matchAuthorRules(state.element(), collector);
-
- if (state.element()->isStyledElement()) {
- if (state.element()->inlineStyle()) {
- // Inline style is immutable as long as there is no CSSOM wrapper.
- bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMutable();
- collector.addElementStyleProperties(state.element()->inlineStyle(), isInlineStyleCacheable);
- }
+ if (const StylePropertySet* inlineStyle = element.inlineStyle()) {
+ // Inline style is immutable as long as there is no CSSOM wrapper.
+ bool isInlineStyleCacheable = !inlineStyle->isMutable();
+ collector.addElementStyleProperties(inlineStyle, isInlineStyleCacheable);
}
}
@@ -247,7 +230,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
{
ElementRuleCollector collector(state.elementContext(), state.style());
- matchAllRules(state, collector);
+ matchRules(*element, collector);
applyMatchedProperties(state, collector.matchedResult());
}
« 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