OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CustomElementUpgradeSorter_h |
| 6 #define CustomElementUpgradeSorter_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "platform/heap/Handle.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class Element; |
| 14 class Node; |
| 15 |
| 16 // Does a shadow-including tree order sort of a subset of elements. |
| 17 // https://dom.spec.whatwg.org/#concept-shadow-including-tree-order |
| 18 class CORE_EXPORT CustomElementUpgradeSorter { |
| 19 STACK_ALLOCATED(); |
| 20 public: |
| 21 CustomElementUpgradeSorter(); |
| 22 |
| 23 // Record an element of interest. The DOM tree must not be |
| 24 // modified between calls to add and the call to sorted. |
| 25 void add(Element*); |
| 26 |
| 27 // Adds shadow-including descendents of parent to result in |
| 28 // shadow-including tree order. This operation is destroys the |
| 29 // state of this sorter; after calling sorted, you must not call |
| 30 // add or sorted again with this object. |
| 31 void sorted(HeapVector<Member<Element>>* result, Node* parent); |
| 32 |
| 33 private: |
| 34 using ChildSet = HeapHashSet<Member<Node>>; |
| 35 using ParentChildMap = HeapHashMap<Member<Node>, ChildSet>; |
| 36 |
| 37 void visit( |
| 38 HeapVector<Member<Element>>* result, |
| 39 ChildSet&, |
| 40 const ChildSet::iterator&); |
| 41 |
| 42 Member<HeapHashSet<Member<Element>>> m_elements; |
| 43 |
| 44 // This is the subset of the tree, from root node (usually |
| 45 // document) through elements and shadow roots, to candidates. |
| 46 Member<ParentChildMap> m_parentChildMap; |
| 47 }; |
| 48 |
| 49 } // namespace blink |
| 50 |
| 51 #endif // CustomElementUpgradeSorter_h |
OLD | NEW |