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

Side by Side Diff: third_party/WebKit/Source/core/css/ElementRuleCollector.cpp

Issue 2392343005: Reflow comments in core/css (Closed)
Patch Set: Revert clang-format Created 4 years, 2 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 * (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.
6 * All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * 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/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 11 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 12 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
11 * Copyright (C) 2012 Google Inc. All rights reserved. 13 * Copyright (C) 2012 Google Inc. All rights reserved.
12 * 14 *
13 * This library is free software; you can redistribute it and/or 15 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public 16 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either 17 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version. 18 * version 2 of the License, or (at your option) any later version.
17 * 19 *
18 * This library is distributed in the hope that it will be useful, 20 * This library is distributed in the hope that it will be useful,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 unsigned matched = 0; 137 unsigned matched = 0;
136 138
137 for (const auto& ruleData : *rules) { 139 for (const auto& ruleData : *rules) {
138 if (m_canUseFastReject && 140 if (m_canUseFastReject &&
139 m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>( 141 m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(
140 ruleData.descendantSelectorIdentifierHashes())) { 142 ruleData.descendantSelectorIdentifierHashes())) {
141 fastRejected++; 143 fastRejected++;
142 continue; 144 continue;
143 } 145 }
144 146
145 // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the onl y reason this is needed. 147 // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the
148 // only reason this is needed.
146 if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) 149 if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin())
147 continue; 150 continue;
148 151
149 StyleRule* rule = ruleData.rule(); 152 StyleRule* rule = ruleData.rule();
150 153
151 // If the rule has no properties to apply, then ignore it in the non-debug m ode. 154 // If the rule has no properties to apply, then ignore it in the non-debug
155 // mode.
152 const StylePropertySet& properties = rule->properties(); 156 const StylePropertySet& properties = rule->properties();
153 if (properties.isEmpty() && !m_includeEmptyRules) 157 if (properties.isEmpty() && !m_includeEmptyRules)
154 continue; 158 continue;
155 159
156 SelectorChecker::MatchResult result; 160 SelectorChecker::MatchResult result;
157 context.selector = &ruleData.selector(); 161 context.selector = &ruleData.selector();
158 if (!checker.match(context, result)) { 162 if (!checker.match(context, result)) {
159 rejected++; 163 rejected++;
160 continue; 164 continue;
161 } 165 }
(...skipping 29 matching lines...) Expand all
191 if (!pseudoId.isEmpty()) { 195 if (!pseudoId.isEmpty()) {
192 ASSERT(element.isStyledElement()); 196 ASSERT(element.isStyledElement());
193 collectMatchingRulesForList( 197 collectMatchingRulesForList(
194 matchRequest.ruleSet->shadowPseudoElementRules(pseudoId), cascadeOrder, 198 matchRequest.ruleSet->shadowPseudoElementRules(pseudoId), cascadeOrder,
195 matchRequest); 199 matchRequest);
196 } 200 }
197 201
198 if (element.isVTTElement()) 202 if (element.isVTTElement())
199 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), 203 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(),
200 cascadeOrder, matchRequest); 204 cascadeOrder, matchRequest);
201 // Check whether other types of rules are applicable in the current tree scope . Criteria for this: 205 // Check whether other types of rules are applicable in the current tree
206 // scope. Criteria for this:
202 // a) the rules are UA rules. 207 // a) the rules are UA rules.
203 // b) matching tree boundary crossing rules. 208 // b) matching tree boundary crossing rules.
204 // c) the rules come from a shadow style sheet in the same tree scope as the g iven element. 209 // c) the rules come from a shadow style sheet in the same tree scope as the
210 // given element.
205 // c) is checked in rulesApplicableInCurrentTreeScope. 211 // c) is checked in rulesApplicableInCurrentTreeScope.
206 if (!m_matchingUARules && !matchingTreeBoundaryRules && 212 if (!m_matchingUARules && !matchingTreeBoundaryRules &&
207 !rulesApplicableInCurrentTreeScope(&element, matchRequest.scope)) 213 !rulesApplicableInCurrentTreeScope(&element, matchRequest.scope))
208 return; 214 return;
209 215
210 // We need to collect the rules for id, class, tag, and everything else into a buffer and 216 // We need to collect the rules for id, class, tag, and everything else into a
211 // then sort the buffer. 217 // buffer and then sort the buffer.
212 if (element.hasID()) 218 if (element.hasID())
213 collectMatchingRulesForList( 219 collectMatchingRulesForList(
214 matchRequest.ruleSet->idRules(element.idForStyleResolution()), 220 matchRequest.ruleSet->idRules(element.idForStyleResolution()),
215 cascadeOrder, matchRequest); 221 cascadeOrder, matchRequest);
216 if (element.isStyledElement() && element.hasClass()) { 222 if (element.isStyledElement() && element.hasClass()) {
217 for (size_t i = 0; i < element.classNames().size(); ++i) 223 for (size_t i = 0; i < element.classNames().size(); ++i)
218 collectMatchingRulesForList( 224 collectMatchingRulesForList(
219 matchRequest.ruleSet->classRules(element.classNames()[i]), 225 matchRequest.ruleSet->classRules(element.classNames()[i]),
220 cascadeOrder, matchRequest); 226 cascadeOrder, matchRequest);
221 } 227 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } else { 265 } else {
260 result = findStyleRule(cssRule->cssRules(), styleRule); 266 result = findStyleRule(cssRule->cssRules(), styleRule);
261 } 267 }
262 } 268 }
263 return result; 269 return result;
264 } 270 }
265 271
266 void ElementRuleCollector::appendCSSOMWrapperForRule( 272 void ElementRuleCollector::appendCSSOMWrapperForRule(
267 CSSStyleSheet* parentStyleSheet, 273 CSSStyleSheet* parentStyleSheet,
268 StyleRule* rule) { 274 StyleRule* rule) {
269 // |parentStyleSheet| is 0 if and only if the |rule| is coming from User Agent . In this case, 275 // |parentStyleSheet| is 0 if and only if the |rule| is coming from User
270 // it is safe to create CSSOM wrappers without parentStyleSheets as they will be used only 276 // Agent. In this case, it is safe to create CSSOM wrappers without
271 // by inspector which will not try to edit them. 277 // parentStyleSheets as they will be used only by inspector which will not try
278 // to edit them.
272 CSSRule* cssRule = nullptr; 279 CSSRule* cssRule = nullptr;
273 if (parentStyleSheet) 280 if (parentStyleSheet)
274 cssRule = findStyleRule(parentStyleSheet, rule); 281 cssRule = findStyleRule(parentStyleSheet, rule);
275 else 282 else
276 cssRule = rule->createCSSOMWrapper(); 283 cssRule = rule->createCSSOMWrapper();
277 ASSERT(!parentStyleSheet || cssRule); 284 ASSERT(!parentStyleSheet || cssRule);
278 ensureRuleList()->rules().append(cssRule); 285 ensureRuleList()->rules().append(cssRule);
279 } 286 }
280 287
281 void ElementRuleCollector::sortAndTransferMatchedRules() { 288 void ElementRuleCollector::sortAndTransferMatchedRules() {
(...skipping 24 matching lines...) Expand all
306 ruleData->propertyWhitelist(m_matchingUARules)); 313 ruleData->propertyWhitelist(m_matchingUARules));
307 } 314 }
308 } 315 }
309 316
310 void ElementRuleCollector::didMatchRule( 317 void ElementRuleCollector::didMatchRule(
311 const RuleData& ruleData, 318 const RuleData& ruleData,
312 const SelectorChecker::MatchResult& result, 319 const SelectorChecker::MatchResult& result,
313 CascadeOrder cascadeOrder, 320 CascadeOrder cascadeOrder,
314 const MatchRequest& matchRequest) { 321 const MatchRequest& matchRequest) {
315 PseudoId dynamicPseudo = result.dynamicPseudo; 322 PseudoId dynamicPseudo = result.dynamicPseudo;
316 // If we're matching normal rules, set a pseudo bit if 323 // If we're matching normal rules, set a pseudo bit if we really just matched
317 // we really just matched a pseudo-element. 324 // a pseudo-element.
318 if (dynamicPseudo != PseudoIdNone && 325 if (dynamicPseudo != PseudoIdNone &&
319 m_pseudoStyleRequest.pseudoId == PseudoIdNone) { 326 m_pseudoStyleRequest.pseudoId == PseudoIdNone) {
320 if (m_mode == SelectorChecker::CollectingCSSRules || 327 if (m_mode == SelectorChecker::CollectingCSSRules ||
321 m_mode == SelectorChecker::CollectingStyleRules) 328 m_mode == SelectorChecker::CollectingStyleRules)
322 return; 329 return;
323 // FIXME: Matching should not modify the style directly. 330 // FIXME: Matching should not modify the style directly.
324 if (!m_style || dynamicPseudo >= FirstInternalPseudoId) 331 if (!m_style || dynamicPseudo >= FirstInternalPseudoId)
325 return; 332 return;
326 if ((dynamicPseudo == PseudoIdBefore || dynamicPseudo == PseudoIdAfter) && 333 if ((dynamicPseudo == PseudoIdBefore || dynamicPseudo == PseudoIdAfter) &&
327 !ruleData.rule()->properties().hasProperty(CSSPropertyContent)) 334 !ruleData.rule()->properties().hasProperty(CSSPropertyContent))
(...skipping 21 matching lines...) Expand all
349 356
350 void ElementRuleCollector::sortMatchedRules() { 357 void ElementRuleCollector::sortMatchedRules() {
351 std::sort(m_matchedRules.begin(), m_matchedRules.end(), compareRules); 358 std::sort(m_matchedRules.begin(), m_matchedRules.end(), compareRules);
352 } 359 }
353 360
354 bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) { 361 bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) {
355 clearMatchedRules(); 362 clearMatchedRules();
356 363
357 m_mode = SelectorChecker::SharingRules; 364 m_mode = SelectorChecker::SharingRules;
358 // To check whether a given RuleSet has any rule matching a given element, 365 // To check whether a given RuleSet has any rule matching a given element,
359 // should not see the element's treescope. Because RuleSet has no 366 // should not see the element's treescope. Because RuleSet has no information
360 // information about "scope". 367 // about "scope".
361 MatchRequest matchRequest(ruleSet); 368 MatchRequest matchRequest(ruleSet);
362 collectMatchingRules(matchRequest); 369 collectMatchingRules(matchRequest);
363 collectMatchingShadowHostRules(matchRequest); 370 collectMatchingShadowHostRules(matchRequest);
364 371
365 return !m_matchedRules.isEmpty(); 372 return !m_matchedRules.isEmpty();
366 } 373 }
367 374
368 } // namespace blink 375 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/ElementRuleCollector.h ('k') | third_party/WebKit/Source/core/css/FontFace.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698