Changeset 126280 in webkit
- Timestamp:
- Aug 22, 2012 1:50:22 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126279 r126280 1 2012-08-22 Andrey Adaikin <aandrey@chromium.org> 2 3 Web Inspector: [WebGL] Add minimum transport protocol from backend to frontend 4 https://bugs.webkit.org/show_bug.cgi?id=88973 5 6 Reviewed by Pavel Feldman. 7 8 Added the following protocol methods to communicate with the WebGL injected 9 module: captureFrame, getTraceLog, dropTraceLog, replayTraceLog. 10 11 * inspector/CodeGeneratorInspector.py: 12 * inspector/InjectedScriptWebGLModule.cpp: 13 (WebCore::InjectedScriptWebGLModule::captureFrame): 14 (WebCore): 15 (WebCore::InjectedScriptWebGLModule::dropTraceLog): 16 (WebCore::InjectedScriptWebGLModule::getTraceLog): 17 (WebCore::InjectedScriptWebGLModule::replayTraceLog): 18 * inspector/InjectedScriptWebGLModule.h: 19 (InjectedScriptWebGLModule): 20 * inspector/Inspector.json: 21 * inspector/InspectorController.cpp: 22 (WebCore::InspectorController::InspectorController): 23 * inspector/InspectorWebGLAgent.cpp: 24 (WebCore::InspectorWebGLAgent::InspectorWebGLAgent): 25 (WebCore::InspectorWebGLAgent::dropTraceLog): 26 (WebCore): 27 (WebCore::InspectorWebGLAgent::captureFrame): 28 (WebCore::InspectorWebGLAgent::getTraceLog): 29 (WebCore::InspectorWebGLAgent::replayTraceLog): 30 * inspector/InspectorWebGLAgent.h: 31 (WebCore): 32 (WebCore::InspectorWebGLAgent::create): 33 (InspectorWebGLAgent): 34 1 35 2012-08-22 Hans Wennborg <hans@chromium.org> 2 36 -
trunk/Source/WebCore/inspector/CodeGeneratorInspector.py
r126206 r126280 60 60 61 61 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor", 62 "Debugger.FunctionDetails", "Debugger.CallFrame", 62 "Debugger.FunctionDetails", "Debugger.CallFrame", "WebGL.TraceLog", 63 63 # This should be a temporary hack. TimelineEvent should be created via generated C++ API. 64 64 "Timeline.TimelineEvent"]) -
trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.cpp
r126140 r126280 73 73 } 74 74 75 void InjectedScriptWebGLModule::captureFrame(ErrorString* errorString, const String& contextId)75 void InjectedScriptWebGLModule::captureFrame(ErrorString* errorString, String* traceLogId) 76 76 { 77 77 ScriptFunctionCall function(injectedScriptObject(), "captureFrame"); 78 function.appendArgument(contextId); 78 RefPtr<InspectorValue> resultValue; 79 makeCall(function, &resultValue); 80 if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(traceLogId)) 81 *errorString = "Internal error: captureFrame"; 82 } 83 84 void InjectedScriptWebGLModule::dropTraceLog(ErrorString* errorString, const String& traceLogId) 85 { 86 ScriptFunctionCall function(injectedScriptObject(), "dropTraceLog"); 87 function.appendArgument(traceLogId); 79 88 bool hadException = false; 80 89 callFunctionWithEvalEnabled(function, hadException); 81 90 ASSERT(!hadException); 82 91 if (hadException) 83 *errorString = "Internal error"; 92 *errorString = "Internal error: dropTraceLog"; 93 } 94 95 void InjectedScriptWebGLModule::traceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::WebGL::TraceLog>* traceLog) 96 { 97 ScriptFunctionCall function(injectedScriptObject(), "traceLog"); 98 function.appendArgument(traceLogId); 99 RefPtr<InspectorValue> resultValue; 100 makeCall(function, &resultValue); 101 if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { 102 if (!resultValue->asString(errorString)) 103 *errorString = "Internal error: traceLog"; 104 return; 105 } 106 *traceLog = TypeBuilder::WebGL::TraceLog::runtimeCast(resultValue); 107 } 108 109 void InjectedScriptWebGLModule::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result) 110 { 111 ScriptFunctionCall function(injectedScriptObject(), "replayTraceLog"); 112 function.appendArgument(traceLogId); 113 function.appendArgument(stepNo); 114 RefPtr<InspectorValue> resultValue; 115 makeCall(function, &resultValue); 116 if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(result)) 117 *errorString = "Internal error: replayTraceLog"; 84 118 } 85 119 -
trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.h
r126140 r126280 45 45 class InjectedScriptWebGLModule : public InjectedScriptModule { 46 46 public: 47 InjectedScriptWebGLModule(); 48 47 49 virtual String source() const; 48 50 … … 50 52 51 53 ScriptObject wrapWebGLContext(const ScriptObject& glContext); 52 void captureFrame(ErrorString*, const String& contextId);53 54 private: 55 InjectedScriptWebGLModule();54 void captureFrame(ErrorString*, String*); 55 void dropTraceLog(ErrorString*, const String&); 56 void traceLog(ErrorString*, const String&, RefPtr<TypeBuilder::WebGL::TraceLog>*); 57 void replayTraceLog(ErrorString*, const String&, int, String*); 56 58 }; 57 59 -
trunk/Source/WebCore/inspector/Inspector.json
r126273 r126280 3136 3136 "domain": "WebGL", 3137 3137 "hidden": true, 3138 "types": [], 3138 "types": [ 3139 { 3140 "id": "TraceLogId", 3141 "type": "string", 3142 "description": "Unique object identifier." 3143 }, 3144 { 3145 "id": "Call", 3146 "type": "object", 3147 "properties": [ 3148 { "name": "functionName", "type": "string" } 3149 ] 3150 }, 3151 { 3152 "id": "TraceLog", 3153 "type": "object", 3154 "properties": [ 3155 { "name": "id", "$ref": "TraceLogId" }, 3156 { "name": "calls", "type": "array", "items": { "$ref": "Call" }} 3157 ] 3158 } 3159 ], 3139 3160 "commands": [ 3140 3161 { … … 3145 3166 "name": "disable", 3146 3167 "description": "Disables WebGL inspection." 3168 }, 3169 { 3170 "name": "dropTraceLog", 3171 "parameters": [ 3172 { "name": "traceLogId", "$ref": "TraceLogId" } 3173 ] 3174 }, 3175 { 3176 "name": "captureFrame", 3177 "returns": [ 3178 { "name": "traceLogId", "$ref": "TraceLogId" } 3179 ] 3180 }, 3181 { 3182 "name": "getTraceLog", 3183 "parameters": [ 3184 { "name": "traceLogId", "$ref": "TraceLogId" } 3185 ], 3186 "returns": [ 3187 { "name": "traceLog", "$ref": "TraceLog" } 3188 ] 3189 }, 3190 { 3191 "name": "replayTraceLog", 3192 "parameters": [ 3193 { "name": "traceLogId", "$ref": "TraceLogId" }, 3194 { "name": "stepNo", "type": "integer" } 3195 ], 3196 "returns": [ 3197 { "name": "screenshotDataUrl", "type": "string" } 3198 ] 3147 3199 } 3148 3200 ], -
trunk/Source/WebCore/inspector/InspectorController.cpp
r126140 r126280 149 149 150 150 #if ENABLE(WEBGL) 151 m_agents.append(InspectorWebGLAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get()));151 m_agents.append(InspectorWebGLAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get())); 152 152 #endif 153 153 -
trunk/Source/WebCore/inspector/InspectorWebGLAgent.cpp
r126140 r126280 35 35 #include "InspectorWebGLAgent.h" 36 36 37 #include "InjectedScript.h" 37 38 #include "InjectedScriptManager.h" 38 39 #include "InjectedScriptWebGLModule.h" … … 40 41 #include "InspectorState.h" 41 42 #include "InstrumentingAgents.h" 43 #include "Page.h" 42 44 #include "ScriptObject.h" 43 45 #include "ScriptState.h" … … 49 51 }; 50 52 51 InspectorWebGLAgent::InspectorWebGLAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)53 InspectorWebGLAgent::InspectorWebGLAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InjectedScriptManager* injectedScriptManager) 52 54 : InspectorBaseAgent<InspectorWebGLAgent>("WebGL", instrumentingAgents, state) 55 , m_inspectedPage(page) 53 56 , m_injectedScriptManager(injectedScriptManager) 54 57 , m_frontend(0) … … 96 99 } 97 100 101 void InspectorWebGLAgent::dropTraceLog(ErrorString* errorString, const String& traceLogId) 102 { 103 InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId); 104 if (!module.hasNoValue()) 105 module.dropTraceLog(errorString, traceLogId); 106 } 107 108 void InspectorWebGLAgent::captureFrame(ErrorString* errorString, String* traceLogId) 109 { 110 ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame()); 111 InjectedScriptWebGLModule module = InjectedScriptWebGLModule::moduleForState(m_injectedScriptManager, scriptState); 112 if (module.hasNoValue()) { 113 *errorString = "Inspected frame has gone"; 114 return; 115 } 116 module.captureFrame(errorString, traceLogId); 117 } 118 119 void InspectorWebGLAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::WebGL::TraceLog>& traceLog) 120 { 121 InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId); 122 if (!module.hasNoValue()) 123 module.traceLog(errorString, traceLogId, &traceLog); 124 } 125 126 void InspectorWebGLAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result) 127 { 128 InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId); 129 if (!module.hasNoValue()) 130 module.replayTraceLog(errorString, traceLogId, stepNo, result); 131 } 132 98 133 ScriptObject InspectorWebGLAgent::wrapWebGLRenderingContextForInstrumentation(const ScriptObject& glContext) 99 134 { … … 110 145 } 111 146 147 InjectedScriptWebGLModule InspectorWebGLAgent::injectedScriptWebGLModuleForTraceLogId(ErrorString* errorString, const String& traceLogId) 148 { 149 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(traceLogId); 150 if (injectedScript.hasNoValue()) { 151 *errorString = "Inspected frame has gone"; 152 return InjectedScriptWebGLModule(); 153 } 154 InjectedScriptWebGLModule module = InjectedScriptWebGLModule::moduleForState(m_injectedScriptManager, injectedScript.scriptState()); 155 if (module.hasNoValue()) { 156 ASSERT_NOT_REACHED(); 157 *errorString = "Internal error: no WebGL module"; 158 return InjectedScriptWebGLModule(); 159 } 160 return module; 161 } 162 112 163 } // namespace WebCore 113 164 -
trunk/Source/WebCore/inspector/InspectorWebGLAgent.h
r126140 r126280 36 36 #include "InspectorBaseAgent.h" 37 37 #include "InspectorFrontend.h" 38 #include "InspectorTypeBuilder.h" 38 39 #include "PlatformString.h" 39 40 #include "ScriptState.h" … … 44 45 45 46 class InjectedScriptManager; 47 class InjectedScriptWebGLModule; 46 48 class InspectorState; 47 49 class InstrumentingAgents; 50 class Page; 48 51 class ScriptObject; 49 52 … … 52 55 class InspectorWebGLAgent : public InspectorBaseAgent<InspectorWebGLAgent>, public InspectorBackendDispatcher::WebGLCommandHandler { 53 56 public: 54 static PassOwnPtr<InspectorWebGLAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)57 static PassOwnPtr<InspectorWebGLAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InjectedScriptManager* injectedScriptManager) 55 58 { 56 return adoptPtr(new InspectorWebGLAgent(instrumentingAgents, state, injectedScriptManager));59 return adoptPtr(new InspectorWebGLAgent(instrumentingAgents, state, page, injectedScriptManager)); 57 60 } 58 61 ~InspectorWebGLAgent(); … … 69 72 virtual void enable(ErrorString*); 70 73 virtual void disable(ErrorString*); 74 virtual void dropTraceLog(ErrorString*, const String&); 75 virtual void captureFrame(ErrorString*, String*); 76 virtual void getTraceLog(ErrorString*, const String&, RefPtr<TypeBuilder::WebGL::TraceLog>&); 77 virtual void replayTraceLog(ErrorString*, const String&, int, String*); 71 78 72 79 // Called from the injected script. … … 75 82 76 83 private: 77 InspectorWebGLAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);84 InspectorWebGLAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*); 78 85 86 InjectedScriptWebGLModule injectedScriptWebGLModuleForTraceLogId(ErrorString*, const String&); 87 88 Page* m_inspectedPage; 79 89 InjectedScriptManager* m_injectedScriptManager; 80 90 InspectorFrontend::WebGL* m_frontend;
Note: See TracChangeset
for help on using the changeset viewer.