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

Side by Side Diff: third_party/WebKit/Source/core/css/RuleSet.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 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All
6 * 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 68
67 static inline bool isCommonAttributeSelectorAttribute( 69 static inline bool isCommonAttributeSelectorAttribute(
68 const QualifiedName& attribute) { 70 const QualifiedName& attribute) {
69 // These are explicitly tested for equality in canShareStyleWithElement. 71 // These are explicitly tested for equality in canShareStyleWithElement.
70 return attribute == typeAttr || attribute == readonlyAttr; 72 return attribute == typeAttr || attribute == readonlyAttr;
71 } 73 }
72 74
73 static bool containsUncommonAttributeSelector(const CSSSelector& selector) { 75 static bool containsUncommonAttributeSelector(const CSSSelector& selector) {
74 const CSSSelector* current = &selector; 76 const CSSSelector* current = &selector;
75 for (; current; current = current->tagHistory()) { 77 for (; current; current = current->tagHistory()) {
76 // Allow certain common attributes (used in the default style) in the select ors that match the current element. 78 // Allow certain common attributes (used in the default style) in the
79 // selectors that match the current element.
77 if (current->isAttributeSelector() && 80 if (current->isAttributeSelector() &&
78 !isCommonAttributeSelectorAttribute(current->attribute())) 81 !isCommonAttributeSelectorAttribute(current->attribute()))
79 return true; 82 return true;
80 if (selectorListContainsUncommonAttributeSelector(current)) 83 if (selectorListContainsUncommonAttributeSelector(current))
81 return true; 84 return true;
82 if (current->relationIsAffectedByPseudoContent() || 85 if (current->relationIsAffectedByPseudoContent() ||
83 current->getPseudoType() == CSSSelector::PseudoSlotted) 86 current->getPseudoType() == CSSSelector::PseudoSlotted)
84 return false; 87 return false;
85 if (current->relation() != CSSSelector::SubSelector) { 88 if (current->relation() != CSSSelector::SubSelector) {
86 current = current->tagHistory(); 89 current = current->tagHistory();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Prefer rule sets in order of most likely to apply infrequently. 191 // Prefer rule sets in order of most likely to apply infrequently.
189 if (!id.isEmpty()) { 192 if (!id.isEmpty()) {
190 addToRuleSet(id, ensurePendingRules()->idRules, ruleData); 193 addToRuleSet(id, ensurePendingRules()->idRules, ruleData);
191 return true; 194 return true;
192 } 195 }
193 if (!className.isEmpty()) { 196 if (!className.isEmpty()) {
194 addToRuleSet(className, ensurePendingRules()->classRules, ruleData); 197 addToRuleSet(className, ensurePendingRules()->classRules, ruleData);
195 return true; 198 return true;
196 } 199 }
197 if (!customPseudoElementName.isEmpty()) { 200 if (!customPseudoElementName.isEmpty()) {
198 // Custom pseudos come before ids and classes in the order of tagHistory, an d have a relation of 201 // Custom pseudos come before ids and classes in the order of tagHistory,
199 // ShadowPseudo between them. Therefore we should never be a situation where extractValuesforSelector 202 // and have a relation of ShadowPseudo between them. Therefore we should
200 // finsd id and className in addition to custom pseudo. 203 // never be a situation where extractValuesforSelector finsd id and
204 // className in addition to custom pseudo.
201 ASSERT(id.isEmpty() && className.isEmpty()); 205 ASSERT(id.isEmpty() && className.isEmpty());
202 addToRuleSet(customPseudoElementName, 206 addToRuleSet(customPseudoElementName,
203 ensurePendingRules()->shadowPseudoElementRules, ruleData); 207 ensurePendingRules()->shadowPseudoElementRules, ruleData);
204 return true; 208 return true;
205 } 209 }
206 210
207 switch (component.getPseudoType()) { 211 switch (component.getPseudoType()) {
208 case CSSSelector::PseudoCue: 212 case CSSSelector::PseudoCue:
209 m_cuePseudoRules.append(ruleData); 213 m_cuePseudoRules.append(ruleData);
210 return true; 214 return true;
(...skipping 24 matching lines...) Expand all
235 239
236 void RuleSet::addRule(StyleRule* rule, 240 void RuleSet::addRule(StyleRule* rule,
237 unsigned selectorIndex, 241 unsigned selectorIndex,
238 AddRuleFlags addRuleFlags) { 242 AddRuleFlags addRuleFlags) {
239 RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags); 243 RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags);
240 if (m_features.collectFeaturesFromRuleData(ruleData) == 244 if (m_features.collectFeaturesFromRuleData(ruleData) ==
241 RuleFeatureSet::SelectorNeverMatches) 245 RuleFeatureSet::SelectorNeverMatches)
242 return; 246 return;
243 247
244 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) { 248 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) {
245 // If we didn't find a specialized map to stick it in, file under universal rules. 249 // If we didn't find a specialized map to stick it in, file under universal
250 // rules.
246 m_universalRules.append(ruleData); 251 m_universalRules.append(ruleData);
247 } 252 }
248 } 253 }
249 254
250 void RuleSet::addPageRule(StyleRulePage* rule) { 255 void RuleSet::addPageRule(StyleRulePage* rule) {
251 ensurePendingRules(); // So that m_pageRules.shrinkToFit() gets called. 256 ensurePendingRules(); // So that m_pageRules.shrinkToFit() gets called.
252 m_pageRules.append(rule); 257 m_pageRules.append(rule);
253 } 258 }
254 259
255 void RuleSet::addViewportRule(StyleRuleViewport* rule) { 260 void RuleSet::addViewportRule(StyleRuleViewport* rule) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 431 }
427 432
428 #ifndef NDEBUG 433 #ifndef NDEBUG
429 void RuleSet::show() const { 434 void RuleSet::show() const {
430 for (const auto& rule : m_allRules) 435 for (const auto& rule : m_allRules)
431 rule.selector().show(); 436 rule.selector().show();
432 } 437 }
433 #endif 438 #endif
434 439
435 } // namespace blink 440 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleSet.h ('k') | third_party/WebKit/Source/core/css/SelectorChecker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698