summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-18 14:03:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-18 14:03:11 +0200
commit8d473cf9743f1d30a16a27114e93bd5af5648d23 (patch)
treecdca40d0353886b3ca52f33a2d7b8f1c0011aafc /Source/WebCore/dom/ComposedShadowTreeWalker.cpp
parent1b914638db989aaa98631a1c1e02c7b2d44805d8 (diff)
downloadqtwebkit-8d473cf9743f1d30a16a27114e93bd5af5648d23.tar.gz
Imported WebKit commit 1350e72f7345ced9da2bd9980deeeb5a8d62fab4 (http://svn.webkit.org/repository/webkit/trunk@117578)
Weekly snapshot
Diffstat (limited to 'Source/WebCore/dom/ComposedShadowTreeWalker.cpp')
-rw-r--r--Source/WebCore/dom/ComposedShadowTreeWalker.cpp45
1 files changed, 33 insertions, 12 deletions
diff --git a/Source/WebCore/dom/ComposedShadowTreeWalker.cpp b/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
index d1a889e67..0f8614433 100644
--- a/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
+++ b/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
@@ -27,12 +27,11 @@
#include "config.h"
#include "ComposedShadowTreeWalker.h"
+#include "ContentDistributor.h"
#include "Element.h"
#include "ElementShadow.h"
-#include "HTMLContentSelector.h"
#include "InsertionPoint.h"
-
namespace WebCore {
static inline ElementShadow* shadowFor(const Node* node)
@@ -114,9 +113,9 @@ Node* ComposedShadowTreeWalker::traverseNode(const Node* node, TraversalDirectio
{
ASSERT(node);
if (isInsertionPoint(node)) {
- const HTMLContentSelectionList* selectionList = toInsertionPoint(node)->selections();
- if (HTMLContentSelection* selection = (direction == TraversalDirectionForward ? selectionList->first() : selectionList->last()))
- return traverseNode(selection->node(), direction);
+ const InsertionPoint* insertionPoint = toInsertionPoint(node);
+ if (Node* next = (direction == TraversalDirectionForward ? insertionPoint->first() : insertionPoint->last()))
+ return traverseNode(next, direction);
return traverseLightChildren(node, direction);
}
return const_cast<Node*>(node);
@@ -142,12 +141,12 @@ Node* ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint(const Node
ElementShadow* shadow = shadowOfParent(node);
if (!shadow)
return traverseSiblingInCurrentTree(node, direction);
- HTMLContentSelection* selection = shadow->selectionFor(node);
- if (!selection)
+ InsertionPoint* insertionPoint = shadow->insertionPointFor(node);
+ if (!insertionPoint)
return traverseSiblingInCurrentTree(node, direction);
- if (HTMLContentSelection* nextSelection = (direction == TraversalDirectionForward ? selection->next() : selection->previous()))
- return traverseNode(nextSelection->node(), direction);
- return traverseSiblingOrBackToInsertionPoint(selection->insertionPoint(), direction);
+ if (Node* next = (direction == TraversalDirectionForward ? insertionPoint->nextTo(node) : insertionPoint->previousTo(node)))
+ return traverseNode(next, direction);
+ return traverseSiblingOrBackToInsertionPoint(insertionPoint, direction);
}
Node* ComposedShadowTreeWalker::traverseSiblingInCurrentTree(const Node* node, TraversalDirection direction)
@@ -197,6 +196,28 @@ void ComposedShadowTreeWalker::parent()
assertPostcondition();
}
+void ComposedShadowTreeWalker::parentIncludingInsertionPointAndShadowRoot()
+{
+ ASSERT(m_node);
+ m_node = traverseParentIncludingInsertionPointAndShadowRoot(m_node);
+}
+
+Node* ComposedShadowTreeWalker::traverseParentIncludingInsertionPointAndShadowRoot(const Node* node) const
+{
+ if (ElementShadow* shadow = shadowOfParent(node)) {
+ if (InsertionPoint* insertionPoint = shadow->insertionPointFor(node))
+ return insertionPoint;
+ }
+ if (!node->isShadowRoot())
+ return node->parentNode();
+ const ShadowRoot* shadowRoot = toShadowRoot(node);
+ if (shadowRoot->isYoungest())
+ return shadowRoot->host();
+ InsertionPoint* assignedInsertionPoint = shadowRoot->assignedTo();
+ ASSERT(assignedInsertionPoint);
+ return assignedInsertionPoint;
+}
+
Node* ComposedShadowTreeWalker::traverseParent(const Node* node) const
{
if (!canCrossUpperBoundary() && node->isShadowRoot()) {
@@ -204,8 +225,8 @@ Node* ComposedShadowTreeWalker::traverseParent(const Node* node) const
return 0;
}
if (ElementShadow* shadow = shadowOfParent(node)) {
- if (HTMLContentSelection* selection = shadow->selectionFor(node))
- return traverseParent(selection->insertionPoint());
+ if (InsertionPoint* insertionPoint = shadow->insertionPointFor(node))
+ return traverseParent(insertionPoint);
}
return traverseParentInCurrentTree(node);
}