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