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

Unified Diff: cc/layers/layer_impl.cc

Issue 128303003: Prepare for including compositing reasons in GraphicsLayerDebugInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer_impl.cc
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index 74b69b5572a953f0eb08818e153630400a69cf8e..f0731d4dddb19399b45bc2ce1a661460276bed7b 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -1381,13 +1381,30 @@ void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
std::string str;
debug_info_->AppendAsTraceFormat(&str);
base::JSONReader json_reader;
- // Parsing the JSON and re-encoding it is not very efficient,
- // but it's the simplest way to achieve the desired effect, which
- // is to output:
- // {..., layout_rects: [{geometry_rect: ...}, ...], ...}
- // rather than:
- // {layout_rects: "[{geometry_rect: ...}, ...]", ...}
- state->Set("layout_rects", json_reader.ReadToValue(str));
+ scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
+
+ // TODO(vollick): The TYPE_LIST code below is brittle; it assumes the only
+ // debug info is the layout rects. In future, this will be generalized, and
+ // debug info will return a dictionary to be merged into state. Until then,
+ // we unfortunately have to support both situations. Once we've migrated,
+ // the TYPE_LIST branch will be deleted.
+ if (debug_info_value->IsType(base::Value::TYPE_LIST)) {
+ // Parsing the JSON and re-encoding it is not very efficient,
+ // but it's the simplest way to achieve the desired effect, which
+ // is to output:
+ // {..., layout_rects: [{geometry_rect: ...}, ...], ...}
+ // rather than:
+ // {layout_rects: "[{geometry_rect: ...}, ...]", ...}
+ state->Set("layout_rects", debug_info_value.release());
+ } else if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) {
+ base::DictionaryValue* dictionary_value = NULL;
+ bool converted_to_dictionary =
+ debug_info_value->GetAsDictionary(&dictionary_value);
+ DCHECK(converted_to_dictionary);
+ state->MergeDictionary(dictionary_value);
+ } else {
+ NOTREACHED();
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698