Make all CSSSelector data members private
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Sep 2014 19:24:12 +0000 (19:24 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Sep 2014 19:24:12 +0000 (19:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136784

Reviewed by Benjamin Poulain.

Make all CSSSelector data members private. Previously, some of the data
members such as m_relation / m_match / m_pseudoType were public and
accessed directly from outside the class. The new approach is better
because:
- Those members are bit fields so by using getters, we can hide the
  casts inside the getters. The setters can now also check that the
  bitfield is big enough to actually store the enum value.
- When using those in switch() statements, the compiler now complains
  if we fail to test some of the enum values as the value is now an
  enum, and not merely an unsigned integer.
- Some of these members already has getters (e.g. relation()).
- Better encapsulation.

No new tests, no behavior change.

* css/CSSParserValues.cpp:
(WebCore::CSSParserSelector::parsePagePseudoSelector):
(WebCore::CSSParserSelector::parsePseudoElementSelector):
(WebCore::CSSParserSelector::parsePseudoElementCueFunctionSelector):
(WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector):
(WebCore::CSSParserSelector::setPseudoClassValue):
(WebCore::CSSParserSelector::isSimple):
(WebCore::CSSParserSelector::prependTagSelector):
* css/CSSParserValues.h:
(WebCore::CSSParserSelector::setMatch):
(WebCore::CSSParserSelector::setRelation):
(WebCore::CSSParserSelector::isPseudoElementCueFunction):
* css/CSSSelector.cpp:
(WebCore::CSSSelector::createRareData):
(WebCore::CSSSelector::specificityForOneSelector):
(WebCore::CSSSelector::specificityForPage):
(WebCore::CSSSelector::operator==):
(WebCore::CSSSelector::selectorText):
* css/CSSSelector.h:
(WebCore::CSSSelector::setPseudoElementType):
(WebCore::CSSSelector::setPagePseudoType):
(WebCore::CSSSelector::pseudoClassType):
(WebCore::CSSSelector::setPseudoClassType):
(WebCore::CSSSelector::pseudoElementType):
(WebCore::CSSSelector::pagePseudoClassType):
(WebCore::CSSSelector::setRelation):
(WebCore::CSSSelector::match):
(WebCore::CSSSelector::setMatch):
(WebCore::CSSSelector::matchesPseudoElement):
(WebCore::CSSSelector::isUnknownPseudoElement):
(WebCore::CSSSelector::isCustomPseudoElement):
(WebCore::CSSSelector::isSiblingSelector):
(WebCore::CSSSelector::isAttributeSelector):
(WebCore::CSSSelector::setValue):
(WebCore::CSSSelector::CSSSelector):
(WebCore::CSSSelector::~CSSSelector):
(WebCore::CSSSelector::tagQName):
(WebCore::CSSSelector::value):
* css/CSSSelectorList.cpp:
(WebCore::SelectorNeedsNamespaceResolutionFunctor::operator()):
* css/PageRuleCollector.cpp:
(WebCore::checkPageSelectorComponents):
* css/RuleFeature.cpp:
(WebCore::RuleFeatureSet::collectFeaturesFromSelector):
* css/RuleSet.cpp:
(WebCore::isSelectorMatchingHTMLBasedOnRuleHash):
(WebCore::determinePropertyWhitelistType):
(WebCore::RuleSet::addRule):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchRecursively):
(WebCore::anyAttributeMatches):
(WebCore::canMatchHoverOrActiveInQuirksMode):
(WebCore::SelectorChecker::checkOne):
(WebCore::SelectorChecker::checkScrollbarPseudoClass):
(WebCore::SelectorChecker::determineLinkMatchType):
* css/SelectorChecker.h:
(WebCore::SelectorChecker::isCommonPseudoClassSelector):
* css/SelectorFilter.cpp:
(WebCore::collectDescendantSelectorIdentifierHashes):
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::constructFragments):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAttributeMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAttributeValueMatching):
* dom/SelectorQuery.cpp:
(WebCore::isSingleTagNameSelector):
(WebCore::isSingleClassNameSelector):
(WebCore::findIdMatchingType):
(WebCore::SelectorDataList::SelectorDataList):
(WebCore::selectorForIdLookup):
(WebCore::filterRootById):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173569 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParserValues.cpp
Source/WebCore/css/CSSParserValues.h
Source/WebCore/css/CSSSelector.cpp
Source/WebCore/css/CSSSelector.h
Source/WebCore/css/CSSSelectorList.cpp
Source/WebCore/css/PageRuleCollector.cpp
Source/WebCore/css/RuleFeature.cpp
Source/WebCore/css/RuleSet.cpp
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/css/SelectorChecker.h
Source/WebCore/css/SelectorFilter.cpp
Source/WebCore/cssjit/SelectorCompiler.cpp
Source/WebCore/dom/SelectorQuery.cpp

index 92873ba..812cb5f 100644 (file)
@@ -1,3 +1,96 @@
+2014-09-12  Chris Dumez  <cdumez@apple.com>
+
+        Make all CSSSelector data members private
+        https://bugs.webkit.org/show_bug.cgi?id=136784
+
+        Reviewed by Benjamin Poulain.
+
+        Make all CSSSelector data members private. Previously, some of the data
+        members such as m_relation / m_match / m_pseudoType were public and
+        accessed directly from outside the class. The new approach is better
+        because:
+        - Those members are bit fields so by using getters, we can hide the
+          casts inside the getters. The setters can now also check that the
+          bitfield is big enough to actually store the enum value.
+        - When using those in switch() statements, the compiler now complains
+          if we fail to test some of the enum values as the value is now an
+          enum, and not merely an unsigned integer.
+        - Some of these members already has getters (e.g. relation()).
+        - Better encapsulation.
+
+        No new tests, no behavior change.
+
+        * css/CSSParserValues.cpp:
+        (WebCore::CSSParserSelector::parsePagePseudoSelector):
+        (WebCore::CSSParserSelector::parsePseudoElementSelector):
+        (WebCore::CSSParserSelector::parsePseudoElementCueFunctionSelector):
+        (WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector):
+        (WebCore::CSSParserSelector::setPseudoClassValue):
+        (WebCore::CSSParserSelector::isSimple):
+        (WebCore::CSSParserSelector::prependTagSelector):
+        * css/CSSParserValues.h:
+        (WebCore::CSSParserSelector::setMatch):
+        (WebCore::CSSParserSelector::setRelation):
+        (WebCore::CSSParserSelector::isPseudoElementCueFunction):
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::createRareData):
+        (WebCore::CSSSelector::specificityForOneSelector):
+        (WebCore::CSSSelector::specificityForPage):
+        (WebCore::CSSSelector::operator==):
+        (WebCore::CSSSelector::selectorText):
+        * css/CSSSelector.h:
+        (WebCore::CSSSelector::setPseudoElementType):
+        (WebCore::CSSSelector::setPagePseudoType):
+        (WebCore::CSSSelector::pseudoClassType):
+        (WebCore::CSSSelector::setPseudoClassType):
+        (WebCore::CSSSelector::pseudoElementType):
+        (WebCore::CSSSelector::pagePseudoClassType):
+        (WebCore::CSSSelector::setRelation):
+        (WebCore::CSSSelector::match):
+        (WebCore::CSSSelector::setMatch):
+        (WebCore::CSSSelector::matchesPseudoElement):
+        (WebCore::CSSSelector::isUnknownPseudoElement):
+        (WebCore::CSSSelector::isCustomPseudoElement):
+        (WebCore::CSSSelector::isSiblingSelector):
+        (WebCore::CSSSelector::isAttributeSelector):
+        (WebCore::CSSSelector::setValue):
+        (WebCore::CSSSelector::CSSSelector):
+        (WebCore::CSSSelector::~CSSSelector):
+        (WebCore::CSSSelector::tagQName):
+        (WebCore::CSSSelector::value):
+        * css/CSSSelectorList.cpp:
+        (WebCore::SelectorNeedsNamespaceResolutionFunctor::operator()):
+        * css/PageRuleCollector.cpp:
+        (WebCore::checkPageSelectorComponents):
+        * css/RuleFeature.cpp:
+        (WebCore::RuleFeatureSet::collectFeaturesFromSelector):
+        * css/RuleSet.cpp:
+        (WebCore::isSelectorMatchingHTMLBasedOnRuleHash):
+        (WebCore::determinePropertyWhitelistType):
+        (WebCore::RuleSet::addRule):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::matchRecursively):
+        (WebCore::anyAttributeMatches):
+        (WebCore::canMatchHoverOrActiveInQuirksMode):
+        (WebCore::SelectorChecker::checkOne):
+        (WebCore::SelectorChecker::checkScrollbarPseudoClass):
+        (WebCore::SelectorChecker::determineLinkMatchType):
+        * css/SelectorChecker.h:
+        (WebCore::SelectorChecker::isCommonPseudoClassSelector):
+        * css/SelectorFilter.cpp:
+        (WebCore::collectDescendantSelectorIdentifierHashes):
+        * cssjit/SelectorCompiler.cpp:
+        (WebCore::SelectorCompiler::constructFragments):
+        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAttributeMatching):
+        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAttributeValueMatching):
+        * dom/SelectorQuery.cpp:
+        (WebCore::isSingleTagNameSelector):
+        (WebCore::isSingleClassNameSelector):
+        (WebCore::findIdMatchingType):
+        (WebCore::SelectorDataList::SelectorDataList):
+        (WebCore::selectorForIdLookup):
+        (WebCore::filterRootById):
+
 2014-09-12  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         REGRESSION(r173441): [GTK] All buttons appear insensitive
index d42ed08..c236c73 100644 (file)
@@ -167,7 +167,7 @@ CSSParserSelector* CSSParserSelector::parsePagePseudoSelector(const CSSParserStr
         return nullptr;
 
     auto selector = std::make_unique<CSSParserSelector>();
-    selector->m_selector->m_match = CSSSelector::PagePseudoClass;
+    selector->m_selector->setMatch(CSSSelector::PagePseudoClass);
     selector->m_selector->setPagePseudoType(pseudoType);
     return selector.release();
 }
@@ -182,7 +182,7 @@ CSSParserSelector* CSSParserSelector::parsePseudoElementSelector(CSSParserString
         return nullptr;
 
     auto selector = std::make_unique<CSSParserSelector>();
-    selector->m_selector->m_match = CSSSelector::PseudoElement;
+    selector->m_selector->setMatch(CSSSelector::PseudoElement);
     selector->m_selector->setPseudoElementType(pseudoType);
     selector->m_selector->setValue(name);
     return selector.release();
@@ -199,7 +199,7 @@ CSSParserSelector* CSSParserSelector::parsePseudoElementCueFunctionSelector(cons
         return nullptr;
 
     auto selector = std::make_unique<CSSParserSelector>();
-    selector->m_selector->m_match = CSSSelector::PseudoElement;
+    selector->m_selector->setMatch(CSSSelector::PseudoElement);
     selector->m_selector->setPseudoElementType(CSSSelector::PseudoElementCue);
     selector->adoptSelectorVector(*selectorVector);
     return selector.release();
@@ -211,13 +211,13 @@ CSSParserSelector* CSSParserSelector::parsePseudoClassAndCompatibilityElementSel
     PseudoClassOrCompatibilityPseudoElement pseudoType = parsePseudoClassAndCompatibilityElementString(pseudoTypeString);
     if (pseudoType.pseudoClass != CSSSelector::PseudoClassUnknown) {
         auto selector = std::make_unique<CSSParserSelector>();
-        selector->m_selector->m_match = CSSSelector::PseudoClass;
-        selector->m_selector->m_pseudoType = pseudoType.pseudoClass;
+        selector->m_selector->setMatch(CSSSelector::PseudoClass);
+        selector->m_selector->setPseudoClassType(pseudoType.pseudoClass);
         return selector.release();
     }
     if (pseudoType.compatibilityPseudoElement != CSSSelector::PseudoElementUnknown) {
         auto selector = std::make_unique<CSSParserSelector>();
-        selector->m_selector->m_match = CSSSelector::PseudoElement;
+        selector->m_selector->setMatch(CSSSelector::PseudoElement);
         selector->m_selector->setPseudoElementType(pseudoType.compatibilityPseudoElement);
         AtomicString name = pseudoTypeString;
         selector->m_selector->setValue(name);
@@ -260,10 +260,10 @@ void CSSParserSelector::adoptSelectorVector(Vector<std::unique_ptr<CSSParserSele
 
 void CSSParserSelector::setPseudoClassValue(const CSSParserString& pseudoClassString)
 {
-    ASSERT(m_selector->m_match == CSSSelector::PseudoClass);
+    ASSERT(m_selector->match() == CSSSelector::PseudoClass);
 
     PseudoClassOrCompatibilityPseudoElement pseudoType = parsePseudoClassAndCompatibilityElementString(pseudoClassString);
-    m_selector->m_pseudoType = pseudoType.pseudoClass;
+    m_selector->setPseudoClassType(pseudoType.pseudoClass);
 }
 
 bool CSSParserSelector::isSimple() const
@@ -274,7 +274,7 @@ bool CSSParserSelector::isSimple() const
     if (!m_tagHistory)
         return true;
 
-    if (m_selector->m_match == CSSSelector::Tag) {
+    if (m_selector->match() == CSSSelector::Tag) {
         // We can't check against anyQName() here because namespace may not be nullAtom.
         // Example:
         //     @namespace "http://www.w3.org/2000/svg";
@@ -312,7 +312,7 @@ void CSSParserSelector::prependTagSelector(const QualifiedName& tagQName, bool t
     m_tagHistory = WTF::move(second);
 
     m_selector = std::make_unique<CSSSelector>(tagQName, tagIsForNamespaceRule);
-    m_selector->m_relation = CSSSelector::SubSelector;
+    m_selector->setRelation(CSSSelector::SubSelector);
 }
 
 }
index b4f926f..d524a05 100644 (file)
@@ -195,8 +195,8 @@ public:
     void setValue(const AtomicString& value) { m_selector->setValue(value); }
     void setAttribute(const QualifiedName& value, bool isCaseInsensitive) { m_selector->setAttribute(value, isCaseInsensitive); }
     void setArgument(const AtomicString& value) { m_selector->setArgument(value); }
-    void setMatch(CSSSelector::Match value) { m_selector->m_match = value; }
-    void setRelation(CSSSelector::Relation value) { m_selector->m_relation = value; }
+    void setMatch(CSSSelector::Match value) { m_selector->setMatch(value); }
+    void setRelation(CSSSelector::Relation value) { m_selector->setRelation(value); }
     void setForPage() { m_selector->setForPage(); }
 
 
@@ -209,7 +209,7 @@ public:
     bool isPseudoElementCueFunction() const
     {
 #if ENABLE(VIDEO_TRACK)
-        return m_selector->m_match == CSSSelector::PseudoElement && m_selector->pseudoElementType() == CSSSelector::PseudoElementCue;
+        return m_selector->match() == CSSSelector::PseudoElement && m_selector->pseudoElementType() == CSSSelector::PseudoElementCue;
 #else
         return false;
 #endif
index 6cec439..21356f9 100644 (file)
@@ -44,7 +44,7 @@ using namespace HTMLNames;
 
 void CSSSelector::createRareData()
 {
-    ASSERT(m_match != Tag);
+    ASSERT(match() != Tag);
     if (m_hasRareData)
         return;
     // Move the value to the rare data stucture.
@@ -85,10 +85,12 @@ inline unsigned CSSSelector::specificityForOneSelector() const
 {
     // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity. This function
     // isn't quite correct.
-    switch (m_match) {
+    switch (match()) {
     case Id:
         return 0x10000;
 
+    case PagePseudoClass:
+        break;
     case PseudoClass:
         // FIXME: PsuedoAny should base the specificity on the sub-selectors.
         // See http://lists.w3.org/Archives/Public/www-style/2010Sep/0530.html
@@ -105,7 +107,6 @@ inline unsigned CSSSelector::specificityForOneSelector() const
     case Begin:
     case End:
         return 0x100;
-
     case Tag:
         return (tagQName().localName() != starAtom) ? 1 : 0;
     case Unknown:
@@ -121,7 +122,7 @@ unsigned CSSSelector::specificityForPage() const
     unsigned s = 0;
 
     for (const CSSSelector* component = this; component; component = component->tagHistory()) {
-        switch (component->m_match) {
+        switch (component->match()) {
         case Tag:
             s += tagQName().localName() == starAtom ? 0 : 4;
             break;
@@ -208,13 +209,13 @@ bool CSSSelector::operator==(const CSSSelector& other) const
     while (sel1 && sel2) {
         if (sel1->attribute() != sel2->attribute()
             || sel1->relation() != sel2->relation()
-            || sel1->m_match != sel2->m_match
+            || sel1->match() != sel2->match()
             || sel1->value() != sel2->value()
             || sel1->m_pseudoType != sel2->m_pseudoType
             || sel1->argument() != sel2->argument()) {
             return false;
         }
-        if (sel1->m_match == Tag) {
+        if (sel1->match() == Tag) {
             if (sel1->tagQName() != sel2->tagQName())
                 return false;
         }
@@ -249,7 +250,7 @@ String CSSSelector::selectorText(const String& rightSide) const
 {
     StringBuilder str;
 
-    if (m_match == CSSSelector::Tag && !m_tagIsForNamespaceRule) {
+    if (match() == CSSSelector::Tag && !m_tagIsForNamespaceRule) {
         if (tagQName().prefix().isNull())
             str.append(tagQName().localName());
         else {
@@ -261,13 +262,13 @@ String CSSSelector::selectorText(const String& rightSide) const
 
     const CSSSelector* cs = this;
     while (true) {
-        if (cs->m_match == CSSSelector::Id) {
+        if (cs->match() == CSSSelector::Id) {
             str.append('#');
             serializeIdentifier(cs->value(), str);
-        } else if (cs->m_match == CSSSelector::Class) {
+        } else if (cs->match() == CSSSelector::Class) {
             str.append('.');
             serializeIdentifier(cs->value(), str);
-        } else if (cs->m_match == CSSSelector::PseudoClass) {
+        } else if (cs->match() == CSSSelector::PseudoClass) {
             switch (cs->pseudoClassType()) {
 #if ENABLE(FULLSCREEN_API)
             case CSSSelector::PseudoClassAnimatingFullScreenTransition:
@@ -469,7 +470,7 @@ String CSSSelector::selectorText(const String& rightSide) const
             case CSSSelector::PseudoClassUnknown:
                 ASSERT_NOT_REACHED();
             }
-        } else if (cs->m_match == CSSSelector::PseudoElement) {
+        } else if (cs->match() == CSSSelector::PseudoElement) {
             str.appendLiteral("::");
             str.append(cs->value());
         } else if (cs->isAttributeSelector()) {
@@ -480,7 +481,7 @@ String CSSSelector::selectorText(const String& rightSide) const
                 str.append('|');
             }
             str.append(cs->attribute().localName());
-            switch (cs->m_match) {
+            switch (cs->match()) {
                 case CSSSelector::Exact:
                     str.append('=');
                     break;
@@ -506,11 +507,11 @@ String CSSSelector::selectorText(const String& rightSide) const
                 default:
                     break;
             }
-            if (cs->m_match != CSSSelector::Set) {
+            if (cs->match() != CSSSelector::Set) {
                 serializeString(cs->value(), str);
                 str.append(']');
             }
-        } else if (cs->m_match == CSSSelector::PagePseudoClass) {
+        } else if (cs->match() == CSSSelector::PagePseudoClass) {
             switch (cs->pagePseudoClassType()) {
             case PagePseudoClassFirst:
                 str.appendLiteral(":first");
index 31c53b0..b817367 100644 (file)
@@ -205,8 +205,6 @@ namespace WebCore {
         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; }
 
-        void setPseudoElementType(PseudoElementType pseudoElementType) { m_pseudoType = pseudoElementType; }
-        void setPagePseudoType(PagePseudoClassType pagePseudoType) { m_pseudoType = pagePseudoType; }
         void setValue(const AtomicString&);
         void setAttribute(const QualifiedName&, bool isCaseInsensitive);
         void setArgument(const AtomicString&);
@@ -219,21 +217,36 @@ namespace WebCore {
 
         PseudoClassType pseudoClassType() const
         {
-            ASSERT(m_match == PseudoClass);
+            ASSERT(match() == PseudoClass);
             return static_cast<PseudoClassType>(m_pseudoType);
         }
+        void setPseudoClassType(PseudoClassType pseudoType)
+        {
+            m_pseudoType = pseudoType;
+            ASSERT(m_pseudoType == pseudoType);
+        }
 
         PseudoElementType pseudoElementType() const
         {
-            ASSERT(m_match == PseudoElement);
+            ASSERT(match() == PseudoElement);
             return static_cast<PseudoElementType>(m_pseudoType);
         }
+        void setPseudoElementType(PseudoElementType pseudoElementType)
+        {
+            m_pseudoType = pseudoElementType;
+            ASSERT(m_pseudoType == pseudoElementType);
+        }
 
         PagePseudoClassType pagePseudoClassType() const
         {
-            ASSERT(m_match == PagePseudoClass);
+            ASSERT(match() == PagePseudoClass);
             return static_cast<PagePseudoClassType>(m_pseudoType);
         }
+        void setPagePseudoType(PagePseudoClassType pagePseudoType)
+        {
+            m_pseudoType = pagePseudoType;
+            ASSERT(m_pseudoType == pagePseudoType);
+        }
 
         bool matchesPseudoElement() const;
         bool isUnknownPseudoElement() const;
@@ -242,6 +255,18 @@ namespace WebCore {
         bool isAttributeSelector() const;
 
         Relation relation() const { return static_cast<Relation>(m_relation); }
+        void setRelation(Relation relation)
+        {
+            m_relation = relation;
+            ASSERT(m_relation == relation);
+        }
+
+        Match match() const { return static_cast<Match>(m_match); }
+        void setMatch(Match match)
+        {
+            m_match = match;
+            ASSERT(m_match == match);
+        }
 
         bool isLastInSelectorList() const { return m_isLastInSelectorList; }
         void setLastInSelectorList() { m_isLastInSelectorList = true; }
@@ -253,11 +278,10 @@ namespace WebCore {
         bool isForPage() const { return m_isForPage; }
         void setForPage() { m_isForPage = true; }
 
+    private:
         unsigned m_relation           : 3; // enum Relation
         mutable unsigned m_match      : 4; // enum Match
         mutable unsigned m_pseudoType : 8; // PseudoType
-
-    private:
         mutable bool m_parsedNth      : 1; // Used for :nth-*
         bool m_isLastInSelectorList   : 1;
         bool m_isLastInTagHistory     : 1;
@@ -315,17 +339,17 @@ inline const AtomicString& CSSSelector::attributeCanonicalLocalName() const
 
 inline bool CSSSelector::matchesPseudoElement() const
 {
-    return m_match == PseudoElement;
+    return match() == PseudoElement;
 }
 
 inline bool CSSSelector::isUnknownPseudoElement() const
 {
-    return m_match == PseudoElement && m_pseudoType == PseudoElementUnknown;
+    return match() == PseudoElement && pseudoElementType() == PseudoElementUnknown;
 }
 
 inline bool CSSSelector::isCustomPseudoElement() const
 {
-    return m_match == PseudoElement && (m_pseudoType == PseudoElementUserAgentCustom || m_pseudoType == PseudoElementWebKitCustom);
+    return match() == PseudoElement && (pseudoElementType() == PseudoElementUserAgentCustom || pseudoElementType() == PseudoElementWebKitCustom);
 }
 
 static inline bool pseudoClassIsRelativeToSiblings(CSSSelector::PseudoClassType type)
@@ -345,25 +369,25 @@ static inline bool pseudoClassIsRelativeToSiblings(CSSSelector::PseudoClassType
 
 inline bool CSSSelector::isSiblingSelector() const
 {
-    return m_relation == DirectAdjacent
-        || m_relation == IndirectAdjacent
-        || (m_match == CSSSelector::PseudoClass && pseudoClassIsRelativeToSiblings(pseudoClassType()));
+    return relation() == DirectAdjacent
+        || relation() == IndirectAdjacent
+        || (match() == CSSSelector::PseudoClass && pseudoClassIsRelativeToSiblings(pseudoClassType()));
 }
 
 inline bool CSSSelector::isAttributeSelector() const
 {
-    return m_match == CSSSelector::Exact
-        || m_match ==  CSSSelector::Set
-        || m_match == CSSSelector::List
-        || m_match == CSSSelector::Hyphen
-        || m_match == CSSSelector::Contain
-        || m_match == CSSSelector::Begin
-        || m_match == CSSSelector::End;
+    return match() == CSSSelector::Exact
+        || match() ==  CSSSelector::Set
+        || match() == CSSSelector::List
+        || match() == CSSSelector::Hyphen
+        || match() == CSSSelector::Contain
+        || match() == CSSSelector::Begin
+        || match() == CSSSelector::End;
 }
 
 inline void CSSSelector::setValue(const AtomicString& value)
 {
-    ASSERT(m_match != Tag);
+    ASSERT(match() != Tag);
     // Need to do ref counting manually for the union.
     if (m_hasRareData) {
         if (m_data.m_rareData->m_value)
@@ -417,7 +441,7 @@ inline CSSSelector::CSSSelector(const CSSSelector& o)
     , m_isForPage(o.m_isForPage)
     , m_tagIsForNamespaceRule(o.m_tagIsForNamespaceRule)
 {
-    if (o.m_match == Tag) {
+    if (o.match() == Tag) {
         m_data.m_tagQName = o.m_data.m_tagQName;
         m_data.m_tagQName->ref();
     } else if (o.m_hasRareData) {
@@ -431,7 +455,7 @@ inline CSSSelector::CSSSelector(const CSSSelector& o)
 
 inline CSSSelector::~CSSSelector()
 {
-    if (m_match == Tag)
+    if (match() == Tag)
         m_data.m_tagQName->deref();
     else if (m_hasRareData)
         m_data.m_rareData->deref();
@@ -441,13 +465,13 @@ inline CSSSelector::~CSSSelector()
 
 inline const QualifiedName& CSSSelector::tagQName() const
 {
-    ASSERT(m_match == Tag);
+    ASSERT(match() == Tag);
     return *reinterpret_cast<const QualifiedName*>(&m_data.m_tagQName);
 }
 
 inline const AtomicString& CSSSelector::value() const
 {
-    ASSERT(m_match != Tag);
+    ASSERT(match() != Tag);
     // AtomicString is really just an AtomicStringImpl* so the cast below is safe.
     // FIXME: Perhaps call sites could be changed to accept AtomicStringImpl?
     return *reinterpret_cast<const AtomicString*>(m_hasRareData ? &m_data.m_rareData->m_value : &m_data.m_value);
index 037641c..4e2b7b9 100644 (file)
@@ -166,7 +166,7 @@ class SelectorNeedsNamespaceResolutionFunctor {
 public:
     bool operator()(const CSSSelector* selector)
     {
-        if (selector->m_match == CSSSelector::Tag && selector->tagQName().prefix() != nullAtom && selector->tagQName().prefix() != starAtom)
+        if (selector->match() == CSSSelector::Tag && selector->tagQName().prefix() != nullAtom && selector->tagQName().prefix() != starAtom)
             return true;
         if (selector->isAttributeSelector() && selector->attribute().prefix() != nullAtom && selector->attribute().prefix() != starAtom)
             return true;
index 362cd7e..839e878 100644 (file)
@@ -92,11 +92,11 @@ void PageRuleCollector::matchPageRules(RuleSet* rules, bool isLeftPage, bool isF
 static bool checkPageSelectorComponents(const CSSSelector* selector, bool isLeftPage, bool isFirstPage, const String& pageName)
 {
     for (const CSSSelector* component = selector; component; component = component->tagHistory()) {
-        if (component->m_match == CSSSelector::Tag) {
+        if (component->match() == CSSSelector::Tag) {
             const AtomicString& localName = component->tagQName().localName();
             if (localName != starAtom && localName != pageName)
                 return false;
-        } else if (component->m_match == CSSSelector::PagePseudoClass) {
+        } else if (component->match() == CSSSelector::PagePseudoClass) {
             CSSSelector::PagePseudoClassType pseudoType = component->pagePseudoClassType();
             if ((pseudoType == CSSSelector::PagePseudoClassLeft && !isLeftPage)
                 || (pseudoType == CSSSelector::PagePseudoClassRight && isLeftPage)
index 5c49baf..58de5d5 100644 (file)
@@ -35,14 +35,14 @@ namespace WebCore {
 
 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector* selector)
 {
-    if (selector->m_match == CSSSelector::Id)
+    if (selector->match() == CSSSelector::Id)
         idsInRules.add(selector->value().impl());
-    else if (selector->m_match == CSSSelector::Class)
+    else if (selector->match() == CSSSelector::Class)
         classesInRules.add(selector->value().impl());
     else if (selector->isAttributeSelector()) {
         attributeCanonicalLocalNamesInRules.add(selector->attributeCanonicalLocalName().impl());
         attributeLocalNamesInRules.add(selector->attribute().localName().impl());
-    } else if (selector->m_match == CSSSelector::PseudoElement) {
+    } else if (selector->match() == CSSSelector::PseudoElement) {
         switch (selector->pseudoElementType()) {
         case CSSSelector::PseudoElementFirstLine:
             usesFirstLineRules = true;
index ee4175d..b71e996 100644 (file)
@@ -58,13 +58,13 @@ static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector& sele
     if (selector.tagHistory())
         return false;
 
-    if (selector.m_match == CSSSelector::Tag) {
+    if (selector.match() == CSSSelector::Tag) {
         const AtomicString& selectorNamespace = selector.tagQName().namespaceURI();
         return selectorNamespace == starAtom || selectorNamespace == xhtmlNamespaceURI;
     }
     if (SelectorChecker::isCommonPseudoClassSelector(&selector))
         return true;
-    return selector.m_match == CSSSelector::Id || selector.m_match == CSSSelector::Class;
+    return selector.match() == CSSSelector::Id || selector.match() == CSSSelector::Class;
 }
 
 static bool selectorCanMatchPseudoElement(const CSSSelector& rootSelector)
@@ -135,7 +135,7 @@ static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
         return PropertyWhitelistRegion;
 #if ENABLE(VIDEO_TRACK)
     for (const CSSSelector* component = selector; component; component = component->tagHistory()) {
-        if (component->m_match == CSSSelector::PseudoElement && (component->pseudoElementType() == CSSSelector::PseudoElementCue || component->value() == TextTrackCue::cueShadowPseudoId()))
+        if (component->match() == CSSSelector::PseudoElement && (component->pseudoElementType() == CSSSelector::PseudoElementCue || component->value() == TextTrackCue::cueShadowPseudoId()))
             return PropertyWhitelistCue;
     }
 #else
@@ -214,13 +214,13 @@ void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR
     const CSSSelector* focusSelector = nullptr;
     const CSSSelector* selector = ruleData.selector();
     do {
-        if (selector->m_match == CSSSelector::Id) {
+        if (selector->match() == CSSSelector::Id) {
             addToRuleSet(selector->value().impl(), m_idRules, ruleData);
             return;
         }
 
 #if ENABLE(VIDEO_TRACK)
-        if (selector->m_match == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementCue) {
+        if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementCue) {
             m_cuePseudoRules.append(ruleData);
             return;
         }
@@ -231,7 +231,7 @@ void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR
             return;
         }
 
-        if (selector->m_match == CSSSelector::Class) {
+        if (selector->match() == CSSSelector::Class) {
             AtomicStringImpl* className = selector->value().impl();
             if (!classSelector) {
                 classSelector = selector;
@@ -245,7 +245,7 @@ void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR
             }
         }
 
-        if (selector->m_match == CSSSelector::Tag && selector->tagQName().localName() != starAtom)
+        if (selector->match() == CSSSelector::Tag && selector->tagQName().localName() != starAtom)
             tagSelector = selector;
 
         if (SelectorChecker::isCommonPseudoClassSelector(selector)) {
index ee623c6..be74207 100644 (file)
@@ -224,7 +224,7 @@ SelectorChecker::Match SelectorChecker::matchRecursively(const CheckingContextWi
     if (!checkOne(context))
         return SelectorFailsLocally;
 
-    if (context.selector->m_match == CSSSelector::PseudoElement) {
+    if (context.selector->match() == CSSSelector::PseudoElement) {
         // In Selectors Level 4, a pseudo element inside a functional pseudo class is undefined (issue 7).
         // Make it as matching failure until the spec clarifies this case.
         if (context.inFunctionalPseudoClass)
@@ -337,7 +337,7 @@ SelectorChecker::Match SelectorChecker::matchRecursively(const CheckingContextWi
         nextContext.hasSelectionPseudo = dynamicPseudo == SELECTION;
         if ((context.elementStyle || context.resolvingMode == Mode::CollectingRules) && dynamicPseudo != NOPSEUDO
             && !nextContext.hasSelectionPseudo
-            && !(nextContext.hasScrollbarPseudo && nextContext.selector->m_match == CSSSelector::PseudoClass))
+            && !(nextContext.hasScrollbarPseudo && nextContext.selector->match() == CSSSelector::PseudoClass))
             return SelectorFailsCompletely;
         return matchRecursively(nextContext, dynamicPseudo);
 
@@ -427,7 +427,7 @@ static bool anyAttributeMatches(Element* element, const CSSSelector* selector, c
         if (!attribute.matches(selectorAttr.prefix(), element->isHTMLElement() ? selector->attributeCanonicalLocalName() : selectorAttr.localName(), selectorAttr.namespaceURI()))
             continue;
 
-        if (attributeValueMatches(attribute, static_cast<CSSSelector::Match>(selector->m_match), selector->value(), caseSensitive))
+        if (attributeValueMatches(attribute, selector->match(), selector->value(), caseSensitive))
             return true;
     }
 
@@ -451,7 +451,7 @@ static bool canMatchHoverOrActiveInQuirksMode(const SelectorChecker::CheckingCon
         return true;
 
     for (const CSSSelector* selector = context.firstSelectorOfTheFragment; selector; selector = selector->tagHistory()) {
-        switch (selector->m_match) {
+        switch (selector->match()) {
         case CSSSelector::Tag:
             if (selector->tagQName() != anyQName())
                 return true;
@@ -496,13 +496,13 @@ bool SelectorChecker::checkOne(const CheckingContextWithStatus& context) const
     ASSERT(element);
     ASSERT(selector);
 
-    if (selector->m_match == CSSSelector::Tag)
+    if (selector->match() == CSSSelector::Tag)
         return SelectorChecker::tagMatches(element, selector->tagQName());
 
-    if (selector->m_match == CSSSelector::Class)
+    if (selector->match() == CSSSelector::Class)
         return element->hasClass() && element->classNames().contains(selector->value());
 
-    if (selector->m_match == CSSSelector::Id)
+    if (selector->match() == CSSSelector::Id)
         return element->hasID() && element->idForStyleResolution() == selector->value();
 
     if (selector->isAttributeSelector()) {
@@ -516,7 +516,7 @@ bool SelectorChecker::checkOne(const CheckingContextWithStatus& context) const
             return false;
     }
 
-    if (selector->m_match == CSSSelector::PseudoClass) {
+    if (selector->match() == CSSSelector::PseudoClass) {
         // Handle :not up front.
         if (selector->pseudoClassType() == CSSSelector::PseudoClassNot) {
             const CSSSelectorList* selectorList = selector->selectorList();
@@ -529,7 +529,7 @@ bool SelectorChecker::checkOne(const CheckingContextWithStatus& context) const
             subContext.inFunctionalPseudoClass = true;
             subContext.firstSelectorOfTheFragment = selectorList->first();
             for (subContext.selector = selectorList->first(); subContext.selector; subContext.selector = subContext.selector->tagHistory()) {
-                if (subContext.selector->m_match == CSSSelector::PseudoClass) {
+                if (subContext.selector->match() == CSSSelector::PseudoClass) {
                     // :not cannot nest. I don't really know why this is a
                     // restriction in CSS3, but it is, so let's honor it.
                     // the parser enforces that this never occurs
@@ -868,7 +868,7 @@ bool SelectorChecker::checkOne(const CheckingContextWithStatus& context) const
         return false;
     }
 #if ENABLE(VIDEO_TRACK)
-    else if (selector->m_match == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementCue) {
+    if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementCue) {
         CheckingContextWithStatus subContext(context);
 
         PseudoId ignoreDynamicPseudo = NOPSEUDO;
@@ -888,7 +888,7 @@ bool SelectorChecker::checkOne(const CheckingContextWithStatus& context) const
 
 bool SelectorChecker::checkScrollbarPseudoClass(const CheckingContextWithStatus& context, const CSSSelector* selector) const
 {
-    ASSERT(selector->m_match == CSSSelector::PseudoClass);
+    ASSERT(selector->match() == CSSSelector::PseudoClass);
 
     switch (selector->pseudoClassType()) {
     case CSSSelector::PseudoClassWindowInactive:
@@ -933,7 +933,7 @@ unsigned SelectorChecker::determineLinkMatchType(const CSSSelector* selector)
     // Statically determine if this selector will match a link in visited, unvisited or any state, or never.
     // :visited never matches other elements than the innermost link element.
     for (; selector; selector = selector->tagHistory()) {
-        if (selector->m_match == CSSSelector::PseudoClass) {
+        if (selector->match() == CSSSelector::PseudoClass) {
             switch (selector->pseudoClassType()) {
             case CSSSelector::PseudoClassNot:
                 {
@@ -943,7 +943,7 @@ unsigned SelectorChecker::determineLinkMatchType(const CSSSelector* selector)
                         break;
 
                     for (const CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = subSelector->tagHistory()) {
-                        if (subSelector->m_match == CSSSelector::PseudoClass) {
+                        if (subSelector->match() == CSSSelector::PseudoClass) {
                             CSSSelector::PseudoClassType subType = subSelector->pseudoClassType();
                             if (subType == CSSSelector::PseudoClassVisited)
                                 linkMatchType &= ~SelectorChecker::MatchVisited;
index 886f363..47c1c90 100644 (file)
@@ -94,7 +94,7 @@ private:
 
 inline bool SelectorChecker::isCommonPseudoClassSelector(const CSSSelector* selector)
 {
-    if (selector->m_match != CSSSelector::PseudoClass)
+    if (selector->match() != CSSSelector::PseudoClass)
         return false;
     CSSSelector::PseudoClassType pseudoType = selector->pseudoClassType();
     return pseudoType == CSSSelector::PseudoClassLink
index 2fa5d03..799cf3b 100644 (file)
@@ -112,7 +112,7 @@ void SelectorFilter::pushParent(Element* parent)
 
 static inline void collectDescendantSelectorIdentifierHashes(const CSSSelector* selector, unsigned*& hash)
 {
-    switch (selector->m_match) {
+    switch (selector->match()) {
     case CSSSelector::Id:
         if (!selector->value().isEmpty())
             (*hash++) = selector->value().impl()->existingHash() * IdAttributeSalt;
index 99a5037..2c30a03 100644 (file)
@@ -705,7 +705,7 @@ static FunctionType constructFragments(const CSSSelector* rootSelector, Selector
             return FunctionType::CannotMatchAnything;
         }
 
-        switch (selector->m_match) {
+        switch (selector->match()) {
         case CSSSelector::Tag:
             ASSERT(!fragment.tagName);
             fragment.tagName = &(selector->tagQName());
@@ -2177,7 +2177,7 @@ void SelectorCodeGenerator::generateElementAttributeMatching(Assembler::JumpList
 
     successCases.link(&m_assembler);
 
-    if (attributeSelector.m_match != CSSSelector::Set) {
+    if (attributeSelector.match() != CSSSelector::Set) {
         // We make the assumption that name matching fails in most cases and we keep value matching outside
         // of the loop. We re-enter the loop if needed.
         // FIXME: exact case sensitive value matching is so simple that it should be done in the loop.
@@ -2269,7 +2269,7 @@ void SelectorCodeGenerator::generateElementAttributeValueMatching(Assembler::Jum
     ASSERT(!expectedValue.isNull());
     bool defaultToCaseSensitiveValueMatch = attributeInfo.canDefaultToCaseSensitiveValueMatch();
 
-    switch (attributeSelector.m_match) {
+    switch (attributeSelector.match()) {
     case CSSSelector::Begin:
         generateElementAttributeFunctionCallValueMatching(failureCases, currentAttributeAddress, expectedValue, defaultToCaseSensitiveValueMatch, attributeValueBeginsWith<CaseSensitive>, attributeValueBeginsWith<CaseInsensitive>);
         break;
index c9dd60e..f157d18 100644 (file)
@@ -37,12 +37,12 @@ namespace WebCore {
 #if !ASSERT_DISABLED
 static bool isSingleTagNameSelector(const CSSSelector& selector)
 {
-    return selector.isLastInTagHistory() && selector.m_match == CSSSelector::Tag;
+    return selector.isLastInTagHistory() && selector.match() == CSSSelector::Tag;
 }
 
 static bool isSingleClassNameSelector(const CSSSelector& selector)
 {
-    return selector.isLastInTagHistory() && selector.m_match == CSSSelector::Class;
+    return selector.isLastInTagHistory() && selector.match() == CSSSelector::Class;
 }
 #endif
 
@@ -56,7 +56,7 @@ static IdMatchingType findIdMatchingType(const CSSSelector& firstSelector)
 {
     bool inRightmost = true;
     for (const CSSSelector* selector = &firstSelector; selector; selector = selector->tagHistory()) {
-        if (selector->m_match == CSSSelector::Id) {
+        if (selector->match() == CSSSelector::Id) {
             if (inRightmost)
                 return IdMatchingType::Rightmost;
             return IdMatchingType::Filter;
@@ -80,7 +80,7 @@ SelectorDataList::SelectorDataList(const CSSSelectorList& selectorList)
     if (selectorCount == 1) {
         const CSSSelector& selector = *m_selectors.first().selector;
         if (selector.isLastInTagHistory()) {
-            switch (selector.m_match) {
+            switch (selector.match()) {
             case CSSSelector::Tag:
                 m_matchType = TagNameMatch;
                 break;
@@ -168,7 +168,7 @@ static const CSSSelector* selectorForIdLookup(const ContainerNode& rootNode, con
         return nullptr;
 
     for (const CSSSelector* selector = &firstSelector; selector; selector = selector->tagHistory()) {
-        if (selector->m_match == CSSSelector::Id)
+        if (selector->match() == CSSSelector::Id)
             return selector;
         if (selector->relation() != CSSSelector::SubSelector)
             break;
@@ -224,7 +224,7 @@ static ContainerNode& filterRootById(ContainerNode& rootNode, const CSSSelector&
     // Thus we can skip the rightmost match.
     const CSSSelector* selector = &firstSelector;
     do {
-        ASSERT(selector->m_match != CSSSelector::Id);
+        ASSERT(selector->match() != CSSSelector::Id);
         if (selector->relation() != CSSSelector::SubSelector)
             break;
         selector = selector->tagHistory();
@@ -232,7 +232,7 @@ static ContainerNode& filterRootById(ContainerNode& rootNode, const CSSSelector&
 
     bool inAdjacentChain = false;
     for (; selector; selector = selector->tagHistory()) {
-        if (selector->m_match == CSSSelector::Id) {
+        if (selector->match() == CSSSelector::Id) {
             const AtomicString& idToMatch = selector->value();
             if (ContainerNode* searchRoot = rootNode.treeScope().getElementById(idToMatch)) {
                 if (LIKELY(!rootNode.treeScope().containsMultipleElementsWithId(idToMatch))) {