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

Unified Diff: third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.cpp

Issue 2348993002: Don't include LayoutObject.h from FrameView.h (Closed)
Patch Set: Created 4 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
Index: third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.cpp
diff --git a/third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.cpp b/third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.cpp
index 7217ff76fc427fa2df879061fb10b6ab6c6404ef..3ebdd3b010cd779cfe2583e5b5a52954b4065c83 100644
--- a/third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.cpp
+++ b/third_party/WebKit/Source/core/layout/DepthOrderedLayoutObjectList.cpp
@@ -10,27 +10,58 @@
namespace blink {
+struct DepthOrderedLayoutObjectListData {
+ // LayoutObjects sorted by depth (deepest first). This structure is only
+ // populated at the beginning of enumerations. See ordered().
+ Vector<DepthOrderedLayoutObjectList::LayoutObjectWithDepth> m_orderedObjects;
+
+ // 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_objects;
+};
+
+DepthOrderedLayoutObjectList::DepthOrderedLayoutObjectList()
+ : m_data(new DepthOrderedLayoutObjectListData)
+{
+}
+
+DepthOrderedLayoutObjectList::~DepthOrderedLayoutObjectList()
+{
+ delete m_data;
+}
+
+int DepthOrderedLayoutObjectList::size() const
+{
+ return m_data->m_objects.size();
+}
+
+bool DepthOrderedLayoutObjectList::isEmpty() const
+{
+ return m_data->m_objects.isEmpty();
+}
+
void DepthOrderedLayoutObjectList::add(LayoutObject& object)
{
ASSERT(!object.frameView()->isInPerformLayout());
- m_objects.add(&object);
- m_orderedObjects.clear();
+ m_data->m_objects.add(&object);
+ m_data->m_orderedObjects.clear();
}
void DepthOrderedLayoutObjectList::remove(LayoutObject& object)
{
- auto it = m_objects.find(&object);
- if (it == m_objects.end())
+ auto it = m_data->m_objects.find(&object);
+ if (it == m_data->m_objects.end())
return;
ASSERT(!object.frameView()->isInPerformLayout());
- m_objects.remove(it);
- m_orderedObjects.clear();
+ m_data->m_objects.remove(it);
+ m_data->m_orderedObjects.clear();
}
void DepthOrderedLayoutObjectList::clear()
{
- m_objects.clear();
- m_orderedObjects.clear();
+ m_data->m_objects.clear();
+ m_data->m_orderedObjects.clear();
}
unsigned DepthOrderedLayoutObjectList::LayoutObjectWithDepth::determineDepth(LayoutObject* object)
@@ -41,14 +72,19 @@ unsigned DepthOrderedLayoutObjectList::LayoutObjectWithDepth::determineDepth(Lay
return depth;
}
+const HashSet<LayoutObject*>& DepthOrderedLayoutObjectList::unordered() const
+{
+ return m_data->m_objects;
+}
+
const Vector<DepthOrderedLayoutObjectList::LayoutObjectWithDepth>& DepthOrderedLayoutObjectList::ordered()
{
- if (m_objects.isEmpty() || !m_orderedObjects.isEmpty())
- return m_orderedObjects;
+ if (m_data->m_objects.isEmpty() || !m_data->m_orderedObjects.isEmpty())
+ return m_data->m_orderedObjects;
- copyToVector(m_objects, m_orderedObjects);
- std::sort(m_orderedObjects.begin(), m_orderedObjects.end());
- return m_orderedObjects;
+ copyToVector(m_data->m_objects, m_data->m_orderedObjects);
+ std::sort(m_data->m_orderedObjects.begin(), m_data->m_orderedObjects.end());
+ return m_data->m_orderedObjects;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698