[Pkg-mozext-commits] [firebug] 27/48: Issue 7485: ScriptPanel.showInfoTip needs to share logic with ScriptPanel.getPopupObject

David Prévot taffit at moszumanska.debian.org
Tue Jun 3 01:47:44 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository firebug.

commit 187fda83a17e1e695d5f387deb3f1bb20c482baf
Author: Jan Odvarko <odvarko at gmail.com>
Date:   Thu May 29 12:18:04 2014 +0200

    Issue 7485: 	ScriptPanel.showInfoTip needs to share logic with ScriptPanel.getPopupObject
---
 .../content/firebug/debugger/script/scriptPanel.js | 69 ++++++++++++----------
 extension/content/firebug/editor/sourceEditor.js   | 34 +++++++----
 2 files changed, 62 insertions(+), 41 deletions(-)

diff --git a/extension/content/firebug/debugger/script/scriptPanel.js b/extension/content/firebug/debugger/script/scriptPanel.js
index 6ddbd07..838d6fb 100644
--- a/extension/content/firebug/debugger/script/scriptPanel.js
+++ b/extension/content/firebug/debugger/script/scriptPanel.js
@@ -1406,16 +1406,17 @@ ScriptPanel.prototype = Obj.extend(BasePanel,
         if (!info.rangeParent)
             return Firebug.getRepObject(target);
 
-        var rangeOffset = info.rangeOffset || 0;
-        var expr = getExpressionAt(info.rangeParent.data, rangeOffset);
-        if (!expr || !expr.expr)
+        var expr = this.getExpressionUnderCursor(info.x, info.y,
+            info.rangeParent, info.rangeOffset);
+
+        if (!expr)
             return Firebug.getRepObject(target);
 
         var evalResult;
         var success = (result, context) => { evalResult = result; }
         var failure = (result, context) => { }
 
-        CommandLine.evaluate(expr.expr, this.context, null,
+        CommandLine.evaluate(expr, this.context, null,
             this.context.getCurrentGlobal(),
             success, failure, {noStateChange: true});
 
@@ -1749,32 +1750,7 @@ ScriptPanel.prototype = Obj.extend(BasePanel,
         if (!viewContent)
             return;
 
-        // First try to get selected expression under the cursor.
-        var text = this.scriptView.getSelectedTextFrom(x, y);
-        if (!text)
-        {
-            // See http://code.google.com/p/fbug/issues/detail?id=889
-            // Idea from: Jonathan Zarate's rikaichan extension (http://www.polarcloud.com/rikaichan/)
-            if (!rangeParent)
-                return false;
-
-            rangeOffset = rangeOffset || 0;
-            var row = Dom.getAncestorByClass(rangeParent, "firebug-line");
-            var expr = null;
-            if (row)
-            {
-                var range = rangeParent.ownerDocument.createRange();
-                range.setStart(row, 0);
-                range.setEnd(rangeParent, rangeOffset);
-                expr = getExpressionAt(range.startContainer.textContent, range.toString().length);
-            }
-
-            if (!expr || !expr.expr)
-                return false;
-
-            text = expr.expr;
-        }
-
+        var text = this.getExpressionUnderCursor(x, y, rangeParent, rangeOffset);
         if (text == this.infoTipExpr)
             return true;
         else
@@ -1842,6 +1818,39 @@ ScriptPanel.prototype = Obj.extend(BasePanel,
     },
 
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+    getExpressionUnderCursor: function(x, y, rangeParent, rangeOffset)
+    {
+        // First try to get selected expression under the cursor.
+        var text = this.scriptView.getSelectedTextFrom(x, y);
+        if (!text)
+        {
+            // See http://code.google.com/p/fbug/issues/detail?id=889
+            // Idea from: Jonathan Zarate's rikaichan extension (http://www.polarcloud.com/rikaichan/)
+            if (!rangeParent)
+                return false;
+
+            rangeOffset = rangeOffset || 0;
+            var row = Dom.getAncestorByClass(rangeParent, "firebug-line");
+            var expr = null;
+            if (row)
+            {
+                var range = rangeParent.ownerDocument.createRange();
+                range.setStart(row, 0);
+                range.setEnd(rangeParent, rangeOffset);
+                expr = getExpressionAt(range.startContainer.textContent, range.toString().length);
+            }
+
+            if (!expr || !expr.expr)
+                return false;
+
+            text = expr.expr;
+        }
+
+        return text;
+    },
+
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     // Executable Lines
 
     onViewportChange: function(from, to)
diff --git a/extension/content/firebug/editor/sourceEditor.js b/extension/content/firebug/editor/sourceEditor.js
index c8df204..1c9494f 100644
--- a/extension/content/firebug/editor/sourceEditor.js
+++ b/extension/content/firebug/editor/sourceEditor.js
@@ -208,12 +208,7 @@ SourceEditor.prototype =
         // So, handle 'mousedown' first to remember the clicked element, etc. and
         // allow to use it through getContextMenuInfo.
         var scroller = this.editorObject.display.scroller;
-        scroller.addEventListener("mousedown", function(event)
-        {
-            self.currentTarget = event.target;
-            self.rangeParent = event.rangeParent;
-            self.rangeOffset = event.rangeOffset;
-        });
+        scroller.addEventListener("mousedown", this.onMouseDown.bind(this));
 
         Trace.sysout("sourceEditor.init; ", this.view);
 
@@ -234,6 +229,27 @@ SourceEditor.prototype =
     },
 
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+    // Events
+
+    onMouseDown: function(event)
+    {
+        var target = event.target;
+
+        // Click info object can be retrieved through getContextMenuInfo method.
+        this.clickInfo = {};
+
+        this.clickInfo.currentTarget = target;
+        this.clickInfo.rangeParent = event.rangeParent;
+        this.clickInfo.rangeOffset = event.rangeOffset;
+
+        var scrollParent = Dom.getOverflowParent(target);
+        var scrollX = event.clientX + (scrollParent ? scrollParent.scrollLeft : 0);
+
+        this.clickInfo.x = scrollX;
+        this.clickInfo.y = event.clientY;
+    },
+
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     // Load CM Scripts
 
     loadScripts: function(doc, callback)
@@ -583,11 +599,7 @@ SourceEditor.prototype =
     // xxxHonza: see onInit for more details
     getContextMenuInfo: function()
     {
-        return {
-            target: this.currentTarget,
-            rangeParent: this.rangeParent,
-            rangeOffset: this.rangeOffset,
-        }
+        return this.clickInfo;
     },
 
     getContextMenuItems: function()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git



More information about the Pkg-mozext-commits mailing list