Bug 1317032 - If a page uses or removes many <object> elements which are not actually plugins, loading the page goes to a crawl because we recalculate the plugin UI every time. Don't do that by only dispatching a PluginRemoved event for actual plugins, not images/unknown/iframe-type <objects>, r?qdot draft
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 15 Dec 2016 10:42:10 -0500
changeset 449956 b9e0ab51e9fbbe7f40d4e24160b8f679b8dd7d34
parent 449666 18b5a7a5d833f09b1f1e5cc45f4c0ff6235a1d5e
child 539630 558698ac6c31477cce21560907509cc1f53c68d9
push id38721
push userbsmedberg@mozilla.com
push dateThu, 15 Dec 2016 15:43:08 +0000
reviewersqdot
bugs1317032
milestone53.0a1
Bug 1317032 - If a page uses or removes many <object> elements which are not actually plugins, loading the page goes to a crawl because we recalculate the plugin UI every time. Don't do that by only dispatching a PluginRemoved event for actual plugins, not images/unknown/iframe-type <objects>, r?qdot MozReview-Commit-ID: I84UcPLObCA
dom/base/nsObjectLoadingContent.cpp
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -637,21 +637,23 @@ nsObjectLoadingContent::UnbindFromTree(b
     QueueCheckPluginStopEvent();
   } else if (mType != eType_Image) {
     // nsImageLoadingContent handles the image case.
     // Reset state and clear pending events
     /// XXX(johns): The implementation for GenericFrame notes that ideally we
     ///             would keep the docshell around, but trash the frameloader
     UnloadObject();
   }
-  nsIDocument* doc = thisContent->GetComposedDoc();
-  if (doc && doc->IsActive()) {
-    nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(doc,
-                                                       NS_LITERAL_STRING("PluginRemoved"));
-    NS_DispatchToCurrentThread(ev);
+  if (mType == eType_Plugin) {
+    nsIDocument* doc = thisContent->GetComposedDoc();
+    if (doc && doc->IsActive()) {
+      nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(doc,
+                                                         NS_LITERAL_STRING("PluginRemoved"));
+      NS_DispatchToCurrentThread(ev);
+    }
   }
 }
 
 nsObjectLoadingContent::nsObjectLoadingContent()
   : mType(eType_Loading)
   , mFallbackType(eFallbackAlternate)
   , mRunID(0)
   , mHasRunID(false)