Bug 538619 - Fennec Crashes on N900 when Lycos Mail is browsed. [r=dougt,mfinkle]
authorBenjamin Stover <bstover@mozilla.com>
Wed, 13 Jan 2010 10:23:39 -0800
changeset 1293 c5693a45cb7a803f1f283720c3db4de69a7fb399
parent 1292 736269688cd5cc4646df8f90d2bbd7fb5c3fbfe2
child 1294 91ea40f29e9b0a0e276f52f35a8360f54ebc36e6
push id1149
push userbstover@mozilla.com
push dateWed, 13 Jan 2010 18:23:53 +0000
reviewersdougt, mfinkle
bugs538619
Bug 538619 - Fennec Crashes on N900 when Lycos Mail is browsed. [r=dougt,mfinkle]
chrome/content/browser.js
--- a/chrome/content/browser.js
+++ b/chrome/content/browser.js
@@ -3232,71 +3232,64 @@ PluginObserver.prototype = {
     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) {
-    let doc = subject.ownerDocument.defaultView.top.document;
-    if (data == "init") {
-      if (doc.pluginCache === undefined)
-        doc.pluginCache = [];
-      doc.pluginCache.push(subject);
-    } else if (data == "reflow") {
+    if (data == "reflow")
       this.updateCurrentBrowser();
-    } else if (data == "destroy") {
-      if (doc.pluginCache) {
-        let index = doc.pluginCache.indexOf(subject);
-        if (index != -1)
-          doc.pluginCache.splice(index, 1);
-      }
-    }
   },
 
   /** Update flash objects */
   handleEvent: function handleEvent(ev) {
     if (ev.type == "TabSelect") {
       if (ev.lastTab) {
         let browser = ev.lastTab.browser;
         let oldDoc = browser.contentDocument;
+
+        let plugins = oldDoc.querySelectorAll("embed,object");
+
         browser.removeEventListener("ZoomChanged", this, false);
         browser.removeEventListener("MozAfterPaint", this, false);
-        if (oldDoc.pluginCache)
-          this.updateEmbedRegions(oldDoc.pluginCache, this._emptyRect);
+        this.updateEmbedRegions(plugins, this._emptyRect);
       }
 
       let browser = Browser.selectedBrowser;
       browser.addEventListener("ZoomChanged", this, false);
       browser.addEventListener("MozAfterPaint", this, false);
     }
 
     this.updateCurrentBrowser();
   },
 
   /** Update the current browser's flash objects. */
   updateCurrentBrowser: function updateCurrentBrowser() {
     let doc = Browser.selectedTab.browser.contentDocument;
-    if (!doc.pluginCache)
-      return;
 
     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(doc.pluginCache, rect);
+      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.
-        self.updateEmbedRegions(doc.pluginCache, self.getCriticalRect());
+        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;
     if (!bv.isRendering())