Changeset 154037 in webkit


Ignore:
Timestamp:
Aug 13, 2013 7:16:56 PM (11 years ago)
Author:
rniwa@webkit.org
Message:

REGRESSION(r150187): Safari fails to render allrecipe.com comment popups
https://bugs.webkit.org/show_bug.cgi?id=119780

Reviewed by Benjamin Poulain.

Source/WebCore:

The bug was caused by SelectorDataList::executeFastPathForIdSelector not verifying that
elements found by getAllElementsById are descendents of rootNode when there are multiple
elements of the same id. This resulted in querySelector and querySelectorAll of an element
returning nodes outside of the element.

Fixed the bug by checking this condition when we have multiple elements of the same id.

Test: fast/selectors/querySelector-id-with-multiple-elements-with-same-id.html

  • dom/SelectorQuery.cpp:

(WebCore::SelectorDataList::executeFastPathForIdSelector):

LayoutTests:

  • fast/selectors/querySelector-id-with-multiple-elements-with-same-id-expected.txt: Added.
  • fast/selectors/querySelector-id-with-multiple-elements-with-same-id.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r154035 r154037  
     12013-08-13  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION(r150187): Safari fails to render allrecipe.com comment popups
     4        https://bugs.webkit.org/show_bug.cgi?id=119780
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        * fast/selectors/querySelector-id-with-multiple-elements-with-same-id-expected.txt: Added.
     9        * fast/selectors/querySelector-id-with-multiple-elements-with-same-id.html: Added.
     10
    1112013-08-13  Sam Weinig  <sam@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r154036 r154037  
     12013-08-13  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION(r150187): Safari fails to render allrecipe.com comment popups
     4        https://bugs.webkit.org/show_bug.cgi?id=119780
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        The bug was caused by SelectorDataList::executeFastPathForIdSelector not verifying that
     9        elements found by getAllElementsById are descendents of rootNode when there are multiple
     10        elements of the same id. This resulted in querySelector and querySelectorAll of an element
     11        returning nodes outside of the element.
     12
     13        Fixed the bug by checking this condition when we have multiple elements of the same id.
     14
     15        Test: fast/selectors/querySelector-id-with-multiple-elements-with-same-id.html
     16
     17        * dom/SelectorQuery.cpp:
     18        (WebCore::SelectorDataList::executeFastPathForIdSelector):
     19
    1202013-08-12  Ryosuke Niwa  <rniwa@webkit.org>
    221
  • trunk/Source/WebCore/dom/SelectorQuery.cpp

    r153939 r154037  
    133133        ASSERT(elements);
    134134        size_t count = elements->size();
     135        bool rootNodeIsTreeScopeRoot = isTreeScopeRoot(rootNode);
    135136        for (size_t i = 0; i < count; ++i) {
    136137            Element* element = elements->at(i);
    137             if (selectorMatches(selectorData, element, rootNode)) {
     138            if ((rootNodeIsTreeScopeRoot || element->isDescendantOf(rootNode)) && selectorMatches(selectorData, element, rootNode)) {
    138139                matchedElements.append(element);
    139140                if (firstMatchOnly)
Note: See TracChangeset for help on using the changeset viewer.