Bug 1484071 - Crop large data URLs before displaying them in the status bar r=Felipe
☠☠ backed out by bd0449584cba ☠ ☠
authorNikki S <nikkisharpley@gmail.com>
Tue, 05 Mar 2019 22:11:37 +0000
changeset 520360 6890499eb5d12fe8bce5ce1289ecb052ceb89343
parent 520359 c7cfa9240f33da062f3e072b2cbc23c6377ec387
child 520361 6fa85e4e05636f782b5bcc935e0e87dcd60af1ba
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe
bugs1484071
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1484071 - Crop large data URLs before displaying them in the status bar r=Felipe This commit provides a simple fix to reduce the time spent rendering larger data URLs (such as large screenshots) in the status panel when the Highlights tab is hovered over. By limiting the number of characters displayed, this decreases the time spent in the _showDelayed function. Differential Revision: https://phabricator.services.mozilla.com/D21593
browser/base/content/tabbrowser.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -5343,23 +5343,36 @@ var StatusPanel = {
     }
     types.push("defaultStatus");
     for (type of types) {
       if ((text = XULBrowserWindow[type])) {
         break;
       }
     }
 
+    // If it's a long data: URI that uses base64 encoding, truncate to
+    // a reasonable length rather than trying to display the entire thing.
+    // We can't shorten arbitrary URIs like this, as bidi etc might mean
+    // we need the trailing characters for display. But a base64-encoded
+    // data-URI is plain ASCII, so this is OK for status panel display.
+    // (See bug 1484071.)
+    let textCropped = false;
+    if (text.length > 500 && text.match(/^data:[^,]+;base64,/)) {
+      text = text.substring(0, 500) + "\u2026";
+      textCropped = true;
+    }
+
     if (this._labelElement.value != text ||
         (text && !this.isVisible)) {
       this.panel.setAttribute("previoustype", this.panel.getAttribute("type"));
       this.panel.setAttribute("type", type);
       this._label = text;
-      this._labelElement.setAttribute("crop", type == "overLink" ? "center" : "end");
-    }
+      this._labelElement.setAttribute("crop", (type == "overLink" && !textCropped) ? "center" : "end");
+    }
+
   },
 
   get _labelElement() {
     delete this._labelElement;
     return this._labelElement = document.getElementById("statuspanel-label");
   },
 
   set _label(val) {