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

Unified Diff: Source/WebCore/dom/ContainerNodeAlgorithms.h

Issue 10914322: Merge 127534 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1229/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/dom/ContainerNode.cpp ('k') | Source/WebCore/dom/ContainerNodeAlgorithms.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/ContainerNodeAlgorithms.h
===================================================================
--- Source/WebCore/dom/ContainerNodeAlgorithms.h (revision 128789)
+++ Source/WebCore/dom/ContainerNodeAlgorithms.h (working copy)
@@ -281,13 +281,37 @@
class ChildFrameDisconnector {
public:
- explicit ChildFrameDisconnector(Node* root);
+ enum ShouldIncludeRoot {
+ DoNotIncludeRoot,
+ IncludeRoot
+ };
+
+ explicit ChildFrameDisconnector(Node* root, ShouldIncludeRoot shouldIncludeRoot = IncludeRoot)
+ : m_root(root)
+ {
+ collectDescendant(m_root, shouldIncludeRoot);
+ rootNodes().add(m_root);
+ }
+
+ ~ChildFrameDisconnector()
+ {
+ rootNodes().remove(m_root);
+ }
+
void disconnect();
+ static bool nodeHasDisconnector(Node*);
+
private:
- void collectDescendant(Node* root);
+ void collectDescendant(Node* root, ShouldIncludeRoot);
void collectDescendant(ElementShadow*);
+ static HashSet<Node*>& rootNodes()
+ {
+ DEFINE_STATIC_LOCAL(HashSet<Node*>, nodes, ());
+ return nodes;
+ }
+
class Target {
public:
Target(HTMLFrameOwnerElement* element)
@@ -305,16 +329,13 @@
};
Vector<Target, 10> m_list;
+ Node* m_root;
};
-inline ChildFrameDisconnector::ChildFrameDisconnector(Node* root)
+inline void ChildFrameDisconnector::collectDescendant(Node* root, ShouldIncludeRoot shouldIncludeRoot)
{
- collectDescendant(root);
-}
-
-inline void ChildFrameDisconnector::collectDescendant(Node* root)
-{
- for (Node* node = root; node; node = node->traverseNextNode(root)) {
+ for (Node* node = shouldIncludeRoot == IncludeRoot ? root : root->firstChild(); node;
+ node = node->traverseNextNode(root)) {
if (!node->isElementNode())
continue;
Element* element = toElement(node);
@@ -335,6 +356,20 @@
}
}
+inline bool ChildFrameDisconnector::nodeHasDisconnector(Node* node)
+{
+ HashSet<Node*>& nodes = rootNodes();
+
+ if (nodes.isEmpty())
+ return false;
+
+ for (; node; node = node->parentNode())
+ if (nodes.contains(node))
+ return true;
+
+ return false;
+}
+
} // namespace WebCore
#endif // ContainerNodeAlgorithms_h
« no previous file with comments | « Source/WebCore/dom/ContainerNode.cpp ('k') | Source/WebCore/dom/ContainerNodeAlgorithms.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698