From b63fa8f9298ab69176cf826289debb593ba94703 Mon Sep 17 00:00:00 2001 From: Tetsuharu OHZEKI Date: Sun, 2 Feb 2020 16:53:54 +0000 Subject: [PATCH] Bug 1597475 - Fix uses of nsIDocShellTreeItem in nsDocumentViewer::GetContentSize(). r=emilio Differential Revision: https://phabricator.services.mozilla.com/D61415 --HG-- extra : moz-landing-system : lando --- layout/base/nsDocumentViewer.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 6dcd47ebad30..dfed89ff72e1 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -18,6 +18,7 @@ #include "nsIContent.h" #include "nsIContentViewer.h" #include "nsIDocumentViewerPrint.h" +#include "mozilla/dom/BrowsingContext.h" #include "mozilla/dom/BeforeUnloadEvent.h" #include "mozilla/dom/PopupBlocker.h" #include "mozilla/dom/Document.h" @@ -3171,16 +3172,14 @@ nsresult nsDocumentViewer::GetContentSizeInternal(int32_t* aWidth, NS_IMETHODIMP nsDocumentViewer::GetContentSize(int32_t* aWidth, int32_t* aHeight) { - // Skip doing this on docshell-less documents for now - nsCOMPtr docShellAsItem(mContainer); - NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_NOT_AVAILABLE); + NS_ENSURE_TRUE(mContainer, NS_ERROR_NOT_AVAILABLE); - nsCOMPtr docShellParent; - docShellAsItem->GetInProcessSameTypeParent(getter_AddRefs(docShellParent)); + RefPtr bc = mContainer->GetBrowsingContext(); + NS_ENSURE_TRUE(bc, NS_ERROR_NOT_AVAILABLE); // It's only valid to access this from a top frame. Doesn't work from // sub-frames. - NS_ENSURE_TRUE(!docShellParent, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(bc->IsTop(), NS_ERROR_FAILURE); return GetContentSizeInternal(aWidth, aHeight, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);