diff options
| author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-25 13:35:59 +0200 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-25 13:35:59 +0200 |
| commit | 79ad030d505ccf79cf10aa9f8189ca3e2f61f6f4 (patch) | |
| tree | 0287b1a69d84492c901e8bc820e635e7133809a0 /Source/WebCore/dom/TreeScope.cpp | |
| parent | 682ab87480e7757346802ce7f54cfdbdfeb2339e (diff) | |
| download | qtwebkit-79ad030d505ccf79cf10aa9f8189ca3e2f61f6f4.tar.gz | |
Imported WebKit commit c4b613825abd39ac739a47d7b4410468fcef66dc (http://svn.webkit.org/repository/webkit/trunk@121147)
New snapshot that includes Win32 debug build fix (use SVGAllInOne)
Diffstat (limited to 'Source/WebCore/dom/TreeScope.cpp')
| -rw-r--r-- | Source/WebCore/dom/TreeScope.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Source/WebCore/dom/TreeScope.cpp b/Source/WebCore/dom/TreeScope.cpp index b546591f7..5642fcf8d 100644 --- a/Source/WebCore/dom/TreeScope.cpp +++ b/Source/WebCore/dom/TreeScope.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "TreeScope.h" +#include "ComposedShadowTreeWalker.h" #include "ContainerNode.h" #include "ContextFeatures.h" #include "DOMSelection.h" @@ -38,6 +39,7 @@ #include "HTMLFrameOwnerElement.h" #include "HTMLMapElement.h" #include "HTMLNames.h" +#include "InsertionPoint.h" #include "Page.h" #include "ShadowRoot.h" #include "TreeScopeAdopter.h" @@ -224,17 +226,23 @@ Node* TreeScope::focusedNode() node = focusedFrameOwnerElement(document->page()->focusController()->focusedFrame(), document->frame()); if (!node) return 0; - - TreeScope* treeScope = node->treeScope(); - - while (treeScope != this && treeScope != document) { - node = toShadowRoot(treeScope->rootNode())->host(); - treeScope = node->treeScope(); + Vector<Node*> targetStack; + Node* last = 0; + for (ComposedShadowTreeParentWalker walker(node); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) { + Node* node = walker.get(); + if (targetStack.isEmpty()) + targetStack.append(node); + else if (isInsertionPoint(node) && toInsertionPoint(node)->contains(last)) + targetStack.append(targetStack.last()); + if (node == rootNode()) + return targetStack.last(); + last = node; + if (node->isShadowRoot()) { + ASSERT(!targetStack.isEmpty()); + targetStack.removeLast(); + } } - if (this != treeScope) - return 0; - - return node; + return 0; } static void listTreeScopes(Node* node, Vector<TreeScope*, 5>& treeScopes) |
