Changeset 141098 in webkit
- Timestamp:
- Jan 29, 2013 4:43:45 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141094 r141098 1 2013-01-29 Andrey Adaikin <aandrey@chromium.org> 2 3 Web Inspector: [Canvas] support instrumenting canvases in iframes (backend side) 4 https://bugs.webkit.org/show_bug.cgi?id=107951 5 6 Reviewed by Pavel Feldman. 7 8 Stub Canvas dispatcher for now to silence alerts in tests. 9 10 * inspector/profiler/canvas-profiler-test.js: 11 (initialize_CanvasWebGLProfilerTest.InspectorTest.enableCanvasAgent.InspectorBackend.registerCanvasDispatcher): 12 1 13 2013-01-29 Eugene Klyuchnikov <eustas@chromium.org> 2 14 -
trunk/LayoutTests/inspector/profiler/canvas-profiler-test.js
r140679 r141098 3 3 InspectorTest.enableCanvasAgent = function(callback) 4 4 { 5 var dispatcher = InspectorBackend._domainDispatchers["Canvas"]; 6 if (!dispatcher) { 7 InspectorBackend.registerCanvasDispatcher({ 8 contextCreated: function() {} 9 }); 10 } 11 5 12 function canvasAgentEnabled(error) 6 13 { -
trunk/Source/WebCore/ChangeLog
r141094 r141098 1 2013-01-29 Andrey Adaikin <aandrey@chromium.org> 2 3 Web Inspector: [Canvas] support instrumenting canvases in iframes (backend side) 4 https://bugs.webkit.org/show_bug.cgi?id=107951 5 6 Reviewed by Pavel Feldman. 7 8 Accept optional FrameId argument for captureFrame and startCapturing commands. 9 Add event to the protocol to inform about instrumented canvas context creation. 10 11 * inspector/Inspector.json: 12 * inspector/InspectorCanvasAgent.cpp: 13 (WebCore::InspectorCanvasAgent::InspectorCanvasAgent): 14 (WebCore::InspectorCanvasAgent::hasUninstrumentedCanvases): 15 (WebCore::InspectorCanvasAgent::captureFrame): 16 (WebCore::InspectorCanvasAgent::startCapturing): 17 (WebCore::InspectorCanvasAgent::getTraceLog): 18 (WebCore::InspectorCanvasAgent::replayTraceLog): 19 (WebCore::InspectorCanvasAgent::getResourceInfo): 20 (WebCore::InspectorCanvasAgent::getResourceState): 21 (WebCore::InspectorCanvasAgent::wrapCanvas2DRenderingContextForInstrumentation): 22 (WebCore::InspectorCanvasAgent::wrapWebGLRenderingContextForInstrumentation): 23 (WebCore::InspectorCanvasAgent::notifyRenderingContextWasWrapped): 24 (WebCore): 25 (WebCore::InspectorCanvasAgent::findFramesWithUninstrumentedCanvases): 26 (WebCore::InspectorCanvasAgent::frameNavigated): 27 (WebCore::InspectorCanvasAgent::frameDetached): 28 * inspector/InspectorCanvasAgent.h: 29 (WebCore): 30 (WebCore::InspectorCanvasAgent::create): 31 (InspectorCanvasAgent): 32 * inspector/InspectorController.cpp: 33 (WebCore::InspectorController::InspectorController): 34 * inspector/InspectorInstrumentation.cpp: 35 (WebCore): 36 (WebCore::InspectorInstrumentation::frameDetachedFromParentImpl): 37 (WebCore::InspectorInstrumentation::didCommitLoadImpl): 38 1 39 2013-01-29 Eugene Klyuchnikov <eustas@chromium.org> 2 40 -
trunk/Source/WebCore/inspector/Inspector.json
r140818 r141098 3329 3329 { 3330 3330 "name": "captureFrame", 3331 "returns": [ 3332 { "name": "traceLogId", "$ref": "TraceLogId" } 3333 ] 3331 "parameters": [ 3332 { "name": "frameId", "$ref": "Network.FrameId", "optional": true, "description": "Identifier of the frame containing document whose canvases are to be captured. If omitted, main frame is assumed." } 3333 ], 3334 "returns": [ 3335 { "name": "traceLogId", "$ref": "TraceLogId", "description": "Identifier of the trace log containing captured canvas calls." } 3336 ], 3337 "description": "Starts (or continues) a canvas frame capturing which will be stopped automatically after the next frame is prepared." 3334 3338 }, 3335 3339 { 3336 3340 "name": "startCapturing", 3337 "returns": [ 3338 { "name": "traceLogId", "$ref": "TraceLogId" } 3339 ] 3341 "parameters": [ 3342 { "name": "frameId", "$ref": "Network.FrameId", "optional": true, "description": "Identifier of the frame containing document whose canvases are to be captured. If omitted, main frame is assumed." } 3343 ], 3344 "returns": [ 3345 { "name": "traceLogId", "$ref": "TraceLogId", "description": "Identifier of the trace log containing captured canvas calls." } 3346 ], 3347 "description": "Starts (or continues) consecutive canvas frames capturing. The capturing is stopped by the corresponding stopCapturing command." 3340 3348 }, 3341 3349 { … … 3386 3394 } 3387 3395 ], 3388 "events": [] 3396 "events": [ 3397 { 3398 "name": "contextCreated", 3399 "parameters": [ 3400 { "name": "frameId", "$ref": "Network.FrameId", "description": "Identifier of the frame containing a canvas with a context." } 3401 ], 3402 "description": "Fired when a canvas context has been created in the given frame. The context may not be instrumented (see hasUninstrumentedCanvases command)." 3403 } 3404 ] 3389 3405 }, 3390 3406 { -
trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp
r140963 r141098 36 36 37 37 #include "BindingVisitors.h" 38 #include "DOMWindow.h" 38 39 #include "Frame.h" 39 40 #include "HTMLCanvasElement.h" … … 43 44 #include "InjectedScriptManager.h" 44 45 #include "InspectorFrontend.h" 46 #include "InspectorPageAgent.h" 45 47 #include "InspectorState.h" 46 48 #include "InstrumentingAgents.h" … … 50 52 #include "ScriptState.h" 51 53 54 using WebCore::TypeBuilder::Canvas::ResourceInfo; 55 using WebCore::TypeBuilder::Canvas::ResourceState; 56 using WebCore::TypeBuilder::Canvas::TraceLog; 57 using WebCore::TypeBuilder::Canvas::TraceLogId; 58 using WebCore::TypeBuilder::Network::FrameId; 59 52 60 namespace WebCore { 53 61 … … 56 64 }; 57 65 58 InspectorCanvasAgent::InspectorCanvasAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, Page* page, InjectedScriptManager* injectedScriptManager)66 InspectorCanvasAgent::InspectorCanvasAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager) 59 67 : InspectorBaseAgent<InspectorCanvasAgent>("Canvas", instrumentingAgents, state) 60 , m_ inspectedPage(page)68 , m_pageAgent(pageAgent) 61 69 , m_injectedScriptManager(injectedScriptManager) 62 70 , m_frontend(0) … … 118 126 if (!checkIsEnabled(errorString)) 119 127 return; 120 *result = m_framesWithUninstrumentedCanvases.contains(m_inspectedPage->mainFrame()); 121 } 122 123 void InspectorCanvasAgent::captureFrame(ErrorString* errorString, String* traceLogId) 124 { 125 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(m_inspectedPage->mainFrame())); 128 *result = !m_framesWithUninstrumentedCanvases.isEmpty(); 129 } 130 131 void InspectorCanvasAgent::captureFrame(ErrorString* errorString, const FrameId* frameId, TraceLogId* traceLogId) 132 { 133 Frame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId) : m_pageAgent->mainFrame(); 134 if (!frame) 135 return; 136 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(frame)); 126 137 if (!module.hasNoValue()) 127 138 module.captureFrame(errorString, traceLogId); 128 139 } 129 140 130 void InspectorCanvasAgent::startCapturing(ErrorString* errorString, String* traceLogId) 131 { 132 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(m_inspectedPage->mainFrame())); 141 void InspectorCanvasAgent::startCapturing(ErrorString* errorString, const FrameId* frameId, TraceLogId* traceLogId) 142 { 143 Frame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId) : m_pageAgent->mainFrame(); 144 if (!frame) 145 return; 146 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(frame)); 133 147 if (!module.hasNoValue()) 134 148 module.startCapturing(errorString, traceLogId); … … 142 156 } 143 157 144 void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, const int* maxLength, RefPtr<T ypeBuilder::Canvas::TraceLog>& traceLog)158 void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TraceLog>& traceLog) 145 159 { 146 160 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId); … … 149 163 } 150 164 151 void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr< TypeBuilder::Canvas::ResourceState>& result)165 void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr<ResourceState>& result) 152 166 { 153 167 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId); … … 156 170 } 157 171 158 void InspectorCanvasAgent::getResourceInfo(ErrorString* errorString, const String& resourceId, RefPtr< TypeBuilder::Canvas::ResourceInfo>& result)172 void InspectorCanvasAgent::getResourceInfo(ErrorString* errorString, const String& resourceId, RefPtr<ResourceInfo>& result) 159 173 { 160 174 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, resourceId); … … 163 177 } 164 178 165 void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr< TypeBuilder::Canvas::ResourceState>& result)179 void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr<ResourceState>& result) 166 180 { 167 181 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId); … … 176 190 if (module.hasNoValue()) 177 191 return ScriptObject(); 178 return module.wrapCanvas2DContext(context);192 return notifyRenderingContextWasWrapped(module.wrapCanvas2DContext(context)); 179 193 } 180 194 … … 186 200 if (module.hasNoValue()) 187 201 return ScriptObject(); 188 return module.wrapWebGLContext(glContext);202 return notifyRenderingContextWasWrapped(module.wrapWebGLContext(glContext)); 189 203 } 190 204 #endif 205 206 ScriptObject InspectorCanvasAgent::notifyRenderingContextWasWrapped(const ScriptObject& wrappedContext) 207 { 208 ASSERT(m_frontend); 209 ScriptState* scriptState = wrappedContext.scriptState(); 210 DOMWindow* domWindow = scriptState ? domWindowFromScriptState(scriptState) : 0; 211 Frame* frame = domWindow ? domWindow->frame() : 0; 212 String frameId = m_pageAgent->frameId(frame); 213 if (!frameId.isEmpty()) 214 m_frontend->contextCreated(frameId); 215 return wrappedContext; 216 } 191 217 192 218 InjectedScriptCanvasModule InspectorCanvasAgent::injectedScriptCanvasModule(ErrorString* errorString, ScriptState* scriptState) … … 253 279 Page* m_page; 254 280 HashSet<Frame*>& m_framesWithUninstrumentedCanvases; 255 } nodeVisitor(m_inspectedPage, m_framesWithUninstrumentedCanvases); 256 281 } nodeVisitor(m_pageAgent->page(), m_framesWithUninstrumentedCanvases); 282 283 m_framesWithUninstrumentedCanvases.clear(); 257 284 ScriptProfiler::visitNodeWrappers(&nodeVisitor); 285 286 for (HashSet<Frame*>::iterator it = m_framesWithUninstrumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it) { 287 String frameId = m_pageAgent->frameId(*it); 288 if (!frameId.isEmpty()) 289 m_frontend->contextCreated(frameId); 290 } 258 291 } 259 292 … … 266 299 } 267 300 268 void InspectorCanvasAgent::reset() 269 { 270 m_framesWithUninstrumentedCanvases.clear(); 301 void InspectorCanvasAgent::frameNavigated(Frame* frame) 302 { 303 if (!m_enabled) 304 return; 305 if (frame == m_pageAgent->mainFrame()) 306 m_framesWithUninstrumentedCanvases.clear(); 307 else { 308 while (frame) { 309 m_framesWithUninstrumentedCanvases.remove(frame); 310 frame = frame->tree()->traverseNext(); 311 } 312 } 313 } 314 315 void InspectorCanvasAgent::frameDetached(Frame* frame) 316 { 271 317 if (m_enabled) 272 findFramesWithUninstrumentedCanvases();318 m_framesWithUninstrumentedCanvases.remove(frame); 273 319 } 274 320 -
trunk/Source/WebCore/inspector/InspectorCanvasAgent.h
r140963 r141098 48 48 class InjectedScriptCanvasModule; 49 49 class InjectedScriptManager; 50 class InspectorPageAgent; 50 51 class InspectorState; 51 52 class InstrumentingAgents; 52 class Page;53 53 class ScriptObject; 54 54 … … 57 57 class InspectorCanvasAgent : public InspectorBaseAgent<InspectorCanvasAgent>, public InspectorBackendDispatcher::CanvasCommandHandler { 58 58 public: 59 static PassOwnPtr<InspectorCanvasAgent> create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, Page* page, InjectedScriptManager* injectedScriptManager)59 static PassOwnPtr<InspectorCanvasAgent> create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager) 60 60 { 61 return adoptPtr(new InspectorCanvasAgent(instrumentingAgents, state, page , injectedScriptManager));61 return adoptPtr(new InspectorCanvasAgent(instrumentingAgents, state, pageAgent, injectedScriptManager)); 62 62 } 63 63 ~InspectorCanvasAgent(); … … 68 68 69 69 // Called from InspectorInstrumentation 70 void reset(); 70 void frameNavigated(Frame*); 71 void frameDetached(Frame*); 71 72 72 73 // Called from InspectorCanvasInstrumentation … … 81 82 virtual void dropTraceLog(ErrorString*, const String&); 82 83 virtual void hasUninstrumentedCanvases(ErrorString*, bool*); 83 virtual void captureFrame(ErrorString*, String*);84 virtual void startCapturing(ErrorString*, String*);84 virtual void captureFrame(ErrorString*, const TypeBuilder::Network::FrameId*, TypeBuilder::Canvas::TraceLogId*); 85 virtual void startCapturing(ErrorString*, const TypeBuilder::Network::FrameId*, TypeBuilder::Canvas::TraceLogId*); 85 86 virtual void stopCapturing(ErrorString*, const String&); 86 87 virtual void getTraceLog(ErrorString*, const String&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&); … … 90 91 91 92 private: 92 InspectorCanvasAgent(InstrumentingAgents*, InspectorCompositeState*, Page*, InjectedScriptManager*);93 InspectorCanvasAgent(InstrumentingAgents*, InspectorCompositeState*, InspectorPageAgent*, InjectedScriptManager*); 93 94 94 95 InjectedScriptCanvasModule injectedScriptCanvasModule(ErrorString*, ScriptState*); … … 98 99 void findFramesWithUninstrumentedCanvases(); 99 100 bool checkIsEnabled(ErrorString*) const; 101 ScriptObject notifyRenderingContextWasWrapped(const ScriptObject&); 100 102 101 Page* m_inspectedPage;103 InspectorPageAgent* m_pageAgent; 102 104 InjectedScriptManager* m_injectedScriptManager; 103 105 InspectorFrontend::Canvas* m_frontend; -
trunk/Source/WebCore/inspector/InspectorController.cpp
r140823 r141098 159 159 #endif 160 160 161 m_agents.append(InspectorCanvasAgent::create(m_instrumentingAgents.get(), m_state.get(), page , m_injectedScriptManager.get()));161 m_agents.append(InspectorCanvasAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent, m_injectedScriptManager.get())); 162 162 163 163 m_agents.append(InspectorInputAgent::create(m_instrumentingAgents.get(), m_state.get(), page)); -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r140649 r141098 903 903 void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents* instrumentingAgents, Frame* frame) 904 904 { 905 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) 906 canvasAgent->frameDetached(frame); 905 907 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent()) 906 908 pageAgent->frameDetached(frame); … … 938 940 layerTreeAgent->reset(); 939 941 #endif 940 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())941 canvasAgent->reset();942 942 inspectorAgent->didCommitLoad(); 943 943 } 944 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) 945 canvasAgent->frameNavigated(loader->frame()); 944 946 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent()) 945 947 pageAgent->frameNavigated(loader);
Note: See TracChangeset
for help on using the changeset viewer.