Bug 781279 - Forget update plugin geometry frame when presentation detaches. r=roc
authorChris Pearce <cpearce@mozilla.com>
Fri, 24 Aug 2012 23:12:21 +1200
changeset 105321 fe4538ef86c5eb28a9c950419b32bd0548c82578
parent 105320 a485ff9049542ead6fb380e3e8f047d7e05eec7b
child 105322 e80dea0213a0e1afffa0d8723d948e54f87f0c56
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersroc
bugs781279
milestone17.0a1
Bug 781279 - Forget update plugin geometry frame when presentation detaches. r=roc
layout/generic/nsSubDocumentFrame.cpp
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -833,16 +833,28 @@ BeginSwapDocShellsForViews(nsIView* aSib
 void
 nsSubDocumentFrame::DestroyFrom(nsIFrame* aDestructRoot)
 {
   if (mPostedReflowCallback) {
     PresContext()->PresShell()->CancelReflowCallback(this);
     mPostedReflowCallback = false;
   }
 
+  // Forget about plugin geometry updates in the subdoc's PresContext,
+  // otherwise we can be left with dangling pointers to the "plugin for
+  // geometry update frame" in the root PresContext.
+  nsIFrame* subdocRootFrame = GetSubdocumentRootFrame();
+  if (subdocRootFrame) {
+    nsPresContext* pc = subdocRootFrame->PresContext();
+    nsRootPresContext* rpc = pc ? pc->GetRootPresContext() : nullptr;
+    if (rpc) {
+      rpc->RootForgetUpdatePluginGeometryFrameForPresContext(pc);
+    }
+  }
+
   // Detach the subdocument's views and stash them in the frame loader.
   // We can then reattach them if we're being reframed (for example if
   // the frame has been made position:fixed).
   nsFrameLoader* frameloader = FrameLoader();
   if (frameloader) {
     nsIView* detachedViews = ::BeginSwapDocShellsForViews(mInnerView->GetFirstChild());
     frameloader->SetDetachedSubdocView(detachedViews, mContent->OwnerDoc());