Bug 813204 - Don't send multiple hasTouchListener events for the same document. r=wesj
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 21 Nov 2012 15:15:40 -0500
changeset 113953 d00a4624190f4b04985e89eb3c79bbab292faad3
parent 113952 c4d013240eaca747d82771e693af4a940179f96d
child 113954 7ae5ff606cf2d57a6b758e88500749beaa425532
push id18467
push userkgupta@mozilla.com
push dateWed, 21 Nov 2012 22:39:17 +0000
treeherdermozilla-inbound@d00a4624190f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs813204
milestone20.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 813204 - Don't send multiple hasTouchListener events for the same document. r=wesj
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2453,16 +2453,17 @@ function Tab(aURL, aParams) {
   this.userScrollPos = { x: 0, y: 0 };
   this.contentDocumentIsDisplayed = true;
   this.pluginDoorhangerTimeout = null;
   this.shouldShowPluginDoorhanger = true;
   this.clickToPlayPluginsActivated = false;
   this.desktopMode = false;
   this.originalURI = null;
   this.savedArticle = null;
+  this.hasTouchListener = false;
 
   this.create(aURL, aParams);
 }
 
 Tab.prototype = {
   create: function(aURL, aParams) {
     if (this.browser)
       return;
@@ -3323,16 +3324,17 @@ Tab.prototype = {
     };
 
     sendMessageToJava(message);
 
     if (!sameDocument) {
       // XXX This code assumes that this is the earliest hook we have at which
       // browser.contentDocument is changed to the new document we're loading
       this.contentDocumentIsDisplayed = false;
+      this.hasTouchListener = false;
     } else {
       this.sendViewportUpdate();
     }
   },
 
   // Properties used to cache security state used to update the UI
   _state: null,
   _hostChanged: false, // onLocationChange will flip this bit
@@ -3725,19 +3727,20 @@ var BrowserEventHandler = {
       } catch (e) {}
     }
     return null;
   },
 
   observe: function(aSubject, aTopic, aData) {
     if (aTopic == "dom-touch-listener-added") {
       let tab = BrowserApp.getTabForWindow(aSubject.top);
-      if (!tab)
+      if (!tab || tab.hasTouchListener)
         return;
 
+      tab.hasTouchListener = true;
       sendMessageToJava({
         gecko: {
           type: "Tab:HasTouchListener",
           tabID: tab.id
         }
       });
       return;
     } else if (aTopic == "nsPref:changed") {