Changeset 139273 in webkit


Ignore:
Timestamp:
Jan 9, 2013 6:51:59 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Node::containingShadowRoot should be constant time
https://bugs.webkit.org/show_bug.cgi?id=106494

Patch by Elliott Sprehn <Elliott Sprehn> on 2013-01-09
Reviewed by Dimitri Glazkov.

There's no reason to traverse up the tree to find the containing
ShadowRoot when we already know if we're in a ShadowRoot by looking at
the treeScope().

No new tests, just refactoring.

  • dom/Node.cpp:

(WebCore::Node::containingShadowRoot):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139269 r139273  
     12013-01-09  Elliott Sprehn  <esprehn@gmail.com>
     2
     3        Node::containingShadowRoot should be constant time
     4        https://bugs.webkit.org/show_bug.cgi?id=106494
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        There's no reason to traverse up the tree to find the containing
     9        ShadowRoot when we already know if we're in a ShadowRoot by looking at
     10        the treeScope().
     11
     12        No new tests, just refactoring.
     13
     14        * dom/Node.cpp:
     15        (WebCore::Node::containingShadowRoot):
     16
    1172013-01-09  Hajime Morrita  <morrita@google.com>
    218
  • trunk/Source/WebCore/dom/Node.cpp

    r138811 r139273  
    12431243ShadowRoot* Node::containingShadowRoot() const
    12441244{
    1245     Node* root = const_cast<Node*>(this);
    1246     while (root) {
    1247         if (root->isShadowRoot())
    1248             return toShadowRoot(root);
    1249         root = root->parentNodeGuaranteedHostFree();
    1250     }
    1251     return 0;
     1245    Node* root = treeScope()->rootNode();
     1246    return root && root->isShadowRoot() ? toShadowRoot(root) : 0;
    12521247}
    12531248
Note: See TracChangeset for help on using the changeset viewer.