Bug 1551040 - Add const versions of Document casts. r=edgar

Depends on D101516

Differential Revision: https://phabricator.services.mozilla.com/D101517
This commit is contained in:
Emilio Cobos Álvarez 2021-01-17 14:44:44 +00:00
parent 1ff0ef892e
commit 5c1a39349e
3 changed files with 12 additions and 0 deletions

View File

@ -3556,12 +3556,14 @@ class Document : public nsINode,
* Defined inline in nsHTMLDocument.h
*/
inline nsHTMLDocument* AsHTMLDocument();
inline const nsHTMLDocument* AsHTMLDocument() const;
/**
* Asserts IsSVGDocument, and can't return null.
* Defined inline in SVGDocument.h
*/
inline SVGDocument* AsSVGDocument();
inline const SVGDocument* AsSVGDocument() const;
/*
* Given a node, get a weak reference to it and append that reference to

View File

@ -202,6 +202,11 @@ inline nsHTMLDocument* Document::AsHTMLDocument() {
return static_cast<nsHTMLDocument*>(this);
}
inline const nsHTMLDocument* Document::AsHTMLDocument() const {
MOZ_ASSERT(IsHTMLOrXHTML());
return static_cast<const nsHTMLDocument*>(this);
}
} // namespace dom
} // namespace mozilla

View File

@ -43,6 +43,11 @@ inline SVGDocument* Document::AsSVGDocument() {
return static_cast<SVGDocument*>(this);
}
inline const SVGDocument* Document::AsSVGDocument() const {
MOZ_ASSERT(IsSVGDocument());
return static_cast<const SVGDocument*>(this);
}
} // namespace dom
} // namespace mozilla