Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Side by Side Diff: Source/core/dom/Node.cpp

Issue 21123005: Node.contains should return true for nodes in Shadow DOM. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make contains-something condition clearer. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/dom/Node.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 975
976 bool Node::contains(const Node* node) const 976 bool Node::contains(const Node* node) const
977 { 977 {
978 if (!node) 978 if (!node)
979 return false; 979 return false;
980 return this == node || node->isDescendantOf(this); 980 return this == node || node->isDescendantOf(this);
981 } 981 }
982 982
983 bool Node::containsIncludingShadowDOM(const Node* node) const 983 bool Node::containsIncludingShadowDOM(const Node* node) const
984 { 984 {
985 for (; node; node = node->parentOrShadowHostNode()) { 985 if (!node)
986 if (node == this) 986 return false;
987 return true; 987
988 if (this == node)
989 return true;
990
991 if (document() != node->document())
992 return false;
993
994 if (inDocument() != node->inDocument())
995 return false;
996
997 bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildNodes ();
998 bool hasShadow = isElementNode() && toElement(this)->shadow();
999 if (!hasChildren && !hasShadow)
1000 return false;
1001
1002 for (; node; node = node->shadowHost()) {
1003 if (treeScope() == node->treeScope())
1004 return contains(node);
988 } 1005 }
1006
989 return false; 1007 return false;
990 } 1008 }
991 1009
992 bool Node::containsIncludingHostElements(const Node* node) const 1010 bool Node::containsIncludingHostElements(const Node* node) const
993 { 1011 {
994 while (node) { 1012 while (node) {
995 if (node == this) 1013 if (node == this)
996 return true; 1014 return true;
997 if (node->isDocumentFragment() && static_cast<const DocumentFragment*>(n ode)->isTemplateContent()) 1015 if (node->isDocumentFragment() && static_cast<const DocumentFragment*>(n ode)->isTemplateContent())
998 node = static_cast<const TemplateContentDocumentFragment*>(node)->ho st(); 1016 node = static_cast<const TemplateContentDocumentFragment*>(node)->ho st();
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 node->showTreeForThis(); 2712 node->showTreeForThis();
2695 } 2713 }
2696 2714
2697 void showNodePath(const WebCore::Node* node) 2715 void showNodePath(const WebCore::Node* node)
2698 { 2716 {
2699 if (node) 2717 if (node)
2700 node->showNodePathForThis(); 2718 node->showNodePathForThis();
2701 } 2719 }
2702 2720
2703 #endif 2721 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/dom/Node.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698