Bug 1552104. Need to clear display items when we remove a document from the view tree but it sticks around. r=mattwoodrow
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 16 May 2019 21:14:19 +0000
changeset 533112 a056128cc98626d1e89fdb681a39ee5ce4801a1f
parent 533111 aa06b77b2d6b613e2c0d51cf19f730ad3a1f27d7
child 533113 83a094f31fb025b5cb6b196003708b746f0591b6
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1552104
milestone68.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 1552104. Need to clear display items when we remove a document from the view tree but it sticks around. r=mattwoodrow This happens in one test on try server that has some iframes that navigate. I audited everywhere else that we change the view tree, this seems like the only place it can happen. Differential Revision: https://phabricator.services.mozilla.com/D31399
layout/base/nsDocumentViewer.cpp
layout/generic/nsSubDocumentFrame.h
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1726,16 +1726,26 @@ nsDocumentViewer::Destroy() {
     if (mPresShell) {
       nsViewManager* vm = mPresShell->GetViewManager();
       if (vm) {
         nsView* rootView = vm->GetRootView();
 
         if (rootView) {
           nsView* rootViewParent = rootView->GetParent();
           if (rootViewParent) {
+            nsView* subdocview = rootViewParent->GetParent();
+            if (subdocview) {
+              nsIFrame* f = subdocview->GetFrame();
+              if (f) {
+                nsSubDocumentFrame* s = do_QueryFrame(f);
+                if (s) {
+                  s->ClearDisplayItems();
+                }
+              }
+            }
             nsViewManager* parentVM = rootViewParent->GetViewManager();
             if (parentVM) {
               parentVM->RemoveChild(rootView);
             }
           }
         }
       }
     }
--- a/layout/generic/nsSubDocumentFrame.h
+++ b/layout/generic/nsSubDocumentFrame.h
@@ -117,34 +117,34 @@ class nsSubDocumentFrame final : public 
   }
 
   nsFrameLoader* FrameLoader() const;
   void ResetFrameLoader();
 
   void PropagateIsUnderHiddenEmbedderElementToSubView(
       bool aIsUnderHiddenEmbedderElement);
 
+  void ClearDisplayItems();
+
  protected:
   friend class AsyncFrameInit;
 
   // Helper method to look up the HTML marginwidth & marginheight attributes.
   mozilla::CSSIntSize GetMarginAttributes();
 
   bool IsInline() { return mIsInline; }
 
   nscoord GetIntrinsicISize();
   nscoord GetIntrinsicBSize();
 
   // Show our document viewer. The document viewer is hidden via a script
   // runner, so that we can save and restore the presentation if we're
   // being reframed.
   void ShowViewer();
 
-  void ClearDisplayItems();
-
   /* Obtains the frame we should use for intrinsic size information if we are
    * an HTML <object> or <embed>  (a replaced element - not <iframe>)
    * and our sub-document has an intrinsic size. The frame returned is the
    * frame for the document element of the document we're embedding.
    *
    * Called "Obtain*" and not "Get*" because of comment on GetDocShell that
    * says it should be called ObtainDocShell because of its side effects.
    */