Changeset 109313 in webkit


Ignore:
Timestamp:
Feb 29, 2012 10:39:22 PM (12 years ago)
Author:
shinyak@chromium.org
Message:

Refactoring: HTMLContentSelector should be InsertionPoint-aware.
https://bugs.webkit.org/show_bug.cgi?id=79901

Reviewed by Hajime Morita.

ContentSelectorQuery took HTMLContentElement as argument, but patch changes it to take InsertionPoint instead.
If InsertionPoint is not HTMLContentElement, ContentSelectorQuery will selects the rest of light children.

Now InsertionPoint has pure virtual method 'select'. <shadow> will implement this as a method returning empty string.

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::hasInsertionPoint):

  • dom/ShadowRoot.h:

(ShadowRoot):

  • dom/ShadowTree.cpp:

(WebCore::ShadowTree::needsReattachHostChildrenAndShadow):
(WebCore::ShadowTree::hostChildrenChanged):

  • html/shadow/ContentSelectorQuery.cpp:

(WebCore::ContentSelectorQuery::ContentSelectorQuery):
(WebCore::ContentSelectorQuery::matches):

  • html/shadow/ContentSelectorQuery.h:

(WebCore):
(ContentSelectorQuery):

  • html/shadow/HTMLContentElement.cpp:

(WebCore::HTMLContentElement::detach):

  • html/shadow/HTMLContentElement.h:

(WebCore::toHTMLContentElement):
(WebCore):

  • html/shadow/HTMLContentSelector.cpp:

(WebCore::HTMLContentSelector::select):

  • html/shadow/HTMLContentSelector.h:

(HTMLContentSelector):

  • html/shadow/InsertionPoint.h:

(InsertionPoint):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109311 r109313  
     12012-02-29  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        Refactoring: HTMLContentSelector should be InsertionPoint-aware.
     4        https://bugs.webkit.org/show_bug.cgi?id=79901
     5
     6        Reviewed by Hajime Morita.
     7
     8        ContentSelectorQuery took HTMLContentElement as argument, but patch changes it to take InsertionPoint instead.
     9        If InsertionPoint is not HTMLContentElement, ContentSelectorQuery will selects the rest of light children.
     10
     11        Now InsertionPoint has pure virtual method 'select'. <shadow> will implement this as a method returning empty string.
     12
     13        * dom/ShadowRoot.cpp:
     14        (WebCore::ShadowRoot::hasInsertionPoint):
     15        * dom/ShadowRoot.h:
     16        (ShadowRoot):
     17        * dom/ShadowTree.cpp:
     18        (WebCore::ShadowTree::needsReattachHostChildrenAndShadow):
     19        (WebCore::ShadowTree::hostChildrenChanged):
     20        * html/shadow/ContentSelectorQuery.cpp:
     21        (WebCore::ContentSelectorQuery::ContentSelectorQuery):
     22        (WebCore::ContentSelectorQuery::matches):
     23        * html/shadow/ContentSelectorQuery.h:
     24        (WebCore):
     25        (ContentSelectorQuery):
     26        * html/shadow/HTMLContentElement.cpp:
     27        (WebCore::HTMLContentElement::detach):
     28        * html/shadow/HTMLContentElement.h:
     29        (WebCore::toHTMLContentElement):
     30        (WebCore):
     31        * html/shadow/HTMLContentSelector.cpp:
     32        (WebCore::HTMLContentSelector::select):
     33        * html/shadow/HTMLContentSelector.h:
     34        (HTMLContentSelector):
     35        * html/shadow/InsertionPoint.h:
     36        (InsertionPoint):
     37
    1382012-02-29  Luke Macpherson   <macpherson@chromium.org>
    239
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r109251 r109313  
    179179}
    180180
    181 bool ShadowRoot::hasContentElement() const
     181bool ShadowRoot::hasInsertionPoint() const
    182182{
    183183    for (Node* n = firstChild(); n; n = n->traverseNextNode(this)) {
    184         if (n->isContentElement())
     184        if (isInsertionPoint(n))
    185185            return true;
    186186    }
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r109251 r109313  
    8080    bool isOldest() const { return !olderShadowRoot(); }
    8181
    82     bool hasContentElement() const;
     82    bool hasInsertionPoint() const;
    8383
    8484private:
  • trunk/Source/WebCore/dom/ShadowTree.cpp

    r109290 r109313  
    263263bool ShadowTree::needsReattachHostChildrenAndShadow()
    264264{
    265     return m_needsRecalculateContent || (youngestShadowRoot() && youngestShadowRoot()->hasContentElement());
     265    return m_needsRecalculateContent || (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint());
    266266}
    267267
     
    270270    ASSERT(youngestShadowRoot());
    271271
    272     if (!youngestShadowRoot()->hasContentElement())
     272    if (!youngestShadowRoot()->hasInsertionPoint())
    273273        return;
    274274
  • trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp

    r106225 r109313  
    3030#include "CSSParser.h"
    3131#include "CSSSelectorList.h"
    32 #include "HTMLContentElement.h"
     32#include "InsertionPoint.h"
    3333
    3434namespace WebCore {
    3535
    36 ContentSelectorQuery::ContentSelectorQuery(const HTMLContentElement* element)
    37     : m_contentElement(element)
    38     , m_selectorChecker(element->document(), !element->document()->inQuirksMode())
     36ContentSelectorQuery::ContentSelectorQuery(const InsertionPoint* insertionPoint)
     37    : m_insertionPoint(insertionPoint)
     38    , m_selectorChecker(insertionPoint->document(), !insertionPoint->document()->inQuirksMode())
    3939{
    4040    m_selectorChecker.setCollectingRulesOnly(true);
    4141
    42     if (element->select().isNull() || element->select().isEmpty()) {
     42    if (insertionPoint->select().isNull() || insertionPoint->select().isEmpty()) {
    4343        m_isValidSelector = true;
    4444        return;
     
    4646
    4747    CSSParser parser(true);
    48     parser.parseSelector(element->select(), element->document(), m_selectorList);
     48    parser.parseSelector(insertionPoint->select(), insertionPoint->document(), m_selectorList);
    4949
    5050    m_isValidSelector = ContentSelectorQuery::validateSelectorList();
     
    6464        return false;
    6565
    66     ASSERT(node->parentNode() == m_contentElement->shadowTreeRootNode()->shadowHost());
     66    ASSERT(node->parentNode() == m_insertionPoint->shadowTreeRootNode()->shadowHost());
    6767
    68     if (m_contentElement->select().isNull() || m_contentElement->select().isEmpty())
     68    if (m_insertionPoint->select().isNull() || m_insertionPoint->select().isEmpty())
    6969        return true;
    7070
  • trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h

    r106225 r109313  
    4242class Document;
    4343class Node;
    44 class HTMLContentElement;
     44class InsertionPoint;
    4545
    4646class ContentSelectorQuery {
    4747    WTF_MAKE_NONCOPYABLE(ContentSelectorQuery);
    4848public:
    49     explicit ContentSelectorQuery(const HTMLContentElement*);
     49    explicit ContentSelectorQuery(const InsertionPoint*);
    5050
    5151    bool isValidSelector() const;
     
    5454    bool validateSelectorList();
    5555
    56     const HTMLContentElement* m_contentElement;
     56    const InsertionPoint* m_insertionPoint;
    5757    SelectorDataList m_selectors;
    5858    CSSSelectorList m_selectorList;
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp

    r108959 r109313  
    9595
    9696        // When content element is detached, shadow tree should be recreated to re-calculate selector for
    97         // other content elements.
     97        // other insertion points.
    9898        root->tree()->setNeedsReattachHostChildrenAndShadow();
    9999    }
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.h

    r109179 r109313  
    6767};
    6868
     69inline const HTMLContentElement* toHTMLContentElement(const Node* node)
     70{
     71    ASSERT(!node || node->isContentElement());
     72    return static_cast<const HTMLContentElement*>(node);
     73}
     74
    6975inline HTMLContentElement* toHTMLContentElement(Node* node)
    7076{
  • trunk/Source/WebCore/html/shadow/HTMLContentSelector.cpp

    r108605 r109313  
    109109}
    110110
    111 void HTMLContentSelector::select(HTMLContentElement* contentElement, HTMLContentSelectionList* selections)
     111void HTMLContentSelector::select(InsertionPoint* insertionPoint, HTMLContentSelectionList* selections)
    112112{
    113113    ASSERT(selections->isEmpty());
    114114
    115     ContentSelectorQuery query(contentElement);
     115    ContentSelectorQuery query(insertionPoint);
     116
    116117    for (size_t i = 0; i < m_candidates.size(); ++i) {
    117118        Node* child = m_candidates[i].get();
     
    121122            continue;
    122123
    123         RefPtr<HTMLContentSelection> selection = HTMLContentSelection::create(contentElement, child);
     124        RefPtr<HTMLContentSelection> selection = HTMLContentSelection::create(insertionPoint, child);
    124125
    125126        selections->append(selection);
  • trunk/Source/WebCore/html/shadow/HTMLContentSelector.h

    r108605 r109313  
    131131    ~HTMLContentSelector();
    132132
    133     void select(HTMLContentElement*, HTMLContentSelectionList*);
     133    void select(InsertionPoint*, HTMLContentSelectionList*);
    134134    void unselect(HTMLContentSelectionList*);
    135135    HTMLContentSelection* findFor(Node* key) const;
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r109179 r109313  
    3434#include "HTMLContentSelector.h"
    3535#include "HTMLElement.h"
     36#include <wtf/Forward.h>
    3637
    3738namespace WebCore {
     
    4445    bool hasSelection() const { return m_selections.first(); }
    4546    bool isShadowBoundary() const;
     47
     48    virtual const AtomicString& select() const = 0;
    4649
    4750protected:
Note: See TracChangeset for help on using the changeset viewer.