Backed out changeset 497dbf087ad5 (add diagnostic asserts) (bug 1354933)
authorTimothy Nikkel <tnikkel@gmail.com>
Fri, 07 Jul 2017 14:54:55 -0500
changeset 420596 9ff81e376529981389074a985083d161e2f155d3
parent 420595 20cfd275556463d76fbf17197796291c8897901e
child 420597 9804b2b94597631f04a91bbf307246a6a219f7b7
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1354933
milestone56.0a1
backs out497dbf087ad59eeeb898427b80152ead617c89c9
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
Backed out changeset 497dbf087ad5 (add diagnostic asserts) (bug 1354933)
layout/base/nsDocumentViewer.cpp
view/nsView.cpp
view/nsViewManager.cpp
view/nsViewManager.h
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -321,18 +321,16 @@ private:
 protected:
   // These return the current shell/prescontext etc.
   nsIPresShell* GetPresShell();
   nsPresContext* GetPresContext();
   nsViewManager* GetViewManager();
 
   void DetachFromTopLevelWidget();
 
-  void SetPrintRelated();
-
   // IMPORTANT: The ownership implicit in the following member
   // variables has been explicitly checked and set using nsCOMPtr
   // for owning pointers and raw COM interface pointers for weak
   // (ie, non owning) references. If you add any members to this
   // class, please make the ownership explicit (pinkerton, scc).
 
   WeakPtr<nsDocShell> mContainer; // it owns me!
   nsWeakPtr mTopContainerWhilePrinting;
@@ -403,17 +401,16 @@ protected:
   /* character set member data */
   int32_t mHintCharsetSource;
   const Encoding* mHintCharset;
   const Encoding* mForceCharacterSet;
 
   bool mIsPageMode;
   bool mInitializedForPrintPreview;
   bool mHidden;
-  bool mPrintRelated; // Only use for asserts.
 };
 
 namespace mozilla {
 
 /**
  * A RAII class for automatic dispatch of the 'beforeprint' and 'afterprint'
  * events ('beforeprint' on construction, 'afterprint' on destruction).
  *
@@ -539,33 +536,21 @@ nsDocumentViewer::nsDocumentViewer()
     mDebugFile(nullptr),
 #endif // DEBUG
 #endif // NS_PRINTING
     mHintCharsetSource(kCharsetUninitialized),
     mHintCharset(nullptr),
     mForceCharacterSet(nullptr),
     mIsPageMode(false),
     mInitializedForPrintPreview(false),
-    mHidden(false),
-    mPrintRelated(false)
+    mHidden(false)
 {
   PrepareToStartLoad();
 }
 
-void
-nsDocumentViewer::SetPrintRelated()
-{
-  if (!mPrintRelated) {
-    if (mViewManager) {
-      mViewManager->SetPrintRelated();
-    }
-  }
-  mPrintRelated = true;
-}
-
 NS_IMPL_ADDREF(nsDocumentViewer)
 NS_IMPL_RELEASE(nsDocumentViewer)
 
 NS_INTERFACE_MAP_BEGIN(nsDocumentViewer)
     NS_INTERFACE_MAP_ENTRY(nsIContentViewer)
     NS_INTERFACE_MAP_ENTRY(nsIContentViewerFile)
     NS_INTERFACE_MAP_ENTRY(nsIContentViewerEdit)
     NS_INTERFACE_MAP_ENTRY(nsIDocumentViewerPrint)
@@ -2538,20 +2523,16 @@ nsDocumentViewer::MakeWindow(const nsSiz
   mViewManager = new nsViewManager();
 
   nsDeviceContext *dx = mPresContext->DeviceContext();
 
   nsresult rv = mViewManager->Init(dx);
   if (NS_FAILED(rv))
     return rv;
 
-  if (mPrintRelated) {
-    mViewManager->SetPrintRelated();
-  }
-
   // The root view is always at 0,0.
   nsRect tbounds(nsPoint(0, 0), aSize);
   // Create a view
   nsView* view = mViewManager->CreateView(tbounds, aContainerView);
   if (!view)
     return NS_ERROR_OUT_OF_MEMORY;
 
   // Create a widget if we were given a parent widget or don't have a
@@ -2864,18 +2845,16 @@ NS_IMETHODIMP nsDocumentViewer::SetComma
  *	@update 01/24/00 dwc
  */
 NS_IMETHODIMP
 nsDocumentViewer::Print(bool              aSilent,
                           FILE *            aDebugFile,
                           nsIPrintSettings* aPrintSettings)
 {
 #ifdef NS_PRINTING
-  SetPrintRelated();
-
   nsCOMPtr<nsIPrintSettings> printSettings;
 
 #ifdef DEBUG
   nsresult rv = NS_ERROR_FAILURE;
 
   mDebugFile = aDebugFile;
   // if they don't pass in a PrintSettings, then make one
   // it will have all the default values
@@ -3925,18 +3904,16 @@ nsDocViewerFocusListener::Init(nsDocumen
  */
 
 #ifdef NS_PRINTING
 
 NS_IMETHODIMP
 nsDocumentViewer::Print(nsIPrintSettings*       aPrintSettings,
                           nsIWebProgressListener* aWebProgressListener)
 {
-  SetPrintRelated();
-
   // Printing XUL documents is not supported.
   nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocument));
   if (xulDoc) {
     return NS_ERROR_FAILURE;
   }
 
   if (!mContainer) {
     PR_PL(("Container was destroyed yet we are still trying to use it!"));
@@ -4036,18 +4013,16 @@ nsDocumentViewer::Print(nsIPrintSettings
   return rv;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings,
                                mozIDOMWindowProxy* aChildDOMWin,
                                nsIWebProgressListener* aWebProgressListener)
 {
-  SetPrintRelated();
-
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
   NS_WARNING_ASSERTION(
     IsInitializedForPrintPreview(),
     "Using docshell.printPreview is the preferred way for print previewing!");
 
   NS_ENSURE_ARG_POINTER(aChildDOMWin);
   nsresult rv = NS_OK;
 
@@ -4136,18 +4111,16 @@ nsDocumentViewer::PrintPreview(nsIPrintS
   return NS_ERROR_FAILURE;
 #endif
 }
 
 //----------------------------------------------------------------------
 NS_IMETHODIMP
 nsDocumentViewer::PrintPreviewNavigate(int16_t aType, int32_t aPageNum)
 {
-  SetPrintRelated();
-
   if (!GetIsPrintPreview() ||
       mPrintEngine->GetIsCreatingPrintPreview())
     return NS_ERROR_FAILURE;
 
   nsIScrollableFrame* sf =
     mPrintEngine->GetPrintPreviewPresShell()->GetRootScrollFrameAsScrollable();
   if (!sf)
     return NS_OK;
@@ -4480,19 +4453,16 @@ nsDocumentViewer::GetIsPrinting()
 }
 
 //------------------------------------------------------------
 // Notification from the PrintEngine of the current Printing status
 void
 nsDocumentViewer::SetIsPrinting(bool aIsPrinting)
 {
 #ifdef NS_PRINTING
-  if (aIsPrinting) {
-    SetPrintRelated();
-  }
   // Set all the docShells in the docshell tree to be printing.
   // that way if anyone of them tries to "navigate" it can't
   nsCOMPtr<nsIDocShell> docShell(mContainer);
   if (docShell || !aIsPrinting) {
     SetIsPrintingInDocShellTree(docShell, aIsPrinting, true);
   } else {
     NS_WARNING("Did you close a window before printing?");
   }
@@ -4520,19 +4490,16 @@ nsDocumentViewer::GetIsPrintPreview()
 }
 
 //------------------------------------------------------------
 // Notification from the PrintEngine of the current PP status
 void
 nsDocumentViewer::SetIsPrintPreview(bool aIsPrintPreview)
 {
 #ifdef NS_PRINTING
-  if (aIsPrintPreview) {
-    SetPrintRelated();
-  }
   // Set all the docShells in the docshell tree to be printing.
   // that way if anyone of them tries to "navigate" it can't
   nsCOMPtr<nsIDocShell> docShell(mContainer);
   if (docShell || !aIsPrintPreview) {
     SetIsPrintingInDocShellTree(docShell, aIsPrintPreview, true);
   }
   if (!aIsPrintPreview) {
     // Dispatch the 'afterprint' event now, if pending:
@@ -4557,17 +4524,16 @@ nsDocumentViewer::SetIsPrintPreview(bool
 //----------------------------------------------------------------------------------
 // nsIDocumentViewerPrint IFace
 //----------------------------------------------------------------------------------
 
 //------------------------------------------------------------
 void
 nsDocumentViewer::IncrementDestroyRefCount()
 {
-  SetPrintRelated();
   ++mDestroyRefCount;
 }
 
 //------------------------------------------------------------
 
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
 //------------------------------------------------------------
 // Reset ESM focus for all descendent doc shells.
@@ -4594,18 +4560,16 @@ ResetFocusState(nsIDocShell* aDocShell)
   }
 }
 #endif // NS_PRINTING && NS_PRINT_PREVIEW
 
 void
 nsDocumentViewer::ReturnToGalleyPresentation()
 {
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
-  SetPrintRelated();
-
   if (!GetIsPrintPreview()) {
     NS_ERROR("Wow, we should never get here!");
     return;
   }
 
   SetIsPrintPreview(false);
 
   mPrintEngine->TurnScriptingOn(true);
@@ -4635,17 +4599,16 @@ nsDocumentViewer::ReturnToGalleyPresenta
 //   This IS called from two places in this module for cleaning
 //   up when an error occurred during the start up printing
 //   and print preview
 //
 void
 nsDocumentViewer::OnDonePrinting()
 {
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
-  SetPrintRelated();
   // If Destroy() has been called during calling nsPrintEngine::Print() or
   // nsPrintEngine::PrintPreview(), mPrintEngine is already nullptr here.
   // So, the following clean up does nothing in such case.
   // (Do we need some of this for that case?)
   if (mPrintEngine) {
     RefPtr<nsPrintEngine> pe = mPrintEngine;
     if (GetIsPrintPreview()) {
       pe->DestroyPrintingData();
@@ -4670,20 +4633,16 @@ nsDocumentViewer::OnDonePrinting()
       mClosingWhilePrinting = false;
     }
   }
 #endif // NS_PRINTING && NS_PRINT_PREVIEW
 }
 
 NS_IMETHODIMP nsDocumentViewer::SetPageMode(bool aPageMode, nsIPrintSettings* aPrintSettings)
 {
-  if (aPageMode) {
-    SetPrintRelated();
-  }
-
   // XXX Page mode is only partially working; it's currently used for
   // reftests that require a paginated context
   mIsPageMode = aPageMode;
 
   // The DestroyPresShell call requires a script blocker, since the
   // PresShell::Destroy call it does can cause scripts to run, which could
   // re-entrantly call methods on the nsDocumentViewer.
   nsAutoScriptBlocker scriptBlocker;
@@ -4777,17 +4736,16 @@ bool
 nsDocumentViewer::IsInitializedForPrintPreview()
 {
   return mInitializedForPrintPreview;
 }
 
 void
 nsDocumentViewer::InitializeForPrintPreview()
 {
-  SetPrintRelated();
   mInitializedForPrintPreview = true;
 }
 
 void
 nsDocumentViewer::SetPrintPreviewPresentation(nsViewManager* aViewManager,
                                               nsPresContext* aPresContext,
                                               nsIPresShell* aPresShell)
 {
--- a/view/nsView.cpp
+++ b/view/nsView.cpp
@@ -61,18 +61,16 @@ void nsView::DropMouseGrabbing()
   if (presShell)
     presShell->ClearMouseCaptureOnView(this);
 }
 
 nsView::~nsView()
 {
   MOZ_COUNT_DTOR(nsView);
 
-  bool printRelated = mViewManager && mViewManager->GetPrintRelated();
-
   while (GetFirstChild())
   {
     nsView* child = GetFirstChild();
     if (child->GetViewManager() == mViewManager) {
       child->Destroy();
     } else {
       // just unhook it. Someone else will want to destroy this.
       RemoveChild(child);
@@ -114,21 +112,16 @@ nsView::~nsView()
   if (mPreviousWindow) {
     mPreviousWindow->SetPreviouslyAttachedWidgetListener(nullptr);
   }
 
   // Destroy and release the widget
   DestroyWidget();
 
   delete mDirtyRegion;
-
-  if (MOZ_UNLIKELY(mFrame)) {
-    gfxCriticalNoteOnce << "~nsView mFrame printRelated " << (printRelated ? "true" : "false");
-  }
-  MOZ_RELEASE_ASSERT(!mFrame);
 }
 
 class DestroyWidgetRunnable : public Runnable {
 public:
   NS_DECL_NSIRUNNABLE
 
   explicit DestroyWidgetRunnable(nsIWidget* aWidget)
     : mozilla::Runnable("DestroyWidgetRunnable")
--- a/view/nsViewManager.cpp
+++ b/view/nsViewManager.cpp
@@ -58,17 +58,16 @@ nsViewManager::nsViewManager()
   : mPresShell(nullptr)
   , mDelayedResize(NSCOORD_NONE, NSCOORD_NONE)
   , mRootView(nullptr)
   , mRootViewManager(this)
   , mRefreshDisableCount(0)
   , mPainting(false)
   , mRecursiveRefreshPending(false)
   , mHasPendingWidgetGeometryChanges(false)
-  , mPrintRelated(false)
 {
   if (gViewManagers == nullptr) {
     // Create an array to hold a list of view managers
     gViewManagers = new nsTArray<nsViewManager*>;
   }
 
   gViewManagers->AppendElement(this);
 }
--- a/view/nsViewManager.h
+++ b/view/nsViewManager.h
@@ -314,19 +314,16 @@ public:
    */
   void UpdateWidgetGeometry();
 
   int32_t AppUnitsPerDevPixel() const
   {
     return mContext->AppUnitsPerDevPixel();
   }
 
-  void SetPrintRelated() { mPrintRelated = true; }
-  bool GetPrintRelated() { return mPrintRelated; }
-
 private:
   static uint32_t gLastUserEventTime;
 
   /* Update the cached RootViewManager pointer on this view manager. */
   void InvalidateHierarchy();
   void FlushPendingInvalidates();
 
   void ProcessPendingUpdatesForView(nsView *aView,
@@ -405,17 +402,16 @@ private:
   // the root view manager.  Some have accessor functions to enforce
   // this, as noted.
 
   int32_t           mRefreshDisableCount;
   // Use IsPainting() and SetPainting() to access mPainting.
   bool              mPainting;
   bool              mRecursiveRefreshPending;
   bool              mHasPendingWidgetGeometryChanges;
-  bool              mPrintRelated;
 
   //from here to public should be static and locked... MMP
 
   //list of view managers
   static nsTArray<nsViewManager*> *gViewManagers;
 };
 
 /**