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

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

Issue 315043005: Simplify CSSSelector::isAttributeSelector() by not checking each Match type (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move new value to end of enum 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
« no previous file with comments | « no previous file | no next file » | 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-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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // http://www.w3.org/TR/css3-selectors/#specificity 103 // http://www.w3.org/TR/css3-selectors/#specificity
104 // We use 256 as the base of the specificity number system. 104 // We use 256 as the base of the specificity number system.
105 unsigned specificity() const; 105 unsigned specificity() const;
106 106
107 /* how the attribute value has to match.... Default is Exact */ 107 /* how the attribute value has to match.... Default is Exact */
108 enum Match { 108 enum Match {
109 Unknown = 0, 109 Unknown = 0,
110 Tag, // Example: div 110 Tag, // Example: div
111 Id, // Example: #id 111 Id, // Example: #id
112 Class, // example: .class 112 Class, // example: .class
113 PseudoClass, // Example: :nth-child(2)
114 PseudoElement, // Example: ::first-line
115 PagePseudoClass, // ??
113 Exact, // Example: E[foo="bar"] 116 Exact, // Example: E[foo="bar"]
114 Set, // Example: E[foo] 117 Set, // Example: E[foo]
118 Hyphen, // Example: E[foo|="bar"]
115 List, // Example: E[foo~="bar"] 119 List, // Example: E[foo~="bar"]
116 Hyphen, // Example: E[foo|="bar"]
117 PseudoClass, // Example: :nth-child(2)
118 PseudoElement, // Example: ::first-line
119 Contain, // css3: E[foo*="bar"] 120 Contain, // css3: E[foo*="bar"]
120 Begin, // css3: E[foo^="bar"] 121 Begin, // css3: E[foo^="bar"]
121 End, // css3: E[foo$="bar"] 122 End, // css3: E[foo$="bar"]
122 PagePseudoClass // ?? 123 FirstAttributeSelectorMatch = Exact,
123 }; 124 };
124 125
125 enum Relation { 126 enum Relation {
126 Descendant = 0, // "Space" combinator 127 Descendant = 0, // "Space" combinator
127 Child, // > combinator 128 Child, // > combinator
128 DirectAdjacent, // + combinator 129 DirectAdjacent, // + combinator
129 IndirectAdjacent, // ~ combinator 130 IndirectAdjacent, // ~ combinator
130 SubSelector, // "No space" combinator 131 SubSelector, // "No space" combinator
131 ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pseudo element 132 ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pseudo element
132 ShadowDeep // /shadow-deep/ combinator 133 ShadowDeep // /shadow-deep/ combinator
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 || type == PseudoOnlyChild 396 || type == PseudoOnlyChild
396 || type == PseudoOnlyOfType 397 || type == PseudoOnlyOfType
397 || type == PseudoNthChild 398 || type == PseudoNthChild
398 || type == PseudoNthOfType 399 || type == PseudoNthOfType
399 || type == PseudoNthLastChild 400 || type == PseudoNthLastChild
400 || type == PseudoNthLastOfType; 401 || type == PseudoNthLastOfType;
401 } 402 }
402 403
403 inline bool CSSSelector::isAttributeSelector() const 404 inline bool CSSSelector::isAttributeSelector() const
404 { 405 {
405 return m_match == CSSSelector::Exact 406 return m_match >= FirstAttributeSelectorMatch;
406 || m_match == CSSSelector::Set
407 || m_match == CSSSelector::List
408 || m_match == CSSSelector::Hyphen
409 || m_match == CSSSelector::Contain
410 || m_match == CSSSelector::Begin
411 || m_match == CSSSelector::End;
412 } 407 }
413 408
414 inline bool CSSSelector::isContentPseudoElement() const 409 inline bool CSSSelector::isContentPseudoElement() const
415 { 410 {
416 return m_match == PseudoElement && pseudoType() == PseudoContent; 411 return m_match == PseudoElement && pseudoType() == PseudoContent;
417 } 412 }
418 413
419 inline bool CSSSelector::isShadowPseudoElement() const 414 inline bool CSSSelector::isShadowPseudoElement() const
420 { 415 {
421 return m_match == PseudoElement && pseudoType() == PseudoShadow; 416 return m_match == PseudoElement && pseudoType() == PseudoShadow;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 if (m_hasRareData) 507 if (m_hasRareData)
513 return m_data.m_rareData->m_value; 508 return m_data.m_rareData->m_value;
514 // AtomicString is really just a StringImpl* so the cast below is safe. 509 // AtomicString is really just a StringImpl* so the cast below is safe.
515 // FIXME: Perhaps call sites could be changed to accept StringImpl? 510 // FIXME: Perhaps call sites could be changed to accept StringImpl?
516 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); 511 return *reinterpret_cast<const AtomicString*>(&m_data.m_value);
517 } 512 }
518 513
519 } // namespace WebCore 514 } // namespace WebCore
520 515
521 #endif // CSSSelector_h 516 #endif // CSSSelector_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698