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

Unified Diff: Source/core/rendering/RenderObject.cpp

Issue 357703002: Introduce builders for tracing event arguments (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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: Source/core/rendering/RenderObject.cpp
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp
index 4728932f4336a8a2e5db0e9762673725d363d0dc..a611d863e2c7ba530bbd6afe1775896d718f9a97 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -1464,22 +1464,22 @@ bool RenderObject::isPaintInvalidationContainer() const
return hasLayer() && toRenderLayerModelObject(this)->layer()->isPaintInvalidationContainer();
}
-template<typename T> PassRefPtr<JSONValue> jsonObjectForRect(const T& rect)
+template<typename T> void addJsonObjectForRect(TracedValue& value, const char* name, const T& rect)
{
- RefPtr<JSONObject> object = JSONObject::create();
- object->setNumber("x", rect.x());
- object->setNumber("y", rect.y());
- object->setNumber("width", rect.width());
- object->setNumber("height", rect.height());
- return object.release();
+ value.beginDictionary(name)
+ .setDouble("x", rect.x())
+ .setDouble("y", rect.y())
+ .setDouble("width", rect.width())
+ .setDouble("height", rect.height())
+ .endDictionary();
}
-static PassRefPtr<JSONValue> jsonObjectForPaintInvalidationInfo(const IntRect& rect, const String& invalidationReason)
+static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvalidationInfo(const IntRect& rect, const String& invalidationReason)
{
- RefPtr<JSONObject> object = JSONObject::create();
- object->setValue("rect", jsonObjectForRect(rect));
- object->setString("invalidation_reason", invalidationReason);
- return object.release();
+ TracedValue value;
+ addJsonObjectForRect(value, "rect", rect);
+ value.setString("invalidation_reason", invalidationReason);
+ return value.finish();
}
LayoutRect RenderObject::computePaintInvalidationRect(const RenderLayerModelObject* paintInvalidationContainer) const
@@ -1499,7 +1499,7 @@ void RenderObject::invalidatePaintUsingContainer(const RenderLayerModelObject* p
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::invalidatePaintUsingContainer()",
"object", this->debugName().ascii(),
- "info", TracedValue::fromJSONValue(jsonObjectForPaintInvalidationInfo(r, invalidationReasonToString(invalidationReason))));
+ "info", jsonObjectForPaintInvalidationInfo(r, invalidationReasonToString(invalidationReason)));
// For querying RenderLayer::compositingState()
DisableCompositingQueryAsserts disabler;
@@ -1617,13 +1617,12 @@ void RenderObject::invalidateTreeAfterLayout(const RenderLayerModelObject& paint
}
}
-static PassRefPtr<JSONValue> jsonObjectForOldAndNewRects(const LayoutRect& oldRect, const LayoutRect& newRect)
+static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForOldAndNewRects(const LayoutRect& oldRect, const LayoutRect& newRect)
{
- RefPtr<JSONObject> object = JSONObject::create();
-
- object->setValue("old", jsonObjectForRect(oldRect));
- object->setValue("new", jsonObjectForRect(newRect));
- return object.release();
+ TracedValue value;
+ addJsonObjectForRect(value, "old", oldRect);
+ addJsonObjectForRect(value, "new", newRect);
+ return value.finish();
}
bool RenderObject::invalidatePaintAfterLayoutIfNeeded(const RenderLayerModelObject* paintInvalidationContainer, InvalidationReason invalidationReason,
@@ -1641,7 +1640,7 @@ bool RenderObject::invalidatePaintAfterLayoutIfNeeded(const RenderLayerModelObje
// FIXME: This should use a ConvertableToTraceFormat when they are available in Blink.
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::invalidatePaintAfterLayoutIfNeeded()",
"object", this->debugName().ascii(),
- "info", TracedValue::fromJSONValue(jsonObjectForOldAndNewRects(oldBounds, newBounds)));
+ "info", jsonObjectForOldAndNewRects(oldBounds, newBounds));
// Presumably a background or a border exists if border-fit:lines was specified.
if (invalidationReason == InvalidationIncremental && style()->borderFit() == BorderFitLines)

Powered by Google App Engine
This is Rietveld 408576698