Chromium Code Reviews| Index: Source/core/css/CSSSelector.h |
| diff --git a/Source/core/css/CSSSelector.h b/Source/core/css/CSSSelector.h |
| index 176bc34a69f32f0362996dd870d74e22f0ef850d..079ca89056f1b027a5adb8505bf3a5778b3dac34 100644 |
| --- a/Source/core/css/CSSSelector.h |
| +++ b/Source/core/css/CSSSelector.h |
| @@ -239,6 +239,11 @@ namespace blink { |
| RightBottomMarginBox, |
| }; |
| + enum AttributeMatchType { |
| + CaseSensitive, |
| + CaseInsensitive, |
| + }; |
| + |
| PseudoType pseudoType() const |
| { |
| if (m_pseudoType == PseudoNotParsed) |
| @@ -262,6 +267,7 @@ namespace blink { |
| // how you use the returned QualifiedName. |
| // http://www.w3.org/TR/css3-selectors/#attrnmsp |
| const QualifiedName& attribute() const; |
| + AttributeMatchType attributeMatchType() const; |
| // Returns the argument of a parameterized selector. For example, nth-child(2) would have an argument of 2. |
| const AtomicString& argument() const { return m_hasRareData ? m_data.m_rareData->m_argument : nullAtom; } |
| const CSSSelectorList* selectorList() const { return m_hasRareData ? m_data.m_rareData->m_selectorList.get() : 0; } |
| @@ -272,7 +278,7 @@ namespace blink { |
| #endif |
| void setValue(const AtomicString&); |
| - void setAttribute(const QualifiedName&); |
| + void setAttribute(const QualifiedName&, AttributeMatchType); |
| void setArgument(const AtomicString&); |
| void setSelectorList(PassOwnPtr<CSSSelectorList>); |
| void setMatchUserAgentOnly(); |
| @@ -344,10 +350,20 @@ namespace blink { |
| bool parseNth(); |
| bool matchNth(int count); |
| + int nthAValue() const { return m_bits.m_nth.m_a; } |
| + void setNthAValue(int nthA) { m_bits.m_nth.m_a = nthA; } |
| + int nthBValue() const { return m_bits.m_nth.m_b; } |
| + void setNthBValue(int nthB) { m_bits.m_nth.m_b = nthB; } |
| AtomicString m_value; |
| - int m_a; // Used for :nth-* |
| - int m_b; // Used for :nth-* |
| + union Bits { |
| + Bits() : m_nth() { } |
|
eseidel
2014/07/30 20:12:41
How does this initailize to zeros? Do structs hav
fs
2014/07/31 09:27:15
This boils down to "value-initialize" vs. "default
|
| + struct { |
| + int m_a; // Used for :nth-* |
| + int m_b; // Used for :nth-* |
| + } m_nth; |
| + AttributeMatchType m_attributeMatchType; // used for attribute selector (with value) |
| + } m_bits; |
| QualifiedName m_attribute; // used for attribute selector |
| AtomicString m_argument; // Used for :contains, :lang, :nth-* |
| OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :not |
| @@ -372,6 +388,13 @@ inline const QualifiedName& CSSSelector::attribute() const |
| return m_data.m_rareData->m_attribute; |
| } |
| +inline CSSSelector::AttributeMatchType CSSSelector::attributeMatchType() const |
| +{ |
| + ASSERT(isAttributeSelector()); |
| + ASSERT(m_hasRareData); |
| + return m_data.m_rareData->m_bits.m_attributeMatchType; |
| +} |
| + |
| inline bool CSSSelector::matchesPseudoElement() const |
| { |
| if (m_pseudoType == PseudoUnknown) |