Changeset 143150 in webkit


Ignore:
Timestamp:
Feb 17, 2013 10:37:10 PM (11 years ago)
Author:
Dimitri Glazkov
Message:

Stop passing around SelectorChecker in ContentSelectorQuery.
https://bugs.webkit.org/show_bug.cgi?id=110041

Now that SelectorChecker has no interesting state, we can simplify ContentSelectorQuery and get rid of a class.

Reviewed by Andreas Kling.

No functional changes, covered by existing tests.

  • html/shadow/ContentSelectorQuery.cpp:

(WebCore::ContentSelectorDataList::checkContentSelector): Zapped ContentSelectorChecker and moved its only remaining method here.
(WebCore::ContentSelectorDataList::matches): Removed SelectorChecker argument.
(WebCore::ContentSelectorQuery::ContentSelectorQuery): Removed an unnecessary member.
(WebCore::ContentSelectorQuery::matches): Removed unnecessary argument.

  • html/shadow/ContentSelectorQuery.h:

(WebCore): Cleaned up the file.
(ContentSelectorDataList): Updated decls.
(ContentSelectorQuery): Ditto.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143148 r143150  
     12013-02-17  Dimitri Glazkov  <dglazkov@chromium.org>
     2
     3        Stop passing around SelectorChecker in ContentSelectorQuery.
     4        https://bugs.webkit.org/show_bug.cgi?id=110041
     5
     6        Now that SelectorChecker has no interesting state, we can simplify ContentSelectorQuery and get rid of a class.
     7
     8        Reviewed by Andreas Kling.
     9
     10        No functional changes, covered by existing tests.
     11
     12        * html/shadow/ContentSelectorQuery.cpp:
     13        (WebCore::ContentSelectorDataList::checkContentSelector): Zapped ContentSelectorChecker and moved its only remaining method here.
     14        (WebCore::ContentSelectorDataList::matches): Removed SelectorChecker argument.
     15        (WebCore::ContentSelectorQuery::ContentSelectorQuery): Removed an unnecessary member.
     16        (WebCore::ContentSelectorQuery::matches): Removed unnecessary argument.
     17        * html/shadow/ContentSelectorQuery.h:
     18        (WebCore): Cleaned up the file.
     19        (ContentSelectorDataList): Updated decls.
     20        (ContentSelectorQuery): Ditto.
     21
    1222013-02-17  Mike West  <mkwst@chromium.org>
    223
  • trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp

    r142717 r143150  
    3636namespace WebCore {
    3737
    38 ContentSelectorChecker::ContentSelectorChecker(Document* document)
    39     : m_selectorChecker(document, SelectorChecker::CollectingRules)
     38bool ContentSelectorDataList::checkContentSelector(const CSSSelector* selector, const Vector<RefPtr<Node> >& siblings, int nth)
    4039{
    41 }
    42 
    43 bool ContentSelectorChecker::checkContentSelector(const CSSSelector* selector, const Vector<RefPtr<Node> >& siblings, int nth) const
    44 {
    45     SelectorChecker::SelectorCheckingContext context(selector, toElement(siblings[nth].get()), SelectorChecker::VisitedMatchEnabled);
     40    Element* element = toElement(siblings[nth].get());
     41    SelectorChecker selectorChecker(element->document(), SelectorChecker::CollectingRules);
     42    SelectorChecker::SelectorCheckingContext context(selector, element, SelectorChecker::VisitedMatchEnabled);
    4643    ShadowDOMSiblingTraversalStrategy strategy(siblings, nth);
    4744    PseudoId ignoreDynamicPseudo = NOPSEUDO;
    48     return m_selectorChecker.match(context, ignoreDynamicPseudo, strategy) == SelectorChecker::SelectorMatches;
     45    return selectorChecker.match(context, ignoreDynamicPseudo, strategy) == SelectorChecker::SelectorMatches;
    4946}
    5047
     
    5552}
    5653
    57 bool ContentSelectorDataList::matches(const ContentSelectorChecker& selectorChecker, const Vector<RefPtr<Node> >& siblings, int nth) const
     54bool ContentSelectorDataList::matches(const Vector<RefPtr<Node> >& siblings, int nth) const
    5855{
    5956    unsigned selectorCount = m_selectors.size();
    6057    for (unsigned i = 0; i < selectorCount; ++i) {
    61         if (selectorChecker.checkContentSelector(m_selectors[i], siblings, nth))
     58        if (checkContentSelector(m_selectors[i], siblings, nth))
    6259            return true;
    6360    }
     
    6764ContentSelectorQuery::ContentSelectorQuery(InsertionPoint* insertionPoint)
    6865    : m_insertionPoint(insertionPoint)
    69     , m_selectorChecker(insertionPoint->document())
    7066{
    7167    m_selectors.initialize(insertionPoint->selectorList());
     
    8379        return false;
    8480    case InsertionPoint::HasToMatchSelector:
    85         return node->isElementNode() && m_selectors.matches(m_selectorChecker, siblings, nth);
     81        return node->isElementNode() && m_selectors.matches(siblings, nth);
    8682    default:
    8783        ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h

    r140530 r143150  
    4444class InsertionPoint;
    4545
    46 class ContentSelectorChecker {
    47 public:
    48     ContentSelectorChecker(Document*);
    49 
    50     bool checkContentSelector(const CSSSelector*, const Vector<RefPtr<Node> >& siblings, int nthNode) const;
    51 private:
    52     SelectorChecker m_selectorChecker;
    53 };
    54 
    5546class ContentSelectorDataList {
    5647public:
    5748    void initialize(const CSSSelectorList&);
    58     bool matches(const ContentSelectorChecker&, const Vector<RefPtr<Node> >& siblings, int nthNode) const;
     49    bool matches(const Vector<RefPtr<Node> >& siblings, int nthNode) const;
    5950
    6051private:
     52    static bool checkContentSelector(const CSSSelector*, const Vector<RefPtr<Node> >& siblings, int nthNode);
     53
    6154    Vector<const CSSSelector*> m_selectors;
    6255};
     
    6861
    6962    bool matches(const Vector<RefPtr<Node> >& siblings, int nthNode) const;
     63
    7064private:
    71 
    7265    InsertionPoint* m_insertionPoint;
    7366    ContentSelectorDataList m_selectors;
    74     ContentSelectorChecker m_selectorChecker;
    7567};
    7668
Note: See TracChangeset for help on using the changeset viewer.