Diff
Modified: trunk/LayoutTests/ChangeLog (123311 => 123312)
--- trunk/LayoutTests/ChangeLog 2012-07-23 08:06:07 UTC (rev 123311)
+++ trunk/LayoutTests/ChangeLog 2012-07-23 08:08:36 UTC (rev 123312)
@@ -1,3 +1,13 @@
+2012-07-23 Hayato Ito <[email protected]>
+
+ ComposedShadowTreeWalker should skip an empty insertion points.
+ https://bugs.webkit.org/show_bug.cgi?id=91826
+
+ Reviewed by Hajime Morita.
+
+ * fast/dom/shadow/composed-shadow-tree-walker-expected.txt:
+ * fast/dom/shadow/composed-shadow-tree-walker.html:
+
2012-07-23 Kristóf Kosztyó <[email protected]>
[Qt] Unreviewed gardening. Skip the new failing tests.
Modified: trunk/LayoutTests/fast/dom/shadow/composed-shadow-tree-walker-expected.txt (123311 => 123312)
--- trunk/LayoutTests/fast/dom/shadow/composed-shadow-tree-walker-expected.txt 2012-07-23 08:06:07 UTC (rev 123311)
+++ trunk/LayoutTests/fast/dom/shadow/composed-shadow-tree-walker-expected.txt 2012-07-23 08:08:36 UTC (rev 123312)
@@ -213,6 +213,63 @@
DIV id=c
DIV id=b
+Test for a content element which does not select any nodes nor have fallback elements.
+Composed Shadow Tree:
+DIV id=a
+ DIV id=b
+ DIV id=c
+
+Traverse in forward.
+DIV id=a
+DIV id=b
+DIV id=c
+Traverse in backward.
+DIV id=c
+DIV id=b
+DIV id=a
+
+Test for a nested insertion point.
+Composed Shadow Tree:
+DIV id=a
+ DIV id=b
+ DIV id=c
+
+Traverse in forward.
+DIV id=a
+DIV id=b
+DIV id=c
+Traverse in backward.
+DIV id=c
+DIV id=b
+DIV id=a
+
+Test for nested insertion points. Some of them are either empty insertion points or inactive insertion points.
+Composed Shadow Tree:
+DIV id=a
+ DIV id=b
+ CONTENT id=inactive-insertion-point class=select-4
+ DIV id=f class=select-4
+ DIV id=c
+ DIV id=d class=select-2
+ DIV id=e class=select-2
+
+Traverse in forward.
+DIV id=a
+DIV id=b
+CONTENT id=inactive-insertion-point class=select-4
+DIV id=f class=select-4
+DIV id=c
+DIV id=d class=select-2
+DIV id=e class=select-2
+Traverse in backward.
+DIV id=e class=select-2
+DIV id=d class=select-2
+DIV id=c
+DIV id=f class=select-4
+CONTENT id=inactive-insertion-point class=select-4
+DIV id=b
+DIV id=a
+
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/shadow/composed-shadow-tree-walker.html (123311 => 123312)
--- trunk/LayoutTests/fast/dom/shadow/composed-shadow-tree-walker.html 2012-07-23 08:06:07 UTC (rev 123311)
+++ trunk/LayoutTests/fast/dom/shadow/composed-shadow-tree-walker.html 2012-07-23 08:08:36 UTC (rev 123312)
@@ -194,6 +194,40 @@
debug('Test for traversal, starting with a node in an orphaned shadow subtree.');
showComposedShadowTree(getNodeInShadowTreeStack('a/b'));
+debug('Test for a content element which does not select any nodes nor have fallback elements.');
+testComposedShadowTree(
+ createDOM('div', {'id': 'a'},
+ createShadowRoot(createDOM('content', {'select': '#none'}),
+ createDOM('div', {'id': 'b'}),
+ createDOM('content', {'select': '#none'}),
+ createDOM('div', {'id': 'c'}),
+ createDOM('content', {'select': '#none'}))));
+
+debug('Test for a nested insertion point.');
+testComposedShadowTree(
+ createDOM('div', {'id': 'a'},
+ createShadowRoot(createDOM('div', {'id': 'b'},
+ createShadowRoot(createDOM('content', {})),
+ createDOM('content', {}))),
+ createDOM('div', {'id': 'c'})));
+
+debug('Test for nested insertion points. Some of them are either empty insertion points or inactive insertion points.');
+testComposedShadowTree(
+ createDOM('div', {'id': 'a'},
+ createShadowRoot(createDOM('content', {'select': '#none'}),
+ createDOM('div', {'id': 'b'},
+ createShadowRoot(createDOM('content', {'select': '.select-1'}),
+ createDOM('div', {'id': 'c'}),
+ createDOM('content', {'select': '.select-2'})),
+ createDOM('content', {'class': 'select-1', 'select': '.select-4'}),
+ createDOM('content', {'class': 'select-2', 'select': '#none'}),
+ createDOM('div', {'id': 'd', 'class': 'select-2'}),
+ createDOM('content', {'class': 'select-2', 'select': '#none'}),
+ createDOM('div', {'id': 'e', 'class': 'select-2'}),
+ createDOM('content', {'class': 'select-2', 'select': '#none'}))),
+ createDOM('content', {'id': 'inactive-insertion-point', 'class': 'select-4'}),
+ createDOM('div', {'id': 'should-not-be-selected'}),
+ createDOM('div', {'id': 'f', 'class': 'select-4'})));
</script>
<script src=""
</body>
Modified: trunk/Source/WebCore/ChangeLog (123311 => 123312)
--- trunk/Source/WebCore/ChangeLog 2012-07-23 08:06:07 UTC (rev 123311)
+++ trunk/Source/WebCore/ChangeLog 2012-07-23 08:08:36 UTC (rev 123312)
@@ -1,3 +1,30 @@
+2012-07-23 Hayato Ito <[email protected]>
+
+ ComposedShadowTreeWalker should skip an empty insertion points.
+ https://bugs.webkit.org/show_bug.cgi?id=91826
+
+ Reviewed by Hajime Morita.
+
+ ComposedShadowTreeWalker wrongly returns 'null' if it encounters
+ an insertion point into where no nodes are distributed. We should
+ skip such an insertion point and continue walking using the next
+ possible node, which might be a next sibling or a next distributed
+ node, and resolve the next node recursively.
+
+ Test: fast/dom/shadow/composed-shadow-tree-walker.html
+
+ * dom/ComposedShadowTreeWalker.cpp:
+ (WebCore::ComposedShadowTreeWalker::traverseLightChildren):
+ (WebCore):
+ (WebCore::ComposedShadowTreeWalker::traverseSiblings):
+ (WebCore::ComposedShadowTreeWalker::traverseNode):
+ (WebCore::ComposedShadowTreeWalker::traverseDistributedeNodes):
+ (WebCore::ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint):
+ (WebCore::ComposedShadowTreeWalker::traverseSiblingInCurrentTree):
+ (WebCore::ComposedShadowTreeWalker::traverseBackToYoungerShadowRoot):
+ * dom/ComposedShadowTreeWalker.h:
+ (ComposedShadowTreeWalker):
+
2012-07-23 Patrick Gansterer <[email protected]>
Rename TextCodecWinCE to TextCodecWin
Modified: trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp (123311 => 123312)
--- trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp 2012-07-23 08:06:07 UTC (rev 123311)
+++ trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp 2012-07-23 08:08:36 UTC (rev 123312)
@@ -125,8 +125,15 @@
Node* ComposedShadowTreeWalker::traverseLightChildren(const Node* node, TraversalDirection direction)
{
ASSERT(node);
- if (Node* child = (direction == TraversalDirectionForward ? node->firstChild() : node->lastChild()))
- return traverseNode(child, direction);
+ return traverseSiblings(direction == TraversalDirectionForward ? node->firstChild() : node->lastChild(), direction);
+}
+
+Node* ComposedShadowTreeWalker::traverseSiblings(const Node* node, TraversalDirection direction)
+{
+ for (const Node* sibling = node; sibling; sibling = (direction == TraversalDirectionForward ? sibling->nextSibling() : sibling->previousSibling())) {
+ if (Node* found = traverseNode(sibling, direction))
+ return found;
+ }
return 0;
}
@@ -138,8 +145,8 @@
const InsertionPoint* insertionPoint = toInsertionPoint(node);
if (!insertionPoint->isActive())
return const_cast<Node*>(node);
- if (Node* next = (direction == TraversalDirectionForward ? insertionPoint->first() : insertionPoint->last()))
- return traverseNode(next, direction);
+ if (Node* found = traverseDistributedNodes(direction == TraversalDirectionForward ? insertionPoint->first() : insertionPoint->last(), insertionPoint, direction))
+ return found;
return traverseLightChildren(node, direction);
}
@@ -157,6 +164,15 @@
assertPostcondition();
}
+Node* ComposedShadowTreeWalker::traverseDistributedNodes(const Node* node, const InsertionPoint* insertionPoint, TraversalDirection direction)
+{
+ for (const Node* next = node; next; next = (direction == TraversalDirectionForward ? insertionPoint->nextTo(next) : insertionPoint->previousTo(next))) {
+ if (Node* found = traverseNode(next, direction))
+ return found;
+ }
+ return 0;
+}
+
Node* ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint(const Node* node, TraversalDirection direction)
{
ASSERT(node);
@@ -166,22 +182,23 @@
InsertionPoint* insertionPoint = shadow->insertionPointFor(node);
if (!insertionPoint)
return traverseSiblingInCurrentTree(node, direction);
- if (Node* next = (direction == TraversalDirectionForward ? insertionPoint->nextTo(node) : insertionPoint->previousTo(node)))
- return traverseNode(next, direction);
+
+ if (Node* found = traverseDistributedNodes(direction == TraversalDirectionForward ? insertionPoint->nextTo(node) : insertionPoint->previousTo(node), insertionPoint, direction))
+ return found;
return traverseSiblingOrBackToInsertionPoint(insertionPoint, direction);
}
Node* ComposedShadowTreeWalker::traverseSiblingInCurrentTree(const Node* node, TraversalDirection direction)
{
ASSERT(node);
- if (Node* next = (direction == TraversalDirectionForward ? node->nextSibling() : node->previousSibling()))
- return traverseNode(next, direction);
- if (Node* next = traverseSiblingOrBackToYoungerShadowRoot(node, direction))
+ if (Node* found = traverseSiblings(direction == TraversalDirectionForward ? node->nextSibling() : node->previousSibling(), direction))
+ return found;
+ if (Node* next = traverseBackToYoungerShadowRoot(node, direction))
return next;
return escapeFallbackContentElement(node, direction);
}
-Node* ComposedShadowTreeWalker::traverseSiblingOrBackToYoungerShadowRoot(const Node* node, TraversalDirection direction)
+Node* ComposedShadowTreeWalker::traverseBackToYoungerShadowRoot(const Node* node, TraversalDirection direction)
{
ASSERT(node);
if (node->parentNode() && node->parentNode()->isShadowRoot()) {
Modified: trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h (123311 => 123312)
--- trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h 2012-07-23 08:06:07 UTC (rev 123311)
+++ trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h 2012-07-23 08:08:36 UTC (rev 123312)
@@ -139,7 +139,10 @@
static Node* traverseSiblingOrBackToInsertionPoint(const Node*, TraversalDirection);
static Node* traverseSiblingInCurrentTree(const Node*, TraversalDirection);
- static Node* traverseSiblingOrBackToYoungerShadowRoot(const Node*, TraversalDirection);
+ static Node* traverseSiblings(const Node*, TraversalDirection);
+ static Node* traverseDistributedNodes(const Node*, const InsertionPoint*, TraversalDirection);
+
+ static Node* traverseBackToYoungerShadowRoot(const Node*, TraversalDirection);
static Node* escapeFallbackContentElement(const Node*, TraversalDirection);
Node* traverseNodeEscapingFallbackContents(const Node*, ParentTraversalDetails* = 0) const;