diff --git a/layout/svg/FilterInstance.cpp b/layout/svg/FilterInstance.cpp index 0fb3915a57d2..d8b7a557b565 100644 --- a/layout/svg/FilterInstance.cpp +++ b/layout/svg/FilterInstance.cpp @@ -52,8 +52,7 @@ FilterDescription FilterInstance::GetFilterDescription( } static UniquePtr UserSpaceMetricsForFrame(nsIFrame* aFrame) { - if (aFrame->GetContent()->IsSVGElement()) { - SVGElement* element = static_cast(aFrame->GetContent()); + if (auto* element = SVGElement::FromNodeOrNull(aFrame->GetContent())) { return MakeUnique(element); } return MakeUnique(aFrame); diff --git a/layout/svg/SVGUtils.cpp b/layout/svg/SVGUtils.cpp index 9ad989293f4d..7e78d7aef504 100644 --- a/layout/svg/SVGUtils.cpp +++ b/layout/svg/SVGUtils.cpp @@ -969,7 +969,7 @@ void SVGUtils::SetClipRect(gfxContext* aContext, const gfxMatrix& aCTM, gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, const gfxMatrix* aToBoundsSpace) { - if (aFrame->GetContent()->IsText()) { + if (aFrame->IsTextFrame()) { aFrame = aFrame->GetParent(); } @@ -1008,10 +1008,10 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, MOZ_ASSERT(svg); - nsIContent* content = aFrame->GetContent(); - if (content->IsSVGElement() && - !static_cast(content)->HasValidDimensions()) { - return gfxRect(); + if (auto* element = SVGElement::FromNodeOrNull(aFrame->GetContent())) { + if (!element->HasValidDimensions()) { + return gfxRect(); + } } // Clean out flags which have no effects on returning bbox from now, so that @@ -1043,8 +1043,8 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, // needs investigation to check that we won't break too much content. // NOTE: When changing this to apply to other frame types, make sure to // also update SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset. - MOZ_ASSERT(content->IsSVGElement(), "bad cast"); - SVGElement* element = static_cast(content); + MOZ_ASSERT(aFrame->GetContent()->IsSVGElement(), "bad cast"); + SVGElement* element = static_cast(aFrame->GetContent()); matrix = element->PrependLocalTransformsTo(matrix, eChildToUserSpace); } gfxRect bbox =