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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSSelector.h

Issue 1731583003: blink: Rename enums and functions to not collide with chromium style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get-names-2: . Created 4 years, 9 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-2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * 1999 Waldo Bastian (bastian@kde.org) 3 * 1999 Waldo Bastian (bastian@kde.org)
4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 String selectorText(const String& rightSide = "") const; 86 String selectorText(const String& rightSide = "") const;
87 87
88 bool operator==(const CSSSelector&) const; 88 bool operator==(const CSSSelector&) const;
89 89
90 // http://www.w3.org/TR/css3-selectors/#specificity 90 // http://www.w3.org/TR/css3-selectors/#specificity
91 // We use 256 as the base of the specificity number system. 91 // We use 256 as the base of the specificity number system.
92 unsigned specificity() const; 92 unsigned specificity() const;
93 93
94 /* how the attribute value has to match.... Default is Exact */ 94 /* how the attribute value has to match.... Default is Exact */
95 enum Match { 95 enum MatchType {
96 Unknown, 96 Unknown,
97 Tag, // Example: div 97 Tag, // Example: div
98 Id, // Example: #id 98 Id, // Example: #id
99 Class, // example: .class 99 Class, // example: .class
100 PseudoClass, // Example: :nth-child(2) 100 PseudoClass, // Example: :nth-child(2)
101 PseudoElement, // Example: ::first-line 101 PseudoElement, // Example: ::first-line
102 PagePseudoClass, // ?? 102 PagePseudoClass, // ??
103 AttributeExact, // Example: E[foo="bar"] 103 AttributeExact, // Example: E[foo="bar"]
104 AttributeSet, // Example: E[foo] 104 AttributeSet, // Example: E[foo]
105 AttributeHyphen, // Example: E[foo|="bar"] 105 AttributeHyphen, // Example: E[foo|="bar"]
106 AttributeList, // Example: E[foo~="bar"] 106 AttributeList, // Example: E[foo~="bar"]
107 AttributeContain, // css3: E[foo*="bar"] 107 AttributeContain, // css3: E[foo*="bar"]
108 AttributeBegin, // css3: E[foo^="bar"] 108 AttributeBegin, // css3: E[foo^="bar"]
109 AttributeEnd, // css3: E[foo$="bar"] 109 AttributeEnd, // css3: E[foo$="bar"]
110 FirstAttributeSelectorMatch = AttributeExact, 110 FirstAttributeSelectorMatch = AttributeExact,
111 }; 111 };
112 112
113 enum Relation { 113 enum RelationType {
114 SubSelector, // No combinator 114 SubSelector, // No combinator
115 Descendant, // "Space" combinator 115 Descendant, // "Space" combinator
116 Child, // > combinator 116 Child, // > combinator
117 DirectAdjacent, // + combinator 117 DirectAdjacent, // + combinator
118 IndirectAdjacent, // ~ combinator 118 IndirectAdjacent, // ~ combinator
119 ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pse udo element 119 ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pse udo element
120 ShadowDeep, // /deep/ combinator 120 ShadowDeep, // /deep/ combinator
121 ShadowSlot // slotted to <slot> element 121 ShadowSlot // slotted to <slot> element
122 }; 122 };
123 123
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 PseudoSpatialNavigationFocus, 204 PseudoSpatialNavigationFocus,
205 PseudoListBox, 205 PseudoListBox,
206 PseudoSlotted 206 PseudoSlotted
207 }; 207 };
208 208
209 enum AttributeMatchType { 209 enum AttributeMatchType {
210 CaseSensitive, 210 CaseSensitive,
211 CaseInsensitive, 211 CaseInsensitive,
212 }; 212 };
213 213
214 PseudoType pseudoType() const { return static_cast<PseudoType>(m_pseudoType) ; } 214 PseudoType getPseudoType() const { return static_cast<PseudoType>(m_pseudoTy pe); }
215 void updatePseudoType(const AtomicString&, bool hasArguments); 215 void updatePseudoType(const AtomicString&, bool hasArguments);
216 216
217 static PseudoType parsePseudoType(const AtomicString&, bool hasArguments); 217 static PseudoType parsePseudoType(const AtomicString&, bool hasArguments);
218 static PseudoId pseudoId(PseudoType); 218 static PseudoId pseudoId(PseudoType);
219 219
220 // Selectors are kept in an array by CSSSelectorList. The next component of the selector is 220 // Selectors are kept in an array by CSSSelectorList. The next component of the selector is
221 // the next item in the array. 221 // the next item in the array.
222 const CSSSelector* tagHistory() const { return m_isLastInTagHistory ? 0 : co nst_cast<CSSSelector*>(this + 1); } 222 const CSSSelector* tagHistory() const { return m_isLastInTagHistory ? 0 : co nst_cast<CSSSelector*>(this + 1); }
223 223
224 const QualifiedName& tagQName() const; 224 const QualifiedName& tagQName() const;
225 const AtomicString& value() const; 225 const AtomicString& value() const;
226 const AtomicString& serializingValue() const; 226 const AtomicString& serializingValue() const;
227 227
228 // WARNING: Use of QualifiedName by attribute() is a lie. 228 // WARNING: Use of QualifiedName by attribute() is a lie.
229 // attribute() will return a QualifiedName with prefix and namespaceURI 229 // attribute() will return a QualifiedName with prefix and namespaceURI
230 // set to starAtom to mean "matches any namespace". Be very careful 230 // set to starAtom to mean "matches any namespace". Be very careful
231 // how you use the returned QualifiedName. 231 // how you use the returned QualifiedName.
232 // http://www.w3.org/TR/css3-selectors/#attrnmsp 232 // http://www.w3.org/TR/css3-selectors/#attrnmsp
233 const QualifiedName& attribute() const; 233 const QualifiedName& attribute() const;
234 AttributeMatchType attributeMatchType() const; 234 AttributeMatchType attributeMatch() const;
235 // Returns the argument of a parameterized selector. For example, :lang(en-U S) would have an argument of en-US. 235 // Returns the argument of a parameterized selector. For example, :lang(en-U S) would have an argument of en-US.
236 // Note that :nth-* selectors don't store an argument and just store the num bers. 236 // Note that :nth-* selectors don't store an argument and just store the num bers.
237 const AtomicString& argument() const { return m_hasRareData ? m_data.m_rareD ata->m_argument : nullAtom; } 237 const AtomicString& argument() const { return m_hasRareData ? m_data.m_rareD ata->m_argument : nullAtom; }
238 const CSSSelectorList* selectorList() const { return m_hasRareData ? m_data. m_rareData->m_selectorList.get() : nullptr; } 238 const CSSSelectorList* selectorList() const { return m_hasRareData ? m_data. m_rareData->m_selectorList.get() : nullptr; }
239 239
240 #ifndef NDEBUG 240 #ifndef NDEBUG
241 void show() const; 241 void show() const;
242 void show(int indent) const; 242 void show(int indent) const;
243 #endif 243 #endif
244 244
245 bool isASCIILower(const AtomicString& value); 245 bool isASCIILower(const AtomicString& value);
246 void setValue(const AtomicString&, bool matchLowerCase); 246 void setValue(const AtomicString&, bool matchLowerCase);
247 void setAttribute(const QualifiedName&, AttributeMatchType); 247 void setAttribute(const QualifiedName&, AttributeMatchType);
248 void setArgument(const AtomicString&); 248 void setArgument(const AtomicString&);
249 void setSelectorList(PassOwnPtr<CSSSelectorList>); 249 void setSelectorList(PassOwnPtr<CSSSelectorList>);
250 250
251 void setNth(int a, int b); 251 void setNth(int a, int b);
252 bool matchNth(int count) const; 252 bool matchNth(int count) const;
253 253
254 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r elation == IndirectAdjacent; } 254 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r elation == IndirectAdjacent; }
255 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat ion == ShadowDeep; } 255 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat ion == ShadowDeep; }
256 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM atch; } 256 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM atch; }
257 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu doType == PseudoHostContext; } 257 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu doType == PseudoHostContext; }
258 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon text || m_pseudoType == PseudoContent; } 258 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon text || m_pseudoType == PseudoContent; }
259 259
260 Relation relation() const { return static_cast<Relation>(m_relation); } 260 RelationType relation() const { return static_cast<RelationType>(m_relation) ; }
261 void setRelation(Relation relation) 261 void setRelation(RelationType relation)
262 { 262 {
263 m_relation = relation; 263 m_relation = relation;
264 ASSERT(static_cast<Relation>(m_relation) == relation); // using a bitfie ld. 264 ASSERT(static_cast<RelationType>(m_relation) == relation); // using a bi tfield.
265 } 265 }
266 266
267 Match match() const { return static_cast<Match>(m_match); } 267 MatchType match() const { return static_cast<MatchType>(m_match); }
268 void setMatch(Match match) 268 void setMatch(MatchType match)
269 { 269 {
270 m_match = match; 270 m_match = match;
271 ASSERT(static_cast<Match>(m_match) == match); // using a bitfield. 271 ASSERT(static_cast<MatchType>(m_match) == match); // using a bitfield.
272 } 272 }
273 273
274 bool isLastInSelectorList() const { return m_isLastInSelectorList; } 274 bool isLastInSelectorList() const { return m_isLastInSelectorList; }
275 void setLastInSelectorList() { m_isLastInSelectorList = true; } 275 void setLastInSelectorList() { m_isLastInSelectorList = true; }
276 bool isLastInTagHistory() const { return m_isLastInTagHistory; } 276 bool isLastInTagHistory() const { return m_isLastInTagHistory; }
277 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } 277 void setNotLastInTagHistory() { m_isLastInTagHistory = false; }
278 278
279 // http://dev.w3.org/csswg/selectors4/#compound 279 // http://dev.w3.org/csswg/selectors4/#compound
280 bool isCompound() const; 280 bool isCompound() const;
281 281
282 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited }; 282 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited };
283 unsigned computeLinkMatchType() const; 283 unsigned computeLinkMatchType() const;
284 284
285 bool isForPage() const { return m_isForPage; } 285 bool isForPage() const { return m_isForPage; }
286 void setForPage() { m_isForPage = true; } 286 void setForPage() { m_isForPage = true; }
287 287
288 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffected ByPseudoContent; } 288 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffected ByPseudoContent; }
289 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseudoCo ntent = true; } 289 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseudoCo ntent = true; }
290 290
291 bool matchesPseudoElement() const; 291 bool matchesPseudoElement() const;
292 292
293 private: 293 private:
294 unsigned m_relation : 3; // enum Relation 294 unsigned m_relation : 3; // enum RelationType
295 unsigned m_match : 4; // enum Match 295 unsigned m_match : 4; // enum MatchType
296 unsigned m_pseudoType : 8; // enum PseudoType 296 unsigned m_pseudoType : 8; // enum PseudoType
297 unsigned m_isLastInSelectorList : 1; 297 unsigned m_isLastInSelectorList : 1;
298 unsigned m_isLastInTagHistory : 1; 298 unsigned m_isLastInTagHistory : 1;
299 unsigned m_hasRareData : 1; 299 unsigned m_hasRareData : 1;
300 unsigned m_isForPage : 1; 300 unsigned m_isForPage : 1;
301 unsigned m_tagIsImplicit : 1; 301 unsigned m_tagIsImplicit : 1;
302 unsigned m_relationIsAffectedByPseudoContent : 1; 302 unsigned m_relationIsAffectedByPseudoContent : 1;
303 303
304 void setPseudoType(PseudoType pseudoType) 304 void setPseudoType(PseudoType pseudoType)
305 { 305 {
(...skipping 15 matching lines...) Expand all
321 int nthAValue() const { return m_bits.m_nth.m_a; } 321 int nthAValue() const { return m_bits.m_nth.m_a; }
322 int nthBValue() const { return m_bits.m_nth.m_b; } 322 int nthBValue() const { return m_bits.m_nth.m_b; }
323 323
324 AtomicString m_matchingValue; 324 AtomicString m_matchingValue;
325 AtomicString m_serializingValue; 325 AtomicString m_serializingValue;
326 union { 326 union {
327 struct { 327 struct {
328 int m_a; // Used for :nth-* 328 int m_a; // Used for :nth-*
329 int m_b; // Used for :nth-* 329 int m_b; // Used for :nth-*
330 } m_nth; 330 } m_nth;
331 AttributeMatchType m_attributeMatchType; // used for attribute selec tor (with value) 331 AttributeMatchType m_attributeMatch; // used for attribute selector (with value)
332 } m_bits; 332 } m_bits;
333 QualifiedName m_attribute; // used for attribute selector 333 QualifiedName m_attribute; // used for attribute selector
334 AtomicString m_argument; // Used for :contains, :lang, :nth-* 334 AtomicString m_argument; // Used for :contains, :lang, :nth-*
335 OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :no t 335 OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :no t
336 336
337 private: 337 private:
338 RareData(const AtomicString& value); 338 RareData(const AtomicString& value);
339 }; 339 };
340 void createRareData(); 340 void createRareData();
341 341
342 union DataUnion { 342 union DataUnion {
343 DataUnion() 343 DataUnion()
344 : m_value(nullptr) 344 : m_value(nullptr)
345 { 345 {
346 } 346 }
347 StringImpl* m_value; 347 StringImpl* m_value;
348 QualifiedName::QualifiedNameImpl* m_tagQName; 348 QualifiedName::QualifiedNameImpl* m_tagQName;
349 RareData* m_rareData; 349 RareData* m_rareData;
350 } m_data; 350 } m_data;
351 }; 351 };
352 352
353 inline const QualifiedName& CSSSelector::attribute() const 353 inline const QualifiedName& CSSSelector::attribute() const
354 { 354 {
355 ASSERT(isAttributeSelector()); 355 ASSERT(isAttributeSelector());
356 ASSERT(m_hasRareData); 356 ASSERT(m_hasRareData);
357 return m_data.m_rareData->m_attribute; 357 return m_data.m_rareData->m_attribute;
358 } 358 }
359 359
360 inline CSSSelector::AttributeMatchType CSSSelector::attributeMatchType() const 360 inline CSSSelector::AttributeMatchType CSSSelector::attributeMatch() const
361 { 361 {
362 ASSERT(isAttributeSelector()); 362 ASSERT(isAttributeSelector());
363 ASSERT(m_hasRareData); 363 ASSERT(m_hasRareData);
364 return m_data.m_rareData->m_bits.m_attributeMatchType; 364 return m_data.m_rareData->m_bits.m_attributeMatch;
365 } 365 }
366 366
367 inline bool CSSSelector::isASCIILower(const AtomicString& value) 367 inline bool CSSSelector::isASCIILower(const AtomicString& value)
368 { 368 {
369 for (size_t i = 0; i < value.length(); ++i) { 369 for (size_t i = 0; i < value.length(); ++i) {
370 if (isASCIIUpper(value[i])) 370 if (isASCIIUpper(value[i]))
371 return false; 371 return false;
372 } 372 }
373 return true; 373 return true;
374 } 374 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (m_hasRareData) 474 if (m_hasRareData)
475 return m_data.m_rareData->m_serializingValue; 475 return m_data.m_rareData->m_serializingValue;
476 // AtomicString is really just a StringImpl* so the cast below is safe. 476 // AtomicString is really just a StringImpl* so the cast below is safe.
477 // FIXME: Perhaps call sites could be changed to accept StringImpl? 477 // FIXME: Perhaps call sites could be changed to accept StringImpl?
478 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); 478 return *reinterpret_cast<const AtomicString*>(&m_data.m_value);
479 } 479 }
480 480
481 } // namespace blink 481 } // namespace blink
482 482
483 #endif // CSSSelector_h 483 #endif // CSSSelector_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSQuadValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSSelector.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698