Web Inspector: make SourceFrame compile.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 17:19:04 +0000 (17:19 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 17:19:04 +0000 (17:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69345

Reviewed by Yury Semikhatsky.

* inspector/compile-front-end.sh:
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMAgent.prototype.inspectElement):
(WebInspector.DOMDispatcher.prototype.inspectElementRequested):
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype._inspectElementRequested):
* inspector/front-end/ObjectPropertiesSection.js:
(WebInspector.ObjectPropertyTreeElement.prototype._contextMenuEventFired):
(WebInspector.ObjectPropertyTreeElement.prototype.startEditing):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype._applyDiffMarkup):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype._onShowPopover.showObjectPopover):
(WebInspector.SourceFrame.prototype._onShowPopover):
(WebInspector.SourceFrame.prototype._editBreakpointCondition):
(WebInspector.SourceFrame.prototype.startEditing):
(WebInspector.SourceFrame.prototype.commitEditing.didEditContent):
(WebInspector.SourceFrame.prototype.commitEditing):
(WebInspector.SourceFrameDelegate.prototype.requestContent):
(WebInspector.SourceFrameDelegate.prototype.debuggingSupported):
(WebInspector.SourceFrameDelegate.prototype.setBreakpoint):
(WebInspector.SourceFrameDelegate.prototype.removeBreakpoint):
(WebInspector.SourceFrameDelegate.prototype.updateBreakpoint):
(WebInspector.SourceFrameDelegate.prototype.findBreakpoint):
(WebInspector.SourceFrameDelegate.prototype.continueToLine):
(WebInspector.SourceFrameDelegate.prototype.canEditScriptSource):
(WebInspector.SourceFrameDelegate.prototype.setScriptSource):
(WebInspector.SourceFrameDelegate.prototype.setScriptSourceIsBeingEdited):
(WebInspector.SourceFrameDelegate.prototype.debuggerPaused):
(WebInspector.SourceFrameDelegate.prototype.evaluateInSelectedCallFrame):
(WebInspector.SourceFrameDelegate.prototype.releaseEvaluationResult):
(WebInspector.SourceFrameDelegate.prototype.suggestedFileName):
* inspector/front-end/externs.js:
(WebInspector.log):
* inspector/front-end/inspector.js:
(WebInspector.log.logMessage):
(WebInspector.log):
* inspector/front-end/utilities.js:
():

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/compile-front-end.sh
Source/WebCore/inspector/front-end/DOMAgent.js
Source/WebCore/inspector/front-end/ElementsPanel.js
Source/WebCore/inspector/front-end/ObjectPopoverHelper.js
Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
Source/WebCore/inspector/front-end/ResourcesPanel.js
Source/WebCore/inspector/front-end/SourceFrame.js
Source/WebCore/inspector/front-end/externs.js
Source/WebCore/inspector/front-end/inspector.js
Source/WebCore/inspector/front-end/utilities.js

index 72f8176..1221423 100644 (file)
@@ -1,3 +1,50 @@
+2011-10-04  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: make SourceFrame compile.
+        https://bugs.webkit.org/show_bug.cgi?id=69345
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/compile-front-end.sh:
+        * inspector/front-end/DOMAgent.js:
+        (WebInspector.DOMAgent.prototype.inspectElement):
+        (WebInspector.DOMDispatcher.prototype.inspectElementRequested):
+        * inspector/front-end/ElementsPanel.js:
+        (WebInspector.ElementsPanel.prototype._inspectElementRequested):
+        * inspector/front-end/ObjectPropertiesSection.js:
+        (WebInspector.ObjectPropertyTreeElement.prototype._contextMenuEventFired):
+        (WebInspector.ObjectPropertyTreeElement.prototype.startEditing):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype._applyDiffMarkup):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype._onShowPopover.showObjectPopover):
+        (WebInspector.SourceFrame.prototype._onShowPopover):
+        (WebInspector.SourceFrame.prototype._editBreakpointCondition):
+        (WebInspector.SourceFrame.prototype.startEditing):
+        (WebInspector.SourceFrame.prototype.commitEditing.didEditContent):
+        (WebInspector.SourceFrame.prototype.commitEditing):
+        (WebInspector.SourceFrameDelegate.prototype.requestContent):
+        (WebInspector.SourceFrameDelegate.prototype.debuggingSupported):
+        (WebInspector.SourceFrameDelegate.prototype.setBreakpoint):
+        (WebInspector.SourceFrameDelegate.prototype.removeBreakpoint):
+        (WebInspector.SourceFrameDelegate.prototype.updateBreakpoint):
+        (WebInspector.SourceFrameDelegate.prototype.findBreakpoint):
+        (WebInspector.SourceFrameDelegate.prototype.continueToLine):
+        (WebInspector.SourceFrameDelegate.prototype.canEditScriptSource):
+        (WebInspector.SourceFrameDelegate.prototype.setScriptSource):
+        (WebInspector.SourceFrameDelegate.prototype.setScriptSourceIsBeingEdited):
+        (WebInspector.SourceFrameDelegate.prototype.debuggerPaused):
+        (WebInspector.SourceFrameDelegate.prototype.evaluateInSelectedCallFrame):
+        (WebInspector.SourceFrameDelegate.prototype.releaseEvaluationResult):
+        (WebInspector.SourceFrameDelegate.prototype.suggestedFileName):
+        * inspector/front-end/externs.js:
+        (WebInspector.log):
+        * inspector/front-end/inspector.js:
+        (WebInspector.log.logMessage):
+        (WebInspector.log):
+        * inspector/front-end/utilities.js:
+        ():
+
 2011-10-04  Mikhail Naganov  <mnaganov@chromium.org>
 
         Web Inspector: Factor out object properties popup.
index 71fd91a..c62bbaf 100755 (executable)
@@ -93,8 +93,11 @@ java -jar ~/closure/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --warn
         --js Source/WebCore/inspector/front-end/Toolbar.js \
         --js Source/WebCore/inspector/front-end/UIUtils.js \
         --js Source/WebCore/inspector/front-end/View.js \
-    --module jsmodule_inspector:4:jsmodule_sdk,jsmodule_ui \
+    --module jsmodule_inspector:7:jsmodule_sdk,jsmodule_ui \
         --js Source/WebCore/inspector/front-end/ConsoleMessage.js \
         --js Source/WebCore/inspector/front-end/ConsoleView.js \
         --js Source/WebCore/inspector/front-end/JavaScriptContextManager.js \
+        --js Source/WebCore/inspector/front-end/ObjectPopoverHelper.js \
+        --js Source/WebCore/inspector/front-end/ObjectPropertiesSection.js \
+        --js Source/WebCore/inspector/front-end/SourceFrame.js \
         --js Source/WebCore/inspector/front-end/TimelineManager.js
index 6b6fc89..bb411a2 100644 (file)
@@ -617,7 +617,7 @@ WebInspector.DOMAgent.prototype = {
         delete this._idToDOMNode[nodeId];
     },
 
-    _inspectElementRequested: function(nodeId)
+    inspectElement: function(nodeId)
     {
         var node = this._idToDOMNode[nodeId];
         if (node)
@@ -704,11 +704,6 @@ WebInspector.DOMDispatcher.prototype = {
         this._domAgent._childNodeRemoved(parentId, nodeId);
     },
 
-    inspectElementRequested: function(nodeId)
-    {
-        this._domAgent._inspectElementRequested(nodeId);
-    },
-
     searchResults: function(nodeIds)
     {
         if (this._domAgent._searchResultCollector)
index 348b611..748dec4 100644 (file)
@@ -446,8 +446,9 @@ WebInspector.ElementsPanel.prototype = {
             treeElement.hasChildren = event.data.hasChildNodes();
     },
 
-    _inspectElementRequested: function(node)
+    _inspectElementRequested: function(event)
     {
+        var node = event.data;
         WebInspector.updateFocusedNode(node.id);
     },
 
index 5f91ae5..f95064c 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @constructor
+ * @extends {WebInspector.PopoverHelper}
+ */
 WebInspector.ObjectPopoverHelper = function(panelElement, getAnchor, queryObject, onHide, disableOnClick)
 {
     WebInspector.PopoverHelper.call(this, panelElement, getAnchor, this._showObjectPopover.bind(this), onHide, disableOnClick);
index 9626c76..cd12c96 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @constructor
+ * @extends {WebInspector.PropertiesSection}
+ * @param {string=} title
+ * @param {string=} subtitle
+ * @param {string=} emptyPlaceholder
+ * @param {string=} ignoreHasOwnProperty
+ * @param {Array.<WebInspector.RemoteObjectProperty>=} extraProperties
+ * @param {function()=} treeElementConstructor
+ */
 WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPlaceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor)
 {
     this.emptyPlaceholder = (emptyPlaceholder || WebInspector.UIString("No Properties"));
@@ -135,6 +145,10 @@ WebInspector.ObjectPropertiesSection.CompareProperties = function(propertyA, pro
     return diff;
 }
 
+/**
+ * @constructor
+ * @extends {TreeElement}
+ */
 WebInspector.ObjectPropertyTreeElement = function(property)
 {
     this.property = property;
@@ -220,13 +234,12 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
         this.hasChildren = this.property.value.hasChildren && !this.property.wasThrown;
     },
 
-    _contextMenuEventFired: function()
+    _contextMenuEventFired: function(event)
     {
         function selectNode(nodeId)
         {
-            if (nodeId) {
-                WebInspector.panels.elements.switchToAndFocus(WebInspector.domAgent.nodeForId(nodeId));
-            }
+            if (nodeId)
+                WebInspector.domAgent.inspectElement(nodeId);
         }
 
         function revealElement()
@@ -263,11 +276,11 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
         if (typeof this.valueElement._originalTextContent === "string")
             this.valueElement.textContent = this.valueElement._originalTextContent;
 
-        WebInspector.startEditing(this.valueElement, {
-            context: context,
-            commitHandler: this.editingCommitted.bind(this),
-            cancelHandler: this.editingCancelled.bind(this)
-        });
+        var config = new WebInspector.EditingConfig();
+        config.setContext(context);
+        config.setCommitHandler(this.editingCommitted.bind(this));
+        config.setCancelHandler(this.editingCancelled.bind(this));
+        WebInspector.startEditing(this.valueElement, config);
     },
 
     editingEnded: function(context)
index cd21a0b..2ca9d01 100644 (file)
@@ -407,30 +407,9 @@ WebInspector.ResourcesPanel.prototype = {
         }
     },
 
-    _applyDiffMarkup: function(view, baseContent, newContent) {
-        var oldLines = baseContent.split(/\r?\n/);
-        var newLines = newContent.split(/\r?\n/);
-
-        var diff = Array.diff(oldLines, newLines);
-
-        var diffData = {};
-        diffData.added = [];
-        diffData.removed = [];
-        diffData.changed = [];
-
-        var offset = 0;
-        var right = diff.right;
-        for (var i = 0; i < right.length; ++i) {
-            if (typeof right[i] === "string") {
-                if (right.length > i + 1 && right[i + 1].row === i + 1 - offset)
-                    diffData.changed.push(i);
-                else {
-                    diffData.added.push(i);
-                    offset++;
-                }
-            } else
-                offset = i - right[i].row;
-        }
+    _applyDiffMarkup: function(view, baseContent, newContent)
+    {
+        var diffData = TextDiff.compute(baseContent, newContent);
         view.markDiff(diffData);
     },
 
index 4a6cb23..499abf6 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @extends {WebInspector.View}
+ * @constructor
+ */
 WebInspector.SourceFrame = function(delegate, url)
 {
     WebInspector.View.call(this);
@@ -127,6 +131,9 @@ WebInspector.SourceFrame.prototype = {
         this._delegate.requestContent(callback);
     },
 
+    /**
+     * @param {TextDiff} diffData
+     */
     markDiff: function(diffData)
     {
         if (this._diffLines && this.loaded)
@@ -441,6 +448,9 @@ WebInspector.SourceFrame.prototype = {
         return ranges;
     },
 
+    /**
+     * @param {boolean=} skipRevealLine
+     */
     setExecutionLine: function(lineNumber, skipRevealLine)
     {
         this._executionLineNumber = lineNumber;
@@ -760,11 +770,10 @@ WebInspector.SourceFrame.prototype = {
             callback(committed, newText);
         }
 
-        WebInspector.startEditing(this._conditionEditorElement, {
-            context: null,
-            commitHandler: finishEditing.bind(this, true),
-            cancelHandler: finishEditing.bind(this, false)
-        });
+        var config = new WebInspector.EditingConfig();
+        config.setCommitHandler(finishEditing.bind(this, true));
+        config.setCancelHandler(finishEditing.bind(this, false));
+        WebInspector.startEditing(this._conditionEditorElement, config);
         this._conditionEditorElement.value = condition;
         this._conditionEditorElement.select();
     },
@@ -812,7 +821,7 @@ WebInspector.SourceFrame.prototype = {
         return this._delegate.canEditScriptSource();
     },
 
-    startEditing: function(lineNumber)
+    startEditing: function()
     {
         if (!this.canEditSource())
             return false;
@@ -838,10 +847,8 @@ WebInspector.SourceFrame.prototype = {
             this._textViewer.readOnly = false;
 
             if (error) {
-                if (error.message) {
-                    WebInspector.log(error.message, WebInspector.ConsoleMessage.MessageLevel.Error);
-                    WebInspector.showConsole();
-                }
+                if (error.message)
+                    WebInspector.log(error.message, WebInspector.ConsoleMessage.MessageLevel.Error, true);
                 return;
             }
 
@@ -895,6 +902,10 @@ WebInspector.SourceFrame.prototype = {
 WebInspector.SourceFrame.prototype.__proto__ = WebInspector.View.prototype;
 
 
+/**
+ * @implements {WebInspector.TextViewerDelegate}
+ * @constructor
+ */
 WebInspector.TextViewerDelegateForSourceFrame = function(sourceFrame)
 {
     this._sourceFrame = sourceFrame;
@@ -940,83 +951,44 @@ WebInspector.TextViewerDelegateForSourceFrame.prototype = {
     {
         return this._sourceFrame.suggestedFileName();
     }
-};
+}
 
 WebInspector.TextViewerDelegateForSourceFrame.prototype.__proto__ = WebInspector.TextViewerDelegate.prototype;
 
 
+/**
+ * @interface
+ */
 WebInspector.SourceFrameDelegate = function()
 {
 }
 
 WebInspector.SourceFrameDelegate.prototype = {
-    requestContent: function(callback)
-    {
-        // Should be implemented by subclasses.
-    },
+    requestContent: function(callback) { },
 
-    debuggingSupported: function()
-    {
-        return false;
-    },
+    debuggingSupported: function() { return false; },
 
-    setBreakpoint: function(lineNumber, condition, enabled)
-    {
-        // Should be implemented by subclasses.
-    },
+    setBreakpoint: function(lineNumber, condition, enabled) { },
 
-    removeBreakpoint: function(lineNumber)
-    {
-        // Should be implemented by subclasses.
-    },
+    removeBreakpoint: function(lineNumber) { },
 
-    updateBreakpoint: function(lineNumber, condition, enabled)
-    {
-        // Should be implemented by subclasses.
-    },
+    updateBreakpoint: function(lineNumber, condition, enabled) { },
 
-    findBreakpoint: function(lineNumber)
-    {
-        // Should be implemented by subclasses.
-    },
+    findBreakpoint: function(lineNumber) { },
 
-    continueToLine: function(lineNumber)
-    {
-        // Should be implemented by subclasses.
-    },
+    continueToLine: function(lineNumber) { },
 
-    canEditScriptSource: function()
-    {
-        return false;
-    },
+    canEditScriptSource: function() { return false; },
 
-    setScriptSource: function(text, callback)
-    {
-        // Should be implemented by subclasses.
-    },
+    setScriptSource: function(text, callback) { },
 
-    setScriptSourceIsBeingEdited: function(inEditMode)
-    {
-        // Should be implemented by subclasses.
-    },
+    setScriptSourceIsBeingEdited: function(inEditMode) { },
 
-    debuggerPaused: function()
-    {
-        // Should be implemented by subclasses.
-    },
+    debuggerPaused: function() { },
 
-    evaluateInSelectedCallFrame: function(string)
-    {
-        // Should be implemented by subclasses.
-    },
+    evaluateInSelectedCallFrame: function(string) { },
 
-    releaseEvaluationResult: function()
-    {
-        // Should be implemented by subclasses.
-    },
+    releaseEvaluationResult: function() { },
 
-    suggestedFileName: function()
-    {
-        // Should be implemented by subclasses.
-    }
+    suggestedFileName: function() { }
 }
index a93dfde..78346d0 100644 (file)
@@ -105,14 +105,6 @@ WebInspector.debuggerPresentationModel = {
 
 /**
  * @constructor
- */
-WebInspector.ObjectPropertiesSection = function(obj, title)
-{
-    this.element = null;
-}
-
-/**
- * @constructor
  * @extends {TreeOutline}
  */
 WebInspector.ElementsTreeOutline = function()
@@ -200,3 +192,9 @@ Event.prototype.isMetaOrCtrlForTest = false;
  * @param {...*} vararg
  */
 Event.prototype.initWebKitWheelEvent = function(vararg) {}
+
+/**
+ * @param {string=} messageLevel
+ * @param {boolean=} showConsole
+ */
+WebInspector.log = function(message, messageLevel, showConsole) {}
index 1ce9e99..6ace71e 100644 (file)
@@ -957,7 +957,11 @@ WebInspector.didDestroyWorker = function()
         workersPane.removeWorker.apply(workersPane, arguments);
 }
 
-WebInspector.log = function(message, messageLevel)
+/**
+ * @param {string=} messageLevel
+ * @param {boolean=} showConsole
+ */
+WebInspector.log = function(message, messageLevel, showConsole)
 {
     // remember 'this' for setInterval() callback
     var self = this;
@@ -1020,6 +1024,8 @@ WebInspector.log = function(message, messageLevel)
             null);
 
         self.console.addMessage(msg);
+        if (showConsole)
+            WebInspector.showConsole();
     }
 
     // if we can't log the message, queue it
index 505bf97..fea50e0 100644 (file)
@@ -969,6 +969,9 @@ function revertDomChanges(domChanges)
     }
 }
 
+/**
+ * @param {string=} extraFlags
+ */
 function createSearchRegex(query, extraFlags)
 {
     // This should be kept the same as the one in ContentSearchUtils.cpp.
@@ -995,3 +998,43 @@ function countRegexMatches(regex, content)
     }
     return result;
 }
+
+/**
+ * @constructor
+ */
+function TextDiff()
+{
+    this.added = [];
+    this.removed = [];
+    this.changed = [];
+} 
+
+/**
+ * @param {string} baseContent
+ * @param {string} newContent
+ * @return {TextDiff}
+ */
+TextDiff.compute = function(baseContent, newContent)
+{
+    var oldLines = baseContent.split(/\r?\n/);
+    var newLines = newContent.split(/\r?\n/);
+
+    var diff = Array.diff(oldLines, newLines);
+
+    var diffData = new TextDiff();
+
+    var offset = 0;
+    var right = diff.right;
+    for (var i = 0; i < right.length; ++i) {
+        if (typeof right[i] === "string") {
+            if (right.length > i + 1 && right[i + 1].row === i + 1 - offset)
+                diffData.changed.push(i);
+            else {
+                diffData.added.push(i);
+                offset++;
+            }
+        } else
+            offset = i - right[i].row;
+    }
+    return diffData;
+}