Diff
Modified: trunk/Source/WebCore/ChangeLog (126279 => 126280)
--- trunk/Source/WebCore/ChangeLog 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/ChangeLog 2012-08-22 08:50:22 UTC (rev 126280)
@@ -1,3 +1,37 @@
+2012-08-22 Andrey Adaikin <[email protected]>
+
+ Web Inspector: [WebGL] Add minimum transport protocol from backend to frontend
+ https://bugs.webkit.org/show_bug.cgi?id=88973
+
+ Reviewed by Pavel Feldman.
+
+ Added the following protocol methods to communicate with the WebGL injected
+ module: captureFrame, getTraceLog, dropTraceLog, replayTraceLog.
+
+ * inspector/CodeGeneratorInspector.py:
+ * inspector/InjectedScriptWebGLModule.cpp:
+ (WebCore::InjectedScriptWebGLModule::captureFrame):
+ (WebCore):
+ (WebCore::InjectedScriptWebGLModule::dropTraceLog):
+ (WebCore::InjectedScriptWebGLModule::getTraceLog):
+ (WebCore::InjectedScriptWebGLModule::replayTraceLog):
+ * inspector/InjectedScriptWebGLModule.h:
+ (InjectedScriptWebGLModule):
+ * inspector/Inspector.json:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ * inspector/InspectorWebGLAgent.cpp:
+ (WebCore::InspectorWebGLAgent::InspectorWebGLAgent):
+ (WebCore::InspectorWebGLAgent::dropTraceLog):
+ (WebCore):
+ (WebCore::InspectorWebGLAgent::captureFrame):
+ (WebCore::InspectorWebGLAgent::getTraceLog):
+ (WebCore::InspectorWebGLAgent::replayTraceLog):
+ * inspector/InspectorWebGLAgent.h:
+ (WebCore):
+ (WebCore::InspectorWebGLAgent::create):
+ (InspectorWebGLAgent):
+
2012-08-22 Hans Wennborg <[email protected]>
Remove unused field DeleteEntryRequest::m_type
Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.py (126279 => 126280)
--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.py 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.py 2012-08-22 08:50:22 UTC (rev 126280)
@@ -59,7 +59,7 @@
TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor",
- "Debugger.FunctionDetails", "Debugger.CallFrame",
+ "Debugger.FunctionDetails", "Debugger.CallFrame", "WebGL.TraceLog",
# This should be a temporary hack. TimelineEvent should be created via generated C++ API.
"Timeline.TimelineEvent"])
Modified: trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.cpp (126279 => 126280)
--- trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.cpp 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.cpp 2012-08-22 08:50:22 UTC (rev 126280)
@@ -72,17 +72,51 @@
return ScriptObject(glContext.scriptState(), resultValue);
}
-void InjectedScriptWebGLModule::captureFrame(ErrorString* errorString, const String& contextId)
+void InjectedScriptWebGLModule::captureFrame(ErrorString* errorString, String* traceLogId)
{
ScriptFunctionCall function(injectedScriptObject(), "captureFrame");
- function.appendArgument(contextId);
+ RefPtr<InspectorValue> resultValue;
+ makeCall(function, &resultValue);
+ if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(traceLogId))
+ *errorString = "Internal error: captureFrame";
+}
+
+void InjectedScriptWebGLModule::dropTraceLog(ErrorString* errorString, const String& traceLogId)
+{
+ ScriptFunctionCall function(injectedScriptObject(), "dropTraceLog");
+ function.appendArgument(traceLogId);
bool hadException = false;
callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (hadException)
- *errorString = "Internal error";
+ *errorString = "Internal error: dropTraceLog";
}
+void InjectedScriptWebGLModule::traceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::WebGL::TraceLog>* traceLog)
+{
+ ScriptFunctionCall function(injectedScriptObject(), "traceLog");
+ function.appendArgument(traceLogId);
+ RefPtr<InspectorValue> resultValue;
+ makeCall(function, &resultValue);
+ if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue->asString(errorString))
+ *errorString = "Internal error: traceLog";
+ return;
+ }
+ *traceLog = TypeBuilder::WebGL::TraceLog::runtimeCast(resultValue);
+}
+
+void InjectedScriptWebGLModule::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result)
+{
+ ScriptFunctionCall function(injectedScriptObject(), "replayTraceLog");
+ function.appendArgument(traceLogId);
+ function.appendArgument(stepNo);
+ RefPtr<InspectorValue> resultValue;
+ makeCall(function, &resultValue);
+ if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(result))
+ *errorString = "Internal error: replayTraceLog";
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR) && ENABLE(WEBGL)
Modified: trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.h (126279 => 126280)
--- trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.h 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.h 2012-08-22 08:50:22 UTC (rev 126280)
@@ -44,15 +44,17 @@
class InjectedScriptWebGLModule : public InjectedScriptModule {
public:
+ InjectedScriptWebGLModule();
+
virtual String source() const;
static InjectedScriptWebGLModule moduleForState(InjectedScriptManager*, ScriptState*);
ScriptObject wrapWebGLContext(const ScriptObject& glContext);
- void captureFrame(ErrorString*, const String& contextId);
-
-private:
- InjectedScriptWebGLModule();
+ void captureFrame(ErrorString*, String*);
+ void dropTraceLog(ErrorString*, const String&);
+ void traceLog(ErrorString*, const String&, RefPtr<TypeBuilder::WebGL::TraceLog>*);
+ void replayTraceLog(ErrorString*, const String&, int, String*);
};
#endif
Modified: trunk/Source/WebCore/inspector/Inspector.json (126279 => 126280)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-08-22 08:50:22 UTC (rev 126280)
@@ -3135,7 +3135,28 @@
{
"domain": "WebGL",
"hidden": true,
- "types": [],
+ "types": [
+ {
+ "id": "TraceLogId",
+ "type": "string",
+ "description": "Unique object identifier."
+ },
+ {
+ "id": "Call",
+ "type": "object",
+ "properties": [
+ { "name": "functionName", "type": "string" }
+ ]
+ },
+ {
+ "id": "TraceLog",
+ "type": "object",
+ "properties": [
+ { "name": "id", "$ref": "TraceLogId" },
+ { "name": "calls", "type": "array", "items": { "$ref": "Call" }}
+ ]
+ }
+ ],
"commands": [
{
"name": "enable",
@@ -3144,6 +3165,37 @@
{
"name": "disable",
"description": "Disables WebGL inspection."
+ },
+ {
+ "name": "dropTraceLog",
+ "parameters": [
+ { "name": "traceLogId", "$ref": "TraceLogId" }
+ ]
+ },
+ {
+ "name": "captureFrame",
+ "returns": [
+ { "name": "traceLogId", "$ref": "TraceLogId" }
+ ]
+ },
+ {
+ "name": "getTraceLog",
+ "parameters": [
+ { "name": "traceLogId", "$ref": "TraceLogId" }
+ ],
+ "returns": [
+ { "name": "traceLog", "$ref": "TraceLog" }
+ ]
+ },
+ {
+ "name": "replayTraceLog",
+ "parameters": [
+ { "name": "traceLogId", "$ref": "TraceLogId" },
+ { "name": "stepNo", "type": "integer" }
+ ],
+ "returns": [
+ { "name": "screenshotDataUrl", "type": "string" }
+ ]
}
],
"events": []
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (126279 => 126280)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2012-08-22 08:50:22 UTC (rev 126280)
@@ -148,7 +148,7 @@
#endif
#if ENABLE(WEBGL)
- m_agents.append(InspectorWebGLAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get()));
+ m_agents.append(InspectorWebGLAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()));
#endif
ASSERT_ARG(inspectorClient, inspectorClient);
Modified: trunk/Source/WebCore/inspector/InspectorWebGLAgent.cpp (126279 => 126280)
--- trunk/Source/WebCore/inspector/InspectorWebGLAgent.cpp 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/inspector/InspectorWebGLAgent.cpp 2012-08-22 08:50:22 UTC (rev 126280)
@@ -34,11 +34,13 @@
#include "InspectorWebGLAgent.h"
+#include "InjectedScript.h"
#include "InjectedScriptManager.h"
#include "InjectedScriptWebGLModule.h"
#include "InspectorFrontend.h"
#include "InspectorState.h"
#include "InstrumentingAgents.h"
+#include "Page.h"
#include "ScriptObject.h"
#include "ScriptState.h"
@@ -48,8 +50,9 @@
static const char webGLAgentEnabled[] = "webGLAgentEnabled";
};
-InspectorWebGLAgent::InspectorWebGLAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)
+InspectorWebGLAgent::InspectorWebGLAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InjectedScriptManager* injectedScriptManager)
: InspectorBaseAgent<InspectorWebGLAgent>("WebGL", instrumentingAgents, state)
+ , m_inspectedPage(page)
, m_injectedScriptManager(injectedScriptManager)
, m_frontend(0)
, m_enabled(false)
@@ -95,6 +98,38 @@
m_state->setBoolean(WebGLAgentState::webGLAgentEnabled, m_enabled);
}
+void InspectorWebGLAgent::dropTraceLog(ErrorString* errorString, const String& traceLogId)
+{
+ InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId);
+ if (!module.hasNoValue())
+ module.dropTraceLog(errorString, traceLogId);
+}
+
+void InspectorWebGLAgent::captureFrame(ErrorString* errorString, String* traceLogId)
+{
+ ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame());
+ InjectedScriptWebGLModule module = InjectedScriptWebGLModule::moduleForState(m_injectedScriptManager, scriptState);
+ if (module.hasNoValue()) {
+ *errorString = "Inspected frame has gone";
+ return;
+ }
+ module.captureFrame(errorString, traceLogId);
+}
+
+void InspectorWebGLAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::WebGL::TraceLog>& traceLog)
+{
+ InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId);
+ if (!module.hasNoValue())
+ module.traceLog(errorString, traceLogId, &traceLog);
+}
+
+void InspectorWebGLAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result)
+{
+ InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId);
+ if (!module.hasNoValue())
+ module.replayTraceLog(errorString, traceLogId, stepNo, result);
+}
+
ScriptObject InspectorWebGLAgent::wrapWebGLRenderingContextForInstrumentation(const ScriptObject& glContext)
{
if (glContext.hasNoValue()) {
@@ -109,6 +144,22 @@
return module.wrapWebGLContext(glContext);
}
+InjectedScriptWebGLModule InspectorWebGLAgent::injectedScriptWebGLModuleForTraceLogId(ErrorString* errorString, const String& traceLogId)
+{
+ InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(traceLogId);
+ if (injectedScript.hasNoValue()) {
+ *errorString = "Inspected frame has gone";
+ return InjectedScriptWebGLModule();
+ }
+ InjectedScriptWebGLModule module = InjectedScriptWebGLModule::moduleForState(m_injectedScriptManager, injectedScript.scriptState());
+ if (module.hasNoValue()) {
+ ASSERT_NOT_REACHED();
+ *errorString = "Internal error: no WebGL module";
+ return InjectedScriptWebGLModule();
+ }
+ return module;
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR) && ENABLE(WEBGL)
Modified: trunk/Source/WebCore/inspector/InspectorWebGLAgent.h (126279 => 126280)
--- trunk/Source/WebCore/inspector/InspectorWebGLAgent.h 2012-08-22 08:47:53 UTC (rev 126279)
+++ trunk/Source/WebCore/inspector/InspectorWebGLAgent.h 2012-08-22 08:50:22 UTC (rev 126280)
@@ -35,6 +35,7 @@
#include "InspectorBaseAgent.h"
#include "InspectorFrontend.h"
+#include "InspectorTypeBuilder.h"
#include "PlatformString.h"
#include "ScriptState.h"
#include <wtf/PassOwnPtr.h>
@@ -43,17 +44,19 @@
namespace WebCore {
class InjectedScriptManager;
+class InjectedScriptWebGLModule;
class InspectorState;
class InstrumentingAgents;
+class Page;
class ScriptObject;
typedef String ErrorString;
class InspectorWebGLAgent : public InspectorBaseAgent<InspectorWebGLAgent>, public InspectorBackendDispatcher::WebGLCommandHandler {
public:
- static PassOwnPtr<InspectorWebGLAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)
+ static PassOwnPtr<InspectorWebGLAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InjectedScriptManager* injectedScriptManager)
{
- return adoptPtr(new InspectorWebGLAgent(instrumentingAgents, state, injectedScriptManager));
+ return adoptPtr(new InspectorWebGLAgent(instrumentingAgents, state, page, injectedScriptManager));
}
~InspectorWebGLAgent();
@@ -68,14 +71,21 @@
// Called from the front-end.
virtual void enable(ErrorString*);
virtual void disable(ErrorString*);
+ virtual void dropTraceLog(ErrorString*, const String&);
+ virtual void captureFrame(ErrorString*, String*);
+ virtual void getTraceLog(ErrorString*, const String&, RefPtr<TypeBuilder::WebGL::TraceLog>&);
+ virtual void replayTraceLog(ErrorString*, const String&, int, String*);
// Called from the injected script.
// Called from InspectorInstrumentation
private:
- InspectorWebGLAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
+ InspectorWebGLAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
+ InjectedScriptWebGLModule injectedScriptWebGLModuleForTraceLogId(ErrorString*, const String&);
+
+ Page* m_inspectedPage;
InjectedScriptManager* m_injectedScriptManager;
InspectorFrontend::WebGL* m_frontend;
bool m_enabled;