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

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, 2 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 849575cb4960b16ddd153878da7052ca9bc5eca2..56503d84012376488405d0cb8e4819c1408d3c84 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
@@ -601,10 +601,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(
+std::unique_ptr<JSONObject> GraphicsLayer::layerAsJSONInternal(
LayerTreeFlags flags,
RenderingContextMap& renderingContextMap) const {
std::unique_ptr<JSONObject> json = JSONObject::create();
@@ -725,6 +733,14 @@ std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(
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();
@@ -737,6 +753,17 @@ std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(
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