Title: [100572] trunk/Source
Revision
100572
Author
[email protected]
Date
2011-11-17 00:16:44 -0800 (Thu, 17 Nov 2011)

Log Message

Web Inspector: introduce Debugger domain capabilities concept.
https://bugs.webkit.org/show_bug.cgi?id=72393

Many of the Preferences that we have in Settings.js and override in DevTools.js
are really not preferences, but capabilities. Protocol clients should have a way
of figuring out whether some capability is present before using it.

Reviewed by Yury Semikhatsky.

Source/WebCore:

* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::canSetScriptSource):
* bindings/js/ScriptDebugServer.h:
* bindings/v8/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::canSetScriptSource):
* bindings/v8/ScriptDebugServer.h:
* inspector/CodeGeneratorInspector.py:
* inspector/Inspector.json:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::getCapabilities):
* inspector/InspectorDebuggerAgent.h:
* inspector/front-end/DebuggerModel.js:
(WebInspector.DebuggerModel):
(WebInspector.DebuggerModel.prototype.enableDebugger):
(WebInspector.DebuggerModel.prototype.canSetScriptSource):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.canEditScriptSource):
* inspector/front-end/Settings.js:

Source/WebKit/chromium:

* src/js/DevTools.js:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (100571 => 100572)


--- trunk/Source/WebCore/ChangeLog	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/ChangeLog	2011-11-17 08:16:44 UTC (rev 100572)
@@ -1,3 +1,33 @@
+2011-11-15  Pavel Feldman  <[email protected]>
+
+        Web Inspector: introduce Debugger domain capabilities concept.
+        https://bugs.webkit.org/show_bug.cgi?id=72393
+
+        Many of the Preferences that we have in Settings.js and override in DevTools.js
+        are really not preferences, but capabilities. Protocol clients should have a way
+        of figuring out whether some capability is present before using it.
+
+        Reviewed by Yury Semikhatsky.
+
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::canSetScriptSource):
+        * bindings/js/ScriptDebugServer.h:
+        * bindings/v8/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::canSetScriptSource):
+        * bindings/v8/ScriptDebugServer.h:
+        * inspector/CodeGeneratorInspector.py:
+        * inspector/Inspector.json:
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::getCapabilities):
+        * inspector/InspectorDebuggerAgent.h:
+        * inspector/front-end/DebuggerModel.js:
+        (WebInspector.DebuggerModel):
+        (WebInspector.DebuggerModel.prototype.enableDebugger):
+        (WebInspector.DebuggerModel.prototype.canSetScriptSource):
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype.canEditScriptSource):
+        * inspector/front-end/Settings.js:
+
 2011-11-17  Mihnea Ovidenie  <[email protected]>
 
         CSS exclusions: parse the wrap-flow and wrap-through properties

Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp (100571 => 100572)


--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2011-11-17 08:16:44 UTC (rev 100572)
@@ -191,6 +191,11 @@
     m_doneProcessingDebuggerEvents = true;
 }
 
+bool ScriptDebugServer::canSetScriptSource()
+{
+    return false;
+}
+
 bool ScriptDebugServer::setScriptSource(const String&, const String&, bool, String*, ScriptValue*, ScriptObject*)
 {
     // FIXME(40300): implement this.

Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.h (100571 => 100572)


--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.h	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.h	2011-11-17 08:16:44 UTC (rev 100572)
@@ -42,6 +42,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
 #include <wtf/text/TextPosition.h>
 
 namespace JSC {
@@ -80,6 +81,7 @@
     void stepOverStatement();
     void stepOutOfFunction();
 
+    bool canSetScriptSource();
     bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, ScriptValue* newCallFrames, ScriptObject* result);
 
     void recompileAllJSFunctionsSoon();

Modified: trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp (100571 => 100572)


--- trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp	2011-11-17 08:16:44 UTC (rev 100572)
@@ -40,6 +40,7 @@
 #include "V8Binding.h"
 #include "V8JavaScriptCallFrame.h"
 #include <wtf/StdLibExtras.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
@@ -213,6 +214,11 @@
     continueProgram();
 }
 
+bool ScriptDebugServer::canSetScriptSource()
+{
+    return true;
+}
+
 bool ScriptDebugServer::setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, ScriptValue* newCallFrames, ScriptObject* result)
 {
     ensureDebuggerScriptCompiled();

Modified: trunk/Source/WebCore/bindings/v8/ScriptDebugServer.h (100571 => 100572)


--- trunk/Source/WebCore/bindings/v8/ScriptDebugServer.h	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/bindings/v8/ScriptDebugServer.h	2011-11-17 08:16:44 UTC (rev 100572)
@@ -41,6 +41,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
@@ -74,6 +75,7 @@
     void stepOverStatement();
     void stepOutOfFunction();
 
+    bool canSetScriptSource();
     bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, ScriptValue* newCallFrames, ScriptObject* result);
 
     void recompileAllJSFunctionsSoon() { }

Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.py (100571 => 100572)


--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2011-11-17 08:16:44 UTC (rev 100572)
@@ -59,6 +59,9 @@
     exit(1)
 
 
+def dash_to_camelcase(word):
+    return ''.join(x.capitalize() or '-' for x in word.split('-'))
+
 def parse_defines(str):
     if not str:
         return {}
@@ -422,7 +425,7 @@
 class Templates:
     frontend_domain_class = string.Template(
 """    class $domainClassName {
-    public:
+    public:$domainCapabilities
         $domainClassName(InspectorFrontendChannel* inspectorFrontendChannel) : m_inspectorFrontendChannel(inspectorFrontendChannel) { }
 ${frontendDomainMethodDeclarations}        void setInspectorFrontendChannel(InspectorFrontendChannel* inspectorFrontendChannel) { m_inspectorFrontendChannel = inspectorFrontendChannel; }
         InspectorFrontendChannel* getInspectorFrontendChannel() { return m_inspectorFrontendChannel; }
@@ -913,8 +916,8 @@
 
 namespace WebCore {
 
+$capabilities
 
-
 InspectorFrontend::InspectorFrontend(InspectorFrontendChannel* inspectorFrontendChannel)
     : m_inspectorFrontendChannel(inspectorFrontendChannel)
 $constructorInit{
@@ -940,7 +943,7 @@
     this._domainDispatchers = {};
     this._eventArgs = {};
     this._replyArgs = {};
-$delegates$eventArgs$replyArgs$domainDispatchers}
+$delegates$eventArgs$replyArgs$domainDispatchers$capabilities}
 
 InspectorBackendStub.prototype = {
     dumpInspectorTimeStats: 0,
@@ -1182,7 +1185,6 @@
 
 type_map = TypeMap(json_api)
 
-
 class Generator:
     frontend_class_field_lines = []
     frontend_domain_class_lines = []
@@ -1197,6 +1199,7 @@
     backend_js_event_list = []
     backend_js_reply_list = []
     backend_js_domain_dispatcher_list = []
+    backend_js_capabilities_list = []
 
     backend_constructor_param_list = []
     backend_constructor_init_list = []
@@ -1204,6 +1207,7 @@
     backend_forward_list = []
     backend_include_list = []
     frontend_constructor_init_list = []
+    frontend_capabilities_constants_list = []
 
     @staticmethod
     def go():
@@ -1219,16 +1223,27 @@
             agent_field_name = domain_data.agent_field_name
 
             frontend_method_declaration_lines = []
+            domain_capabilities = []
+            if "capabilities" in json_domain:
+                for json_capability in json_domain["capabilities"]:
+                    name = json_capability["name"]
+                    capability_variable_name = "capability%s" % dash_to_camelcase(name)
+                    domain_capabilities.append("\n        static const char* %s;" % capability_variable_name)
+                    Generator.frontend_capabilities_constants_list.append("const char* InspectorFrontend::%s::%s = \"%s\";" % (domain_name, capability_variable_name, name))
+                    Generator.backend_js_capabilities_list.append("    %sAgent.%s = \"%s\";\n" % (domain_name, capability_variable_name, name))
+
             if "events" in json_domain:
                 for json_event in json_domain["events"]:
                     Generator.process_event(json_event, domain_name, frontend_method_declaration_lines)
 
-                Generator.frontend_class_field_lines.append("    %s m_%s;\n" % (domain_name, domain_name_lower))
-                Generator.frontend_constructor_init_list.append("    , m_%s(inspectorFrontendChannel)\n" % domain_name_lower)
-                Generator.frontend_domain_class_lines.append(Templates.frontend_domain_class.substitute(None,
-                    domainClassName=domain_name,
-                    domainFieldName=domain_name_lower,
-                    frontendDomainMethodDeclarations=join(frontend_method_declaration_lines, "")))
+            Generator.frontend_class_field_lines.append("    %s m_%s;\n" % (domain_name, domain_name_lower))
+            Generator.frontend_constructor_init_list.append("    , m_%s(inspectorFrontendChannel)\n" % domain_name_lower)
+            Generator.frontend_domain_class_lines.append(Templates.frontend_domain_class.substitute(None,
+                domainClassName=domain_name,
+                domainFieldName=domain_name_lower,
+                domainCapabilities=join(domain_capabilities, "\n"),
+                frontendDomainMethodDeclarations=join(frontend_method_declaration_lines, "")))
+
             if "commands" in json_domain:
                 for json_command in json_domain["commands"]:
                     Generator.process_command(json_command, domain_name, agent_field_name)
@@ -1390,7 +1405,6 @@
 
         Generator.backend_js_initializer_list.append("    this._registerDelegate('{\"method\": \"%s.%s\"%s, \"id\": 0}');\n" % (domain_name, json_command_name, js_parameters_text))
 
-
 Generator.go()
 
 backend_h_file = open(output_header_dirname + "/InspectorBackendDispatcher.h", "w")
@@ -1416,7 +1430,8 @@
 
 frontend_cpp_file.write(Templates.frontend_cpp.substitute(None,
     constructorInit=join(Generator.frontend_constructor_init_list, ""),
-    methods=join(Generator.frontend_method_list, "\n")))
+    methods=join(Generator.frontend_method_list, "\n"),
+    capabilities=join(Generator.frontend_capabilities_constants_list, "\n")))
 
 backend_cpp_file.write(Templates.backend_cpp.substitute(None,
     methodNameDeclarations=join(Generator.backend_method_name_declaration_list, "\n"),
@@ -1428,7 +1443,8 @@
     delegates=join(Generator.backend_js_initializer_list, ""),
     replyArgs=join(Generator.backend_js_reply_list, ""),
     eventArgs=join(Generator.backend_js_event_list, ""),
-    domainDispatchers=join(Generator.backend_js_domain_dispatcher_list, "")))
+    domainDispatchers=join(Generator.backend_js_domain_dispatcher_list, ""),
+    capabilities=join(Generator.backend_js_capabilities_list, "")))
 
 backend_h_file.close()
 backend_cpp_file.close()

Modified: trunk/Source/WebCore/inspector/Inspector.json (100571 => 100572)


--- trunk/Source/WebCore/inspector/Inspector.json	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/inspector/Inspector.json	2011-11-17 08:16:44 UTC (rev 100572)
@@ -1741,6 +1741,9 @@
     {
         "domain": "Debugger",
         "description": "Debugger domain exposes _javascript_ debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.",
+        "capabilities": [
+            { "name": "set-script-source", "description": "Allows setting script source live" }
+        ],
         "types": [
             {
                 "id": "BreakpointId",
@@ -1791,8 +1794,16 @@
         ],
         "commands": [
             {
+                "name": "getCapabilities",
+                "returns": [
+                    { "name": "capabilities", "type": "array", "items": { "type": "string"}, "description": "List of the debugger domain capabilities" }
+                ],
+                "description": "Returns the list of the debugger capabilities.",
+                "hidden": true
+            },
+            {
                 "name": "enable",
-                "description": "Enables debugger for given page."
+                "description": "Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received."
             },
             {
                 "name": "disable",
@@ -1890,6 +1901,7 @@
                     { "name": "callFrames", "type": "array", "optional": true, "items": { "$ref": "CallFrame"}, "description": "New stack trace in case editing has happened while VM was stopped." },
                     { "name": "result", "type": "object", "optional": true, "description": "VM-specific description of the changes applied.", "hidden": true }
                 ],
+                "capability": "set-script-source",
                 "description": "Edits _javascript_ source live."
             },
             {

Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (100571 => 100572)


--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2011-11-17 08:16:44 UTC (rev 100572)
@@ -100,6 +100,12 @@
     return m_inspectorState->getBoolean(DebuggerAgentState::debuggerEnabled);
 }
 
+void InspectorDebuggerAgent::getCapabilities(ErrorString*, RefPtr<InspectorArray>* capabilities)
+{
+    if (scriptDebugServer().canSetScriptSource())
+        (*capabilities)->pushString(InspectorFrontend::Debugger::capabilitySetScriptSource);
+}
+
 void InspectorDebuggerAgent::enable(ErrorString*)
 {
     if (enabled())

Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h (100571 => 100572)


--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h	2011-11-17 08:16:44 UTC (rev 100572)
@@ -64,6 +64,7 @@
 
     virtual ~InspectorDebuggerAgent();
 
+    void getCapabilities(ErrorString*, RefPtr<InspectorArray>*);
     void enable(ErrorString*);
     void disable(ErrorString*);
     bool enabled();

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerModel.js (100571 => 100572)


--- trunk/Source/WebCore/inspector/front-end/DebuggerModel.js	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerModel.js	2011-11-17 08:16:44 UTC (rev 100572)
@@ -40,6 +40,8 @@
      */
     this._scripts = {};
 
+    this._capabilitiesObject = {};
+
     InspectorBackend.registerDebuggerDispatcher(new WebInspector.DebuggerDispatcher(this));
 }
 
@@ -85,6 +87,16 @@
 WebInspector.DebuggerModel.prototype = {
     enableDebugger: function()
     {
+        /**
+         * @param {Protocol.Error} error
+         * @param {Array.<string>} capabilities
+         */
+        function callback(error, capabilities)
+        {
+            for (var i = 0; i < capabilities.length; ++i)
+                this._capabilitiesObject[capabilities[i]] = true;
+        }
+        DebuggerAgent.getCapabilities(callback.bind(this));
         DebuggerAgent.enable();
     },
 
@@ -93,6 +105,14 @@
         DebuggerAgent.disable();
     },
 
+    /**
+     * @return {boolean}
+     */
+    canSetScriptSource: function()
+    {
+        return !!this._capabilitiesObject[DebuggerAgent.capabilitySetScriptSource];
+    },
+
     _debuggerWasEnabled: function()
     {
         this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerWasEnabled);

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (100571 => 100572)


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-11-17 08:16:44 UTC (rev 100572)
@@ -246,7 +246,7 @@
      */
     canEditScriptSource: function(uiSourceCode)
     {
-        if (!Preferences.canEditScriptSource || this._formatSource)
+        if (!WebInspector.debuggerModel.canSetScriptSource() || this._formatSource)
             return false;
         var rawSourceCode = uiSourceCode.rawSourceCode;
         var script = this._scriptForRawSourceCode(rawSourceCode);

Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (100571 => 100572)


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2011-11-17 08:16:44 UTC (rev 100572)
@@ -30,7 +30,6 @@
 
 
 var Preferences = {
-    canEditScriptSource: false,
     maxInlineTextChildLength: 80,
     minConsoleHeight: 75,
     minSidebarWidth: 100,

Modified: trunk/Source/WebKit/chromium/ChangeLog (100571 => 100572)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-11-17 08:16:44 UTC (rev 100572)
@@ -1,3 +1,16 @@
+2011-11-15  Pavel Feldman  <[email protected]>
+
+        Web Inspector: introduce Debugger domain capabilities concept.
+        https://bugs.webkit.org/show_bug.cgi?id=72393
+
+        Many of the Preferences that we have in Settings.js and override in DevTools.js
+        are really not preferences, but capabilities. Protocol clients should have a way
+        of figuring out whether some capability is present before using it.
+
+        Reviewed by Yury Semikhatsky.
+
+        * src/js/DevTools.js:
+
 2011-11-11  Adrienne Walker  <[email protected]>
 
         [chromium] Expose mock scrollbars to window.internals

Modified: trunk/Source/WebKit/chromium/src/js/DevTools.js (100571 => 100572)


--- trunk/Source/WebKit/chromium/src/js/DevTools.js	2011-11-17 08:10:07 UTC (rev 100571)
+++ trunk/Source/WebKit/chromium/src/js/DevTools.js	2011-11-17 08:16:44 UTC (rev 100572)
@@ -40,7 +40,6 @@
     Preferences.detailedHeapProfiles = true;
     Preferences.debuggerAlwaysEnabled = true;
     Preferences.profilerAlwaysEnabled = true;
-    Preferences.canEditScriptSource = true;
     Preferences._onlineDetectionEnabled_ = false;
     Preferences.nativeInstrumentationEnabled = true;
     Preferences.fileSystemEnabled = false;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to