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

Side by Side Diff: Source/core/css/RuleFeature.cpp

Issue 322803004: Make all CSSSelector data members private (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix win dbg build error Created 6 years, 6 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 | Annotate | Revision Log
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 r ights 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 26 matching lines...) Expand all
37 #include "core/css/StyleRule.h" 37 #include "core/css/StyleRule.h"
38 #include "core/css/invalidation/DescendantInvalidationSet.h" 38 #include "core/css/invalidation/DescendantInvalidationSet.h"
39 #include "core/dom/Element.h" 39 #include "core/dom/Element.h"
40 #include "core/dom/Node.h" 40 #include "core/dom/Node.h"
41 #include "wtf/BitVector.h" 41 #include "wtf/BitVector.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 static bool isSkippableComponentForInvalidation(const CSSSelector& selector) 45 static bool isSkippableComponentForInvalidation(const CSSSelector& selector)
46 { 46 {
47 if (selector.m_match == CSSSelector::Tag 47 if (selector.match() == CSSSelector::Tag
48 || selector.m_match == CSSSelector::Id 48 || selector.match() == CSSSelector::Id
49 || selector.isAttributeSelector()) 49 || selector.isAttributeSelector())
50 return true; 50 return true;
51 if (selector.m_match == CSSSelector::PseudoElement) { 51 if (selector.match() == CSSSelector::PseudoElement) {
52 switch (selector.pseudoType()) { 52 switch (selector.pseudoType()) {
53 case CSSSelector::PseudoBefore: 53 case CSSSelector::PseudoBefore:
54 case CSSSelector::PseudoAfter: 54 case CSSSelector::PseudoAfter:
55 case CSSSelector::PseudoBackdrop: 55 case CSSSelector::PseudoBackdrop:
56 case CSSSelector::PseudoShadow: 56 case CSSSelector::PseudoShadow:
57 return true; 57 return true;
58 default: 58 default:
59 return selector.isCustomPseudoElement(); 59 return selector.isCustomPseudoElement();
60 } 60 }
61 } 61 }
62 if (selector.m_match != CSSSelector::PseudoClass) 62 if (selector.match() != CSSSelector::PseudoClass)
63 return false; 63 return false;
64 switch (selector.pseudoType()) { 64 switch (selector.pseudoType()) {
65 case CSSSelector::PseudoEmpty: 65 case CSSSelector::PseudoEmpty:
66 case CSSSelector::PseudoFirstChild: 66 case CSSSelector::PseudoFirstChild:
67 case CSSSelector::PseudoFirstOfType: 67 case CSSSelector::PseudoFirstOfType:
68 case CSSSelector::PseudoLastChild: 68 case CSSSelector::PseudoLastChild:
69 case CSSSelector::PseudoLastOfType: 69 case CSSSelector::PseudoLastOfType:
70 case CSSSelector::PseudoOnlyChild: 70 case CSSSelector::PseudoOnlyChild:
71 case CSSSelector::PseudoOnlyOfType: 71 case CSSSelector::PseudoOnlyOfType:
72 case CSSSelector::PseudoNthChild: 72 case CSSSelector::PseudoNthChild:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 visitor->trace(rule); 116 visitor->trace(rule);
117 } 117 }
118 118
119 // This method is somewhat conservative in what it accepts. 119 // This method is somewhat conservative in what it accepts.
120 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector) 120 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector)
121 { 121 {
122 bool foundDescendantRelation = false; 122 bool foundDescendantRelation = false;
123 bool foundIdent = false; 123 bool foundIdent = false;
124 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { 124 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) {
125 125
126 if (component->m_match == CSSSelector::Class || component->m_match == CS SSelector::Id 126 if (component->match() == CSSSelector::Class || component->match() == CS SSelector::Id
127 || (component->m_match == CSSSelector::Tag && component->tagQName(). localName() != starAtom) 127 || (component->match() == CSSSelector::Tag && component->tagQName(). localName() != starAtom)
128 || component->isAttributeSelector() || component->isCustomPseudoElem ent()) { 128 || component->isAttributeSelector() || component->isCustomPseudoElem ent()) {
129 if (!foundDescendantRelation) 129 if (!foundDescendantRelation)
130 foundIdent = true; 130 foundIdent = true;
131 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) { 131 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) {
132 if (const CSSSelectorList* selectorList = component->selectorList()) { 132 if (const CSSSelectorList* selectorList = component->selectorList()) {
133 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { 133 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) {
134 InvalidationSetMode hostMode = invalidationSetModeForSelecto r(*selector); 134 InvalidationSetMode hostMode = invalidationSetModeForSelecto r(*selector);
135 if (hostMode == UseSubtreeStyleChange) 135 if (hostMode == UseSubtreeStyleChange)
136 return foundDescendantRelation ? UseLocalStyleChange : U seSubtreeStyleChange; 136 return foundDescendantRelation ? UseLocalStyleChange : U seSubtreeStyleChange;
137 if (!foundDescendantRelation && hostMode == AddFeatures) 137 if (!foundDescendantRelation && hostMode == AddFeatures)
(...skipping 18 matching lines...) Expand all
156 // All combinators should be handled above. 156 // All combinators should be handled above.
157 ASSERT_NOT_REACHED(); 157 ASSERT_NOT_REACHED();
158 return UseLocalStyleChange; 158 return UseLocalStyleChange;
159 } 159 }
160 } 160 }
161 return foundIdent ? AddFeatures : UseLocalStyleChange; 161 return foundIdent ? AddFeatures : UseLocalStyleChange;
162 } 162 }
163 163
164 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features) 164 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features)
165 { 165 {
166 if (selector.m_match == CSSSelector::Tag) 166 if (selector.match() == CSSSelector::Tag)
167 features.tagName = selector.tagQName().localName(); 167 features.tagName = selector.tagQName().localName();
168 else if (selector.m_match == CSSSelector::Id) 168 else if (selector.match() == CSSSelector::Id)
169 features.id = selector.value(); 169 features.id = selector.value();
170 else if (selector.m_match == CSSSelector::Class) 170 else if (selector.match() == CSSSelector::Class)
171 features.classes.append(selector.value()); 171 features.classes.append(selector.value());
172 else if (selector.isAttributeSelector()) 172 else if (selector.isAttributeSelector())
173 features.attributes.append(selector.attribute().localName()); 173 features.attributes.append(selector.attribute().localName());
174 else if (selector.isCustomPseudoElement()) 174 else if (selector.isCustomPseudoElement())
175 features.customPseudoElement = true; 175 features.customPseudoElement = true;
176 } 176 }
177 177
178 RuleFeatureSet::RuleFeatureSet() 178 RuleFeatureSet::RuleFeatureSet()
179 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled()) 179 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled())
180 { 180 {
181 } 181 }
182 182
183 RuleFeatureSet::~RuleFeatureSet() 183 RuleFeatureSet::~RuleFeatureSet()
184 { 184 {
185 } 185 }
186 186
187 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS elector& selector) 187 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS elector& selector)
188 { 188 {
189 if (selector.m_match == CSSSelector::Class) 189 if (selector.match() == CSSSelector::Class)
190 return &ensureClassInvalidationSet(selector.value()); 190 return &ensureClassInvalidationSet(selector.value());
191 if (selector.isAttributeSelector()) 191 if (selector.isAttributeSelector())
192 return &ensureAttributeInvalidationSet(selector.attribute().localName()) ; 192 return &ensureAttributeInvalidationSet(selector.attribute().localName()) ;
193 if (selector.m_match == CSSSelector::Id) 193 if (selector.match() == CSSSelector::Id)
194 return &ensureIdInvalidationSet(selector.value()); 194 return &ensureIdInvalidationSet(selector.value());
195 if (selector.m_match == CSSSelector::PseudoClass) { 195 if (selector.match() == CSSSelector::PseudoClass) {
196 CSSSelector::PseudoType pseudo = selector.pseudoType(); 196 CSSSelector::PseudoType pseudo = selector.pseudoType();
197 if (pseudo == CSSSelector::PseudoHover || pseudo == CSSSelector::PseudoA ctive || pseudo == CSSSelector::PseudoFocus) 197 if (pseudo == CSSSelector::PseudoHover || pseudo == CSSSelector::PseudoA ctive || pseudo == CSSSelector::PseudoFocus)
198 return &ensurePseudoInvalidationSet(pseudo); 198 return &ensurePseudoInvalidationSet(pseudo);
199 } 199 }
200 return 0; 200 return 0;
201 } 201 }
202 202
203 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) 203 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector)
204 { 204 {
205 InvalidationSetMode mode = invalidationSetModeForSelector(selector); 205 InvalidationSetMode mode = invalidationSetModeForSelector(selector);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 visitor->trace(siblingRules); 520 visitor->trace(siblingRules);
521 visitor->trace(uncommonAttributeRules); 521 visitor->trace(uncommonAttributeRules);
522 visitor->trace(m_classInvalidationSets); 522 visitor->trace(m_classInvalidationSets);
523 visitor->trace(m_attributeInvalidationSets); 523 visitor->trace(m_attributeInvalidationSets);
524 visitor->trace(m_idInvalidationSets); 524 visitor->trace(m_idInvalidationSets);
525 visitor->trace(m_pseudoInvalidationSets); 525 visitor->trace(m_pseudoInvalidationSets);
526 visitor->trace(m_styleInvalidator); 526 visitor->trace(m_styleInvalidator);
527 } 527 }
528 528
529 } // namespace WebCore 529 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698