Bug 836176 - Part 3: Remove nsIHTMLDocument; r=farre

Differential Revision: https://phabricator.services.mozilla.com/D32925

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-06-04 17:27:43 +00:00
Родитель b952303dbe
Коммит adf073ce68
25 изменённых файлов: 51 добавлений и 122 удалений

Просмотреть файл

@ -986,7 +986,7 @@ VariablesView.prototype = {
/**
* Gets the owner document holding this view.
* @return nsIHTMLDocument
* @return HTMLDocument
*/
get document() {
return this._document || (this._document = this._parent.ownerDocument);
@ -2048,7 +2048,7 @@ Scope.prototype = {
/**
* Gets the owner document holding this scope.
* @return nsIHTMLDocument
* @return HTMLDocument
*/
get document() {
return this._document || (this._document = this.ownerView.document);

Просмотреть файл

@ -45,7 +45,7 @@ class nsDocShellEditorData {
// If this frame is editable, store HTML editor here. It's owned here.
RefPtr<mozilla::HTMLEditor> mHTMLEditor;
// Backup for the corresponding nsIHTMLDocument's editing state while
// Backup for the corresponding HTMLDocument's editing state while
// the editor is detached.
mozilla::dom::Document::EditingState mDetachedEditingState;

Просмотреть файл

@ -117,11 +117,11 @@ bool WindowNamedPropertiesHandler::getOwnPropDescriptor(
}
// The rest of this function is for HTML documents only.
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(win->GetExtantDoc());
if (!htmlDoc) {
Document* doc = win->GetExtantDoc();
if (!doc || !doc->IsHTMLOrXHTML()) {
return true;
}
nsHTMLDocument* document = static_cast<nsHTMLDocument*>(htmlDoc.get());
nsHTMLDocument* document = doc->AsHTMLDocument();
JS::Rooted<JS::Value> v(aCx);
Element* element = document->GetElementById(str);
@ -197,11 +197,11 @@ bool WindowNamedPropertiesHandler::ownPropNames(
}
names.Clear();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(win->GetExtantDoc());
if (!htmlDoc) {
Document* doc = win->GetExtantDoc();
if (!doc || !doc->IsHTMLOrXHTML()) {
return true;
}
nsHTMLDocument* document = static_cast<nsHTMLDocument*>(htmlDoc.get());
nsHTMLDocument* document = doc->AsHTMLDocument();
// Document names are enumerable, so we want to get them no matter what flags
// is.
document->GetSupportedNames(names);

Просмотреть файл

@ -158,7 +158,6 @@
#include "nsIForm.h"
#include "nsIFragmentContentSink.h"
#include "nsContainerFrame.h"
#include "nsIHTMLDocument.h"
#include "nsIHttpChannelInternal.h"
#include "nsIIdleService.h"
#include "nsIImageLoadingContent.h"
@ -2656,14 +2655,13 @@ nsresult nsContentUtils::GenerateStateKey(nsIContent* aContent,
return NS_OK;
}
nsCOMPtr<nsIHTMLDocument> htmlDocument =
do_QueryInterface(aContent->GetUncomposedDoc());
RefPtr<Document> doc = aContent->GetUncomposedDoc();
KeyAppendInt(partID, aKey); // first append a partID
bool generatedUniqueKey = false;
if (htmlDocument) {
nsHTMLDocument* htmlDoc = static_cast<nsHTMLDocument*>(htmlDocument.get());
if (doc && doc->IsHTMLOrXHTML()) {
nsHTMLDocument* htmlDoc = doc->AsHTMLDocument();
RefPtr<nsContentList> htmlForms;
RefPtr<nsContentList> htmlFormControls;
htmlDoc->GetFormsAndFormControls(getter_AddRefs(htmlForms),
@ -2708,7 +2706,7 @@ nsresult nsContentUtils::GenerateStateKey(nsIContent* aContent,
// highly likely guess that the highest form parsed so far is the one.
// This code should not be on trunk, only branch.
//
index = htmlDocument->GetNumFormsSynchronous() - 1;
index = htmlDoc->GetNumFormsSynchronous() - 1;
}
if (index > -1) {
KeyAppendInt(index, aKey);
@ -4520,10 +4518,6 @@ already_AddRefed<DocumentFragment> nsContentUtils::CreateContextualFragment(
// for compiling event handlers... so just bail out.
RefPtr<Document> document = aContextNode->OwnerDoc();
bool isHTML = document->IsHTMLDocument();
#ifdef DEBUG
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
NS_ASSERTION(!isHTML || htmlDoc, "Should have HTMLDocument here!");
#endif
if (isHTML) {
RefPtr<DocumentFragment> frag =

Просмотреть файл

@ -28,7 +28,7 @@
#include "nsPIDOMWindow.h"
#include "mozilla/dom/Document.h"
#include "nsIHTMLDocument.h"
#include "nsHTMLDocument.h"
#include "nsGkAtoms.h"
#include "nsIFrame.h"
#include "nsIURI.h"
@ -122,10 +122,9 @@ static nsresult EncodeForTextUnicode(nsIDocumentEncoder& aEncoder,
if (!selForcedTextPlain && mimeType.EqualsLiteral(kTextMime)) {
// SetSelection and EncodeToString use this case to signal that text/plain
// was forced because the document is either not an nsIHTMLDocument or it's
// XHTML. We want to pretty print XHTML but not non-nsIHTMLDocuments.
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(&aDocument);
if (!htmlDoc) {
// was forced because the document is either not an HTMLDocument or it's
// XHTML. We want to pretty print XHTML but not non-HTMLDocuments.
if (!aDocument.IsHTMLOrXHTML()) {
selForcedTextPlain = true;
}
}
@ -562,10 +561,6 @@ static nsresult AppendDOMNode(nsITransferable* aTransferable,
// Note that XHTML is not counted as HTML here, because we can't copy it
// properly (all the copy code for non-plaintext assumes using HTML
// serializers and parsers is OK, and those mess up XHTML).
DebugOnly<nsCOMPtr<nsIHTMLDocument>> htmlDoc =
nsCOMPtr<nsIHTMLDocument>(do_QueryInterface(document, &rv));
NS_ENSURE_SUCCESS(rv, NS_OK);
NS_ENSURE_TRUE(document->IsHTMLDocument(), NS_OK);
// init encoder with document and node

Просмотреть файл

@ -17,13 +17,13 @@
#include "nsIFactory.h"
#include "nsISupports.h"
#include "mozilla/dom/Document.h"
#include "nsIHTMLDocument.h"
#include "nsCOMPtr.h"
#include "nsIContentSerializer.h"
#include "mozilla/Encoding.h"
#include "nsIOutputStream.h"
#include "nsRange.h"
#include "nsGkAtoms.h"
#include "nsHTMLDocument.h"
#include "nsIContent.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
@ -1347,8 +1347,7 @@ nsHTMLCopyEncoder::SetSelection(Selection* aSelection) {
// XXX bug 1245883
// also consider ourselves in a text widget if we can't find an html document
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
if (!(htmlDoc && mDocument->IsHTMLDocument())) {
if (!(mDocument && mDocument->IsHTMLDocument())) {
mIsTextWidget = true;
mEncodingScope.mSelection = aSelection;
// mMimeType is set to text/plain when encoding starts.

Просмотреть файл

@ -16,7 +16,6 @@
#include "ContentParent.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMChromeWindow.h"
#include "nsIHTMLDocument.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIFormControl.h"
@ -40,6 +39,7 @@
#include "nsStyleCoord.h"
#include "BrowserChild.h"
#include "nsFrameLoader.h"
#include "nsHTMLDocument.h"
#include "nsNumberControlFrame.h"
#include "nsNetUtil.h"
#include "nsRange.h"
@ -3839,8 +3839,7 @@ Element* nsFocusManager::GetRootForFocus(nsPIDOMWindowOuter* aWindow,
}
// Finally, check if this is a frameset
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(aDocument);
if (htmlDoc) {
if (aDocument && aDocument->IsHTMLOrXHTML()) {
Element* htmlChild = aDocument->GetHtmlChildElement(nsGkAtoms::frameset);
if (htmlChild) {
// In document navigation mode, return the frameset so that navigation

Просмотреть файл

@ -18,8 +18,8 @@
#include "mozilla/dom/HTMLFormControlsCollection.h"
#include "mozilla/dom/HTMLFormElementBinding.h"
#include "mozilla/Move.h"
#include "nsIHTMLDocument.h"
#include "nsGkAtoms.h"
#include "nsHTMLDocument.h"
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "mozilla/dom/Document.h"
@ -358,7 +358,7 @@ static void CollectOrphans(nsINode* aRemovalRoot,
void HTMLFormElement::UnbindFromTree(bool aNullParent) {
// Note, this is explicitly using uncomposed doc, since we count
// only forms in document.
nsCOMPtr<nsIHTMLDocument> oldDocument = do_QueryInterface(GetUncomposedDoc());
RefPtr<Document> oldDocument = GetUncomposedDoc();
// Mark all of our controls as maybe being orphans
MarkOrphans(mControls->mElements);
@ -396,8 +396,8 @@ void HTMLFormElement::UnbindFromTree(bool aNullParent) {
#endif
);
if (oldDocument) {
oldDocument->RemovedForm();
if (oldDocument && oldDocument->IsHTMLOrXHTML()) {
oldDocument->AsHTMLDocument()->RemovedForm();
}
ForgetCurrentSubmission();
}
@ -1483,8 +1483,7 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL,
nsCOMPtr<nsIURI> actionURL;
if (action.IsEmpty()) {
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(document));
if (!htmlDoc) {
if (!document->IsHTMLOrXHTML()) {
// Must be a XML, XUL or other non-HTML document type
// so do nothing.
return NS_OK;

Просмотреть файл

@ -39,7 +39,6 @@ EXPORTS += [
'nsIFormControl.h',
'nsIFormProcessor.h',
'nsIHTMLCollection.h',
'nsIHTMLDocument.h',
'nsIRadioGroupContainer.h',
'nsIRadioVisitor.h',
'nsITextControlElement.h',

Просмотреть файл

@ -32,7 +32,6 @@
#include "nsIDOMWindow.h"
#include "nsMappedAttributes.h"
#include "nsHTMLStyleSheet.h"
#include "nsIHTMLDocument.h"
#include "nsPIDOMWindow.h"
#include "nsIURL.h"
#include "nsEscape.h"

Просмотреть файл

@ -49,7 +49,7 @@
#include "nsIDocShell.h"
#include "mozilla/dom/Document.h"
#include "nsStubDocumentObserver.h"
#include "nsIHTMLDocument.h"
#include "nsHTMLDocument.h"
#include "nsICookieService.h"
#include "nsTArray.h"
#include "nsIScriptSecurityManager.h"
@ -137,7 +137,7 @@ class HTMLContentSink : public nsContentSink, public nsIHTMLContentSink {
protected:
virtual ~HTMLContentSink();
nsCOMPtr<nsIHTMLDocument> mHTMLDocument;
RefPtr<nsHTMLDocument> mHTMLDocument;
// The maximum length of a text run
int32_t mMaxTextRun;
@ -612,7 +612,7 @@ nsresult HTMLContentSink::Init(Document* aDoc, nsIURI* aURI,
aDoc->AddObserver(this);
mIsDocumentObserver = true;
mHTMLDocument = do_QueryInterface(aDoc);
mHTMLDocument = aDoc->AsHTMLDocument();
NS_ASSERTION(mDocShell, "oops no docshell!");
@ -960,6 +960,6 @@ void HTMLContentSink::ContinueInterruptedParsingAsync() {
"HTMLContentSink::ContinueInterruptedParsingIfEnabled", this,
&HTMLContentSink::ContinueInterruptedParsingIfEnabled);
nsCOMPtr<Document> doc = do_QueryInterface(mHTMLDocument);
RefPtr<Document> doc = mHTMLDocument;
doc->Dispatch(mozilla::TaskCategory::Other, ev.forget());
}

Просмотреть файл

@ -160,8 +160,7 @@ nsHTMLDocument::~nsHTMLDocument() {}
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsHTMLDocument, Document, mAll)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(nsHTMLDocument, Document,
nsIHTMLDocument)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(nsHTMLDocument, Document)
JSObject* nsHTMLDocument::WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h"
#include "nsContentList.h"
#include "mozilla/dom/Document.h"
#include "nsIHTMLDocument.h"
#include "nsIHTMLCollection.h"
#include "nsIScriptElement.h"
#include "nsTArray.h"
@ -35,7 +34,7 @@ class WindowProxyHolder;
} // namespace dom
} // namespace mozilla
class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
class nsHTMLDocument : public mozilla::dom::Document {
protected:
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
typedef mozilla::dom::Document Document;
@ -70,7 +69,6 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
virtual bool UseWidthDeviceWidthFallbackViewport() const override;
public:
// nsIHTMLDocument
virtual Element* GetUnfocusedKeyEventTarget() override;
nsContentList* GetExistingForms() const { return mForms; }
@ -82,9 +80,23 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
virtual void AddedForm() override;
virtual void RemovedForm() override;
virtual int32_t GetNumFormsSynchronous() override;
/**
* Called when form->BindToTree() is called so that document knows
* immediately when a form is added
*/
void AddedForm();
/**
* Called when form->SetDocument() is called so that document knows
* immediately when a form is removed
*/
void RemovedForm();
/**
* Called to get a better count of forms than document.forms can provide
* without calling FlushPendingNotifications (bug 138892).
*/
// XXXbz is this still needed now that we can flush just content,
// not the rest?
int32_t GetNumFormsSynchronous();
void SetIsXHTML(bool aXHTML) { mType = (aXHTML ? eXHTML : eHTML); }
virtual nsresult Clone(mozilla::dom::NodeInfo*,
@ -217,8 +229,4 @@ inline nsHTMLDocument* Document::AsHTMLDocument() {
} // namespace dom
} // namespace mozilla
#define NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
NS_INTERFACE_TABLE_ENTRY(_class, nsIHTMLDocument)
#endif /* nsHTMLDocument_h___ */

Просмотреть файл

@ -1,51 +0,0 @@
/* -*- 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/. */
#ifndef nsIHTMLDocument_h
#define nsIHTMLDocument_h
#include "nsISupports.h"
#include "nsCompatibility.h"
class nsIContent;
class nsContentList;
#define NS_IHTMLDOCUMENT_IID \
{ \
0xcf814492, 0x303c, 0x4718, { \
0x9a, 0x3e, 0x39, 0xbc, 0xd5, 0x2c, 0x10, 0xdb \
} \
}
/**
* HTML document extensions to Document.
*/
class nsIHTMLDocument : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLDOCUMENT_IID)
/**
* Called when form->BindToTree() is called so that document knows
* immediately when a form is added
*/
virtual void AddedForm() = 0;
/**
* Called when form->SetDocument() is called so that document knows
* immediately when a form is removed
*/
virtual void RemovedForm() = 0;
/**
* Called to get a better count of forms than document.forms can provide
* without calling FlushPendingNotifications (bug 138892).
*/
// XXXbz is this still needed now that we can flush just content,
// not the rest?
virtual int32_t GetNumFormsSynchronous() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)
#endif /* nsIHTMLDocument_h */

Просмотреть файл

@ -45,7 +45,6 @@
#include "nsError.h"
#include "nsNodeUtils.h"
#include "nsIScriptGlobalObject.h"
#include "nsIHTMLDocument.h"
#include "mozAutoDocUpdate.h"
#include "nsMimeTypes.h"
#include "nsHtml5SVGLoadDispatcher.h"

Просмотреть файл

@ -67,7 +67,6 @@
#include "nsContentUtils.h"
#include "nsCycleCollectionParticipant.h"
#include "nsError.h"
#include "nsIHTMLDocument.h"
#include "nsIStorageStream.h"
#include "nsIPromptFactory.h"
#include "nsIWindowWatcher.h"

Просмотреть файл

@ -45,7 +45,6 @@
#include "nsError.h"
#include "nsNodeUtils.h"
#include "nsIScriptGlobalObject.h"
#include "nsIHTMLDocument.h"
#include "mozAutoDocUpdate.h"
#include "nsMimeTypes.h"
#include "nsHtml5SVGLoadDispatcher.h"

Просмотреть файл

@ -20,7 +20,6 @@
#include "nsNameSpaceManager.h"
#include "txStringUtils.h"
#include "txURIUtils.h"
#include "nsIHTMLDocument.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsIDocumentTransformer.h"
#include "mozilla/StyleSheetInlines.h"

Просмотреть файл

@ -30,7 +30,6 @@
#include "mozilla/dom/Document.h" // for Document
#include "nsIDocumentStateListener.h"
#include "nsIEditor.h" // for nsIEditor
#include "nsIHTMLDocument.h" // for nsIHTMLDocument, etc
#include "nsIInterfaceRequestorUtils.h" // for do_GetInterface
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc
#include "nsIRefreshURI.h" // for nsIRefreshURI

Просмотреть файл

@ -83,7 +83,6 @@
#include "nsIEditorObserver.h" // for nsIEditorObserver
#include "nsIEditorSpellCheck.h" // for nsIEditorSpellCheck
#include "nsIFrame.h" // for nsIFrame
#include "nsIHTMLDocument.h" // for nsIHTMLDocument
#include "nsIInlineSpellChecker.h" // for nsIInlineSpellChecker, etc.
#include "nsNameSpaceManager.h" // for kNameSpaceID_None, etc.
#include "nsINode.h" // for nsINode, etc.

Просмотреть файл

@ -31,8 +31,8 @@
#include "nsNodeInfoManager.h"
#include "nsContentCreatorFunctions.h"
#include "mozilla/PresState.h"
#include "nsIHTMLDocument.h"
#include "nsContentUtils.h"
#include "nsHTMLDocument.h"
#include "nsLayoutUtils.h"
#include "nsBidiPresUtils.h"
#include "nsBidiUtils.h"
@ -5331,8 +5331,7 @@ nsIFrame* ScrollFrameHelper::GetFrameForDir() const {
Element* root = document->GetRootElement();
// But for HTML and XHTML we want the body element.
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
if (htmlDoc) {
if (document && document->IsHTMLOrXHTML()) {
Element* bodyElement = document->GetBodyElement();
if (bodyElement) {
root = bodyElement; // we can trust the document to hold on to it

Просмотреть файл

@ -7,7 +7,6 @@
#include "nsHtml5DocumentBuilder.h"
#include "mozilla/dom/ScriptLoader.h"
#include "nsIHTMLDocument.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsNameSpaceManager.h"
#include "nsStyleLinkElement.h"

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/css/Loader.h"
#include "mozilla/dom/ScriptLoader.h"
#include "nsIDocShell.h"
#include "nsIHTMLDocument.h"
nsHtml5OplessBuilder::nsHtml5OplessBuilder() : nsHtml5DocumentBuilder(true) {}

Просмотреть файл

@ -29,7 +29,6 @@
#include "nsIContentViewer.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIHTMLDocument.h"
#include "nsINestedURI.h"
#include "nsIScriptContext.h"
#include "nsIScriptError.h"

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsIDTD.h"
#include "nsIFormControl.h"
#include "nsIFormProcessor.h"
#include "nsIHTMLDocument.h"
#include "nsIMutationObserver.h"
#include "nsINode.h"
#include "nsIObserverService.h"