diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index 36e58b6544c1..f57aa736357a 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -1037,7 +1037,15 @@ inline nsIContent* nsINode::AsContent() { \ return aContent->_check ? static_cast<_class*>(aContent) : nullptr; \ } \ + static const _class* FromContent(const nsIContent* aContent) \ + { \ + return aContent->_check ? static_cast(aContent) : nullptr; \ + } \ static _class* FromContentOrNull(nsIContent* aContent) \ + { \ + return aContent ? FromContent(aContent) : nullptr; \ + } \ + static const _class* FromContentOrNull(const nsIContent* aContent) \ { \ return aContent ? FromContent(aContent) : nullptr; \ } diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index 4f83a103a9e6..7910c848430d 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -373,7 +373,7 @@ Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed aElement) "RefPtr should just be a pointer"); const nsMappedAttributes* attrs = aElement->GetMappedAttributes(); if (!attrs) { - auto* svg = nsSVGElement::FromContentOrNull(const_cast(aElement)); + auto* svg = nsSVGElement::FromContentOrNull(aElement); if (svg) { if (auto decl = svg->GetContentDeclarationBlock()) { return decl->AsServo()->RefRawStrong();