Bug 540795 - NotifyPluginEventObservers crashes [r=mfinkle] [r=stechz]
authorDoug Turner <mozbugs@dougt.org>
Wed, 20 Jan 2010 13:49:28 -0800
changeset 65987 fac4c5c08eb70e0dea063801c578fec8edd30917
parent 65986 351fb098ea694d6aa21c6869fc46580d1231fdcf
child 65988 1257ef11df8a5185fe15ffb2283916c264405030
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, stechz
bugs540795
Bug 540795 - NotifyPluginEventObservers crashes [r=mfinkle] [r=stechz]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -3187,17 +3187,17 @@ PluginObserver.prototype = {
     if (this._started)
       return;
     this._started = true;
 
     document.getElementById("tabs-container").addEventListener("TabSelect", this, false);
     this._contentShowing.addEventListener("broadcast", this, false);
     let browsers = document.getElementById("browsers");
     browsers.addEventListener("RenderStateChanged", this, false);
-    gObserverService.addObserver(this, "plugin-changed-event", false);
+    gObserverService.addObserver(this, "plugin-reflow-event", false);
     Elements.stack.addEventListener("PopupChanged", this, false);
 
     let browser = Browser.selectedBrowser;
     if (browser) {
       browser.addEventListener("ZoomChanged", this, false);
       browser.addEventListener("MozAfterPaint", this, false);
     }
   },
@@ -3207,30 +3207,29 @@ PluginObserver.prototype = {
     if (!this._started)
       return;
     this._started = false;
 
     document.getElementById("tabs-container").removeEventListener("TabSelect", this, false);
     this._contentShowing.removeEventListener("broadcast", this, false);
     let browsers = document.getElementById("browsers");
     browsers.removeEventListener("RenderStateChanged", this, false);
-    gObserverService.removeObserver(this, "plugin-changed-event");
+    gObserverService.removeObserver(this, "plugin-reflow-event");
     Elements.stack.removeEventListener("PopupChanged", this, false);
 
     let browser = Browser.selectedBrowser;
     if (browser) {
       browser.removeEventListener("ZoomChanged", this, false);
       browser.removeEventListener("MozAfterPaint", this, false);
     }
   },
 
   /** Observe listens for plugin change events and maintains an embed cache. */
   observe: function observe(subject, topic, data) {
-    if (data == "reflow")
-      this.updateCurrentBrowser();
+    this.updateCurrentBrowser();
   },
 
   /** Update flash objects */
   handleEvent: function handleEvent(ev) {
     if (ev.type == "TabSelect") {
       if (ev.lastTab) {
         let browser = ev.lastTab.browser;
         let oldDoc = browser.contentDocument;
@@ -3253,29 +3252,29 @@ PluginObserver.prototype = {
   /** Update the current browser's flash objects. */
   updateCurrentBrowser: function updateCurrentBrowser() {
     let doc = Browser.selectedTab.browser.contentDocument;
 
     let rect = this.getCriticalRect();
     if (rect == this._emptyRect && !this._isRendering)
       return;
 
-    let plugins = doc.querySelectorAll("embed,object");
-
     if (this._isRendering) {
       // Update immediately if not just starting to render
       if (rect == this._emptyRect)
         this._isRendering = false;
-      this.updateEmbedRegions(plugins, rect);
+        let plugins = doc.querySelectorAll("embed,object");
+        this.updateEmbedRegions(plugins, rect);
     } else {
       // Wait a moment so that any chrome redraws occur first.
       let self = this;
       setTimeout(function() {
         self._isRendering = true;
         // Recalculate critical rect so we don't render when we ought not to.
+        let plugins = doc.querySelectorAll("embed,object");
         self.updateEmbedRegions(plugins, self.getCriticalRect());
       }, 0);
     }
   },
 
   /** More accurate version of finding the current visible region. Returns client coords. */
   getCriticalRect: function getCriticalRect() {
     let bv = this._bv;