summaryrefslogtreecommitdiffstats
path: root/layout/svg/nsSVGOuterSVGFrame.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-04 14:35:31 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-04 14:35:31 -0500
commit7edd685eee95759d66a457cf428f42e0dda94671 (patch)
treec4514958ea133084552be32d331c115afc509daa /layout/svg/nsSVGOuterSVGFrame.cpp
parent0083d404eff36f873cde465d50cd34b112bd124f (diff)
parentfc7d9fade54dfbe275c4808dabe30a19415082e0 (diff)
downloadUXP-7edd685eee95759d66a457cf428f42e0dda94671.tar
UXP-7edd685eee95759d66a457cf428f42e0dda94671.tar.gz
UXP-7edd685eee95759d66a457cf428f42e0dda94671.tar.lz
UXP-7edd685eee95759d66a457cf428f42e0dda94671.tar.xz
UXP-7edd685eee95759d66a457cf428f42e0dda94671.zip
Merge branch 'master' into configurebuild-work
Diffstat (limited to 'layout/svg/nsSVGOuterSVGFrame.cpp')
-rw-r--r--layout/svg/nsSVGOuterSVGFrame.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp
index 683f10bc7..aeadccbc5 100644
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -979,21 +979,43 @@ nsSVGOuterSVGAnonChildFrame::GetType() const
}
bool
-nsSVGOuterSVGAnonChildFrame::HasChildrenOnlyTransform(gfx::Matrix *aTransform) const
+nsSVGOuterSVGAnonChildFrame::IsSVGTransformed(Matrix* aOwnTransform,
+ Matrix* aFromParentTransform) const
{
- // We must claim our nsSVGOuterSVGFrame's children-only transforms as our own
- // so that the children we are used to wrap are transformed properly.
+ // Our elements 'transform' attribute is applied to our nsSVGOuterSVGFrame
+ // parent, and the element's children-only transforms are applied to us, the
+ // anonymous child frame. Since we are the child frame, we apply the
+ // children-only transforms as if they are our own transform.
- SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
+ SVGSVGElement* content = static_cast<SVGSVGElement*>(mContent);
+
+ if (!content->HasChildrenOnlyTransform()) {
+ return false;
+ }
+
+ // Outer-<svg> doesn't use x/y, so we can pass eChildToUserSpace here.
+ gfxMatrix ownMatrix =
+ content->PrependLocalTransformsTo(gfxMatrix(), eChildToUserSpace);
- bool hasTransform = content->HasChildrenOnlyTransform();
+ if (ownMatrix.IsIdentity()) {
+ return false;
+ }
+
+ if (aOwnTransform) {
+ if (ownMatrix.HasNonTranslation()) {
+ // Note: viewBox, currentScale and currentTranslate should only
+ // produce a rectilinear transform.
+ // The nsDisplayTransform code will apply this transform to our frame,
+ // including to our frame position. We don't want our frame position to
+ // be scaled though, so we need to correct for that in the transform.
+ CSSPoint pos = CSSPixel::FromAppUnits(GetPosition());
+ CSSPoint scaledPos = CSSPoint(ownMatrix._11 * pos.x, ownMatrix._22 * pos.y);
+ CSSPoint deltaPos = scaledPos - pos;
+ ownMatrix *= gfxMatrix::Translation(-deltaPos.x, -deltaPos.y);
+ }
- if (hasTransform && aTransform) {
- // Outer-<svg> doesn't use x/y, so we can pass eChildToUserSpace here.
- gfxMatrix identity;
- *aTransform = gfx::ToMatrix(
- content->PrependLocalTransformsTo(identity, eChildToUserSpace));
+ *aOwnTransform = gfx::ToMatrix(ownMatrix);
}
- return hasTransform;
+ return true;
}