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-13 11:39:30 +00:00
Родитель 8798b5286b
Коммит 91d84e11c8
3 изменённых файлов: 12 добавлений и 0 удалений

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

@ -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

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

@ -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

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

@ -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