Bug 1823269 - Simplify SVGUtils::GetCanvasTM r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D172948
This commit is contained in:
Robert Longson 2023-03-19 20:53:34 +00:00
parent 19e0568f4d
commit 4efc5e5de1

View File

@ -341,24 +341,24 @@ nsIFrame* SVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame,
gfxMatrix SVGUtils::GetCanvasTM(nsIFrame* aFrame) {
// XXX yuck, we really need a common interface for GetCanvasTM
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
if (!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) {
return GetCSSPxToDevPxMatrix(aFrame);
}
LayoutFrameType type = aFrame->Type();
if (type == LayoutFrameType::SVGForeignObject) {
if (aFrame->IsSVGForeignObjectFrame()) {
return static_cast<SVGForeignObjectFrame*>(aFrame)->GetCanvasTM();
}
if (type == LayoutFrameType::SVGOuterSVG) {
return GetCSSPxToDevPxMatrix(aFrame);
}
SVGContainerFrame* containerFrame = do_QueryFrame(aFrame);
if (containerFrame) {
if (SVGContainerFrame* containerFrame = do_QueryFrame(aFrame)) {
return containerFrame->GetCanvasTM();
}
return static_cast<SVGGeometryFrame*>(aFrame)->GetCanvasTM();
MOZ_ASSERT(aFrame->GetParent()->IsFrameOfType(nsIFrame::eSVGContainer));
auto* parent = static_cast<SVGContainerFrame*>(aFrame->GetParent());
auto* content = static_cast<SVGElement*>(aFrame->GetContent());
return content->PrependLocalTransformsTo(parent->GetCanvasTM());
}
bool SVGUtils::IsSVGTransformed(const nsIFrame* aFrame,