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

Unified Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp

Issue 2383323002: [SPv2] Introduce an option to output the GraphicsLayer tree as a flat layer list. (Closed)
Patch Set: none 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/platform/graphics/GraphicsLayer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
index c65fe69813019e2192353d116d99b82892ac5df0..b9154ad0b4eb4e92720a50673763c848e78cb9e1 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
@@ -607,10 +607,18 @@ static String pointerAsString(const void* ptr)
std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags) const
{
RenderingContextMap renderingContextMap;
+ if (flags & OutputChildrenAsLayerList) {
+ std::unique_ptr<JSONObject> json = JSONObject::create();
+ std::unique_ptr<JSONArray> layersArray = JSONArray::create();
+ for (auto& child : m_children)
+ child->layersAsJSONArray(flags, renderingContextMap, layersArray.get());
+ json->setArray("layers", std::move(layersArray));
+ return json;
+ }
return layerTreeAsJSONInternal(flags, renderingContextMap);
}
-std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlags flags, RenderingContextMap& renderingContextMap) const
+std::unique_ptr<JSONObject> GraphicsLayer::layerAsJSONInternal(LayerTreeFlags flags, RenderingContextMap& renderingContextMap) const
{
std::unique_ptr<JSONObject> json = JSONObject::create();
@@ -714,6 +722,12 @@ std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlag
}
json->setArray("squashingDisallowedReasons", std::move(squashingDisallowedReasonsJSON));
}
+ return json;
+}
+
+std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlags flags, RenderingContextMap& renderingContextMap) const
+{
+ std::unique_ptr<JSONObject> json = layerAsJSONInternal(flags, renderingContextMap);
if (m_children.size()) {
std::unique_ptr<JSONArray> childrenJSON = JSONArray::create();
@@ -725,6 +739,16 @@ std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlag
return json;
}
+void GraphicsLayer::layersAsJSONArray(LayerTreeFlags flags, RenderingContextMap& renderingContextMap, JSONArray* jsonArray) const
+{
+ jsonArray->pushObject(layerAsJSONInternal(flags, renderingContextMap));
+
+ if (m_children.size()) {
+ for (auto& child : m_children)
+ child->layersAsJSONArray(flags, renderingContextMap, jsonArray);
+ }
+}
+
String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const
{
return layerTreeAsJSON(flags)->toPrettyJSONString();

Powered by Google App Engine
This is Rietveld 408576698