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

Side by Side Diff: sky/engine/core/css/ElementRuleCollector.cpp

Issue 833443003: Remove applyAuthorStyles flag. (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 | « no previous file | sky/engine/core/css/SelectorChecker.h » ('j') | 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 if (!propertySet) 75 if (!propertySet)
76 return; 76 return;
77 m_result.ranges.lastAuthorRule = m_result.matchedProperties.size(); 77 m_result.ranges.lastAuthorRule = m_result.matchedProperties.size();
78 if (m_result.ranges.firstAuthorRule == -1) 78 if (m_result.ranges.firstAuthorRule == -1)
79 m_result.ranges.firstAuthorRule = m_result.ranges.lastAuthorRule; 79 m_result.ranges.firstAuthorRule = m_result.ranges.lastAuthorRule;
80 m_result.addMatchedProperties(propertySet); 80 m_result.addMatchedProperties(propertySet);
81 if (!isCacheable) 81 if (!isCacheable)
82 m_result.isCacheable = false; 82 m_result.isCacheable = false;
83 } 83 }
84 84
85 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont ainerNode* scopingNode, bool elementApplyAuthorStyles) 85 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont ainerNode* scopingNode)
86 { 86 {
87 TreeScope& treeScope = element->treeScope(); 87 TreeScope& treeScope = element->treeScope();
88 88 return !scopingNode ||
89 // [skipped, because already checked] a) it's a UA rule 89 treeScope == scopingNode->treeScope() ||
90 // b) element is allowed to apply author rules 90 SelectorChecker::isHostInItsShadowTree(*element, scopingNode);
91 if (elementApplyAuthorStyles)
92 return true;
93 // c) the rules comes from a scoped style sheet within the same tree scope
94 if (!scopingNode || treeScope == scopingNode->treeScope())
95 return true;
96 // d) the rules comes from a scoped style sheet within an active shadow root whose host is the given element
97 if (SelectorChecker::isHostInItsShadowTree(*element, scopingNode))
98 return true;
99 return false;
100 } 91 }
101 92
102 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest , RuleRange& ruleRange, SelectorChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder cascadeOrder) 93 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest , RuleRange& ruleRange, SelectorChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder cascadeOrder)
103 { 94 {
104 ASSERT(matchRequest.ruleSet); 95 ASSERT(matchRequest.ruleSet);
105 ASSERT(m_context.element()); 96 ASSERT(m_context.element());
106 97
107 Element& element = *m_context.element(); 98 Element& element = *m_context.element();
108 99
109 // Check whether other types of rules are applicable in the current tree sco pe. Criteria for this: 100 if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, match Request.scope))
110 // a) it's a UA rule
111 // b) the tree scope allows author rules
112 // c) the rules comes from a scoped style sheet within the same tree scope
113 // d) the rules comes from a scoped style sheet within an active shadow root whose host is the given element
114 // e) the rules can cross boundaries
115 // b)-e) is checked in rulesApplicableInCurrentTreeScope.
116 if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, match Request.scope, matchRequest.elementApplyAuthorStyles))
117 return; 101 return;
118 102
119 // We need to collect the rules for id, class, tag, and everything else into a buffer and 103 // We need to collect the rules for id, class, tag, and everything else into a buffer and
120 // then sort the buffer. 104 // then sort the buffer.
121 if (element.hasID()) 105 if (element.hasID())
122 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForS tyleResolution()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR ange); 106 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForS tyleResolution()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR ange);
123 if (element.isStyledElement() && element.hasClass()) { 107 if (element.isStyledElement() && element.hasClass()) {
124 for (size_t i = 0; i < element.classNames().size(); ++i) 108 for (size_t i = 0; i < element.classNames().size(); ++i)
125 collectMatchingRulesForList(matchRequest.ruleSet->classRules(element .classNames()[i]), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR ange); 109 collectMatchingRulesForList(matchRequest.ruleSet->classRules(element .classNames()[i]), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR ange);
126 } 110 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return matchedRule1.position() < matchedRule2.position(); 166 return matchedRule1.position() < matchedRule2.position();
183 } 167 }
184 168
185 void ElementRuleCollector::sortMatchedRules() 169 void ElementRuleCollector::sortMatchedRules()
186 { 170 {
187 ASSERT(m_matchedRules); 171 ASSERT(m_matchedRules);
188 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules); 172 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules);
189 } 173 }
190 174
191 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/css/SelectorChecker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698