From 91d84e11c8ebc0aa87b9ee82d86adb928f697485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 13 Jan 2021 11:39:30 +0000 Subject: [PATCH] Bug 1551040 - Add const versions of Document casts. r=edgar Depends on D101516 Differential Revision: https://phabricator.services.mozilla.com/D101517 --- dom/base/Document.h | 2 ++ dom/html/nsHTMLDocument.h | 5 +++++ dom/svg/SVGDocument.h | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/dom/base/Document.h b/dom/base/Document.h index e017b9eadeb9..cc8b83ad4a43 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -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 diff --git a/dom/html/nsHTMLDocument.h b/dom/html/nsHTMLDocument.h index 91d783531bf9..6c0471dbc8c8 100644 --- a/dom/html/nsHTMLDocument.h +++ b/dom/html/nsHTMLDocument.h @@ -202,6 +202,11 @@ inline nsHTMLDocument* Document::AsHTMLDocument() { return static_cast(this); } +inline const nsHTMLDocument* Document::AsHTMLDocument() const { + MOZ_ASSERT(IsHTMLOrXHTML()); + return static_cast(this); +} + } // namespace dom } // namespace mozilla diff --git a/dom/svg/SVGDocument.h b/dom/svg/SVGDocument.h index 44d74356cef5..86c7ed01753e 100644 --- a/dom/svg/SVGDocument.h +++ b/dom/svg/SVGDocument.h @@ -43,6 +43,11 @@ inline SVGDocument* Document::AsSVGDocument() { return static_cast(this); } +inline const SVGDocument* Document::AsSVGDocument() const { + MOZ_ASSERT(IsSVGDocument()); + return static_cast(this); +} + } // namespace dom } // namespace mozilla