Bug 1960678 - Make DocumentFlavor an enum class. r=emilio,necko-reviewers,sunil
Differential Revision: https://phabricator.services.mozilla.com/D245599
This commit is contained in:
@@ -100,7 +100,7 @@ nsresult DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
|||||||
rv = NS_NewDOMDocument(getter_AddRefs(doc), aNamespaceURI, aQualifiedName,
|
rv = NS_NewDOMDocument(getter_AddRefs(doc), aNamespaceURI, aQualifiedName,
|
||||||
aDoctype, mDocumentURI, mBaseURI,
|
aDoctype, mDocumentURI, mBaseURI,
|
||||||
mOwner->NodePrincipal(), true, scriptHandlingObject,
|
mOwner->NodePrincipal(), true, scriptHandlingObject,
|
||||||
DocumentFlavorXML);
|
DocumentFlavor::XML);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// When DOMImplementation's createDocument method is invoked with
|
// When DOMImplementation's createDocument method is invoked with
|
||||||
@@ -153,7 +153,7 @@ nsresult DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
|
|||||||
nsresult rv =
|
nsresult rv =
|
||||||
NS_NewDOMDocument(getter_AddRefs(doc), u""_ns, u""_ns, doctype,
|
NS_NewDOMDocument(getter_AddRefs(doc), u""_ns, u""_ns, doctype,
|
||||||
mDocumentURI, mBaseURI, mOwner->NodePrincipal(), true,
|
mDocumentURI, mBaseURI, mOwner->NodePrincipal(), true,
|
||||||
scriptHandlingObject, DocumentFlavorLegacyGuess);
|
scriptHandlingObject, DocumentFlavor::LegacyGuess);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMParser)
|
|||||||
already_AddRefed<Document> DOMParser::ParseFromStringInternal(
|
already_AddRefed<Document> DOMParser::ParseFromStringInternal(
|
||||||
const nsAString& aStr, SupportedType aType, ErrorResult& aRv) {
|
const nsAString& aStr, SupportedType aType, ErrorResult& aRv) {
|
||||||
if (aType == SupportedType::Text_html) {
|
if (aType == SupportedType::Text_html) {
|
||||||
nsCOMPtr<Document> document = SetUpDocument(DocumentFlavorHTML, aRv);
|
nsCOMPtr<Document> document = SetUpDocument(DocumentFlavor::HTML, aRv);
|
||||||
if (NS_WARN_IF(aRv.Failed())) {
|
if (NS_WARN_IF(aRv.Failed())) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -191,8 +191,8 @@ already_AddRefed<Document> DOMParser::ParseFromStream(nsIInputStream* aStream,
|
|||||||
stream = bufferedStream;
|
stream = bufferedStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<Document> document =
|
nsCOMPtr<Document> document = SetUpDocument(
|
||||||
SetUpDocument(svg ? DocumentFlavorSVG : DocumentFlavorLegacyGuess, aRv);
|
svg ? DocumentFlavor::SVG : DocumentFlavor::LegacyGuess, aRv);
|
||||||
if (NS_WARN_IF(aRv.Failed())) {
|
if (NS_WARN_IF(aRv.Failed())) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13340,7 +13340,7 @@ Document* Document::GetTemplateContentsOwner() {
|
|||||||
Document::GetDocumentURI(), Document::GetDocBaseURI(), NodePrincipal(),
|
Document::GetDocumentURI(), Document::GetDocBaseURI(), NodePrincipal(),
|
||||||
true, // aLoadedAsData
|
true, // aLoadedAsData
|
||||||
scriptObject, // aEventObject
|
scriptObject, // aEventObject
|
||||||
IsHTMLDocument() ? DocumentFlavorHTML : DocumentFlavorXML);
|
IsHTMLDocument() ? DocumentFlavor::HTML : DocumentFlavor::XML);
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
|
||||||
mTemplateContentsOwner = document;
|
mTemplateContentsOwner = document;
|
||||||
@@ -16604,7 +16604,7 @@ already_AddRefed<Document> Document::Constructor(const GlobalObject& aGlobal,
|
|||||||
nsCOMPtr<Document> doc;
|
nsCOMPtr<Document> doc;
|
||||||
nsresult res = NS_NewDOMDocument(getter_AddRefs(doc), VoidString(), u""_ns,
|
nsresult res = NS_NewDOMDocument(getter_AddRefs(doc), VoidString(), u""_ns,
|
||||||
nullptr, uri, uri, prin->GetPrincipal(),
|
nullptr, uri, uri, prin->GetPrincipal(),
|
||||||
true, global, DocumentFlavorPlain);
|
true, global, DocumentFlavor::Plain);
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
rv.Throw(res);
|
rv.Throw(res);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -5715,12 +5715,12 @@ nsresult NS_NewVideoDocument(mozilla::dom::Document** aInstancePtrResult,
|
|||||||
nsIPrincipal* aPartitionedPrincipal);
|
nsIPrincipal* aPartitionedPrincipal);
|
||||||
|
|
||||||
// Enum for requesting a particular type of document when creating a doc
|
// Enum for requesting a particular type of document when creating a doc
|
||||||
enum DocumentFlavor {
|
enum class DocumentFlavor : uint8_t {
|
||||||
DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
|
LegacyGuess, // compat with old code until made HTML5-compliant
|
||||||
DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true
|
HTML, // HTMLDocument with HTMLness bit set to true
|
||||||
DocumentFlavorSVG, // SVGDocument
|
SVG, // SVGDocument
|
||||||
DocumentFlavorXML, // XMLDocument
|
XML, // XMLDocument
|
||||||
DocumentFlavorPlain, // Just a Document
|
Plain, // Just a Document
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: it's the caller's responsibility to create or get aPrincipal as needed
|
// Note: it's the caller's responsibility to create or get aPrincipal as needed
|
||||||
|
|||||||
@@ -6166,13 +6166,13 @@ static already_AddRefed<Document> CreateInertDocument(const Document* aTemplate,
|
|||||||
/* static */
|
/* static */
|
||||||
already_AddRefed<Document> nsContentUtils::CreateInertXMLDocument(
|
already_AddRefed<Document> nsContentUtils::CreateInertXMLDocument(
|
||||||
const Document* aTemplate) {
|
const Document* aTemplate) {
|
||||||
return CreateInertDocument(aTemplate, DocumentFlavorXML);
|
return CreateInertDocument(aTemplate, DocumentFlavor::XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
already_AddRefed<Document> nsContentUtils::CreateInertHTMLDocument(
|
already_AddRefed<Document> nsContentUtils::CreateInertHTMLDocument(
|
||||||
const Document* aTemplate) {
|
const Document* aTemplate) {
|
||||||
return CreateInertDocument(aTemplate, DocumentFlavorHTML);
|
return CreateInertDocument(aTemplate, DocumentFlavor::HTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ static already_AddRefed<Document> CreateHTMLDoc() {
|
|||||||
uri, uri, principal,
|
uri, uri, principal,
|
||||||
false, // aLoadedAsData
|
false, // aLoadedAsData
|
||||||
nullptr, // aEventObject
|
nullptr, // aEventObject
|
||||||
DocumentFlavorHTML));
|
DocumentFlavor::HTML));
|
||||||
MOZ_RELEASE_ASSERT(doc);
|
MOZ_RELEASE_ASSERT(doc);
|
||||||
return doc.forget();
|
return doc.forget();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ static already_AddRefed<Document> SetUpDocument() {
|
|||||||
uri, uri, principal,
|
uri, uri, principal,
|
||||||
false, // aLoadedAsData
|
false, // aLoadedAsData
|
||||||
nullptr, // aEventObject
|
nullptr, // aEventObject
|
||||||
DocumentFlavorHTML);
|
DocumentFlavor::HTML);
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -2182,7 +2182,7 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request) {
|
|||||||
rv = NS_NewDOMDocument(
|
rv = NS_NewDOMDocument(
|
||||||
getter_AddRefs(mResponseXML), emptyStr, emptyStr, nullptr, docURI,
|
getter_AddRefs(mResponseXML), emptyStr, emptyStr, nullptr, docURI,
|
||||||
baseURI, requestingPrincipal, true, global,
|
baseURI, requestingPrincipal, true, global,
|
||||||
mIsHtml ? DocumentFlavorHTML : DocumentFlavorLegacyGuess);
|
mIsHtml ? DocumentFlavor::HTML : DocumentFlavor::LegacyGuess);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
mResponseXML->SetChromeXHRDocURI(chromeXHRDocURI);
|
mResponseXML->SetChromeXHRDocURI(chromeXHRDocURI);
|
||||||
mResponseXML->SetChromeXHRDocBaseURI(chromeXHRDocBaseURI);
|
mResponseXML->SetChromeXHRDocBaseURI(chromeXHRDocBaseURI);
|
||||||
|
|||||||
@@ -65,18 +65,18 @@ nsresult NS_NewDOMDocument(Document** aInstancePtrResult,
|
|||||||
nsCOMPtr<Document> d;
|
nsCOMPtr<Document> d;
|
||||||
bool isHTML = false;
|
bool isHTML = false;
|
||||||
bool isXHTML = false;
|
bool isXHTML = false;
|
||||||
if (aFlavor == DocumentFlavorSVG) {
|
if (aFlavor == DocumentFlavor::SVG) {
|
||||||
rv = NS_NewSVGDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
rv = NS_NewSVGDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
||||||
} else if (aFlavor == DocumentFlavorHTML) {
|
} else if (aFlavor == DocumentFlavor::HTML) {
|
||||||
rv = NS_NewHTMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
rv = NS_NewHTMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
||||||
isHTML = true;
|
isHTML = true;
|
||||||
} else if (aFlavor == DocumentFlavorXML) {
|
} else if (aFlavor == DocumentFlavor::XML) {
|
||||||
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
||||||
} else if (aFlavor == DocumentFlavorPlain) {
|
} else if (aFlavor == DocumentFlavor::Plain) {
|
||||||
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal,
|
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal,
|
||||||
aLoadedAsData, true);
|
aLoadedAsData, true);
|
||||||
} else if (aDoctype) {
|
} else if (aDoctype) {
|
||||||
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
MOZ_ASSERT(aFlavor == DocumentFlavor::LegacyGuess);
|
||||||
nsAutoString publicId, name;
|
nsAutoString publicId, name;
|
||||||
aDoctype->GetPublicId(publicId);
|
aDoctype->GetPublicId(publicId);
|
||||||
if (publicId.IsEmpty()) {
|
if (publicId.IsEmpty()) {
|
||||||
@@ -100,13 +100,11 @@ nsresult NS_NewDOMDocument(Document** aInstancePtrResult,
|
|||||||
isXHTML = true;
|
isXHTML = true;
|
||||||
} else if (publicId.EqualsLiteral("-//W3C//DTD SVG 1.1//EN")) {
|
} else if (publicId.EqualsLiteral("-//W3C//DTD SVG 1.1//EN")) {
|
||||||
rv = NS_NewSVGDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
rv = NS_NewSVGDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
||||||
}
|
} else {
|
||||||
// XXX Add support for XUL documents.
|
|
||||||
else {
|
|
||||||
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
MOZ_ASSERT(aFlavor == DocumentFlavor::LegacyGuess);
|
||||||
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
rv = NS_NewXMLDocument(getter_AddRefs(d), aPrincipal, aPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ nsresult gfxSVGGlyphsDocument::ParseDocument(const uint8_t* aBuffer,
|
|||||||
uri, uri, principal,
|
uri, uri, principal,
|
||||||
false, // aLoadedAsData
|
false, // aLoadedAsData
|
||||||
nullptr, // aEventObject
|
nullptr, // aEventObject
|
||||||
DocumentFlavorSVG);
|
DocumentFlavor::SVG);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel;
|
nsCOMPtr<nsIChannel> channel;
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ void GetACookieNoHttp(nsICookieService* aCookieService, const char* aSpec,
|
|||||||
uri, uri, principal,
|
uri, uri, principal,
|
||||||
false, // aLoadedAsData
|
false, // aLoadedAsData
|
||||||
nullptr, // aEventObject
|
nullptr, // aEventObject
|
||||||
DocumentFlavorHTML);
|
DocumentFlavor::HTML);
|
||||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||||
|
|
||||||
nsAutoString cookie;
|
nsAutoString cookie;
|
||||||
|
|||||||
Reference in New Issue
Block a user