Diff
Modified: trunk/Source/WebCore/ChangeLog (135590 => 135591)
--- trunk/Source/WebCore/ChangeLog 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/ChangeLog 2012-11-23 12:20:24 UTC (rev 135591)
@@ -1,3 +1,37 @@
+2012-11-23 Andrey Adaikin <[email protected]>
+
+ Web Inspector: [Canvas] add startCapturing and stopCapturing methods to protocol
+ https://bugs.webkit.org/show_bug.cgi?id=103053
+
+ Reviewed by Pavel Feldman.
+
+ Add startCapturing and stopCapturing methods to the protocol to instrument several canvas frames in a row.
+ Drive-by: support start offset index in retrieving trace logs in the backend as well as "alive" flag.
+
+ * inspector/InjectedScriptCanvasModule.cpp:
+ (WebCore::InjectedScriptCanvasModule::captureFrame):
+ (WebCore):
+ (WebCore::InjectedScriptCanvasModule::startCapturing):
+ (WebCore::InjectedScriptCanvasModule::callStartCapturingFunction):
+ (WebCore::InjectedScriptCanvasModule::stopCapturing):
+ (WebCore::InjectedScriptCanvasModule::dropTraceLog):
+ (WebCore::InjectedScriptCanvasModule::callVoidFunctionWithTraceLogIdArgument):
+ (WebCore::InjectedScriptCanvasModule::traceLog):
+ * inspector/InjectedScriptCanvasModule.h:
+ (InjectedScriptCanvasModule):
+ * inspector/InjectedScriptCanvasModuleSource.js:
+ (.):
+ * inspector/Inspector.json:
+ * inspector/InspectorCanvasAgent.cpp:
+ (WebCore::InspectorCanvasAgent::startCapturing):
+ (WebCore):
+ (WebCore::InspectorCanvasAgent::stopCapturing):
+ (WebCore::InspectorCanvasAgent::getTraceLog):
+ * inspector/InspectorCanvasAgent.h:
+ (InspectorCanvasAgent):
+ * inspector/front-end/CanvasProfileView.js:
+ (WebInspector.CanvasProfileView):
+
2012-11-23 Andrey Kosyakov <[email protected]>
Web Inspector: dispatch events upon certain user actions on inspector's notification services
Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.cpp (135590 => 135591)
--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.cpp 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.cpp 2012-11-23 12:20:24 UTC (rev 135591)
@@ -86,28 +86,50 @@
void InjectedScriptCanvasModule::captureFrame(ErrorString* errorString, String* traceLogId)
{
- ScriptFunctionCall function(injectedScriptObject(), "captureFrame");
+ callStartCapturingFunction("captureFrame", errorString, traceLogId);
+}
+
+void InjectedScriptCanvasModule::startCapturing(ErrorString* errorString, String* traceLogId)
+{
+ callStartCapturingFunction("startCapturing", errorString, traceLogId);
+}
+
+void InjectedScriptCanvasModule::callStartCapturingFunction(const String& functionName, ErrorString* errorString, String* traceLogId)
+{
+ ScriptFunctionCall function(injectedScriptObject(), functionName);
RefPtr<InspectorValue> resultValue;
makeCall(function, &resultValue);
if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(traceLogId))
- *errorString = "Internal error: captureFrame";
+ *errorString = "Internal error: " + functionName;
}
+void InjectedScriptCanvasModule::stopCapturing(ErrorString* errorString, const String& traceLogId)
+{
+ callVoidFunctionWithTraceLogIdArgument("stopCapturing", errorString, traceLogId);
+}
+
void InjectedScriptCanvasModule::dropTraceLog(ErrorString* errorString, const String& traceLogId)
{
- ScriptFunctionCall function(injectedScriptObject(), "dropTraceLog");
+ callVoidFunctionWithTraceLogIdArgument("dropTraceLog", errorString, traceLogId);
+}
+
+void InjectedScriptCanvasModule::callVoidFunctionWithTraceLogIdArgument(const String& functionName, ErrorString* errorString, const String& traceLogId)
+{
+ ScriptFunctionCall function(injectedScriptObject(), functionName);
function.appendArgument(traceLogId);
bool hadException = false;
callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (hadException)
- *errorString = "Internal error: dropTraceLog";
+ *errorString = "Internal error: " + functionName;
}
-void InjectedScriptCanvasModule::traceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::Canvas::TraceLog>* traceLog)
+void InjectedScriptCanvasModule::traceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, RefPtr<TypeBuilder::Canvas::TraceLog>* traceLog)
{
ScriptFunctionCall function(injectedScriptObject(), "traceLog");
function.appendArgument(traceLogId);
+ if (startOffset)
+ function.appendArgument(*startOffset);
RefPtr<InspectorValue> resultValue;
makeCall(function, &resultValue);
if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h (135590 => 135591)
--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h 2012-11-23 12:20:24 UTC (rev 135591)
@@ -56,12 +56,16 @@
#endif
void captureFrame(ErrorString*, String*);
+ void startCapturing(ErrorString*, String*);
+ void stopCapturing(ErrorString*, const String&);
void dropTraceLog(ErrorString*, const String&);
- void traceLog(ErrorString*, const String&, RefPtr<TypeBuilder::Canvas::TraceLog>*);
+ void traceLog(ErrorString*, const String&, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>*);
void replayTraceLog(ErrorString*, const String&, int, String*);
private:
ScriptObject callWrapContextFunction(const String&, const ScriptObject&);
+ void callStartCapturingFunction(const String&, ErrorString*, String*);
+ void callVoidFunctionWithTraceLogIdArgument(const String&, ErrorString*, const String&);
};
#endif
Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js (135590 => 135591)
--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js 2012-11-23 12:20:24 UTC (rev 135591)
@@ -2552,39 +2552,85 @@
return resource.proxyObject();
},
+ /**
+ * @return {string}
+ */
captureFrame: function()
{
+ return this._callStartCapturingFunction(this._manager.captureFrame);
+ },
+
+ /**
+ * @return {string}
+ */
+ startCapturing: function()
+ {
+ return this._callStartCapturingFunction(this._manager.startCapturing);
+ },
+
+ /**
+ * @param {function(this:ResourceTrackingManager)} func
+ * @return {string}
+ */
+ _callStartCapturingFunction: function(func)
+ {
+ var oldTraceLog = this._manager.lastTraceLog();
+ func.call(this._manager);
+ var traceLog = this._manager.lastTraceLog();
+ if (traceLog === oldTraceLog) {
+ for (var id in this._traceLogs) {
+ if (this._traceLogs[id] === traceLog)
+ return id;
+ }
+ }
var id = this._makeTraceLogId();
- this._manager.captureFrame();
- this._traceLogs[id] = this._manager.lastTraceLog();
+ this._traceLogs[id] = traceLog;
return id;
},
/**
* @param {string} id
*/
+ stopCapturing: function(id)
+ {
+ var traceLog = this._traceLogs[id];
+ if (traceLog)
+ this._manager.stopCapturing(traceLog);
+ },
+
+ /**
+ * @param {string} id
+ */
dropTraceLog: function(id)
{
- if (this._traceLogPlayer && this._traceLogPlayer.traceLog() === this._traceLogs[id])
+ this.stopCapturing(id);
+ if (this._traceLogPlayer && this._traceLogPlayer.traceLog() === this._traceLogs[id]) {
this._traceLogPlayer = null;
+ this._replayContexts = [];
+ }
delete this._traceLogs[id];
},
/**
* @param {string} id
+ * @param {number=} startOffset
* @return {Object|string}
*/
- traceLog: function(id)
+ traceLog: function(id, startOffset)
{
var traceLog = this._traceLogs[id];
if (!traceLog)
return "Error: Trace log with this ID not found.";
+ startOffset = Math.max(0, startOffset || 0);
+ var alive = this._manager.capturing() && this._manager.lastTraceLog() === traceLog;
var result = {
id: id,
- calls: []
+ calls: [],
+ alive: alive,
+ startOffset: startOffset
};
var calls = traceLog.replayableCalls();
- for (var i = 0, n = calls.length; i < n; ++i) {
+ for (var i = startOffset, n = calls.length; i < n; ++i) {
var call = calls[i];
var args = call.args().map(function(argument) {
return argument + "";
Modified: trunk/Source/WebCore/inspector/Inspector.json (135590 => 135591)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-11-23 12:20:24 UTC (rev 135591)
@@ -3180,7 +3180,9 @@
"type": "object",
"properties": [
{ "name": "id", "$ref": "TraceLogId" },
- { "name": "calls", "type": "array", "items": { "$ref": "Call" } }
+ { "name": "calls", "type": "array", "items": { "$ref": "Call" } },
+ { "name": "startOffset", "type": "integer", "optional": true },
+ { "name": "alive", "type": "boolean", "optional": true }
]
}
],
@@ -3206,9 +3208,22 @@
]
},
{
+ "name": "startCapturing",
+ "returns": [
+ { "name": "traceLogId", "$ref": "TraceLogId" }
+ ]
+ },
+ {
+ "name": "stopCapturing",
+ "parameters": [
+ { "name": "traceLogId", "$ref": "TraceLogId" }
+ ]
+ },
+ {
"name": "getTraceLog",
"parameters": [
- { "name": "traceLogId", "$ref": "TraceLogId" }
+ { "name": "traceLogId", "$ref": "TraceLogId" },
+ { "name": "startOffset", "type": "integer", "optional": true }
],
"returns": [
{ "name": "traceLog", "$ref": "TraceLog" }
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp (135590 => 135591)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2012-11-23 12:20:24 UTC (rev 135591)
@@ -112,13 +112,31 @@
module.captureFrame(errorString, traceLogId);
}
-void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::Canvas::TraceLog>& traceLog)
+void InspectorCanvasAgent::startCapturing(ErrorString* errorString, String* traceLogId)
{
+ ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame());
+ InjectedScriptCanvasModule module = InjectedScriptCanvasModule::moduleForState(m_injectedScriptManager, scriptState);
+ if (module.hasNoValue()) {
+ *errorString = "Inspected frame has gone";
+ return;
+ }
+ module.startCapturing(errorString, traceLogId);
+}
+
+void InspectorCanvasAgent::stopCapturing(ErrorString* errorString, const String& traceLogId)
+{
InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId);
if (!module.hasNoValue())
- module.traceLog(errorString, traceLogId, &traceLog);
+ module.stopCapturing(errorString, traceLogId);
}
+void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, RefPtr<TypeBuilder::Canvas::TraceLog>& traceLog)
+{
+ InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId);
+ if (!module.hasNoValue())
+ module.traceLog(errorString, traceLogId, startOffset, &traceLog);
+}
+
void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result)
{
InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId);
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.h (135590 => 135591)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2012-11-23 12:20:24 UTC (rev 135591)
@@ -64,6 +64,7 @@
virtual void clearFrontend();
virtual void restore();
+ // Called from InspectorCanvasInstrumentation
ScriptObject wrapCanvas2DRenderingContextForInstrumentation(const ScriptObject&);
#if ENABLE(WEBGL)
ScriptObject wrapWebGLRenderingContextForInstrumentation(const ScriptObject&);
@@ -74,13 +75,11 @@
virtual void disable(ErrorString*);
virtual void dropTraceLog(ErrorString*, const String&);
virtual void captureFrame(ErrorString*, String*);
- virtual void getTraceLog(ErrorString*, const String&, RefPtr<TypeBuilder::Canvas::TraceLog>&);
+ virtual void startCapturing(ErrorString*, String*);
+ virtual void stopCapturing(ErrorString*, const String&);
+ virtual void getTraceLog(ErrorString*, const String&, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&);
virtual void replayTraceLog(ErrorString*, const String&, int, String*);
- // Called from the injected script.
-
- // Called from InspectorInstrumentation
-
private:
InspectorCanvasAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
Modified: trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js (135590 => 135591)
--- trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js 2012-11-23 12:15:59 UTC (rev 135590)
+++ trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js 2012-11-23 12:20:24 UTC (rev 135591)
@@ -72,7 +72,7 @@
this._splitView.show(this.element);
this._enableWaitIcon(true);
- CanvasAgent.getTraceLog(this._traceLogId, this._didReceiveTraceLog.bind(this));
+ CanvasAgent.getTraceLog(this._traceLogId, 0, this._didReceiveTraceLog.bind(this));
}
WebInspector.CanvasProfileView.prototype = {