[Pkg-mozext-commits] [firebug] 18/48: Issue 7475: Inspection of selected expressions in the Script panel

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 aa650dbcc93b1bc9d33a36e0425be6ef5b887542
Author: Jan Odvarko <odvarko at gmail.com>
Date:   Wed May 28 14:30:42 2014 +0200

    Issue 7475: Inspection of selected expressions in the Script panel
---
 .../content/firebug/debugger/script/scriptPanel.js | 27 ++++++++++++++--------
 .../content/firebug/debugger/script/scriptView.js  | 17 ++++++++++++++
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/extension/content/firebug/debugger/script/scriptPanel.js b/extension/content/firebug/debugger/script/scriptPanel.js
index cb106f5..7c34327 100644
--- a/extension/content/firebug/debugger/script/scriptPanel.js
+++ b/extension/content/firebug/debugger/script/scriptPanel.js
@@ -1749,20 +1749,27 @@ ScriptPanel.prototype = Obj.extend(BasePanel,
         if (!viewContent)
             return;
 
-        // 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;
+        // 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 expr = getExpressionAt(rangeParent.data, rangeOffset);
-        if (!expr || !expr.expr)
-            return false;
+            rangeOffset = rangeOffset || 0;
+            var expr = getExpressionAt(rangeParent.data, rangeOffset);
+            if (!expr || !expr.expr)
+                return false;
+
+            text = expr.expr;
+        }
 
-        if (expr.expr == this.infoTipExpr)
+        if (text == this.infoTipExpr)
             return true;
         else
-            return this.populateInfoTip(infoTip, expr.expr);
+            return this.populateInfoTip(infoTip, text);
     },
 
     populateInfoTip: function(infoTip, expr)
diff --git a/extension/content/firebug/debugger/script/scriptView.js b/extension/content/firebug/debugger/script/scriptView.js
index 8ccea4f..a6fdabf 100644
--- a/extension/content/firebug/debugger/script/scriptView.js
+++ b/extension/content/firebug/debugger/script/scriptView.js
@@ -553,6 +553,23 @@ ScriptView.prototype = Obj.extend(new EventSource(),
     {
         return this.editor;
     },
+
+    getSelectedTextFrom: function(x, y)
+    {
+        var doc = this.editor.view.ownerDocument;
+        var selection = doc.querySelectorAll(".CodeMirror-selected");
+        if (selection.length)
+        {
+            for (var i=0; i<selection.length; i++)
+            {
+                var node = selection[i];
+                var pos = Dom.getLTRBWH(node);
+
+                if (x > pos.left && x < pos.right && y > pos.top && y < pos.bottom)
+                    return this.editor.getSelectedText();
+            }
+        }
+    }
 });
 
 // ********************************************************************************************* //

-- 
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