Web Inspector: [Canvas] set CanvasAgent in InstrumentingAgents upon calling enable...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2012 15:47:15 +0000 (15:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2012 15:47:15 +0000 (15:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97331

Patch by Andrey Adaikin <aandrey@chromium.org> on 2012-09-24
Reviewed by Yury Semikhatsky.

We should set CanvasAgent in InstrumentingAgents from enable() command and remove from disable(), instead of doing this in constructor and destructor.

* inspector/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
(WebCore::InspectorCanvasAgent::~InspectorCanvasAgent):
(WebCore::InspectorCanvasAgent::restore):
(WebCore::InspectorCanvasAgent::enable):
(WebCore::InspectorCanvasAgent::disable):
* inspector/InspectorCanvasAgent.h:
(InspectorCanvasAgent):
* inspector/InspectorCanvasInstrumentation.h:
(WebCore::InspectorInstrumentation::wrapCanvas2DRenderingContextForInstrumentation):
(WebCore::InspectorInstrumentation::wrapWebGLRenderingContextForInstrumentation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129374 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorCanvasAgent.cpp
Source/WebCore/inspector/InspectorCanvasAgent.h
Source/WebCore/inspector/InspectorCanvasInstrumentation.h

index 8fcd520..dc1a34b 100644 (file)
@@ -1,3 +1,24 @@
+2012-09-24  Andrey Adaikin  <aandrey@chromium.org>
+
+        Web Inspector: [Canvas] set CanvasAgent in InstrumentingAgents upon calling enable command
+        https://bugs.webkit.org/show_bug.cgi?id=97331
+
+        Reviewed by Yury Semikhatsky.
+
+        We should set CanvasAgent in InstrumentingAgents from enable() command and remove from disable(), instead of doing this in constructor and destructor.
+
+        * inspector/InspectorCanvasAgent.cpp:
+        (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
+        (WebCore::InspectorCanvasAgent::~InspectorCanvasAgent):
+        (WebCore::InspectorCanvasAgent::restore):
+        (WebCore::InspectorCanvasAgent::enable):
+        (WebCore::InspectorCanvasAgent::disable):
+        * inspector/InspectorCanvasAgent.h:
+        (InspectorCanvasAgent):
+        * inspector/InspectorCanvasInstrumentation.h:
+        (WebCore::InspectorInstrumentation::wrapCanvas2DRenderingContextForInstrumentation):
+        (WebCore::InspectorInstrumentation::wrapWebGLRenderingContextForInstrumentation):
+
 2012-09-24  Patrick Gansterer  <paroga@webkit.org>
 
         Remove remaining WTF_DEPRECATED_STRING_OPERATORS from cpp files
index 5e3ffcb..10bef0c 100644 (file)
@@ -55,14 +55,11 @@ InspectorCanvasAgent::InspectorCanvasAgent(InstrumentingAgents* instrumentingAge
     , m_inspectedPage(page)
     , m_injectedScriptManager(injectedScriptManager)
     , m_frontend(0)
-    , m_enabled(false)
 {
-    m_instrumentingAgents->setInspectorCanvasAgent(this);
 }
 
 InspectorCanvasAgent::~InspectorCanvasAgent()
 {
-    m_instrumentingAgents->setInspectorCanvasAgent(0);
 }
 
 void InspectorCanvasAgent::setFrontend(InspectorFrontend* frontend)
@@ -79,23 +76,22 @@ void InspectorCanvasAgent::clearFrontend()
 
 void InspectorCanvasAgent::restore()
 {
-    m_enabled = m_state->getBoolean(CanvasAgentState::canvasAgentEnabled);
+    if (m_state->getBoolean(CanvasAgentState::canvasAgentEnabled)) {
+        ErrorString error;
+        enable(&error);
+    }
 }
 
 void InspectorCanvasAgent::enable(ErrorString*)
 {
-    if (m_enabled)
-        return;
-    m_enabled = true;
-    m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, m_enabled);
+    m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, true);
+    m_instrumentingAgents->setInspectorCanvasAgent(this);
 }
 
 void InspectorCanvasAgent::disable(ErrorString*)
 {
-    if (!m_enabled)
-        return;
-    m_enabled = false;
-    m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, m_enabled);
+    m_instrumentingAgents->setInspectorCanvasAgent(0);
+    m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, false);
 }
 
 void InspectorCanvasAgent::dropTraceLog(ErrorString* errorString, const String& traceLogId)
index e868619..ef4cbd5 100644 (file)
@@ -64,8 +64,6 @@ public:
     virtual void clearFrontend();
     virtual void restore();
 
-    bool enabled() { return m_enabled; }
-
     ScriptObject wrapCanvas2DRenderingContextForInstrumentation(const ScriptObject&);
 #if ENABLE(WEBGL)
     ScriptObject wrapWebGLRenderingContextForInstrumentation(const ScriptObject&);
@@ -91,7 +89,6 @@ private:
     Page* m_inspectedPage;
     InjectedScriptManager* m_injectedScriptManager;
     InspectorFrontend::Canvas* m_frontend;
-    bool m_enabled;
 };
 
 } // namespace WebCore
index 783a146..2c2bea9 100644 (file)
@@ -42,8 +42,7 @@ ScriptObject InspectorInstrumentation::wrapCanvas2DRenderingContextForInstrument
 {
 #if ENABLE(INSPECTOR)
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) {
-        InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent();
-        if (canvasAgent && canvasAgent->enabled())
+        if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
             return canvasAgent->wrapCanvas2DRenderingContextForInstrumentation(context);
     }
 #endif
@@ -55,8 +54,7 @@ ScriptObject InspectorInstrumentation::wrapWebGLRenderingContextForInstrumentati
 {
 #if ENABLE(INSPECTOR)
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) {
-        InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent();
-        if (canvasAgent && canvasAgent->enabled())
+        if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
             return canvasAgent->wrapWebGLRenderingContextForInstrumentation(glContext);
     }
 #endif