Web Inspector: introduce InspectorFrontendAPI for actions initiated from the applicat...
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Nov 2011 12:54:59 +0000 (12:54 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Nov 2011 12:54:59 +0000 (12:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=62985

Source/WebCore:

Both: inspector protocol and WebCore/InspectorController have a number of unnecessary
methods for plumbing the menu action handlers through the WebKit and WebCore.
I intend to remove this menu support from the protocol and WebCore/InspectorController API.
I am starting with exposing the new front-end API in the WebCore and using it in the WebKit/mac port.
WebKit/win and WebKit2 to follow.

Reviewed by Yury Semikhatsky.

* WebCore.exp.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::InspectorFrontendClientLocal):
(WebCore::InspectorFrontendClientLocal::frontendLoaded):
(WebCore::InspectorFrontendClientLocal::setAttachedWindow):
(WebCore::InspectorFrontendClientLocal::isDebuggingEnabled):
(WebCore::InspectorFrontendClientLocal::setDebuggingEnabled):
(WebCore::InspectorFrontendClientLocal::isJavaScriptProfilingEnabled):
(WebCore::InspectorFrontendClientLocal::setJavaScriptProfilingEnabled):
(WebCore::InspectorFrontendClientLocal::isTimelineProfilingEnabled):
(WebCore::InspectorFrontendClientLocal::setTimelineProfilingEnabled):
(WebCore::InspectorFrontendClientLocal::isProfilingJavaScript):
(WebCore::InspectorFrontendClientLocal::startProfilingJavaScript):
(WebCore::InspectorFrontendClientLocal::stopProfilingJavaScript):
(WebCore::InspectorFrontendClientLocal::evaluateAsBoolean):
(WebCore::InspectorFrontendClientLocal::evaluateOnLoad):
* inspector/InspectorFrontendClientLocal.h:
* inspector/front-end/InspectorFrontendAPI.js: Added.
(InspectorFrontendAPI.isDebuggingEnabled):
(InspectorFrontendAPI.setDebuggingEnabled):
(InspectorFrontendAPI.isJavaScriptProfilingEnabled):
(InspectorFrontendAPI.setJavaScriptProfilingEnabled):
(InspectorFrontendAPI.isTimelineProfilingEnabled):
(InspectorFrontendAPI.setTimelineProfilingEnabled):
(InspectorFrontendAPI.isProfilingJavaScript):
(InspectorFrontendAPI.startProfilingJavaScript):
(InspectorFrontendAPI.stopProfilingJavaScript):
(InspectorFrontendAPI.setAttachedWindow):
* inspector/front-end/ProfileView.js:
(WebInspector.CPUProfileType):
(WebInspector.CPUProfileType.prototype.isRecordingProfile):
(WebInspector.CPUProfileType.prototype.startRecordingProfile):
(WebInspector.CPUProfileType.prototype.stopRecordingProfile):
* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel.prototype.get profilerEnabled):
(WebInspector.ProfilesPanel.prototype.enableProfiler):
(WebInspector.ProfilesPanel.prototype.disableProfiler):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel):
(WebInspector.ScriptsPanel.prototype.get debuggingEnabled):
(WebInspector.ScriptsPanel.prototype.enableDebugging):
(WebInspector.ScriptsPanel.prototype.disableDebugging):
(WebInspector.ScriptsPanel.prototype.toggleDebugging):
* inspector/front-end/TimelinePanel.js:
(WebInspector.TimelinePanel.prototype._memoryOverviewItemSelected):
(WebInspector.TimelinePanel.prototype.setTimelineProfilingEnabled):
(WebInspector.TimelinePanel.prototype.get timelineProfilingEnabled):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
* inspector/front-end/inspector.js:

Source/WebKit/mac:

Both: inspector protocol and WebCore/InspectorController have a number of unnecessary
methods for plumbing the menu action handlers through the WebKit and WebCore.
I intend to remove this menu support from the protocol and WebCore/InspectorController API.
I am starting with exposing the new front-end API in the WebCore and using it in the WebKit/mac port.
WebKit/win and WebKit2 to follow.

Reviewed by Yury Semikhatsky.

* WebCoreSupport/WebInspectorClient.mm:
(-[WebInspectorWindowController destroyInspectorView:]):
* WebInspector/WebInspector.mm:
(-[WebInspector showWindow]):
(-[WebInspector show:]):
(-[WebInspector showConsole:]):
(-[WebInspector isDebuggingJavaScript]):
(-[WebInspector toggleDebuggingJavaScript:]):
(-[WebInspector startDebuggingJavaScript:]):
(-[WebInspector stopDebuggingJavaScript:]):
(-[WebInspector isProfilingJavaScript]):
(-[WebInspector toggleProfilingJavaScript:]):
(-[WebInspector startProfilingJavaScript:]):
(-[WebInspector stopProfilingJavaScript:]):
(-[WebInspector isJavaScriptProfilingEnabled]):
(-[WebInspector setJavaScriptProfilingEnabled:]):
(-[WebInspector isTimelineProfilingEnabled]):
(-[WebInspector setTimelineProfilingEnabled:]):
(-[WebInspector setFrontend:]):
(-[WebInspector releaseFrontend]):
(-[WebInspector showWindow:]):
* WebInspector/WebInspectorFrontend.h:
* WebInspector/WebInspectorFrontend.mm:
(-[WebInspectorFrontend isDebuggingEnabled]):
(-[WebInspectorFrontend setDebuggingEnabled:]):
(-[WebInspectorFrontend isProfilingJavaScript]):
(-[WebInspectorFrontend startProfilingJavaScript]):
(-[WebInspectorFrontend stopProfilingJavaScript]):
(-[WebInspectorFrontend isJavaScriptProfilingEnabled]):
(-[WebInspectorFrontend setJavaScriptProfilingEnabled:]):
(-[WebInspectorFrontend isTimelineProfilingEnabled]):
(-[WebInspectorFrontend setTimelineProfilingEnabled:]):
* WebInspector/WebInspectorPrivate.h:

Source/WebKit/win:

Both: inspector protocol and WebCore/InspectorController have a number of unnecessary
methods for plumbing the menu action handlers through the WebKit and WebCore.
I intend to remove this menu support from the protocol and WebCore/InspectorController API.
I am starting with exposing the new front-end API in the WebCore and using it in the WebKit/mac port.
WebKit/win and WebKit2 to follow.

Reviewed by Yury Semikhatsky.

* WebInspector.cpp:
(WebInspector::createInstance):
(WebInspector::WebInspector):
(WebInspector::webViewClosed):
(WebInspector::showConsole):
(WebInspector::isDebuggingJavaScript):
(WebInspector::toggleDebuggingJavaScript):
(WebInspector::isProfilingJavaScript):
(WebInspector::toggleProfilingJavaScript):
(WebInspector::isJavaScriptProfilingEnabled):
(WebInspector::setJavaScriptProfilingEnabled):
(WebInspector::isTimelineProfilingEnabled):
(WebInspector::setTimelineProfilingEnabled):
* WebInspector.h:
* WebView.cpp:
(WebView::WebView):
(WebView::close):
(WebView::initWithFrame):
(WebView::inspector):
* WebView.h:

LayoutTests:

Reviewed by Yury Semikhatsky.

* http/tests/inspector/debugger-test.js:
(initialize_DebuggerTest.InspectorTest.completeDebuggerTest.disableDebugger):

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

27 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/debugger-test.js
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Source/WebCore/inspector/InspectorFrontendClientLocal.h
Source/WebCore/inspector/front-end/InspectorFrontendAPI.js [new file with mode: 0644]
Source/WebCore/inspector/front-end/ProfileView.js
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/WebKit.qrc
Source/WebCore/inspector/front-end/inspector.html
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
Source/WebKit/mac/WebInspector/WebInspector.mm
Source/WebKit/mac/WebInspector/WebInspectorFrontend.h
Source/WebKit/mac/WebInspector/WebInspectorFrontend.mm
Source/WebKit/mac/WebInspector/WebInspectorPrivate.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit/win/WebCoreSupport/WebInspectorClient.h
Source/WebKit/win/WebInspector.cpp
Source/WebKit/win/WebInspector.h
Source/WebKit/win/WebView.cpp
Source/WebKit/win/WebView.h

index 1392a95..73a574e 100644 (file)
@@ -1,3 +1,13 @@
+2011-06-20  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: introduce InspectorFrontendAPI for actions initiated from the application menu.
+        https://bugs.webkit.org/show_bug.cgi?id=62985
+
+        Reviewed by Yury Semikhatsky.
+
+        * http/tests/inspector/debugger-test.js:
+        (initialize_DebuggerTest.InspectorTest.completeDebuggerTest.disableDebugger):
+
 2011-11-21  Steve Block  <steveblock@google.com>
 
         Inspector tests flakily crashing on Linux dbg canary
index 2268ed4..8e195ce 100644 (file)
@@ -10,7 +10,7 @@ InspectorTest.startDebuggerTest = function(callback, quiet)
         startTest();
     else {
         InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasEnabled", startTest);
-        WebInspector.panels.scripts._toggleDebugging(false);
+        WebInspector.panels.scripts.toggleDebugging(false);
     }
 
     function startTest()
@@ -35,7 +35,7 @@ InspectorTest.completeDebuggerTest = function()
             completeTest();
         else {
             InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasDisabled", completeTest);
-            scriptsPanel._toggleDebugging(false);
+            scriptsPanel.toggleDebugging(false);
         }
     }
 
index bea3395..2237a5e 100644 (file)
@@ -1,3 +1,69 @@
+2011-06-20  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: introduce InspectorFrontendAPI for actions initiated from the application menu.
+        https://bugs.webkit.org/show_bug.cgi?id=62985
+
+        Both: inspector protocol and WebCore/InspectorController have a number of unnecessary
+        methods for plumbing the menu action handlers through the WebKit and WebCore.
+        I intend to remove this menu support from the protocol and WebCore/InspectorController API.
+        I am starting with exposing the new front-end API in the WebCore and using it in the WebKit/mac port.
+        WebKit/win and WebKit2 to follow.
+
+        Reviewed by Yury Semikhatsky.
+
+        * WebCore.exp.in:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/InspectorFrontendClientLocal.cpp:
+        (WebCore::InspectorFrontendClientLocal::InspectorFrontendClientLocal):
+        (WebCore::InspectorFrontendClientLocal::frontendLoaded):
+        (WebCore::InspectorFrontendClientLocal::setAttachedWindow):
+        (WebCore::InspectorFrontendClientLocal::isDebuggingEnabled):
+        (WebCore::InspectorFrontendClientLocal::setDebuggingEnabled):
+        (WebCore::InspectorFrontendClientLocal::isJavaScriptProfilingEnabled):
+        (WebCore::InspectorFrontendClientLocal::setJavaScriptProfilingEnabled):
+        (WebCore::InspectorFrontendClientLocal::isTimelineProfilingEnabled):
+        (WebCore::InspectorFrontendClientLocal::setTimelineProfilingEnabled):
+        (WebCore::InspectorFrontendClientLocal::isProfilingJavaScript):
+        (WebCore::InspectorFrontendClientLocal::startProfilingJavaScript):
+        (WebCore::InspectorFrontendClientLocal::stopProfilingJavaScript):
+        (WebCore::InspectorFrontendClientLocal::evaluateAsBoolean):
+        (WebCore::InspectorFrontendClientLocal::evaluateOnLoad):
+        * inspector/InspectorFrontendClientLocal.h:
+        * inspector/front-end/InspectorFrontendAPI.js: Added.
+        (InspectorFrontendAPI.isDebuggingEnabled):
+        (InspectorFrontendAPI.setDebuggingEnabled):
+        (InspectorFrontendAPI.isJavaScriptProfilingEnabled):
+        (InspectorFrontendAPI.setJavaScriptProfilingEnabled):
+        (InspectorFrontendAPI.isTimelineProfilingEnabled):
+        (InspectorFrontendAPI.setTimelineProfilingEnabled):
+        (InspectorFrontendAPI.isProfilingJavaScript):
+        (InspectorFrontendAPI.startProfilingJavaScript):
+        (InspectorFrontendAPI.stopProfilingJavaScript):
+        (InspectorFrontendAPI.setAttachedWindow):
+        * inspector/front-end/ProfileView.js:
+        (WebInspector.CPUProfileType):
+        (WebInspector.CPUProfileType.prototype.isRecordingProfile):
+        (WebInspector.CPUProfileType.prototype.startRecordingProfile):
+        (WebInspector.CPUProfileType.prototype.stopRecordingProfile):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype.get profilerEnabled):
+        (WebInspector.ProfilesPanel.prototype.enableProfiler):
+        (WebInspector.ProfilesPanel.prototype.disableProfiler):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel):
+        (WebInspector.ScriptsPanel.prototype.get debuggingEnabled):
+        (WebInspector.ScriptsPanel.prototype.enableDebugging):
+        (WebInspector.ScriptsPanel.prototype.disableDebugging):
+        (WebInspector.ScriptsPanel.prototype.toggleDebugging):
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.prototype._memoryOverviewItemSelected):
+        (WebInspector.TimelinePanel.prototype.setTimelineProfilingEnabled):
+        (WebInspector.TimelinePanel.prototype.get timelineProfilingEnabled):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+
 2011-11-18  Alexander Pavlov  <apavlov@chromium.org>
 
         Web Inspector: [Protocol] Retain a single universal method for loading a required combination of element styles
index 8e5a7f2..6e8c35e 100644 (file)
@@ -1591,6 +1591,14 @@ __ZN7WebCore21ContextMenuController16clearContextMenuEv
 __ZNK7WebCore21ContextMenuController21checkOrEnableIfNeededERNS_15ContextMenuItemE
 __ZN7WebCore21ContextMenuController23contextMenuItemSelectedEPNS_15ContextMenuItemE
 __ZN7WebCore21contextMenuItemVectorEP14NSMutableArray
+__ZN7WebCore28InspectorFrontendClientLocal26isTimelineProfilingEnabledEv
+__ZN7WebCore28InspectorFrontendClientLocal27setTimelineProfilingEnabledEb
+__ZN7WebCore28InspectorFrontendClientLocal21isProfilingJavaScriptEv
+__ZN7WebCore28InspectorFrontendClientLocal24startProfilingJavaScriptEv
+__ZN7WebCore28InspectorFrontendClientLocal23stopProfilingJavaScriptEv
+__ZN7WebCore28InspectorFrontendClientLocal18isDebuggingEnabledEv
+__ZN7WebCore28InspectorFrontendClientLocal19setDebuggingEnabledEb
+__ZN7WebCore28InspectorFrontendClientLocal11showConsoleEv
 __ZN7WebCore23platformMenuDescriptionERN3WTF6VectorINS_15ContextMenuItemELm0EEE
 __ZN7WebCore6Chrome15showContextMenuEv
 __ZNK7WebCore11ContextMenu19platformDescriptionEv
index d58465f..3d456fd 100644 (file)
             'inspector/front-end/HeapSnapshotWorkerDispatcher.js',
             'inspector/front-end/HelpScreen.js',
             'inspector/front-end/ImageView.js',
+            'inspector/front-end/InspectorFrontendAPI.js',
             'inspector/front-end/InspectorFrontendHostStub.js',
             'inspector/front-end/InspectorView.js',
             'inspector/front-end/InjectedFakeWorker.js',
index c4c818e..22035e0 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\inspector\front-end\InspectorFrontendAPI.js"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\inspector\front-end\InspectorFrontendHostStub.js"
                                        >
                                </File>
index 6e08f41..e7ce55f 100644 (file)
@@ -105,6 +105,7 @@ InspectorFrontendClientLocal::InspectorFrontendClientLocal(InspectorController*
     , m_frontendPage(frontendPage)
     , m_frontendScriptState(0)
     , m_settings(settings)
+    , m_frontendLoaded(false)
 {
     m_frontendPage->settings()->setAllowFileAccessFromFileURLs(true);
     m_dispatchTask = adoptPtr(new InspectorBackendDispatchTask(inspectorController));
@@ -131,6 +132,9 @@ void InspectorFrontendClientLocal::frontendLoaded()
 {
     bringToFront();
     m_inspectorController->connectFrontend();
+    m_frontendLoaded = true;
+    if (!m_evaluateOnLoad.isEmpty())
+        evaluateOnLoad(m_evaluateOnLoad);
 }
 
 void InspectorFrontendClientLocal::requestAttachWindow()
@@ -172,14 +176,7 @@ void InspectorFrontendClientLocal::moveWindowBy(float x, float y)
 
 void InspectorFrontendClientLocal::setAttachedWindow(bool attached)
 {
-    ScriptObject webInspectorObj;
-    if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-    ScriptFunctionCall function(webInspectorObj, "setAttachedWindow");
-    function.appendArgument(attached);
-    function.call();
+    evaluateAsBoolean(String::format("InspectorFrontendAPI.setAttachedWindow(%s)", attached ? "true" : "false"));
 }
 
 void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
@@ -194,6 +191,52 @@ void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
     setAttachedWindowHeight(constrainedAttachedWindowHeight(preferredHeight, inspectedPageHeight));
 }
 
+bool InspectorFrontendClientLocal::isDebuggingEnabled()
+{
+    if (m_frontendLoaded)
+        return evaluateAsBoolean("InspectorFrontendAPI.isDebuggingEnabled()");
+    return false;
+}
+
+void InspectorFrontendClientLocal::setDebuggingEnabled(bool enabled)
+{
+    evaluateOnLoad(String::format("InspectorFrontendAPI.setDebuggingEnabled(%s)", enabled ? "true" : "false"));
+}
+
+bool InspectorFrontendClientLocal::isTimelineProfilingEnabled()
+{
+    if (m_frontendLoaded)
+        return evaluateAsBoolean("InspectorFrontendAPI.isTimelineProfilingEnabled()");
+    return false;
+}
+
+void InspectorFrontendClientLocal::setTimelineProfilingEnabled(bool enabled)
+{
+    evaluateOnLoad(String::format("InspectorFrontendAPI.setTimelineProfilingEnabled(%s)", enabled ? "true" : "false"));
+}
+
+bool InspectorFrontendClientLocal::isProfilingJavaScript()
+{
+    if (m_frontendLoaded)
+        return evaluateAsBoolean("InspectorFrontendAPI.isProfilingJavaScript()");
+    return false;
+}
+
+void InspectorFrontendClientLocal::startProfilingJavaScript()
+{
+    evaluateOnLoad("InspectorFrontendAPI.startProfilingJavaScript()");
+}
+
+void InspectorFrontendClientLocal::stopProfilingJavaScript()
+{
+    evaluateOnLoad("InspectorFrontendAPI.stopProfilingJavaScript()");
+}
+
+void InspectorFrontendClientLocal::showConsole()
+{
+    evaluateOnLoad("InspectorFrontendAPI.showConsole()");
+}
+
 unsigned InspectorFrontendClientLocal::constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight)
 {
     using namespace std;
@@ -205,6 +248,22 @@ void InspectorFrontendClientLocal::sendMessageToBackend(const String& message)
     m_dispatchTask->dispatch(message);
 }
 
+bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& expression)
+{
+    if (!m_frontendPage->mainFrame())
+        return false;
+    ScriptValue value = m_frontendPage->mainFrame()->script()->executeScript(expression);
+    return value.toString(mainWorldScriptState(m_frontendPage->mainFrame())) == "true";
+}
+
+void InspectorFrontendClientLocal::evaluateOnLoad(const String& expression)
+{
+    if (m_frontendLoaded)
+        m_frontendPage->mainFrame()->script()->executeScript(expression);
+    else
+        m_evaluateOnLoad = "setTimeout(function() { " + expression + "; }, 0)";
+}
+
 } // namespace WebCore
 
 #endif
index 47b1570..1606a62 100644 (file)
@@ -32,6 +32,7 @@
 #define InspectorFrontendClientLocal_h
 
 #include "InspectorFrontendClient.h"
+#include "PlatformString.h"
 #include "ScriptState.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
@@ -76,12 +77,28 @@ public:
 
     static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight);
 
+    // Direct Frontend API
+    bool isDebuggingEnabled();
+    void setDebuggingEnabled(bool);
+
+    bool isTimelineProfilingEnabled();
+    void setTimelineProfilingEnabled(bool);
+
+    bool isProfilingJavaScript();
+    void startProfilingJavaScript();
+    void stopProfilingJavaScript();
+
+    void showConsole();
+
 protected:
     virtual void setAttachedWindowHeight(unsigned) = 0;
     void setAttachedWindow(bool);
     void restoreAttachedWindowHeight();
 
 private:
+    bool evaluateAsBoolean(const String& expression);
+    void evaluateOnLoad(const String& expression);
+
     friend class FrontendMenuProvider;
     InspectorController* m_inspectorController;
     Page* m_frontendPage;
@@ -89,6 +106,8 @@ private:
     // TODO(yurys): this ref shouldn't be needed.
     RefPtr<InspectorFrontendHost> m_frontendHost;
     OwnPtr<InspectorFrontendClientLocal::Settings> m_settings;
+    bool m_frontendLoaded;
+    String m_evaluateOnLoad;
     OwnPtr<InspectorBackendDispatchTask> m_dispatchTask;
 };
 
diff --git a/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js b/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js
new file mode 100644 (file)
index 0000000..ca0cd3a
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ InspectorFrontendAPI = {
+     isDebuggingEnabled: function()
+     {
+         return WebInspector.panels.scripts.debuggingEnabled;
+     },
+
+     setDebuggingEnabled: function(enabled)
+     {
+         if (enabled) {
+             WebInspector.panels.scripts.enableDebugging();
+             WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.scripts);
+         } else
+             WebInspector.panels.scripts.disableDebugging();
+     },
+
+     isTimelineProfilingEnabled: function()
+     {
+         return WebInspector.panels.timeline.timelineProfilingEnabled;
+     },
+
+     setTimelineProfilingEnabled: function(enabled)
+     {
+         WebInspector.panels.timeline.setTimelineProfilingEnabled(enabled);
+     },
+
+     isProfilingJavaScript: function()
+     {
+         return WebInspector.CPUProfileType.instance && WebInspector.CPUProfileType.instance.isRecordingProfile();
+     },
+
+     startProfilingJavaScript: function()
+     {
+         WebInspector.panels.profiles.enableProfiler();
+         WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.profiles);
+         if (WebInspector.CPUProfileType.instance)
+             WebInspector.CPUProfileType.instance.startRecordingProfile();
+     },
+
+     stopProfilingJavaScript: function()
+     {
+         if (WebInspector.CPUProfileType.instance)
+             WebInspector.CPUProfileType.instance.stopRecordingProfile();
+         WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.profiles);
+     },
+
+     setAttachedWindow: function(attached)
+     {
+         WebInspector.attached = attached;
+     },
+
+     showConsole: function()
+     {
+         WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.console);
+     }
+ }
index 66e73b5..59b6ee5 100644 (file)
@@ -566,6 +566,7 @@ WebInspector.CPUProfileType = function()
 {
     WebInspector.ProfileType.call(this, WebInspector.CPUProfileType.TypeId, WebInspector.UIString("CPU PROFILES"));
     this._recording = false;
+    WebInspector.CPUProfileType.instance = this;
 }
 
 WebInspector.CPUProfileType.TypeId = "CPU";
@@ -596,6 +597,23 @@ WebInspector.CPUProfileType.prototype = {
         return WebInspector.UIString("Control CPU profiling by pressing the %s button on the status bar.");
     },
 
+    isRecordingProfile: function()
+    {
+        return this._recording;
+    },
+
+    startRecordingProfile: function()
+    {
+        this._recording = true;
+        ProfilerAgent.start();
+    },
+
+    stopRecordingProfile: function()
+    {
+        this._recording = false;
+        ProfilerAgent.stop();
+    },
+
     setRecordingProfile: function(isProfiling)
     {
         this._recording = isProfiling;
index 8e5e8c5..83a751a 100644 (file)
@@ -111,7 +111,7 @@ WebInspector.ProfilesPanel = function()
     var panelEnablerDisclaimer = WebInspector.UIString("Enabling profiling will make scripts run slower.");
     var panelEnablerButton = WebInspector.UIString("Enable Profiling");
     this.panelEnablerView = new WebInspector.PanelEnablerView("profiles", panelEnablerHeading, panelEnablerDisclaimer, panelEnablerButton);
-    this.panelEnablerView.addEventListener("enable clicked", this._enableProfiling, this);
+    this.panelEnablerView.addEventListener("enable clicked", this.enableProfiler, this);
 
     this.profileViews = document.createElement("div");
     this.profileViews.id = "profile-views";
@@ -774,13 +774,25 @@ WebInspector.ProfilesPanel.prototype = {
         }
     },
 
-    _enableProfiling: function()
+    get profilerEnabled()
+    {
+        return this._profilerEnabled;
+    },
+
+    enableProfiler: function()
     {
         if (this._profilerEnabled)
             return;
         this._toggleProfiling(this.panelEnablerView.alwaysEnabled);
     },
 
+    disableProfiler: function()
+    {
+        if (!this._profilerEnabled)
+            return;
+        this._toggleProfiling(this.panelEnablerView.alwaysEnabled);
+    },
+
     _toggleProfiling: function(optionalAlways)
     {
         if (this._profilerEnabled) {
index 49d511d..7c44ffc 100644 (file)
@@ -142,7 +142,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
     var panelEnablerButton = WebInspector.UIString("Enable Debugging");
 
     this.panelEnablerView = new WebInspector.PanelEnablerView("scripts", panelEnablerHeading, panelEnablerDisclaimer, panelEnablerButton);
-    this.panelEnablerView.addEventListener("enable clicked", this._enableDebugging, this);
+    this.panelEnablerView.addEventListener("enable clicked", this.enableDebugging, this);
 
     this.element.appendChild(this.viewsContainerElement);
     this.element.appendChild(this.sidebarElement);
@@ -915,14 +915,26 @@ WebInspector.ScriptsPanel.prototype = {
         this._updateBackAndForwardButtons();
     },
 
-    _enableDebugging: function()
+    get debuggingEnabled()
+    {
+        return this._debuggerEnabled;
+    },
+
+    enableDebugging: function()
     {
         if (this._debuggerEnabled)
             return;
-        this._toggleDebugging(this.panelEnablerView.alwaysEnabled);
+        this.toggleDebugging(this.panelEnablerView.alwaysEnabled);
+    },
+
+    disableDebugging: function()
+    {
+        if (!this._debuggerEnabled)
+            return;
+        this.toggleDebugging(this.panelEnablerView.alwaysEnabled);
     },
 
-    _toggleDebugging: function(optionalAlways)
+    toggleDebugging: function(optionalAlways)
     {
         this._paused = false;
         this._waitingToPause = false;
index 76fa432..f788621 100644 (file)
@@ -66,6 +66,7 @@
     <file>ImageView.js</file>
     <file>InjectedFakeWorker.js</file>
     <file>inspector.js</file>
+    <file>InspectorFrontendAPI.js</file>
     <file>InspectorFrontendHostStub.js</file>
     <file>InspectorView.js</file>
     <file>JavaScriptContextManager.js</file>
index 76a21b9..ba7d90c 100644 (file)
@@ -42,6 +42,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="UIUtils.js"></script>
     <script type="text/javascript" src="InspectorBackendStub.js"></script>
     <script type="text/javascript" src="ExtensionRegistryStub.js"></script>
+    <script type="text/javascript" src="InspectorFrontendAPI.js"></script>
     <script type="text/javascript" src="Object.js"></script>
     <script type="text/javascript" src="Settings.js"></script>
     <script type="text/javascript" src="InspectorFrontendHostStub.js"></script>
index 9c56ccb..4a6a579 100644 (file)
@@ -1,3 +1,50 @@
+2011-06-20  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: introduce InspectorFrontendAPI for actions initiated from the application menu.
+        https://bugs.webkit.org/show_bug.cgi?id=62985
+
+        Both: inspector protocol and WebCore/InspectorController have a number of unnecessary
+        methods for plumbing the menu action handlers through the WebKit and WebCore.
+        I intend to remove this menu support from the protocol and WebCore/InspectorController API.
+        I am starting with exposing the new front-end API in the WebCore and using it in the WebKit/mac port.
+        WebKit/win and WebKit2 to follow.
+
+        Reviewed by Yury Semikhatsky.
+
+        * WebCoreSupport/WebInspectorClient.mm:
+        (-[WebInspectorWindowController destroyInspectorView:]):
+        * WebInspector/WebInspector.mm:
+        (-[WebInspector showWindow]):
+        (-[WebInspector show:]):
+        (-[WebInspector showConsole:]):
+        (-[WebInspector isDebuggingJavaScript]):
+        (-[WebInspector toggleDebuggingJavaScript:]):
+        (-[WebInspector startDebuggingJavaScript:]):
+        (-[WebInspector stopDebuggingJavaScript:]):
+        (-[WebInspector isProfilingJavaScript]):
+        (-[WebInspector toggleProfilingJavaScript:]):
+        (-[WebInspector startProfilingJavaScript:]):
+        (-[WebInspector stopProfilingJavaScript:]):
+        (-[WebInspector isJavaScriptProfilingEnabled]):
+        (-[WebInspector setJavaScriptProfilingEnabled:]):
+        (-[WebInspector isTimelineProfilingEnabled]):
+        (-[WebInspector setTimelineProfilingEnabled:]):
+        (-[WebInspector setFrontend:]):
+        (-[WebInspector releaseFrontend]):
+        (-[WebInspector showWindow:]):
+        * WebInspector/WebInspectorFrontend.h:
+        * WebInspector/WebInspectorFrontend.mm:
+        (-[WebInspectorFrontend isDebuggingEnabled]):
+        (-[WebInspectorFrontend setDebuggingEnabled:]):
+        (-[WebInspectorFrontend isProfilingJavaScript]):
+        (-[WebInspectorFrontend startProfilingJavaScript]):
+        (-[WebInspectorFrontend stopProfilingJavaScript]):
+        (-[WebInspectorFrontend isJavaScriptProfilingEnabled]):
+        (-[WebInspectorFrontend setJavaScriptProfilingEnabled:]):
+        (-[WebInspectorFrontend isTimelineProfilingEnabled]):
+        (-[WebInspectorFrontend setTimelineProfilingEnabled:]):
+        * WebInspector/WebInspectorPrivate.h:
+
 2011-11-21  Jochen Eisinger  <jochen@chromium.org>
 
         Implement Meta referrer
index f4d86ae..2d37264 100644 (file)
@@ -431,6 +431,8 @@ void WebInspectorFrontendClient::updateWindowTitle() const
 
 - (void)destroyInspectorView:(bool)notifyInspectorController
 {
+    [[_inspectedWebView.get() inspector] releaseFrontend];
+
     if (_destroyingInspectorView)
         return;
     _destroyingInspectorView = YES;
index f38c7ef..67a7354 100644 (file)
@@ -45,6 +45,7 @@ using namespace WebCore;
     if (!(self = [super init]))
         return nil;
     _webView = webView; // not retained to prevent a cycle
+
     return self;
 }
 
@@ -59,16 +60,21 @@ using namespace WebCore;
     _webView = nil;
 }
 
-- (void)show:(id)sender
+- (void)showWindow
 {
     if (Page* page = core(_webView))
         page->inspectorController()->show();
 }
 
+- (void)show:(id)sender
+{
+    [self showWindow];
+}
+
 - (void)showConsole:(id)sender
 {
-    if (Page* page = core(_webView))
-        page->inspectorController()->showConsole();
+    [self showWindow];
+    [_frontend showConsole];
 }
 
 - (void)showTimeline:(id)sender
@@ -78,60 +84,56 @@ using namespace WebCore;
 
 - (BOOL)isDebuggingJavaScript
 {
-    if (Page* page = core(_webView))
-        return page->inspectorController()->debuggerEnabled();
-    return NO;
+    return _frontend && [_frontend isDebuggingEnabled];
 }
 
 - (void)toggleDebuggingJavaScript:(id)sender
 {
+    [self showWindow];
+
     if ([self isDebuggingJavaScript])
-        [self stopDebuggingJavaScript:sender];
+        [_frontend setDebuggingEnabled:false];
     else
-        [self startDebuggingJavaScript:sender];
+        [_frontend setDebuggingEnabled:true];
 }
 
 - (void)startDebuggingJavaScript:(id)sender
 {
-    Page* page = core(_webView);
-    if (!page)
-        return;
-    page->inspectorController()->showAndEnableDebugger();
+    if (_frontend)
+        [_frontend setDebuggingEnabled:true];
 }
 
 - (void)stopDebuggingJavaScript:(id)sender
 {
-    if (Page* page = core(_webView))
-        page->inspectorController()->disableDebugger();
+    if (_frontend)
+        [_frontend setDebuggingEnabled:false];
 }
 
 - (BOOL)isProfilingJavaScript
 {
-    if (Page* page = core(_webView))
-        return page->inspectorController()->isRecordingUserInitiatedProfile();
-    return NO;
+    return _frontend && [_frontend isProfilingJavaScript];
 }
 
 - (void)toggleProfilingJavaScript:(id)sender
 {
+    [self showWindow];
+
     if ([self isProfilingJavaScript])
-        [self stopProfilingJavaScript:sender];
+        [_frontend stopProfilingJavaScript];
     else
-        [self startProfilingJavaScript:sender];
+        [_frontend startProfilingJavaScript];
 }
 
 - (void)startProfilingJavaScript:(id)sender
 {
-    if (Page* page = core(_webView))
-        page->inspectorController()->startUserInitiatedProfiling();
+    if (_frontend)
+        [_frontend startProfilingJavaScript];
 }
 
 - (void)stopProfilingJavaScript:(id)sender
 {
-    Page* page = core(_webView);
-    if (!page)
-        return;
-    page->inspectorController()->stopUserInitiatedProfiling();
+    if (_frontend)
+        [_frontend stopProfilingJavaScript];
 }
 
 - (BOOL)isJavaScriptProfilingEnabled
@@ -155,21 +157,13 @@ using namespace WebCore;
 
 - (BOOL)isTimelineProfilingEnabled
 {
-    if (Page* page = core(_webView))
-        return page->inspectorController()->timelineProfilerEnabled() ? YES : NO;
-    return NO;
+    return _frontend && [_frontend isTimelineProfilingEnabled];
 }
 
 - (void)setTimelineProfilingEnabled:(BOOL)enabled
 {
-    Page* page = core(_webView);
-    if (!page)
-        return;
-
-    if (enabled)
-        page->inspectorController()->startTimelineProfiler();
-    else
-        page->inspectorController()->stopTimelineProfiler();
+    if (_frontend)
+        [_frontend setTimelineProfilingEnabled:enabled];
 }
 
 - (void)close:(id)sender 
@@ -196,9 +190,14 @@ using namespace WebCore;
 
 - (void)setFrontend:(WebInspectorFrontend *)frontend
 {
-    [_frontend release];
     _frontend = [frontend retain];
 }
+
+- (void)releaseFrontend
+{
+    [_frontend release];
+    _frontend = 0;
+}
 @end
 
 @implementation WebInspector (Obsolete)
@@ -247,6 +246,6 @@ using namespace WebCore;
         logged = YES;
     }
 
-    [self show:sender];
+    [self showWindow];
 }
 @end
index 93bed84..597fd21 100644 (file)
@@ -32,4 +32,17 @@ class WebInspectorFrontendClient;
 - (id)initWithFrontendClient:(WebInspectorFrontendClient *)frontendClient;
 - (void)attach;
 - (void)detach;
+
+- (BOOL)isDebuggingEnabled;
+- (void)setDebuggingEnabled:(BOOL)enabled;
+
+- (BOOL)isTimelineProfilingEnabled;
+- (void)setTimelineProfilingEnabled:(BOOL)enabled;
+
+- (BOOL)isProfilingJavaScript;
+- (void)startProfilingJavaScript;
+- (void)stopProfilingJavaScript;
+
+- (void)showConsole;
+
 @end
index c285ef7..0922e60 100644 (file)
     m_frontendClient->detachWindow();
 }
 
+- (BOOL)isDebuggingEnabled
+{
+    return m_frontendClient->isDebuggingEnabled();
+}
+
+- (void)setDebuggingEnabled:(BOOL)enabled
+{
+    m_frontendClient->setDebuggingEnabled(enabled);
+}
+
+- (BOOL)isProfilingJavaScript
+{
+    return m_frontendClient->isProfilingJavaScript();
+}
+
+- (void)startProfilingJavaScript
+{
+    m_frontendClient->startProfilingJavaScript();
+}
+
+- (void)stopProfilingJavaScript
+{
+    m_frontendClient->stopProfilingJavaScript();
+}
+
+- (BOOL)isTimelineProfilingEnabled
+{
+    return m_frontendClient->isTimelineProfilingEnabled();
+}
+
+- (void)setTimelineProfilingEnabled:(BOOL)enabled
+{
+    m_frontendClient->setTimelineProfilingEnabled(enabled);
+}
+
+- (void)showConsole
+{
+    m_frontendClient->showConsole();
+}
+
 @end
index df1e286..3d924d6 100644 (file)
@@ -34,5 +34,7 @@
 
 @interface WebInspector (WebPrivate)
 - (void)evaluateInFrontend:(id)sender callId:(long)callId script:(NSString *)script;
+- (void)showWindow;
 - (void)setFrontend:(WebInspectorFrontend *)frontend;
+- (void)releaseFrontend;
 @end
index 41a14be..6a9f9e0 100644 (file)
@@ -1,3 +1,37 @@
+2011-06-20  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: introduce InspectorFrontendAPI for actions initiated from the application menu.
+        https://bugs.webkit.org/show_bug.cgi?id=62985
+
+        Both: inspector protocol and WebCore/InspectorController have a number of unnecessary
+        methods for plumbing the menu action handlers through the WebKit and WebCore.
+        I intend to remove this menu support from the protocol and WebCore/InspectorController API.
+        I am starting with exposing the new front-end API in the WebCore and using it in the WebKit/mac port.
+        WebKit/win and WebKit2 to follow.
+
+        Reviewed by Yury Semikhatsky.
+
+        * WebInspector.cpp:
+        (WebInspector::createInstance):
+        (WebInspector::WebInspector):
+        (WebInspector::webViewClosed):
+        (WebInspector::showConsole):
+        (WebInspector::isDebuggingJavaScript):
+        (WebInspector::toggleDebuggingJavaScript):
+        (WebInspector::isProfilingJavaScript):
+        (WebInspector::toggleProfilingJavaScript):
+        (WebInspector::isJavaScriptProfilingEnabled):
+        (WebInspector::setJavaScriptProfilingEnabled):
+        (WebInspector::isTimelineProfilingEnabled):
+        (WebInspector::setTimelineProfilingEnabled):
+        * WebInspector.h:
+        * WebView.cpp:
+        (WebView::WebView):
+        (WebView::close):
+        (WebView::initWithFrame):
+        (WebView::inspector):
+        * WebView.h:
+
 2011-10-17  Antonio Gomes  <agomes@rim.com>
 
         Pass a Frame* parameter in EditorClient::respondToChangedSelection
index 4f8e033..e7a73d2 100644 (file)
@@ -69,6 +69,7 @@ static CFBundleRef getWebKitBundle()
 WebInspectorClient::WebInspectorClient(WebView* webView)
     : m_inspectedWebView(webView)
     , m_frontendPage(0)
+    , m_frontendClient(0)
 {
     ASSERT(m_inspectedWebView);
     m_inspectedWebView->viewWindow((OLE_HANDLE*)&m_inspectedWebViewHwnd);
@@ -171,7 +172,9 @@ void WebInspectorClient::openInspectorFrontend(InspectorController* inspectorCon
         return;
 
     m_frontendPage = core(frontendWebView.get());
-    m_frontendPage->inspectorController()->setInspectorFrontendClient(adoptPtr(new WebInspectorFrontendClient(m_inspectedWebView, m_inspectedWebViewHwnd, frontendHwnd, frontendWebView, frontendWebViewHwnd, this, createFrontendSettings())));
+    OwnPtr<WebInspectorFrontendClient> frontendClient = adoptPtr(new WebInspectorFrontendClient(m_inspectedWebView, m_inspectedWebViewHwnd, frontendHwnd, frontendWebView, frontendWebViewHwnd, this, createFrontendSettings()));
+    m_frontendClient = frontendClient.get();
+    m_frontendPage->inspectorController()->setInspectorFrontendClient(frontendClient.release());
     m_frontendHwnd = frontendHwnd;
 }
 
@@ -203,6 +206,11 @@ void WebInspectorClient::updateHighlight()
         m_highlight->update();
 }
 
+void WebInspectorClient::releaseFrontendClient()
+{
+    m_frontendClient = 0;
+}
+
 WebInspectorFrontendClient::WebInspectorFrontendClient(WebView* inspectedWebView, HWND inspectedWebViewHwnd, HWND frontendHwnd, const COMPtr<WebView>& frontendWebView, HWND frontendWebViewHwnd, WebInspectorClient* inspectorClient, PassOwnPtr<Settings> settings)
     : InspectorFrontendClientLocal(inspectedWebView->page()->inspectorController(),  core(frontendWebView.get()), settings)
     , m_inspectedWebView(inspectedWebView)
@@ -397,6 +405,8 @@ void WebInspectorFrontendClient::showWindowWithoutNotifications()
 
 void WebInspectorFrontendClient::destroyInspectorView(bool notifyInspectorController)
 {
+    m_inspectorClient->releaseFrontendClient();
+
     if (m_destroyingInspectorView)
         return;
     m_destroyingInspectorView = true;
index 6e64f2c..456c5ab 100644 (file)
@@ -46,6 +46,7 @@ class Page;
 
 }
 
+class WebInspectorFrontendClient;
 class WebNodeHighlight;
 class WebView;
 
@@ -67,6 +68,9 @@ public:
     void setInspectorStartsAttached(bool);
 
     void releaseFrontendPage();
+    void releaseFrontendClient();
+
+    WebInspectorFrontendClient* frontendClient() { return m_frontendClient; }
 
     void updateHighlight();
     void frontendClosing()
@@ -81,6 +85,7 @@ private:
 
     WebView* m_inspectedWebView;
     WebCore::Page* m_frontendPage;
+    WebInspectorFrontendClient* m_frontendClient;
     HWND m_inspectedWebViewHwnd;
     HWND m_frontendHwnd;
 
index 976391d..7ec716f 100644 (file)
@@ -29,6 +29,7 @@
 #include "config.h"
 #include "WebInspector.h"
 
+#include "WebInspectorClient.h"
 #include "WebKitDLL.h"
 #include "WebView.h"
 #include <WebCore/InspectorController.h>
 
 using namespace WebCore;
 
-WebInspector* WebInspector::createInstance(WebView* webView)
+WebInspector* WebInspector::createInstance(WebView* webView, WebInspectorClient* inspectorClient)
 {
-    WebInspector* inspector = new WebInspector(webView);
+    WebInspector* inspector = new WebInspector(webView, inspectorClient);
     inspector->AddRef();
     return inspector;
 }
 
-WebInspector::WebInspector(WebView* webView)
+WebInspector::WebInspector(WebView* webView, WebInspectorClient* inspectorClient)
     : m_refCount(0)
     , m_webView(webView)
+    , m_inspectorClient(inspectorClient)
 {
     ASSERT_ARG(webView, webView);
 
@@ -60,9 +62,15 @@ WebInspector::~WebInspector()
     gClassNameCount.remove("WebInspector");
 }
 
+WebInspectorFrontendClient* WebInspector::frontendClient()
+{
+    return m_inspectorClient ? m_inspectorClient->frontendClient() : 0;
+}
+
 void WebInspector::webViewClosed()
 {
     m_webView = 0;
+    m_inspectorClient = 0;
 }
 
 HRESULT STDMETHODCALLTYPE WebInspector::QueryInterface(REFIID riid, void** ppvObject)
@@ -106,9 +114,8 @@ HRESULT STDMETHODCALLTYPE WebInspector::show()
 
 HRESULT STDMETHODCALLTYPE WebInspector::showConsole()
 {
-    if (m_webView)
-        if (Page* page = m_webView->page())
-            page->inspectorController()->showConsole();
+    if (frontendClient())
+        frontendClient()->showConsole();
 
     return S_OK;
 }
@@ -144,32 +151,24 @@ HRESULT STDMETHODCALLTYPE WebInspector::isDebuggingJavaScript(BOOL* isDebugging)
 
     *isDebugging = FALSE;
 
-    if (!m_webView)
-        return S_OK;
-
-    Page* page = m_webView->page();
-    if (!page)
+    if (!frontendClient())
         return S_OK;
 
-    *isDebugging = page->inspectorController()->debuggerEnabled();
+    *isDebugging = frontendClient()->isDebuggingEnabled();
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE WebInspector::toggleDebuggingJavaScript()
 {
-    if (!m_webView)
-        return S_OK;
+    show();
 
-    Page* page = m_webView->page();
-    if (!page)
+    if (!frontendClient())
         return S_OK;
 
-    InspectorController* inspector = page->inspectorController();
-
-    if (inspector->debuggerEnabled())
-        inspector->disableDebugger();
+    if (frontendClient()->isDebuggingEnabled())
+        frontendClient()->setDebuggingEnabled(false);
     else
-        inspector->showAndEnableDebugger();
+        frontendClient()->setDebuggingEnabled(true);
 
     return S_OK;
 }
@@ -181,32 +180,25 @@ HRESULT STDMETHODCALLTYPE WebInspector::isProfilingJavaScript(BOOL* isProfiling)
 
     *isProfiling = FALSE;
 
-    if (!m_webView)
+    if (!frontendClient())
         return S_OK;
 
-    Page* page = m_webView->page();
-    if (!page)
-        return S_OK;
+    *isProfiling = frontendClient()->isProfilingJavaScript();
 
-    *isProfiling = page->inspectorController()->isRecordingUserInitiatedProfile();
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE WebInspector::toggleProfilingJavaScript()
 {
-    if (!m_webView)
-        return S_OK;
+    show();
 
-    Page* page = m_webView->page();
-    if (!page)
+    if (!frontendClient())
         return S_OK;
 
-    InspectorController* inspector = page->inspectorController();
-
-    if (inspector->isRecordingUserInitiatedProfile())
-        inspector->stopUserInitiatedProfiling();
+    if (frontendClient()->isProfilingJavaScript())
+        frontendClient()->stopProfilingJavaScript();
     else
-        inspector->startUserInitiatedProfiling();
+        frontendClient()->startProfilingJavaScript();
 
     return S_OK;
 }
@@ -218,31 +210,21 @@ HRESULT STDMETHODCALLTYPE WebInspector::isJavaScriptProfilingEnabled(BOOL* isPro
 
     *isProfilingEnabled = FALSE;
 
-    if (!m_webView)
-        return S_OK;
-
-    Page* page = m_webView->page();
-    if (!page)
+    if (!frontendClient())
         return S_OK;
 
-    *isProfilingEnabled = page->inspectorController()->profilerEnabled();
+    *isProfilingEnabled = frontendClient()->isJavaScriptProfilingEnabled();
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE WebInspector::setJavaScriptProfilingEnabled(BOOL enabled)
 {
-    if (!m_webView)
-        return S_OK;
+    show();
 
-    Page* page = m_webView->page();
-    if (!page)
+    if (!frontendClient())
         return S_OK;
 
-    if (enabled)
-        page->inspectorController()->enableProfiler();
-    else
-        page->inspectorController()->disableProfiler();
-
+    frontendClient()->setJavaScriptProfilingEnabled(enabled);
     return S_OK;
 }
 
@@ -267,30 +249,20 @@ HRESULT STDMETHODCALLTYPE WebInspector::isTimelineProfilingEnabled(BOOL* isEnabl
 
     *isEnabled = FALSE;
 
-    if (!m_webView)
-        return S_OK;
-
-    Page* page = m_webView->page();
-    if (!page)
+    if (!frontendClient())
         return S_OK;
 
-    *isEnabled = page->inspectorController()->timelineProfilerEnabled();
+    *isEnabled = frontendClient()->isTimelineProfilingEnabled();
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE WebInspector::setTimelineProfilingEnabled(BOOL enabled)
 {
-    if (!m_webView)
-        return S_OK;
+    show();
 
-    Page* page = m_webView->page();
-    if (!page)
+    if (!frontendClient())
         return S_OK;
 
-    if (enabled)
-        page->inspectorController()->startTimelineProfiler();
-    else
-        page->inspectorController()->stopTimelineProfiler();
-
+    frontendClient()->setTimelineProfilingEnabled(enabled);
     return S_OK;
 }
index e2d2fcd..4645999 100644 (file)
 #include "WebKit.h"
 #include <wtf/Noncopyable.h>
 
+class WebInspectorClient;
+class WebInspectorFrontendClient;
 class WebView;
 
 class WebInspector : public IWebInspector, public IWebInspectorPrivate {
     WTF_MAKE_NONCOPYABLE(WebInspector);
 public:
-    static WebInspector* createInstance(WebView*);
+    static WebInspector* createInstance(WebView*, WebInspectorClient*);
 
     void webViewClosed();
 
@@ -67,11 +69,14 @@ public:
     virtual HRESULT STDMETHODCALLTYPE setTimelineProfilingEnabled(BOOL);
 
 private:
-    WebInspector(WebView*);
+    WebInspector(WebView*, WebInspectorClient*);
     ~WebInspector();
 
+    WebInspectorFrontendClient* frontendClient();
+
     ULONG m_refCount;
     WebView* m_webView;
+    WebInspectorClient* m_inspectorClient;
 };
 
 #endif // !defined(WebInspector_h)
index 1141b4c..8877b83 100644 (file)
@@ -338,6 +338,7 @@ WebView::WebView()
     , m_viewWindow(0)
     , m_mainFrame(0)
     , m_page(0)
+    , m_inspectorClient(0)
     , m_hasCustomDropTarget(false)
     , m_useBackForwardList(true)
     , m_userAgentOverridden(false)
@@ -710,6 +711,7 @@ HRESULT STDMETHODCALLTYPE WebView::close()
     setUIDelegate(0);
     setFormDelegate(0);
 
+    m_inspectorClient = 0;
     if (m_webInspector)
         m_webInspector->webViewClosed();
 
@@ -2641,12 +2643,14 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame(
     if (SUCCEEDED(m_preferences->shouldUseHighResolutionTimers(&useHighResolutionTimer)))
         Settings::setShouldUseHighResolutionTimers(useHighResolutionTimer);
 
+    m_inspectorClient = new WebInspectorClient(this);
+
     Page::PageClients pageClients;
     pageClients.chromeClient = new WebChromeClient(this);
     pageClients.contextMenuClient = new WebContextMenuClient(this);
     pageClients.editorClient = new WebEditorClient(this);
     pageClients.dragClient = new WebDragClient(this);
-    pageClients.inspectorClient = new WebInspectorClient(this);
+    pageClients.inspectorClient = m_inspectorClient;
 #if ENABLE(CLIENT_BASED_GEOLOCATION)
     pageClients.geolocationClient = new WebGeolocationClient(this);
 #endif
@@ -5725,7 +5729,7 @@ bool WebView::onIMESetContext(WPARAM wparam, LPARAM)
 HRESULT STDMETHODCALLTYPE WebView::inspector(IWebInspector** inspector)
 {
     if (!m_webInspector)
-        m_webInspector.adoptRef(WebInspector::createInstance(this));
+        m_webInspector.adoptRef(WebInspector::createInstance(this, m_inspectorClient));
 
     return m_webInspector.copyRefTo(inspector);
 }
index b1d0a6c..98d7bb0 100644 (file)
@@ -1042,6 +1042,7 @@ protected:
     HWND m_viewWindow;
     WebFrame* m_mainFrame;
     WebCore::Page* m_page;
+    WebInspectorClient* m_inspectorClient;
     
     RefPtr<RefCountedHBITMAP> m_backingStoreBitmap;
     SIZE m_backingStoreSize;