Bug 1460940 - Remove nsIDOMDocument uses in layout/. r?bz
MozReview-Commit-ID: KixJ5edlCjl
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -54,17 +54,16 @@
#include "nsView.h"
#include "nsCRTGlue.h"
#include "prinrval.h"
#include "nsTArray.h"
#include "nsCOMArray.h"
#include "nsContainerFrame.h"
#include "mozilla/dom/Selection.h"
#include "nsGkAtoms.h"
-#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsRange.h"
#include "nsWindowSizes.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsReadableUtils.h"
#include "nsIPageSequenceFrame.h"
#include "nsIPermissionManager.h"
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -23,17 +23,16 @@
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsIWritablePropertyBag2.h"
#include "nsSubDocumentFrame.h"
#include "nsGenericHTMLElement.h"
#include "nsILinkHandler.h"
-#include "nsIDOMDocument.h"
#include "nsISelectionListener.h"
#include "mozilla/dom/Selection.h"
#include "nsContentUtils.h"
#include "nsLayoutStylesheetCache.h"
#ifdef ACCESSIBILITY
#include "mozilla/a11y/DocAccessible.h"
#endif
#include "mozilla/BasicEvents.h"
--- a/layout/generic/nsFrameSelection.cpp
+++ b/layout/generic/nsFrameSelection.cpp
@@ -54,17 +54,16 @@ static NS_DEFINE_CID(kFrameTraversalCID,
#include "nsCaret.h"
#include "AccessibleCaretEventHub.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "nsITimer.h"
// notifications
-#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsISelectionController.h" //for the enums
#include "nsAutoCopyListener.h"
#include "SelectionChangeListener.h"
#include "nsCopySupport.h"
#include "nsIClipboard.h"
#include "nsIFrameInlines.h"
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -12,17 +12,16 @@
#include "nsArray.h"
#include "nsAutoPtr.h"
#include "nsIServiceManager.h"
#include "nsString.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsIContentInlines.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
-#include "nsIDOMDocument.h"
#include "nsIDOMWindow.h"
#include "nsXBLBinding.h"
#include "nsXBLPrototypeBinding.h"
#include "nsIMutableArray.h"
#include "nsBindingManager.h"
#include "ChildIterator.h"
#include "nsComputedDOMStyle.h"
#include "mozilla/EventStateManager.h"
--- a/layout/inspector/inDeepTreeWalker.cpp
+++ b/layout/inspector/inDeepTreeWalker.cpp
@@ -3,17 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "inDeepTreeWalker.h"
#include "inLayoutUtils.h"
#include "nsString.h"
-#include "nsIDOMDocument.h"
+#include "nsIDocument.h"
#include "nsServiceManagerUtils.h"
#include "nsIContent.h"
#include "ChildIterator.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/InspectorUtils.h"
#include "mozilla/dom/NodeFilterBinding.h"
/*****************************************************************************
@@ -160,17 +160,18 @@ static already_AddRefed<nsINodeList>
GetChildren(nsIDOMNode* aParent,
bool aShowAnonymousContent,
bool aShowSubDocuments)
{
MOZ_ASSERT(aParent);
nsCOMPtr<nsINodeList> ret;
if (aShowSubDocuments) {
- nsCOMPtr<nsIDOMDocument> domdoc = inLayoutUtils::GetSubDocumentFor(aParent);
+ nsCOMPtr<nsIDOMNode> domdoc =
+ do_QueryInterface(inLayoutUtils::GetSubDocumentFor(aParent));
if (domdoc) {
aParent = domdoc;
}
}
nsCOMPtr<nsIContent> parentAsContent = do_QueryInterface(aParent);
if (parentAsContent && aShowAnonymousContent) {
ret = parentAsContent->GetChildren(nsIContent::eAllChildren);
@@ -293,17 +294,18 @@ inDeepTreeWalker::EdgeChild(nsIDOMNode**
*_retval = nullptr;
nsCOMPtr<nsIDOMNode> echild;
if (mShowSubDocuments && mShowDocumentsAsNodes) {
// GetChildren below, will skip the document node from
// the walk. But if mShowDocumentsAsNodes is set to true
// we want to include the (sub)document itself too.
- echild = inLayoutUtils::GetSubDocumentFor(mCurrentNode);
+ echild =
+ do_QueryInterface(inLayoutUtils::GetSubDocumentFor(mCurrentNode));
}
nsCOMPtr<nsINodeList> children;
if (!echild) {
children = GetChildren(mCurrentNode,
mShowAnonymousContent,
mShowSubDocuments);
if (children && children->Length() > 0) {
--- a/layout/inspector/inLayoutUtils.cpp
+++ b/layout/inspector/inLayoutUtils.cpp
@@ -2,17 +2,16 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "inLayoutUtils.h"
#include "nsIDocument.h"
-#include "nsIDOMDocument.h"
#include "nsIContent.h"
#include "nsIContentViewer.h"
#include "nsPIDOMWindow.h"
#include "nsIDocShell.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/dom/Element.h"
@@ -27,26 +26,24 @@ inLayoutUtils::GetEventStateManagerFor(E
nsIDocument* doc = aElement.OwnerDoc();
nsPresContext* presContext = doc->GetPresContext();
if (!presContext)
return nullptr;
return presContext->EventStateManager();
}
-nsIDOMDocument*
+nsIDocument*
inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content) {
nsCOMPtr<nsIDocument> doc = content->GetComposedDoc();
if (doc) {
- nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc->GetSubDocumentFor(content)));
-
- return domdoc;
+ return doc->GetSubDocumentFor(content);
}
}
return nullptr;
}
nsINode*
inLayoutUtils::GetContainerFor(const nsIDocument& aDoc)
--- a/layout/inspector/inLayoutUtils.h
+++ b/layout/inspector/inLayoutUtils.h
@@ -3,29 +3,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __inLayoutUtils_h__
#define __inLayoutUtils_h__
class nsIDocument;
-class nsIDOMDocument;
class nsIDOMNode;
class nsINode;
namespace mozilla {
class EventStateManager;
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
class inLayoutUtils
{
public:
static mozilla::EventStateManager* GetEventStateManagerFor(
mozilla::dom::Element& aElement);
- static nsIDOMDocument* GetSubDocumentFor(nsIDOMNode* aNode);
+ static nsIDocument* GetSubDocumentFor(nsIDOMNode* aNode);
static nsINode* GetContainerFor(const nsIDocument& aDoc);
};
#endif // __inLayoutUtils_h__
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -71,17 +71,16 @@ static const char kPrintingPromptService
#include "nsISelectionController.h"
// Misc
#include "gfxContext.h"
#include "mozilla/gfx/DrawEventRecorder.h"
#include "mozilla/layout/RemotePrintJobChild.h"
#include "nsISupportsUtils.h"
#include "nsIScriptContext.h"
-#include "nsIDOMDocument.h"
#include "nsIDocumentObserver.h"
#include "nsISelectionListener.h"
#include "nsContentCID.h"
#include "nsLayoutCID.h"
#include "nsContentUtils.h"
#include "nsIPresShell.h"
#include "nsLayoutStylesheetCache.h"
#include "nsLayoutUtils.h"
@@ -615,17 +614,17 @@ static void DumpLayoutData(const char* a
#endif
//--------------------------------------------------------------------------------
nsresult
nsPrintJob::CommonPrint(bool aIsPrintPreview,
nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener,
- nsIDOMDocument* aDoc)
+ nsIDocument* aDoc)
{
// Callers must hold a strong reference to |this| to ensure that we stay
// alive for the duration of this method, because our main owning reference
// (on nsDocumentViewer) might be cleared during this function (if we cause
// script to run and it cancels the print operation).
nsresult rv = DoCommonPrint(aIsPrintPreview, aPrintSettings,
aWebProgressListener, aDoc);
@@ -646,17 +645,17 @@ nsPrintJob::CommonPrint(bool
return rv;
}
nsresult
nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener,
- nsIDOMDocument* aDoc)
+ nsIDocument* aDoc)
{
nsresult rv;
if (aIsPrintPreview) {
// The WebProgressListener can be QI'ed to nsIPrintingPromptService
// then that means the progress dialog is already being shown.
nsCOMPtr<nsIPrintingPromptService> pps(do_QueryInterface(aWebProgressListener));
mProgressDialogIsShown = pps != nullptr;
@@ -1027,19 +1026,19 @@ nsPrintJob::DoCommonPrint(bool
//---------------------------------------------------------------------------------
NS_IMETHODIMP
nsPrintJob::Print(nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener)
{
// If we have a print preview document, use that instead of the original
// mDocument. That way animated images etc. get printed using the same state
// as in print preview.
- nsCOMPtr<nsIDOMDocument> doc =
- do_QueryInterface(mPrtPreview && mPrtPreview->mPrintObject ?
- mPrtPreview->mPrintObject->mDocument : mDocument);
+ nsIDocument* doc =
+ mPrtPreview && mPrtPreview->mPrintObject ?
+ mPrtPreview->mPrintObject->mDocument : mDocument;
return CommonPrint(false, aPrintSettings, aWebProgressListener, doc);
}
NS_IMETHODIMP
nsPrintJob::PrintPreview(nsIPrintSettings* aPrintSettings,
mozIDOMWindowProxy* aChildDOMWin,
nsIWebProgressListener* aWebProgressListener)
@@ -1056,21 +1055,19 @@ nsPrintJob::PrintPreview(nsIPrintSetting
FirePrintingErrorEvent(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY);
return NS_ERROR_FAILURE;
}
auto* window = nsPIDOMWindowOuter::From(aChildDOMWin);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
NS_ENSURE_STATE(doc);
- nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(doc);
- MOZ_ASSERT(domDoc);
// Document is not busy -- go ahead with the Print Preview
- return CommonPrint(true, aPrintSettings, aWebProgressListener, domDoc);
+ return CommonPrint(true, aPrintSettings, aWebProgressListener, doc);
}
//----------------------------------------------------------------------------------
NS_IMETHODIMP
nsPrintJob::GetIsFramesetDocument(bool* aIsFramesetDocument)
{
nsCOMPtr<nsIDocShell> webContainer(do_QueryReferent(mContainer));
*aIsFramesetDocument = IsParentAFrameSet(webContainer);
@@ -1405,17 +1402,17 @@ nsPrintJob::BuildDocTree(nsIDocShell*
for (int32_t i=0;i<childWebshellCount;i++) {
nsCOMPtr<nsIDocShellTreeItem> child;
aParentNode->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
nsCOMPtr<nsIContentViewer> viewer;
childAsShell->GetContentViewer(getter_AddRefs(viewer));
if (viewer) {
- nsCOMPtr<nsIDOMDocument> doc = do_GetInterface(childAsShell);
+ nsCOMPtr<nsIDocument> doc = do_GetInterface(childAsShell);
auto po = MakeUnique<nsPrintObject>();
po->mParent = aPO.get();
nsresult rv = po->Init(childAsShell, doc, aPO->mPrintPreview);
if (NS_FAILED(rv))
NS_NOTREACHED("Init failed?");
aPO->mKids.AppendElement(Move(po));
aDocList->AppendElement(aPO->mKids.LastElement().get());
BuildDocTree(childAsShell, aDocList, aPO->mKids.LastElement());
--- a/layout/printing/nsPrintJob.h
+++ b/layout/printing/nsPrintJob.h
@@ -191,21 +191,21 @@ public:
private:
nsPrintJob& operator=(const nsPrintJob& aOther) = delete;
~nsPrintJob();
nsresult CommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener,
- nsIDOMDocument* aDoc);
+ nsIDocument* aDoc);
nsresult DoCommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener,
- nsIDOMDocument* aDoc);
+ nsIDocument* aDoc);
void FirePrintCompletionEvent();
void DisconnectPagePrintTimer();
nsresult AfterNetworkPrint(bool aHandleError);
nsresult SetRootView(nsPrintObject* aPO,
--- a/layout/printing/nsPrintObject.cpp
+++ b/layout/printing/nsPrintObject.cpp
@@ -1,17 +1,16 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPrintObject.h"
#include "nsIContentViewer.h"
-#include "nsIDOMDocument.h"
#include "nsContentUtils.h" // for nsAutoScriptBlocker
#include "nsIInterfaceRequestorUtils.h"
#include "nsPIDOMWindow.h"
#include "nsGkAtoms.h"
#include "nsComponentManagerUtils.h"
#include "nsIDocShellTreeItem.h"
#include "nsIBaseWindow.h"
#include "nsIDocument.h"
@@ -41,55 +40,54 @@ nsPrintObject::~nsPrintObject()
}
}
mDocShell = nullptr;
mTreeOwner = nullptr; // mTreeOwner must be released after mDocShell;
}
//------------------------------------------------------------------
nsresult
-nsPrintObject::Init(nsIDocShell* aDocShell, nsIDOMDocument* aDoc,
+nsPrintObject::Init(nsIDocShell* aDocShell, nsIDocument* aDoc,
bool aPrintPreview)
{
+ NS_ENSURE_STATE(aDoc);
+
mPrintPreview = aPrintPreview;
if (mPrintPreview || mParent) {
mDocShell = aDocShell;
} else {
mTreeOwner = do_GetInterface(aDocShell);
// Create a container docshell for printing.
mDocShell = do_CreateInstance("@mozilla.org/docshell;1");
NS_ENSURE_TRUE(mDocShell, NS_ERROR_OUT_OF_MEMORY);
mDidCreateDocShell = true;
mDocShell->SetItemType(aDocShell->ItemType());
mDocShell->SetTreeOwner(mTreeOwner);
}
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
// Keep the document related to this docshell alive
- nsCOMPtr<nsIDOMDocument> dummy = do_GetInterface(mDocShell);
+ nsCOMPtr<nsIDocument> dummy = do_GetInterface(mDocShell);
mozilla::Unused << dummy;
nsCOMPtr<nsIContentViewer> viewer;
mDocShell->GetContentViewer(getter_AddRefs(viewer));
NS_ENSURE_STATE(viewer);
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
- NS_ENSURE_STATE(doc);
-
if (mParent) {
- nsCOMPtr<nsPIDOMWindowOuter> window = doc->GetWindow();
+ nsCOMPtr<nsPIDOMWindowOuter> window = aDoc->GetWindow();
if (window) {
mContent = window->GetFrameElementInternal();
}
- mDocument = doc;
+ mDocument = aDoc;
return NS_OK;
}
- mDocument = doc->CreateStaticClone(mDocShell);
+ mDocument = aDoc->CreateStaticClone(mDocShell);
NS_ENSURE_STATE(mDocument);
viewer->SetDocument(mDocument);
return NS_OK;
}
//------------------------------------------------------------------
// Resets PO by destroying the presentation
--- a/layout/printing/nsPrintObject.h
+++ b/layout/printing/nsPrintObject.h
@@ -29,18 +29,17 @@ enum PrintObjectType {eDoc = 0, eFrame
class nsPrintObject
{
public:
nsPrintObject();
~nsPrintObject(); // non-virtual
// Methods
- nsresult Init(nsIDocShell* aDocShell, nsIDOMDocument* aDoc,
- bool aPrintPreview);
+ nsresult Init(nsIDocShell* aDocShell, nsIDocument* aDoc, bool aPrintPreview);
bool IsPrintable() { return !mDontPrint; }
void DestroyPresentation();
// Data Members
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIDocShellTreeOwner> mTreeOwner;
nsCOMPtr<nsIDocument> mDocument;
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -6,17 +6,16 @@
#include "nsGkAtoms.h"
#include "nsXULPopupManager.h"
#include "nsMenuFrame.h"
#include "nsMenuPopupFrame.h"
#include "nsMenuBarFrame.h"
#include "nsMenuBarListener.h"
#include "nsContentUtils.h"
-#include "nsIDOMDocument.h"
#include "nsXULElement.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsCSSFrameConstructor.h"
#include "nsGlobalWindow.h"
#include "nsLayoutUtils.h"
#include "nsViewManager.h"
#include "nsIComponentManager.h"