Title: [97843] trunk/Source/WebCore
Revision
97843
Author
podivi...@chromium.org
Date
2011-10-19 02:48:28 -0700 (Wed, 19 Oct 2011)

Log Message

Web Inspector: move JS specific popover handling to _javascript_SourceFrame.
https://bugs.webkit.org/show_bug.cgi?id=70033

Reviewed by Pavel Feldman.

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.uiSourceCodes):
(WebInspector.DebuggerPresentationModel.prototype.get paused):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame):
(WebInspector._javascript_SourceFrame.prototype.shouldShowPopover):
(WebInspector._javascript_SourceFrame.prototype.onShowPopover.showObjectPopover):
(WebInspector._javascript_SourceFrame.prototype.onShowPopover):
(WebInspector._javascript_SourceFrame.prototype.onHidePopover):
(WebInspector._javascript_SourceFrame.prototype._highlightExpression):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._createSourceFrame):
(WebInspector.SourceFrameDelegateForScriptsPanel):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
(WebInspector.SourceFrame.prototype.willHide):
(WebInspector.SourceFrame.prototype._initializeTextViewer):
(WebInspector.SourceFrame.prototype._getPopoverAnchor):
(WebInspector.SourceFrame.prototype.get readOnly):
(WebInspector.SourceFrame.prototype._setReadOnly):
(WebInspector.SourceFrame.prototype.contentChanged):
(WebInspector.SourceFrame.prototype.shouldShowPopover):
(WebInspector.SourceFrame.prototype.onShowPopover):
(WebInspector.SourceFrame.prototype.onHidePopover):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97842 => 97843)


--- trunk/Source/WebCore/ChangeLog	2011-10-19 09:45:48 UTC (rev 97842)
+++ trunk/Source/WebCore/ChangeLog	2011-10-19 09:48:28 UTC (rev 97843)
@@ -1,3 +1,35 @@
+2011-10-13  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: move JS specific popover handling to _javascript_SourceFrame.
+        https://bugs.webkit.org/show_bug.cgi?id=70033
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype.uiSourceCodes):
+        (WebInspector.DebuggerPresentationModel.prototype.get paused):
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame):
+        (WebInspector._javascript_SourceFrame.prototype.shouldShowPopover):
+        (WebInspector._javascript_SourceFrame.prototype.onShowPopover.showObjectPopover):
+        (WebInspector._javascript_SourceFrame.prototype.onShowPopover):
+        (WebInspector._javascript_SourceFrame.prototype.onHidePopover):
+        (WebInspector._javascript_SourceFrame.prototype._highlightExpression):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._createSourceFrame):
+        (WebInspector.SourceFrameDelegateForScriptsPanel):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame):
+        (WebInspector.SourceFrame.prototype.willHide):
+        (WebInspector.SourceFrame.prototype._initializeTextViewer):
+        (WebInspector.SourceFrame.prototype._getPopoverAnchor):
+        (WebInspector.SourceFrame.prototype.get readOnly):
+        (WebInspector.SourceFrame.prototype._setReadOnly):
+        (WebInspector.SourceFrame.prototype.contentChanged):
+        (WebInspector.SourceFrame.prototype.shouldShowPopover):
+        (WebInspector.SourceFrame.prototype.onShowPopover):
+        (WebInspector.SourceFrame.prototype.onHidePopover):
+
 2011-10-19  Tomasz Morawski  <t.moraw...@samsung.com>
 
         [EFL][WK2] Added missing files to build WebKit2 EFL

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


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-10-19 09:45:48 UTC (rev 97842)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-10-19 09:48:28 UTC (rev 97843)
@@ -156,7 +156,7 @@
             for (var i = 0; i < uiSourceCodeList.length; ++i)
                 result.push(uiSourceCodeList[i]);
         }
-        return result;            
+        return result;
     },
 
     /**
@@ -491,6 +491,11 @@
         this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.DebuggerResumed);
     },
 
+    get paused()
+    {
+        return !!WebInspector.debuggerModel.debuggerPausedDetails;
+    },
+
     set selectedCallFrame(callFrame)
     {
         if (this._selectedCallFrame)

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (97842 => 97843)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-10-19 09:45:48 UTC (rev 97842)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-10-19 09:48:28 UTC (rev 97843)
@@ -32,15 +32,96 @@
  * @constructor
  * @extends {WebInspector.SourceFrame}
  * @param {WebInspector.SourceFrameDelegate} delegate
+ * @param {WebInspector.DebuggerPresentationModel} model
  * @param {WebInspector.UISourceCode} uiSourceCode
  */
-WebInspector._javascript_SourceFrame = function(delegate, uiSourceCode)
+WebInspector._javascript_SourceFrame = function(delegate, model, uiSourceCode)
 {
     // FIXME: move all SourceFrame methods related to _javascript_ debugging here and
     // get rid of SourceFrame._delegate.
     WebInspector.SourceFrame.call(this, delegate, uiSourceCode.url);
 
+    this._model = model;
+    this._popoverObjectGroup = "popover";
+
     uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this.contentChanged, this);
 }
 
+WebInspector._javascript_SourceFrame.prototype = {
+    shouldShowPopover: function(element)
+    {
+        if (!this._model.paused)
+            return false;
+        if (!element.enclosingNodeOrSelfWithClass("webkit-line-content"))
+            return false;
+
+        // We are interested in identifiers and "this" keyword.
+        if (element.hasStyleClass("webkit-_javascript_-keyword"))
+            return element.textContent === "this";
+
+        return element.hasStyleClass("webkit-_javascript_-ident");
+    },
+
+    onShowPopover: function(element, showCallback)
+    {
+        if (!this.readOnly) {
+            this.popoverHelper.hidePopover();
+            return;
+        }
+        this._highlightElement = this._highlightExpression(element);
+
+        function showObjectPopover(result, wasThrown)
+        {
+            if (!this._model.paused) {
+                this.popoverHelper.hidePopover();
+                return;
+            }
+            showCallback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
+            this._highlightElement.addStyleClass("source-frame-eval-_expression_");
+        }
+
+        var selectedCallFrame = this._model.selectedCallFrame;
+        selectedCallFrame.evaluate(this._highlightElement.textContent, this._popoverObjectGroup, false, false, showObjectPopover.bind(this));
+    },
+
+    onHidePopover: function()
+    {
+        // Replace higlight element with its contents inplace.
+        var highlightElement = this._highlightElement;
+        if (!highlightElement)
+            return;
+        var parentElement = highlightElement.parentElement;
+        var child = highlightElement.firstChild;
+        while (child) {
+            var nextSibling = child.nextSibling;
+            parentElement.insertBefore(child, highlightElement);
+            child = nextSibling;
+        }
+        parentElement.removeChild(highlightElement);
+        delete this._highlightElement;
+        RuntimeAgent.releaseObjectGroup(this._popoverObjectGroup);
+    },
+
+    _highlightExpression: function(element)
+    {
+        // Collect tokens belonging to evaluated _expression_.
+        var tokens = [ element ];
+        var token = element.previousSibling;
+        while (token && (token.className === "webkit-_javascript_-ident" || token.className === "webkit-_javascript_-keyword" || token.textContent.trim() === ".")) {
+            tokens.push(token);
+            token = token.previousSibling;
+        }
+        tokens.reverse();
+
+        // Wrap them with highlight element.
+        var parentElement = element.parentElement;
+        var nextElement = element.nextSibling;
+        var container = document.createElement("span");
+        for (var i = 0; i < tokens.length; ++i)
+            container.appendChild(tokens[i]);
+        parentElement.insertBefore(container, nextElement);
+        return container;
+    }
+}
+
 WebInspector._javascript_SourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (97842 => 97843)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-10-19 09:45:48 UTC (rev 97842)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-10-19 09:48:28 UTC (rev 97843)
@@ -186,7 +186,7 @@
         WebInspector.debuggerModel.enableDebugger();
 
     WebInspector.settings.showScriptFolders.addChangeListener(this._showScriptFoldersSettingChanged.bind(this));
-    
+
     WebInspector.advancedSearchController.registerSearchScope(new WebInspector.ScriptsSearchScope());
 }
 
@@ -688,7 +688,7 @@
     _createSourceFrame: function(uiSourceCode)
     {
         var delegate = new WebInspector.SourceFrameDelegateForScriptsPanel(this, uiSourceCode);
-        var sourceFrame = new WebInspector._javascript_SourceFrame(delegate, uiSourceCode);
+        var sourceFrame = new WebInspector._javascript_SourceFrame(delegate, this._presentationModel, uiSourceCode);
 
         this.addChildView(sourceFrame);
         sourceFrame._uiSourceCode = uiSourceCode;
@@ -1221,7 +1221,6 @@
     this._scriptsPanel = scriptsPanel;
     this._model = this._scriptsPanel._presentationModel;
     this._uiSourceCode = uiSourceCode;
-    this._popoverObjectGroup = "popover";
 }
 
 WebInspector.SourceFrameDelegateForScriptsPanel.prototype = {
@@ -1230,11 +1229,6 @@
         this._uiSourceCode.requestContent(callback);
     },
 
-    debuggingSupported: function()
-    {
-        return true;
-    },
-
     setBreakpoint: function(lineNumber, condition, enabled)
     {
         this._model.setBreakpoint(this._uiSourceCode, lineNumber, condition, enabled);
@@ -1278,21 +1272,6 @@
         this._scriptsPanel._setScriptSourceIsBeingEdited(this._uiSourceCode, inEditMode);
     },
 
-    debuggerPaused: function()
-    {
-        return WebInspector.panels.scripts.paused;
-    },
-
-    evaluateInSelectedCallFrame: function(string, callback)
-    {
-        this._scriptsPanel.evaluateInSelectedCallFrame(string, this._popoverObjectGroup, false, false, callback);
-    },
-
-    releaseEvaluationResult: function()
-    {
-        RuntimeAgent.releaseObjectGroup(this._popoverObjectGroup);
-    },
-
     suggestedFileName: function()
     {
         var names = this._scriptsPanel._folderAndDisplayNameForScriptURL(this._uiSourceCode.url);

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (97842 => 97843)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-19 09:45:48 UTC (rev 97842)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-19 09:48:28 UTC (rev 97843)
@@ -47,6 +47,10 @@
     this.addChildView(this._textViewer);
     this.element.appendChild(this._textViewer.element);
 
+    this.popoverHelper = new WebInspector.ObjectPopoverHelper(this._textViewer.element,
+            this._getPopoverAnchor.bind(this), this.onShowPopover.bind(this), this.onHidePopover.bind(this), true);
+    this._textViewer.element.addEventListener("mousedown", this._mouseDown.bind(this), true);
+
     this._editButton = new WebInspector.StatusBarButton(WebInspector.UIString("Edit"), "edit-source-status-bar-item");
     this._editButton.addEventListener("click", this._editButtonClicked.bind(this), this);
 
@@ -98,8 +102,8 @@
         if (this.loaded)
             this._textViewer.freeCachedElements();
 
-        if (this._popoverHelper)
-            this._popoverHelper.hidePopover();
+        if (this.popoverHelper)
+            this.popoverHelper.hidePopover();
         this._clearLineHighlight();
         this._textViewer.readOnly = true;
     },
@@ -300,13 +304,6 @@
         this._loaded = true;
         this._textModel.setText(null, content);
 
-        var element = this._textViewer.element;
-        if (this._delegate.debuggingSupported()) {
-            this._popoverHelper = new WebInspector.ObjectPopoverHelper(element,
-                this._getPopoverAnchor.bind(this), this._onShowPopover.bind(this), this._onHidePopover.bind(this), true);
-            element.addEventListener("mousedown", this._mouseDown.bind(this), true);
-        }
-
         this._textViewer.beginUpdates();
 
         this._setTextViewerDecorations();
@@ -677,87 +674,13 @@
         event.preventDefault();
     },
 
-    _onHidePopover: function()
-    {
-        // Replace higlight element with its contents inplace.
-        var highlightElement = this._highlightElement;
-        if (!highlightElement)
-            return;
-        var parentElement = highlightElement.parentElement;
-        var child = highlightElement.firstChild;
-        while (child) {
-            var nextSibling = child.nextSibling;
-            parentElement.insertBefore(child, highlightElement);
-            child = nextSibling;
-        }
-        parentElement.removeChild(highlightElement);
-        delete this._highlightElement;
-        this._delegate.releaseEvaluationResult();
-    },
-
-    _shouldShowPopover: function(element)
-    {
-        if (!this._delegate.debuggerPaused())
-            return false;
-        if (!element.enclosingNodeOrSelfWithClass("webkit-line-content"))
-            return false;
-
-        // We are interested in identifiers and "this" keyword.
-        if (element.hasStyleClass("webkit-_javascript_-keyword"))
-            return element.textContent === "this";
-
-        return element.hasStyleClass("webkit-_javascript_-ident");
-    },
-
     _getPopoverAnchor: function(element)
     {
-        if (!this._shouldShowPopover(element))
+        if (!this.shouldShowPopover(element))
             return;
         return element;
     },
 
-    _highlightExpression: function(element)
-    {
-        // Collect tokens belonging to evaluated exression.
-        var tokens = [ element ];
-        var token = element.previousSibling;
-        while (token && (token.className === "webkit-_javascript_-ident" || token.className === "webkit-_javascript_-keyword" || token.textContent.trim() === ".")) {
-            tokens.push(token);
-            token = token.previousSibling;
-        }
-        tokens.reverse();
-
-        // Wrap them with highlight element.
-        var parentElement = element.parentElement;
-        var nextElement = element.nextSibling;
-        var container = document.createElement("span");
-        for (var i = 0; i < tokens.length; ++i)
-            container.appendChild(tokens[i]);
-        parentElement.insertBefore(container, nextElement);
-        return container;
-    },
-
-    _onShowPopover: function(element, showCallback)
-    {
-        if (!this._textViewer.readOnly) {
-            this._popoverHelper.hidePopover();
-            return;
-        }
-        this._highlightElement = this._highlightExpression(element);
-
-        function showObjectPopover(result, wasThrown)
-        {
-            if (!this._delegate.debuggerPaused()) {
-                this._popoverHelper.hidePopover();
-                return;
-            }
-            showCallback(result, wasThrown);
-            this._highlightElement.addStyleClass("source-frame-eval-_expression_");
-        }
-
-        this._delegate.evaluateInSelectedCallFrame(this._highlightElement.textContent, showObjectPopover.bind(this));
-    },
-
     _editBreakpointCondition: function(lineNumber, condition, callback)
     {
         this._conditionElement = this._createConditionElement(lineNumber);
@@ -885,10 +808,15 @@
         this._setReadOnly(true);
     },
 
+    get readOnly()
+    {
+        return this._textViewer.readOnly;
+    },
+
     _setReadOnly: function(readOnly)
     {
-        if (!readOnly && this._popoverHelper)
-            this._popoverHelper.hidePopover();
+        if (!readOnly && this.popoverHelper)
+            this.popoverHelper.hidePopover();
 
         this._textViewer.readOnly = readOnly;
         this._editButton.toggled = !readOnly;
@@ -902,7 +830,14 @@
         if (!this._contentRequested || !this._textViewer.readOnly)
             return;
         this._delegate.requestContent(this._initializeTextViewer.bind(this));
-    }
+    },
+
+
+    shouldShowPopover: function(element) { },
+
+    onShowPopover: function(element, showCallback) { },
+
+    onHidePopover: function() { },
 }
 
 WebInspector.SourceFrame.prototype.__proto__ = WebInspector.View.prototype;
@@ -972,8 +907,6 @@
 WebInspector.SourceFrameDelegate.prototype = {
     requestContent: function(callback) { },
 
-    debuggingSupported: function() { return false; },
-
     setBreakpoint: function(lineNumber, condition, enabled) { },
 
     removeBreakpoint: function(lineNumber) { },
@@ -990,12 +923,6 @@
 
     setScriptSourceIsBeingEdited: function(inEditMode) { },
 
-    debuggerPaused: function() { },
-
-    evaluateInSelectedCallFrame: function(string) { },
-
-    releaseEvaluationResult: function() { },
-
     suggestedFileName: function() { }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to