[Webkit-unassigned] [Bug 116502] New: Optimized querySelector(All) when selector contains #id

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon May 20 19:32:17 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=116502

           Summary: Optimized querySelector(All) when selector contains
                    #id
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
        OS/Version: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: HTML DOM
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: rniwa at webkit.org
                CC: sam at webkit.org, koivisto at iki.fi,
                    barraclough at apple.com, benjamin at webkit.org,
                    akling at apple.com


Consider implementing the same optimization as https://chromium.googlesource.com/chromium/blink/+/1cd83d3588973a02ab15d94b1b05a28620853624.

There existed an optimization that did an element lookup for an id if the
leftmost part of the selector was an id selector. Without this change, these
queries would do an id lookup:

querySelector("#id"), querySelector("#id.class")

while these wouldn't:

querySelector(".class#id"), querySelector("[name=x]#id")

This change modifies the element lookup to include the latter two.

More importantly, it also extends the optimization for id selectors to limit
traversal of the dom-tree to the sub-tree rooted at the element with an id
matching the rightmost id selector in the whole selector. For id selectors
appearing left of adjacent combinators, the traversal needs to be rooted at
the parent of the element with the given id.

Examples:

querySelector("#id span") - traversal from the id element.
querySelector("#id + div span") - traversal from the parent of the id element.

This fix should make this:

querySelector("#id span")

as fast as:

getElementById("id").querySelector("span")

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list