Changeset 106902 in webkit


Ignore:
Timestamp:
Feb 6, 2012 8:47:15 PM (12 years ago)
Author:
hayato@chromium.org
Message:

Implement querySelector on ShadowRoot.
https://bugs.webkit.org/show_bug.cgi?id=77714

Reviewed by Dimitri Glazkov.

Source/WebCore:

  • dom/SelectorQuery.cpp:

(WebCore::nodeIsRootNodeOfTreeScope):
(WebCore):
(WebCore::SelectorDataList::execute):

LayoutTests:

  • fast/dom/shadow/shadow-root-js-api-expected.txt:
  • fast/dom/shadow/shadow-root-js-api.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106898 r106902  
     12012-02-06  Hayato Ito  <hayato@chromium.org>
     2
     3        Implement querySelector on ShadowRoot.
     4        https://bugs.webkit.org/show_bug.cgi?id=77714
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * fast/dom/shadow/shadow-root-js-api-expected.txt:
     9        * fast/dom/shadow/shadow-root-js-api.html:
     10
    1112012-02-06  David Grogan  <dgrogan@chromium.org>
    212
  • trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt

    r106434 r106902  
    2121PASS shadowRoot.getElementsByTagNameNS('', 'div') is []
    2222PASS shadowRoot.getElementsByTagNameNS('*', 'foo') is []
     23PASS shadowRoot.querySelector('#div1') is div1
     24PASS shadowRoot.querySelector('#foo') is null
     25PASS shadowRoot.querySelector('.class2') is div2
     26PASS shadowRoot.querySelector('.foo') is null
     27PASS shadowRoot.querySelectorAll('div') is [div1, div2]
     28PASS shadowRoot.querySelectorAll('foo') is []
    2329PASS successfullyParsed is true
    2430
  • trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html

    r106434 r106902  
    66<body>
    77<div id="console"></div>
     8<!-- These elements should not be selected in ShadowRoot's querySelector. -->
     9<div id="foo"></div>
     10<div class="foo"></div>
     11<foo></foo>
    812<script>
    913description("Tests for ShadowRoot JS APIs. Can only run within DRT");
     
    4852shouldBe("shadowRoot.getElementsByTagNameNS('*', 'foo')", "[]");
    4953
     54shouldBe("shadowRoot.querySelector('#div1')", "div1");
     55shouldBeNull("shadowRoot.querySelector('#foo')");
     56shouldBe("shadowRoot.querySelector('.class2')", "div2");
     57shouldBeNull("shadowRoot.querySelector('.foo')");
     58shouldBe("shadowRoot.querySelectorAll('div')", "[div1, div2]");
     59shouldBe("shadowRoot.querySelectorAll('foo')", "[]");
    5060</script>
    5161<script src="../../js/resources/js-test-post.js"></script>
  • trunk/Source/WebCore/ChangeLog

    r106901 r106902  
     12012-02-06  Hayato Ito  <hayato@chromium.org>
     2
     3        Implement querySelector on ShadowRoot.
     4        https://bugs.webkit.org/show_bug.cgi?id=77714
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * dom/SelectorQuery.cpp:
     9        (WebCore::nodeIsRootNodeOfTreeScope):
     10        (WebCore):
     11        (WebCore::SelectorDataList::execute):
     12
    1132012-02-06  Martin Robinson  <mrobinson@igalia.com> and Nayan Kumar K  <nayankk@motorola.com>
    214
  • trunk/Source/WebCore/dom/SelectorQuery.cpp

    r104919 r106902  
    9999}
    100100
     101static inline bool isTreeScopeRoot(Node* node)
     102{
     103    ASSERT(node);
     104    return node->isDocumentNode() || node->isShadowRoot();
     105}
     106
    101107template <bool firstMatchOnly>
    102108void SelectorDataList::execute(const SelectorChecker& selectorChecker, Node* rootNode, Vector<RefPtr<Node> >& matchedElements) const
     
    105111        ASSERT(m_selectors.size() == 1);
    106112        CSSSelector* selector = m_selectors[0].selector;
    107         Element* element = rootNode->document()->getElementById(selector->value());
    108         if (!element || !(rootNode->isDocumentNode() || element->isDescendantOf(rootNode)))
     113        Element* element = rootNode->treeScope()->getElementById(selector->value());
     114        if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(rootNode)))
    109115            return;
    110116        if (selectorChecker.checkSelector(m_selectors[0].selector, element, m_selectors[0].isFastCheckable))
Note: See TracChangeset for help on using the changeset viewer.