Chromium Code Reviews| Index: Source/core/dom/Node.cpp |
| diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp |
| index 896dccdae1f847adbcffd2618210de034eeee7fb..3666e4ce8165dc00a193cc39e57d76f0e9d22ad0 100644 |
| --- a/Source/core/dom/Node.cpp |
| +++ b/Source/core/dom/Node.cpp |
| @@ -982,10 +982,26 @@ bool Node::contains(const Node* node) const |
| bool Node::containsIncludingShadowDOM(const Node* node) const |
| { |
| - for (; node; node = node->parentOrShadowHostNode()) { |
| - if (node == this) |
| - return true; |
| + if (!node) |
| + return false; |
| + |
| + if (this == node) |
| + return true; |
| + |
| + if (document() != node->document()) |
| + return false; |
| + |
| + if (inDocument() != node->inDocument()) |
| + return false; |
| + |
| + if (!(isContainerNode() && toContainerNode(this)->hasChildNodes() || isElementNode() && toElement(this)->shadow())) |
|
esprehn
2013/07/30 03:36:26
This is a bit hard to understand, could you propag
|
| + return false; |
| + |
| + for (; node; node = node->shadowHost()) { |
|
esprehn
2013/07/30 03:36:26
Nice!
|
| + if (treeScope() == node->treeScope()) |
| + return contains(node); |
| } |
| + |
| return false; |
| } |