[Pkg-mozext-commits] [firebug] 28/68: Manual porting of: Issue 6130: Text copied from console has lots of line breaks

David Prévot taffit at moszumanska.debian.org
Mon Mar 31 22:45:51 UTC 2014


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

taffit pushed a commit to tag fbtest-1.11.4
in repository firebug.

commit 3ce5d678b3c4a80911958b0eda59fea8f59f1072
Author: Simon Lindholm <simon.lindholm10 at gmail.com>
Date:   Mon Apr 1 02:16:07 2013 +0200

    Manual porting of: Issue 6130: Text copied from console has lots of line breaks
---
 extension/content/firebug/chrome/reps.js          | 35 ++++++++++++++++++++++-
 extension/content/firebug/console/consolePanel.js | 20 +++++++++++--
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/extension/content/firebug/chrome/reps.js b/extension/content/firebug/chrome/reps.js
index 0ef9f02..bce38d8 100644
--- a/extension/content/firebug/chrome/reps.js
+++ b/extension/content/firebug/chrome/reps.js
@@ -57,8 +57,10 @@ catch (err)
 // ********************************************************************************************* //
 // Common Tags
 
-// use pre here to keep line breaks while copying multiline strings 
 var OBJECTBOX = FirebugReps.OBJECTBOX =
+    SPAN({"class": "objectBox objectBox-$className", role: "presentation"});
+
+var PREOBJECTBOX =
     PRE({"class": "objectBox inline objectBox-$className", role: "presentation"});
 
 var OBJECTBLOCK = FirebugReps.OBJECTBLOCK =
@@ -142,6 +144,28 @@ FirebugReps.Number = domplate(Firebug.Rep,
 
 // ********************************************************************************************* //
 
+// To support copying strings with multiple spaces, tabs, newlines etc. correctly
+// we are unfortunately required by Firefox to use a <pre> tag (bug 116083).
+// Don't do that with all OBJECTBOX's though - it inserts newlines *everywhere*.
+// (See issues 3816, 6130.)
+// XXX: This would look much nicer with support for IF in domplate.
+var reSpecialWhitespace = /  |[\t\n]/;
+FirebugReps.SpecialWhitespaceString = domplate(Firebug.Rep,
+{
+    tag: PREOBJECTBOX(""$object""),
+
+    shortTag: OBJECTBOX(""$object|cropMultipleLines""),
+
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+    className: "string",
+
+    supportsObject: function(object, type)
+    {
+        return (type == "string" && reSpecialWhitespace.test(object));
+    }
+});
+
 FirebugReps.String = domplate(Firebug.Rep,
 {
     tag: OBJECTBOX(""$object""),
@@ -192,8 +216,16 @@ FirebugReps.Text = domplate(Firebug.Rep,
 {
     tag: OBJECTBOX("$object"),
 
+    // Refer to SpecialWhitespaceString above.
+    specialWhitespaceTag: PREOBJECTBOX("$object"),
+
     shortTag: OBJECTBOX("$object|cropMultipleLines"),
 
+    getWhitespaceCorrectedTag: function(str)
+    {
+        return reSpecialWhitespace.test(str) ? this.specialWhitespaceTag : this.tag;
+    },
+
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
     className: "text"
@@ -3361,6 +3393,7 @@ Firebug.registerRep(
     FirebugReps.Undefined,
     FirebugReps.Null,
     FirebugReps.Number,
+    FirebugReps.SpecialWhitespaceString,
     FirebugReps.String,
     FirebugReps.nsIDOMHistory, // make this early to avoid exceptions
     FirebugReps.ApplicationCache, // this also
diff --git a/extension/content/firebug/console/consolePanel.js b/extension/content/firebug/console/consolePanel.js
index 08ce40f..1fb3aef 100644
--- a/extension/content/firebug/console/consolePanel.js
+++ b/extension/content/firebug/console/consolePanel.js
@@ -493,7 +493,22 @@ Firebug.ConsolePanel.prototype = Obj.extend(Firebug.ActivablePanel,
         // are dynamically consumed during the rendering process.
         // This allows to derive new templates from an existing ones, without breaking
         // the default subject set within domplate() function.
-        return rep.tag.append({object: object}, row, rep);
+        try
+        {
+            // XXX Hack until we get IF support in domplate (or bug 116083 gets fixed).
+            var tag = rep.tag;
+            if (rep === FirebugReps.Text)
+                tag = rep.getWhitespaceCorrectedTag(object);
+            return tag.append({object: object}, row, rep);
+        }
+        catch (e)
+        {
+            if (FBTrace.DBG_ERRORS)
+            {
+                FBTrace.sysout("consolePanel.appendObject; EXCEPTION " + e, e);
+                FBTrace.sysout("consolePanel.appendObject; rep " + rep.className, rep);
+            }
+        }
     },
 
     appendFormatted: function(objects, row, rep)
@@ -590,7 +605,8 @@ Firebug.ConsolePanel.prototype = Obj.extend(Firebug.ActivablePanel,
             }
             else
             {
-                node = FirebugReps.Text.tag.append({object: part}, row);
+                var tag = FirebugReps.Text.getWhitespaceCorrectedTag(part);
+                node = tag.append({object: part}, row);
             }
 
             // Apply custom style if available.

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