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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.h

Issue 1995933005: CustomElementUpgradeSorter puts elements in shadow-including tree order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.h
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.h b/third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.h
new file mode 100644
index 0000000000000000000000000000000000000000..5892539ba02421d0b3354d8f9fbe827b38b8bd2d
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.h
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CustomElementUpgradeSorter_h
+#define CustomElementUpgradeSorter_h
+
+#include "core/CoreExport.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Element;
+class Node;
+
+// Does a shadow-including tree order sort of a subset of elements.
+// https://dom.spec.whatwg.org/#concept-shadow-including-tree-order
+class CORE_EXPORT CustomElementUpgradeSorter {
+ STACK_ALLOCATED();
+public:
+ CustomElementUpgradeSorter();
+
+ // Record an element of interest. The DOM tree must not be
+ // modified between calls to add and the call to sorted.
+ void add(Element*);
+
+ // Adds shadow-including descendents of parent to result in
+ // shadow-including tree order. This operation is destroys the
+ // state of this sorter; after calling sorted, you must not call
+ // add or sorted again with this object.
+ void sorted(HeapVector<Member<Element>>* result, Node* parent);
+
+private:
+ using ChildSet = HeapHashSet<Member<Node>>;
+ using ParentChildMap = HeapHashMap<Member<Node>, ChildSet>;
+
+ void visit(
+ HeapVector<Member<Element>>* result,
+ ChildSet&,
+ const ChildSet::iterator&);
+
+ Member<HeapHashSet<Member<Element>>> m_elements;
+
+ // This is the subset of the tree, from root node (usually
+ // document) through elements and shadow roots, to candidates.
+ Member<ParentChildMap> m_parentChildMap;
+};
+
+} // namespace blink
+
+#endif // CustomElementUpgradeSorter_h
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698