Index: third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.h |
diff --git a/third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.h b/third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..25be824a499d6dd60e1daf65713d41181e918020 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.h |
@@ -0,0 +1,62 @@ |
+// 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 DepthOrderedLayoutObjectList_h |
+#define DepthOrderedLayoutObjectList_h |
+ |
+#include "wtf/Allocator.h" |
+#include "wtf/HashSet.h" |
+#include "wtf/Vector.h" |
+ |
+namespace blink { |
+ |
+class LayoutObject; |
+ |
+class DepthOrderedLayoutObjectList { |
+public: |
+ DepthOrderedLayoutObjectList() |
+ { } |
+ |
+ int size() { return m_roots.size(); } |
+ bool isEmpty() const { return m_roots.isEmpty(); } |
+ |
+protected: |
+ struct LayoutObjectWithDepth { |
+ LayoutObjectWithDepth(LayoutObject* inObject) |
+ : object(inObject) |
+ , depth(determineDepth(inObject)) |
+ { } |
+ |
+ LayoutObjectWithDepth() |
+ : object(0) |
+ , depth(0) |
+ { } |
+ |
+ LayoutObject* object; |
+ unsigned depth; |
+ |
+ bool operator<(const DepthOrderedLayoutObjectList::LayoutObjectWithDepth& other) const |
+ { |
+ return depth < other.depth; |
+ } |
+ |
+ private: |
+ static unsigned determineDepth(LayoutObject*); |
+ }; |
+ |
+ // LayoutObjects sorted by depth (shallowest first). This structure is only |
+ // populated at the beginning of enumerations. See takeDeepestRoot() in |
+ // subclasses such as LayoutSubtreeRootList or |
+ // OrthogonalWritingModeRootList. |
esprehn
2016/01/31 00:44:56
just merge them into a single class, DepthOrderedL
|
+ Vector<LayoutObjectWithDepth> m_orderedRoots; |
+ |
+ // Outside of layout, LayoutObjects can be added and removed as needed such |
+ // as when style was changed or destroyed. They're kept in this hashset to |
+ // keep those operations fast. |
+ HashSet<LayoutObject*> m_roots; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // DepthOrderedLayoutObjectList_h |