mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
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
This commit is contained in:
parent
fc8693795b
commit
b63fa8f929
@ -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<nsIDocShellTreeItem> docShellAsItem(mContainer);
|
||||
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_NOT_AVAILABLE);
|
||||
NS_ENSURE_TRUE(mContainer, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellParent;
|
||||
docShellAsItem->GetInProcessSameTypeParent(getter_AddRefs(docShellParent));
|
||||
RefPtr<BrowsingContext> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user