Bug 911152 - Don't reprocess the same metadata over and over. r=wesj
☠☠ backed out by cdcb01632607 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 27 Sep 2013 13:57:54 -0400
changeset 149099 cfb6cd8accc3bb6d2cb67d6596f5918252f83030
parent 149098 5a520e97e6a53e28652aa8cef212edcd339490da
child 149100 d39711d1bc60e3fa19a69d1e23efbbe5834b921a
push id34439
push userkwierso@gmail.com
push dateSat, 28 Sep 2013 03:39:12 +0000
treeherdermozilla-inbound@caec8c0c4963 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs911152
milestone27.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 911152 - Don't reprocess the same metadata over and over. r=wesj
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3817,16 +3817,20 @@ Tab.prototype = {
       aMetadata.defaultZoom *= scaleRatio;
     if (aMetadata.minZoom > 0)
       aMetadata.minZoom *= scaleRatio;
     if (aMetadata.maxZoom > 0)
       aMetadata.maxZoom *= scaleRatio;
 
     aMetadata.isRTL = this.browser.contentDocument.documentElement.dir == "rtl";
 
+    // if the metadata hasn't actually changed, no need to do anything
+    if (aMetadata.equals(this.metadata))
+      return;
+
     ViewportHandler.setMetadataForDocument(this.browser.contentDocument, aMetadata);
     this.updateViewportSize(gScreenWidth, aInitialLoad);
     this.sendViewportMetadata();
   },
 
   /** Update viewport when the metadata or the window size changes. */
   updateViewportSize: function updateViewportSize(aOldScreenWidth, aInitialLoad) {
     // When this function gets called on window resize, we must execute
@@ -5803,16 +5807,28 @@ ViewportMetadata.prototype = {
   height: null,
   defaultZoom: null,
   minZoom: null,
   maxZoom: null,
   autoSize: null,
   allowZoom: null,
   isSpecified: null,
   isRTL: null,
+
+  equals: function(aOther) {
+    return this.width === aOther.width
+        && this.height === aOther.height
+        && this.defaultZoom === aOther.defaultZoom
+        && (this.minZoom === aOther.minZoom || (isNaN(minZoom) && isNaN(aOther.minZoom)))
+        && (this.maxZoom === aOther.maxZoom || (isNaN(maxZoom) && isNaN(aOther.maxZoom)))
+        && this.autoSize === aOther.autoSize
+        && this.allowZoom === aOther.allowZoom
+        && this.isSpecified === aOther.isSpecified
+        && this.isRTL === aOther.isRTL;
+  }
 };
 
 
 /**
  * Handler for blocked popups, triggered by DOMUpdatePageReport events in browser.xml
  */
 var PopupBlockerObserver = {
   onUpdatePageReport: function onUpdatePageReport(aEvent) {