Title: [103623] trunk/Source/WebCore
Revision
103623
Author
[email protected]
Date
2011-12-23 05:16:20 -0800 (Fri, 23 Dec 2011)

Log Message

Web Inspector: Migrate to native Function.prototype.bind; fix front-end compilation with the
version of compiler that respects Function.prototype.bind.
https://bugs.webkit.org/show_bug.cgi?id=75170

Reviewed by Yury Semikhatsky.

* inspector/front-end/ApplicationCacheModel.js:
* inspector/front-end/CSSKeywordCompletions.js:
(WebInspector.CSSKeywordCompletions.colors):
* inspector/front-end/CSSStyleModel.js:
* inspector/front-end/CompilerSourceMapping.js:
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMAgent.prototype.pushNodeToFrontend):
(WebInspector.DOMAgent.prototype.pushNodeByPathToFrontend):
(WebInspector.DOMAgent.prototype._dispatchWhenDocumentAvailable.onDocumentAvailable):
(WebInspector.DOMAgent.prototype._dispatchWhenDocumentAvailable):
(WebInspector.DOMAgent.prototype._loadNodeAttributes):
(WebInspector.DOMAgent.prototype.querySelector):
(WebInspector.DOMAgent.prototype.querySelectorAll):
* inspector/front-end/DebuggerModel.js:
* inspector/front-end/DebuggerPresentationModel.js:
* inspector/front-end/ExtensionAPI.js:
(injectedExtensionAPI.InspectorExtensionAPI):
(injectedExtensionAPI):
* inspector/front-end/ExtensionPanel.js:
* inspector/front-end/NetworkManager.js:
(WebInspector.NetworkManager.prototype.enableResourceTracking):
(WebInspector.NetworkManager.prototype.disableResourceTracking):
* inspector/front-end/Script.js:
* inspector/front-end/Settings.js:
* inspector/front-end/TextPrompt.js:
(WebInspector.TextPrompt.prototype.complete):
* inspector/front-end/utilities.js:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (103622 => 103623)


--- trunk/Source/WebCore/ChangeLog	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/ChangeLog	2011-12-23 13:16:20 UTC (rev 103623)
@@ -1,3 +1,39 @@
+2011-12-23  Pavel Feldman  <[email protected]>
+
+        Web Inspector: Migrate to native Function.prototype.bind; fix front-end compilation with the
+        version of compiler that respects Function.prototype.bind.
+        https://bugs.webkit.org/show_bug.cgi?id=75170
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/ApplicationCacheModel.js:
+        * inspector/front-end/CSSKeywordCompletions.js:
+        (WebInspector.CSSKeywordCompletions.colors):
+        * inspector/front-end/CSSStyleModel.js:
+        * inspector/front-end/CompilerSourceMapping.js:
+        * inspector/front-end/DOMAgent.js:
+        (WebInspector.DOMAgent.prototype.pushNodeToFrontend):
+        (WebInspector.DOMAgent.prototype.pushNodeByPathToFrontend):
+        (WebInspector.DOMAgent.prototype._dispatchWhenDocumentAvailable.onDocumentAvailable):
+        (WebInspector.DOMAgent.prototype._dispatchWhenDocumentAvailable):
+        (WebInspector.DOMAgent.prototype._loadNodeAttributes):
+        (WebInspector.DOMAgent.prototype.querySelector):
+        (WebInspector.DOMAgent.prototype.querySelectorAll):
+        * inspector/front-end/DebuggerModel.js:
+        * inspector/front-end/DebuggerPresentationModel.js:
+        * inspector/front-end/ExtensionAPI.js:
+        (injectedExtensionAPI.InspectorExtensionAPI):
+        (injectedExtensionAPI):
+        * inspector/front-end/ExtensionPanel.js:
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkManager.prototype.enableResourceTracking):
+        (WebInspector.NetworkManager.prototype.disableResourceTracking):
+        * inspector/front-end/Script.js:
+        * inspector/front-end/Settings.js:
+        * inspector/front-end/TextPrompt.js:
+        (WebInspector.TextPrompt.prototype.complete):
+        * inspector/front-end/utilities.js:
+
 2011-12-23  Leo Yang  <[email protected]>
 
         [BlackBerry] Add the BlackBerry specific pauseLoad(bool) to ResourceHandle

Modified: trunk/Source/WebCore/inspector/front-end/ApplicationCacheModel.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/ApplicationCacheModel.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/ApplicationCacheModel.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -78,7 +78,7 @@
 
     /**
      * @param {string} frameId
-     * @param {string} error
+     * @param {?Protocol.Error} error
      * @param {string} manifestURL
      */
     _manifestForFrameLoaded: function(frameId, error, manifestURL)
@@ -93,7 +93,7 @@
     },
     
     /**
-     * @param {string} error
+     * @param {?Protocol.Error} error
      * @param {Array.<ApplicationCacheAgent.FrameWithManifest>} framesWithManifests
      */
     _framesWithManifestsLoaded: function(error, framesWithManifests)

Modified: trunk/Source/WebCore/inspector/front-end/CSSKeywordCompletions.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/CSSKeywordCompletions.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/CSSKeywordCompletions.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -49,9 +49,9 @@
 
 WebInspector.CSSKeywordCompletions.colors = function()
 {
-    if (!this._colorsKeySet)
-        this._colorsKeySet = this._colors.keySet();
-    return this._colorsKeySet;
+    if (!WebInspector.CSSKeywordCompletions._colorsKeySet)
+        WebInspector.CSSKeywordCompletions._colorsKeySet = WebInspector.CSSKeywordCompletions._colors.keySet();
+    return WebInspector.CSSKeywordCompletions._colorsKeySet;
 }
 
 // Taken from http://www.w3.org/TR/CSS21/propidx.html.

Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -65,9 +65,9 @@
         /**
          * @param {function(?*)} userCallback
          * @param {?Protocol.Error} error
-         * @param {?Array.<CSSAgent.CSSRule>} matchedPayload
-         * @param {?Array.<CSSAgent.PseudoIdRules>} pseudoPayload
-         * @param {?Array.<CSSAgent.InheritedStyleEntry>} inheritedPayload
+         * @param {Array.<CSSAgent.CSSRule>=} matchedPayload
+         * @param {Array.<CSSAgent.PseudoIdRules>=} pseudoPayload
+         * @param {Array.<CSSAgent.InheritedStyleEntry>=} inheritedPayload
          */
         function callback(userCallback, error, matchedPayload, pseudoPayload, inheritedPayload)
         {

Modified: trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -72,7 +72,7 @@
  * @implements {WebInspector.CompilerSourceMapping}
  * @constructor
  * @param {string} sourceMappingURL
- * @param {string} sourceURL
+ * @param {string} scriptSourceOrigin
  */
 WebInspector.ClosureCompilerSourceMapping = function(sourceMappingURL, scriptSourceOrigin)
 {

Modified: trunk/Source/WebCore/inspector/front-end/DOMAgent.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -589,7 +589,7 @@
      */
     pushNodeToFrontend: function(objectId, callback)
     {
-        this._dispatchWhenDocumentAvailable(DOMAgent.requestNode.bind(DOMAgent), objectId, callback);
+        this._dispatchWhenDocumentAvailable(DOMAgent.requestNode.bind(DOMAgent, objectId), callback);
     },
 
     /**
@@ -598,7 +598,8 @@
      */
     pushNodeByPathToFrontend: function(path, callback)
     {
-        this._dispatchWhenDocumentAvailable(DOMAgent.pushNodeByPathToFrontend.bind(DOMAgent), path, callback);
+        var callbackCast = /** @type {function(*)} */ callback;
+        this._dispatchWhenDocumentAvailable(DOMAgent.pushNodeByPathToFrontend.bind(DOMAgent, path), callbackCast);
     },
 
     /**
@@ -618,18 +619,17 @@
     },
 
     /**
-     * @param {function(*, function()=)} func
-     * @param {*} arg
-     * @param {function()=} callback
+     * @param {function(function()=)} func
+     * @param {function(*)=} callback
      */
-    _dispatchWhenDocumentAvailable: function(func, arg, callback)
+    _dispatchWhenDocumentAvailable: function(func, callback)
     {
-        var callbackWrapper = this._wrapClientCallback(callback);
+        var callbackWrapper = /** @type {function(?Protocol.Error, *=)} */ this._wrapClientCallback(callback);
 
         function onDocumentAvailable()
         {
             if (this._document)
-                func.call(null, arg, callbackWrapper);
+                func(callbackWrapper);
             else {
                 if (callbackWrapper)
                     callbackWrapper("No document");
@@ -682,12 +682,15 @@
         /**
          * @this {WebInspector.DOMAgent}
          * @param {DOMAgent.NodeId} nodeId
+         * @param {?Protocol.Error} error
          * @param {Array.<string>} attributes
          */
-        function callback(nodeId, attributes)
+        function callback(nodeId, error, attributes)
         {
-            if (!attributes)
+            if (error) {
+                console.error("Error during DOMAgent operation: " + error);
                 return;
+            }
             var node = this._idToDOMNode[nodeId];
             if (node) {
                 node._setAttributesPayload(attributes);
@@ -698,8 +701,10 @@
 
         delete this._loadNodeAttributesTimeout;
 
-        for (var nodeId in this._attributeLoadNodeIds)
-            DOMAgent.getAttributes(parseInt(nodeId, 10), this._wrapClientCallback(callback.bind(this, nodeId)));
+        for (var nodeId in this._attributeLoadNodeIds) {
+            var nodeIdAsNumber = parseInt(nodeId, 10);
+            DOMAgent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeIdAsNumber));
+        }
         this._attributeLoadNodeIds = {};
     },
 
@@ -890,21 +895,23 @@
     /**
      * @param {DOMAgent.NodeId} nodeId
      * @param {string} selectors
-     * @param {function(*)=} callback
+     * @param {function(?DOMAgent.NodeId)=} callback
      */
     querySelector: function(nodeId, selectors, callback)
     {
-        DOMAgent.querySelector(nodeId, selectors, this._wrapClientCallback(callback));
+        var callbackCast = /** @type {function(*)|undefined} */callback;
+        DOMAgent.querySelector(nodeId, selectors, this._wrapClientCallback(callbackCast));
     },
 
     /**
      * @param {DOMAgent.NodeId} nodeId
      * @param {string} selectors
-     * @param {function(*)=} callback
+     * @param {function(?Array.<DOMAgent.NodeId>)=} callback
      */
     querySelectorAll: function(nodeId, selectors, callback)
     {
-        DOMAgent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(callback));
+        var callbackCast = /** @type {function(*)|undefined} */callback;
+        DOMAgent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(callbackCast));
     },
 
     /**

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


--- trunk/Source/WebCore/inspector/front-end/DebuggerModel.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerModel.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -145,7 +145,7 @@
      * @param {number} lineNumber
      * @param {number=} columnNumber
      * @param {string=} condition
-     * @param {function(?DebuggerAgent.BreakpointId, Array.<DebuggerAgent.Location>)=} callback
+     * @param {function(?DebuggerAgent.BreakpointId, Array.<DebuggerAgent.Location>=)=} callback
      */
     setBreakpoint: function(url, lineNumber, columnNumber, condition, callback)
     {
@@ -162,7 +162,7 @@
          * @this {WebInspector.DebuggerModel}
          * @param {?Protocol.Error} error
          * @param {DebuggerAgent.BreakpointId} breakpointId
-         * @param {Array.<DebuggerAgent.Location>} locations
+         * @param {Array.<DebuggerAgent.Location>=} locations
          */
         function didSetBreakpoint(error, breakpointId, locations)
         {
@@ -274,7 +274,7 @@
      * @param {string} newSource
      * @param {function(?Protocol.Error)} callback
      * @param {?Protocol.Error} error
-     * @param {Array.<DebuggerAgent.CallFrame>} callFrames
+     * @param {Array.<DebuggerAgent.CallFrame>=} callFrames
      */
     _didEditScriptSource: function(scriptId, newSource, callback, error, callFrames)
     {

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


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -755,7 +755,7 @@
      * @param {string} objectGroup
      * @param {boolean} includeCommandLineAPI
      * @param {boolean} returnByValue
-     * @param {function(?RuntimeAgent.RemoteObject, boolean)=} callback
+     * @param {function(?RuntimeAgent.RemoteObject, boolean=)=} callback
      */
     evaluate: function(code, objectGroup, includeCommandLineAPI, returnByValue, callback)
     {
@@ -763,7 +763,7 @@
          * @this {WebInspector.PresentationCallFrame}
          * @param {?Protocol.Error} error
          * @param {RuntimeAgent.RemoteObject} result
-         * @param {boolean} wasThrown
+         * @param {boolean=} wasThrown
          */
         function didEvaluateOnCallFrame(error, result, wasThrown)
         {

Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -169,7 +169,7 @@
     this.network = new Network();
     defineDeprecatedProperty(this, "webInspector", "resources", "network");
     this.timeline = new Timeline();
-    this.console = new Console();
+    this.console = new ConsoleAPI();
 
     this._onReset_ = new EventSink(events.Reset);
 }
@@ -187,12 +187,12 @@
 /**
  * @constructor
  */
-function Console()
+function ConsoleAPI()
 {
     this._onMessageAdded_ = new EventSink(events.ConsoleMessageAdded);
 }
 
-Console.prototype = {
+ConsoleAPI.prototype = {
     getMessages: function(callback)
     {
         extensionServer.sendRequest({ command: commands.GetConsoleMessages }, callback);
@@ -810,7 +810,7 @@
 }
 
 // Default implementation; platforms will override.
-function buildPlatformExtensionAPI()
+function buildPlatformExtensionAPI(extensionInfo)
 {
     function platformExtensionAPI(coreAPI)
     {

Modified: trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -277,9 +277,9 @@
     /**
      * @param {string} title
      * @param {function(?string=)} callback
-     * @param {Protocol.Error} error
-     * @param {Object} result
-     * @param {boolean} wasThrown
+     * @param {?Protocol.Error} error
+     * @param {RuntimeAgent.RemoteObject} result
+     * @param {boolean=} wasThrown
      */
     _onEvaluate: function(title, callback, error, result, wasThrown)
     {

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotWorker.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotWorker.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotWorker.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -31,19 +31,6 @@
 WebInspector = {};
 WebInspector.UIString = function(s) { return s; };
 
-// Safari lacks 'bind'.
-if (!("bind" in Function.prototype)) {
-    Function.prototype.bind = function(thisObject)
-    {
-        var func = this;
-        var args = Array.prototype.slice.call(arguments, 1);
-        return function bound()
-        {
-            return func.apply(thisObject, args.concat(Array.prototype.slice.call(arguments, 0)));
-        };
-    };
-}
-
 importScripts("BinarySearch.js");
 importScripts("HeapSnapshot.js");
 importScripts("HeapSnapshotWorkerDispatcher.js");

Modified: trunk/Source/WebCore/inspector/front-end/NetworkManager.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/NetworkManager.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/NetworkManager.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -77,14 +77,20 @@
 
     enableResourceTracking: function()
     {
-        var networkAgentEnabled = this.dispatchEventToListeners.bind(this, WebInspector.NetworkManager.EventTypes.ResourceTrackingEnabled);
-        NetworkAgent.enable(networkAgentEnabled);
+        function callback(error)
+        {
+            this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceTrackingEnabled);
+        }
+        NetworkAgent.enable(callback.bind(this));
     },
 
     disableResourceTracking: function()
     {
-        var networkAgentDisabled = this.dispatchEventToListeners.bind(this, WebInspector.NetworkManager.EventTypes.ResourceTrackingDisabled);
-        NetworkAgent.disable(networkAgentDisabled);
+        function callback(error)
+        {
+            this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceTrackingDisabled);
+        }
+        NetworkAgent.disable(callback.bind(this));
     },
 
     inflightResourceForURL: function(url)

Modified: trunk/Source/WebCore/inspector/front-end/Script.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/Script.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/Script.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -32,6 +32,7 @@
  * @param {number} endLine
  * @param {number} endColumn
  * @param {boolean} isContentScript
+ * @param {string=} sourceMapURL
  */
 WebInspector.Script = function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL)
 {

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


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -44,7 +44,8 @@
     exposeWorkersInspection: false,
     applicationTitle: "Web Inspector - %s",
     // FIXME: Remove once navigator is production-ready.
-    useScriptNavigator: false
+    useScriptNavigator: false,
+    showHeapSnapshotObjectsHiddenProperties: false
 }
 
 var Capabilities = {

Modified: trunk/Source/WebCore/inspector/front-end/TextPrompt.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/TextPrompt.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/TextPrompt.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -30,7 +30,7 @@
 /**
  * @constructor
  * @extends WebInspector.Object
- * @param {function(Range, boolean, function(*))} completions
+ * @param {function(Range, boolean, function(Array.<string>=))} completions
  * @param {string} stopCharacters
  */
 WebInspector.TextPrompt = function(completions, stopCharacters)
@@ -365,7 +365,7 @@
         }
 
         var wordPrefixRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, this._completionStopCharacters, this._element, "backward");
-        this._loadCompletions(wordPrefixRange, force, this._completionsReady.bind(this, selection, auto, wordPrefixRange, reverse));
+        this._loadCompletions(wordPrefixRange, force, this._completionsReady.bind(this, selection, auto, wordPrefixRange, !!reverse));
     },
 
     _boxForAnchorAtStart: function(selection, textRange)
@@ -382,6 +382,10 @@
     },
 
     /**
+     * @param {Selection} selection
+     * @param {boolean} auto
+     * @param {Range} originalWordPrefixRange
+     * @param {boolean} reverse
      * @param {Array.<string>=} completions
      */
     _completionsReady: function(selection, auto, originalWordPrefixRange, reverse, completions)
@@ -672,7 +676,7 @@
 /**
  * @constructor
  * @extends {WebInspector.TextPrompt}
- * @param {function(Range, boolean, function(*))} completions
+ * @param {function(Range, boolean, function(Array.<string>=))} completions
  * @param {string} stopCharacters
  */
 WebInspector.TextPromptWithHistory = function(completions, stopCharacters)

Modified: trunk/Source/WebCore/inspector/front-end/utilities.js (103622 => 103623)


--- trunk/Source/WebCore/inspector/front-end/utilities.js	2011-12-23 12:49:31 UTC (rev 103622)
+++ trunk/Source/WebCore/inspector/front-end/utilities.js	2011-12-23 13:16:20 UTC (rev 103623)
@@ -29,20 +29,6 @@
  * http://ejohn.org/files/jsdiff.js (released under the MIT license).
  */
 
-Function.prototype.bind = function(thisObject)
-{
-    var func = this;
-    var args = Array.prototype.slice.call(arguments, 1);
-    function bound()
-    {
-        return func.apply(thisObject, args.concat(Array.prototype.slice.call(arguments, 0)));
-    }
-    bound.toString = function() {
-        return "bound: " + func;
-    };
-    return bound;
-}
-
 /**
  * @param {string=} direction
  */
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to