Diff
Modified: trunk/LayoutTests/ChangeLog (141097 => 141098)
--- trunk/LayoutTests/ChangeLog 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/LayoutTests/ChangeLog 2013-01-29 12:43:45 UTC (rev 141098)
@@ -1,3 +1,15 @@
+2013-01-29 Andrey Adaikin <[email protected]>
+
+ Web Inspector: [Canvas] support instrumenting canvases in iframes (backend side)
+ https://bugs.webkit.org/show_bug.cgi?id=107951
+
+ Reviewed by Pavel Feldman.
+
+ Stub Canvas dispatcher for now to silence alerts in tests.
+
+ * inspector/profiler/canvas-profiler-test.js:
+ (initialize_CanvasWebGLProfilerTest.InspectorTest.enableCanvasAgent.InspectorBackend.registerCanvasDispatcher):
+
2013-01-29 Eugene Klyuchnikov <[email protected]>
Web Inspector: [CPU Profile] Taking profile crashes renderer.
Modified: trunk/LayoutTests/inspector/profiler/canvas-profiler-test.js (141097 => 141098)
--- trunk/LayoutTests/inspector/profiler/canvas-profiler-test.js 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/LayoutTests/inspector/profiler/canvas-profiler-test.js 2013-01-29 12:43:45 UTC (rev 141098)
@@ -2,6 +2,13 @@
InspectorTest.enableCanvasAgent = function(callback)
{
+ var dispatcher = InspectorBackend._domainDispatchers["Canvas"];
+ if (!dispatcher) {
+ InspectorBackend.registerCanvasDispatcher({
+ contextCreated: function() {}
+ });
+ }
+
function canvasAgentEnabled(error)
{
if (!error)
Modified: trunk/Source/WebCore/ChangeLog (141097 => 141098)
--- trunk/Source/WebCore/ChangeLog 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/Source/WebCore/ChangeLog 2013-01-29 12:43:45 UTC (rev 141098)
@@ -1,3 +1,41 @@
+2013-01-29 Andrey Adaikin <[email protected]>
+
+ Web Inspector: [Canvas] support instrumenting canvases in iframes (backend side)
+ https://bugs.webkit.org/show_bug.cgi?id=107951
+
+ Reviewed by Pavel Feldman.
+
+ Accept optional FrameId argument for captureFrame and startCapturing commands.
+ Add event to the protocol to inform about instrumented canvas context creation.
+
+ * inspector/Inspector.json:
+ * inspector/InspectorCanvasAgent.cpp:
+ (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
+ (WebCore::InspectorCanvasAgent::hasUninstrumentedCanvases):
+ (WebCore::InspectorCanvasAgent::captureFrame):
+ (WebCore::InspectorCanvasAgent::startCapturing):
+ (WebCore::InspectorCanvasAgent::getTraceLog):
+ (WebCore::InspectorCanvasAgent::replayTraceLog):
+ (WebCore::InspectorCanvasAgent::getResourceInfo):
+ (WebCore::InspectorCanvasAgent::getResourceState):
+ (WebCore::InspectorCanvasAgent::wrapCanvas2DRenderingContextForInstrumentation):
+ (WebCore::InspectorCanvasAgent::wrapWebGLRenderingContextForInstrumentation):
+ (WebCore::InspectorCanvasAgent::notifyRenderingContextWasWrapped):
+ (WebCore):
+ (WebCore::InspectorCanvasAgent::findFramesWithUninstrumentedCanvases):
+ (WebCore::InspectorCanvasAgent::frameNavigated):
+ (WebCore::InspectorCanvasAgent::frameDetached):
+ * inspector/InspectorCanvasAgent.h:
+ (WebCore):
+ (WebCore::InspectorCanvasAgent::create):
+ (InspectorCanvasAgent):
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore):
+ (WebCore::InspectorInstrumentation::frameDetachedFromParentImpl):
+ (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+
2013-01-29 Eugene Klyuchnikov <[email protected]>
Web Inspector: [CPU Profile] Taking profile crashes renderer.
Modified: trunk/Source/WebCore/inspector/Inspector.json (141097 => 141098)
--- trunk/Source/WebCore/inspector/Inspector.json 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/Source/WebCore/inspector/Inspector.json 2013-01-29 12:43:45 UTC (rev 141098)
@@ -3328,15 +3328,23 @@
},
{
"name": "captureFrame",
+ "parameters": [
+ { "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." }
+ ],
"returns": [
- { "name": "traceLogId", "$ref": "TraceLogId" }
- ]
+ { "name": "traceLogId", "$ref": "TraceLogId", "description": "Identifier of the trace log containing captured canvas calls." }
+ ],
+ "description": "Starts (or continues) a canvas frame capturing which will be stopped automatically after the next frame is prepared."
},
{
"name": "startCapturing",
+ "parameters": [
+ { "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." }
+ ],
"returns": [
- { "name": "traceLogId", "$ref": "TraceLogId" }
- ]
+ { "name": "traceLogId", "$ref": "TraceLogId", "description": "Identifier of the trace log containing captured canvas calls." }
+ ],
+ "description": "Starts (or continues) consecutive canvas frames capturing. The capturing is stopped by the corresponding stopCapturing command."
},
{
"name": "stopCapturing",
@@ -3385,7 +3393,15 @@
]
}
],
- "events": []
+ "events": [
+ {
+ "name": "contextCreated",
+ "parameters": [
+ { "name": "frameId", "$ref": "Network.FrameId", "description": "Identifier of the frame containing a canvas with a context." }
+ ],
+ "description": "Fired when a canvas context has been created in the given frame. The context may not be instrumented (see hasUninstrumentedCanvases command)."
+ }
+ ]
},
{
"domain": "Input",
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp (141097 => 141098)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2013-01-29 12:43:45 UTC (rev 141098)
@@ -35,6 +35,7 @@
#include "InspectorCanvasAgent.h"
#include "BindingVisitors.h"
+#include "DOMWindow.h"
#include "Frame.h"
#include "HTMLCanvasElement.h"
#include "HTMLNames.h"
@@ -42,6 +43,7 @@
#include "InjectedScriptCanvasModule.h"
#include "InjectedScriptManager.h"
#include "InspectorFrontend.h"
+#include "InspectorPageAgent.h"
#include "InspectorState.h"
#include "InstrumentingAgents.h"
#include "Page.h"
@@ -49,15 +51,21 @@
#include "ScriptProfiler.h"
#include "ScriptState.h"
+using WebCore::TypeBuilder::Canvas::ResourceInfo;
+using WebCore::TypeBuilder::Canvas::ResourceState;
+using WebCore::TypeBuilder::Canvas::TraceLog;
+using WebCore::TypeBuilder::Canvas::TraceLogId;
+using WebCore::TypeBuilder::Network::FrameId;
+
namespace WebCore {
namespace CanvasAgentState {
static const char canvasAgentEnabled[] = "canvasAgentEnabled";
};
-InspectorCanvasAgent::InspectorCanvasAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, Page* page, InjectedScriptManager* injectedScriptManager)
+InspectorCanvasAgent::InspectorCanvasAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager)
: InspectorBaseAgent<InspectorCanvasAgent>("Canvas", instrumentingAgents, state)
- , m_inspectedPage(page)
+ , m_pageAgent(pageAgent)
, m_injectedScriptManager(injectedScriptManager)
, m_frontend(0)
, m_enabled(false)
@@ -117,19 +125,25 @@
{
if (!checkIsEnabled(errorString))
return;
- *result = m_framesWithUninstrumentedCanvases.contains(m_inspectedPage->mainFrame());
+ *result = !m_framesWithUninstrumentedCanvases.isEmpty();
}
-void InspectorCanvasAgent::captureFrame(ErrorString* errorString, String* traceLogId)
+void InspectorCanvasAgent::captureFrame(ErrorString* errorString, const FrameId* frameId, TraceLogId* traceLogId)
{
- InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(m_inspectedPage->mainFrame()));
+ Frame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId) : m_pageAgent->mainFrame();
+ if (!frame)
+ return;
+ InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(frame));
if (!module.hasNoValue())
module.captureFrame(errorString, traceLogId);
}
-void InspectorCanvasAgent::startCapturing(ErrorString* errorString, String* traceLogId)
+void InspectorCanvasAgent::startCapturing(ErrorString* errorString, const FrameId* frameId, TraceLogId* traceLogId)
{
- InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(m_inspectedPage->mainFrame()));
+ Frame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId) : m_pageAgent->mainFrame();
+ if (!frame)
+ return;
+ InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, mainWorldScriptState(frame));
if (!module.hasNoValue())
module.startCapturing(errorString, traceLogId);
}
@@ -141,28 +155,28 @@
module.stopCapturing(errorString, traceLogId);
}
-void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TypeBuilder::Canvas::TraceLog>& traceLog)
+void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TraceLog>& traceLog)
{
InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
if (!module.hasNoValue())
module.traceLog(errorString, traceLogId, startOffset, maxLength, &traceLog);
}
-void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr<TypeBuilder::Canvas::ResourceState>& result)
+void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr<ResourceState>& result)
{
InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
if (!module.hasNoValue())
module.replayTraceLog(errorString, traceLogId, stepNo, &result);
}
-void InspectorCanvasAgent::getResourceInfo(ErrorString* errorString, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceInfo>& result)
+void InspectorCanvasAgent::getResourceInfo(ErrorString* errorString, const String& resourceId, RefPtr<ResourceInfo>& result)
{
InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, resourceId);
if (!module.hasNoValue())
module.resourceInfo(errorString, resourceId, &result);
}
-void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceState>& result)
+void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr<ResourceState>& result)
{
InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
if (!module.hasNoValue())
@@ -175,7 +189,7 @@
InjectedScriptCanvasModule module = injectedScriptCanvasModule(&error, context);
if (module.hasNoValue())
return ScriptObject();
- return module.wrapCanvas2DContext(context);
+ return notifyRenderingContextWasWrapped(module.wrapCanvas2DContext(context));
}
#if ENABLE(WEBGL)
@@ -185,10 +199,22 @@
InjectedScriptCanvasModule module = injectedScriptCanvasModule(&error, glContext);
if (module.hasNoValue())
return ScriptObject();
- return module.wrapWebGLContext(glContext);
+ return notifyRenderingContextWasWrapped(module.wrapWebGLContext(glContext));
}
#endif
+ScriptObject InspectorCanvasAgent::notifyRenderingContextWasWrapped(const ScriptObject& wrappedContext)
+{
+ ASSERT(m_frontend);
+ ScriptState* scriptState = wrappedContext.scriptState();
+ DOMWindow* domWindow = scriptState ? domWindowFromScriptState(scriptState) : 0;
+ Frame* frame = domWindow ? domWindow->frame() : 0;
+ String frameId = m_pageAgent->frameId(frame);
+ if (!frameId.isEmpty())
+ m_frontend->contextCreated(frameId);
+ return wrappedContext;
+}
+
InjectedScriptCanvasModule InspectorCanvasAgent::injectedScriptCanvasModule(ErrorString* errorString, ScriptState* scriptState)
{
if (!checkIsEnabled(errorString))
@@ -252,9 +278,16 @@
private:
Page* m_page;
HashSet<Frame*>& m_framesWithUninstrumentedCanvases;
- } nodeVisitor(m_inspectedPage, m_framesWithUninstrumentedCanvases);
+ } nodeVisitor(m_pageAgent->page(), m_framesWithUninstrumentedCanvases);
+ m_framesWithUninstrumentedCanvases.clear();
ScriptProfiler::visitNodeWrappers(&nodeVisitor);
+
+ for (HashSet<Frame*>::iterator it = m_framesWithUninstrumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it) {
+ String frameId = m_pageAgent->frameId(*it);
+ if (!frameId.isEmpty())
+ m_frontend->contextCreated(frameId);
+ }
}
bool InspectorCanvasAgent::checkIsEnabled(ErrorString* errorString) const
@@ -265,11 +298,24 @@
return false;
}
-void InspectorCanvasAgent::reset()
+void InspectorCanvasAgent::frameNavigated(Frame* frame)
{
- m_framesWithUninstrumentedCanvases.clear();
+ if (!m_enabled)
+ return;
+ if (frame == m_pageAgent->mainFrame())
+ m_framesWithUninstrumentedCanvases.clear();
+ else {
+ while (frame) {
+ m_framesWithUninstrumentedCanvases.remove(frame);
+ frame = frame->tree()->traverseNext();
+ }
+ }
+}
+
+void InspectorCanvasAgent::frameDetached(Frame* frame)
+{
if (m_enabled)
- findFramesWithUninstrumentedCanvases();
+ m_framesWithUninstrumentedCanvases.remove(frame);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.h (141097 => 141098)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2013-01-29 12:43:45 UTC (rev 141098)
@@ -47,18 +47,18 @@
class Frame;
class InjectedScriptCanvasModule;
class InjectedScriptManager;
+class InspectorPageAgent;
class InspectorState;
class InstrumentingAgents;
-class Page;
class ScriptObject;
typedef String ErrorString;
class InspectorCanvasAgent : public InspectorBaseAgent<InspectorCanvasAgent>, public InspectorBackendDispatcher::CanvasCommandHandler {
public:
- static PassOwnPtr<InspectorCanvasAgent> create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, Page* page, InjectedScriptManager* injectedScriptManager)
+ static PassOwnPtr<InspectorCanvasAgent> create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager)
{
- return adoptPtr(new InspectorCanvasAgent(instrumentingAgents, state, page, injectedScriptManager));
+ return adoptPtr(new InspectorCanvasAgent(instrumentingAgents, state, pageAgent, injectedScriptManager));
}
~InspectorCanvasAgent();
@@ -67,7 +67,8 @@
virtual void restore();
// Called from InspectorInstrumentation
- void reset();
+ void frameNavigated(Frame*);
+ void frameDetached(Frame*);
// Called from InspectorCanvasInstrumentation
ScriptObject wrapCanvas2DRenderingContextForInstrumentation(const ScriptObject&);
@@ -80,8 +81,8 @@
virtual void disable(ErrorString*);
virtual void dropTraceLog(ErrorString*, const String&);
virtual void hasUninstrumentedCanvases(ErrorString*, bool*);
- virtual void captureFrame(ErrorString*, String*);
- virtual void startCapturing(ErrorString*, String*);
+ virtual void captureFrame(ErrorString*, const TypeBuilder::Network::FrameId*, TypeBuilder::Canvas::TraceLogId*);
+ virtual void startCapturing(ErrorString*, const TypeBuilder::Network::FrameId*, TypeBuilder::Canvas::TraceLogId*);
virtual void stopCapturing(ErrorString*, const String&);
virtual void getTraceLog(ErrorString*, const String&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&);
virtual void replayTraceLog(ErrorString*, const String&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&);
@@ -89,7 +90,7 @@
virtual void getResourceState(ErrorString*, const String&, const String&, RefPtr<TypeBuilder::Canvas::ResourceState>&);
private:
- InspectorCanvasAgent(InstrumentingAgents*, InspectorCompositeState*, Page*, InjectedScriptManager*);
+ InspectorCanvasAgent(InstrumentingAgents*, InspectorCompositeState*, InspectorPageAgent*, InjectedScriptManager*);
InjectedScriptCanvasModule injectedScriptCanvasModule(ErrorString*, ScriptState*);
InjectedScriptCanvasModule injectedScriptCanvasModule(ErrorString*, const ScriptObject&);
@@ -97,8 +98,9 @@
void findFramesWithUninstrumentedCanvases();
bool checkIsEnabled(ErrorString*) const;
+ ScriptObject notifyRenderingContextWasWrapped(const ScriptObject&);
- Page* m_inspectedPage;
+ InspectorPageAgent* m_pageAgent;
InjectedScriptManager* m_injectedScriptManager;
InspectorFrontend::Canvas* m_frontend;
bool m_enabled;
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (141097 => 141098)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2013-01-29 12:43:45 UTC (rev 141098)
@@ -158,7 +158,7 @@
m_agents.append(InspectorWorkerAgent::create(m_instrumentingAgents.get(), m_state.get()));
#endif
- m_agents.append(InspectorCanvasAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()));
+ m_agents.append(InspectorCanvasAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent, m_injectedScriptManager.get()));
m_agents.append(InspectorInputAgent::create(m_instrumentingAgents.get(), m_state.get(), page));
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (141097 => 141098)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2013-01-29 12:34:41 UTC (rev 141097)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2013-01-29 12:43:45 UTC (rev 141098)
@@ -902,6 +902,8 @@
void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
{
+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
+ canvasAgent->frameDetached(frame);
if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
pageAgent->frameDetached(frame);
}
@@ -937,10 +939,10 @@
if (InspectorLayerTreeAgent* layerTreeAgent = instrumentingAgents->inspectorLayerTreeAgent())
layerTreeAgent->reset();
#endif
- if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
- canvasAgent->reset();
inspectorAgent->didCommitLoad();
}
+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
+ canvasAgent->frameNavigated(loader->frame());
if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
pageAgent->frameNavigated(loader);
}