Bug 1145195 part 1 - Create a helper function for PrependLocalTransformsTo in SVGContentUtils r=dholbert

This commit is contained in:
Robert Longson 2015-12-02 22:36:23 +00:00
parent 8864e8fa81
commit 4b118e29ab
22 changed files with 162 additions and 106 deletions

View File

@ -395,7 +395,7 @@ static gfx::Matrix
GetCTMInternal(nsSVGElement *aElement, bool aScreenCTM, bool aHaveRecursed)
{
gfxMatrix matrix = aElement->PrependLocalTransformsTo(gfxMatrix(),
aHaveRecursed ? nsSVGElement::eAllTransforms : nsSVGElement::eUserSpaceToParent);
aHaveRecursed ? eAllTransforms : eUserSpaceToParent);
nsSVGElement *element = aElement;
nsIContent *ancestor = aElement->GetFlattenedTreeParent();
@ -858,3 +858,38 @@ SVGContentUtils::ShapeTypeHasNoCorners(const nsIContent* aContent) {
return aContent && aContent->IsAnyOfSVGElements(nsGkAtoms::circle,
nsGkAtoms::ellipse);
}
gfxMatrix
SVGContentUtils::PrependLocalTransformsTo(
const gfxMatrix &aMatrix,
SVGTransformTypes aWhich,
const gfx::Matrix* aAnimateMotionTransform,
const nsSVGAnimatedTransformList* aTransforms)
{
gfxMatrix result(aMatrix);
if (aWhich == eChildToUserSpace) {
// We don't have anything to prepend.
// eChildToUserSpace is not the common case, which is why we return
// 'result' to benefit from NRVO rather than returning aMatrix before
// creating 'result'.
return result;
}
MOZ_ASSERT(aWhich == eAllTransforms || aWhich == eUserSpaceToParent,
"Unknown TransformTypes");
// animateMotion's resulting transform is supposed to apply *on top of*
// any transformations from the |transform| attribute. So since we're
// PRE-multiplying, we need to apply the animateMotion transform *first*.
if (aAnimateMotionTransform) {
result.PreMultiply(ThebesMatrix(*aAnimateMotionTransform));
}
if (aTransforms) {
result.PreMultiply(
aTransforms->GetAnimValue().GetConsolidationMatrix());
}
return result;
}

View File

@ -27,6 +27,7 @@ class nsStyleCoord;
class nsSVGElement;
namespace mozilla {
class nsSVGAnimatedTransformList;
class SVGAnimatedPreserveAspectRatio;
class SVGPreserveAspectRatio;
namespace dom {
@ -41,6 +42,35 @@ class Matrix;
#define SVG_ZERO_LENGTH_PATH_FIX_FACTOR 512
/**
* SVGTransformTypes controls the transforms that PrependLocalTransformsTo
* applies.
*
* If aWhich is eAllTransforms, then all the transforms from the coordinate
* space established by this element for its children to the coordinate
* space established by this element's parent element for this element, are
* included.
*
* If aWhich is eUserSpaceToParent, then only the transforms from this
* element's userspace to the coordinate space established by its parent is
* included. This includes any transforms introduced by the 'transform'
* attribute, transform animations and animateMotion, but not any offsets
* due to e.g. 'x'/'y' attributes, or any transform due to a 'viewBox'
* attribute. (SVG userspace is defined to be the coordinate space in which
* coordinates on an element apply.)
*
* If aWhich is eChildToUserSpace, then only the transforms from the
* coordinate space established by this element for its childre to this
* elements userspace are included. This includes any offsets due to e.g.
* 'x'/'y' attributes, and any transform due to a 'viewBox' attribute, but
* does not include any transforms due to the 'transform' attribute.
*/
enum SVGTransformTypes {
eAllTransforms,
eUserSpaceToParent,
eChildToUserSpace
};
inline bool
IsSVGWhitespace(char aChar)
{
@ -349,6 +379,17 @@ public:
* to have no corners: circle or ellipse
*/
static bool ShapeTypeHasNoCorners(const nsIContent* aContent);
/**
* Prepends an element's local transforms to the transform matrix.
* This is a helper for nsSVGElement::PrependLocalTransformsTo.
* Any callers probably really want to call that method instead of this one.
*/
static gfxMatrix PrependLocalTransformsTo(
const gfxMatrix &aMatrix,
SVGTransformTypes aWhich,
const Matrix* aAnimateMotionTransform,
const mozilla::nsSVGAnimatedTransformList* aTransforms);
};
#endif

View File

@ -73,8 +73,8 @@ SVGForeignObjectElement::Height()
// nsSVGElement methods
/* virtual */ gfxMatrix
SVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich) const
SVGForeignObjectElement::PrependLocalTransformsTo(
const gfxMatrix &aMatrix, SVGTransformTypes aWhich) const
{
// 'transform' attribute:
gfxMatrix fromUserSpace =

View File

@ -30,8 +30,9 @@ protected:
public:
// nsSVGElement specializations:
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich = eAllTransforms) const override;
virtual gfxMatrix PrependLocalTransformsTo(
const gfxMatrix &aMatrix,
SVGTransformTypes aWhich = eAllTransforms) const override;
virtual bool HasValidDimensions() const override;
// nsIContent interface

View File

@ -12,7 +12,9 @@
#include "nsSVGAnimatedTransformList.h"
#include "nsCharSeparatedTokenizer.h"
using namespace mozilla;
namespace mozilla {
using namespace dom;
static bool
IsMatchingParameter(const nsAString& aString, const nsAString& aParameterName)
@ -30,16 +32,16 @@ IgnoreWhitespace(char16_t aChar)
return false;
}
static dom::SVGViewElement*
static SVGViewElement*
GetViewElement(nsIDocument* aDocument, const nsAString& aId)
{
dom::Element* element = aDocument->GetElementById(aId);
Element* element = aDocument->GetElementById(aId);
return (element && element->IsSVGElement(nsGkAtoms::view)) ?
static_cast<dom::SVGViewElement*>(element) : nullptr;
static_cast<SVGViewElement*>(element) : nullptr;
}
void
SVGFragmentIdentifier::SaveOldPreserveAspectRatio(dom::SVGSVGElement* root)
SVGFragmentIdentifier::SaveOldPreserveAspectRatio(SVGSVGElement* root)
{
if (root->mPreserveAspectRatio.IsExplicitlySet()) {
root->SetPreserveAspectRatioProperty(root->mPreserveAspectRatio.GetBaseValue());
@ -47,19 +49,19 @@ SVGFragmentIdentifier::SaveOldPreserveAspectRatio(dom::SVGSVGElement* root)
}
void
SVGFragmentIdentifier::RestoreOldPreserveAspectRatio(dom::SVGSVGElement* root)
SVGFragmentIdentifier::RestoreOldPreserveAspectRatio(SVGSVGElement* root)
{
const SVGPreserveAspectRatio* oldPARPtr = root->GetPreserveAspectRatioProperty();
if (oldPARPtr) {
root->mPreserveAspectRatio.SetBaseValue(*oldPARPtr, root);
} else if (root->mPreserveAspectRatio.IsExplicitlySet()) {
mozilla::ErrorResult error;
ErrorResult error;
root->RemoveAttribute(NS_LITERAL_STRING("preserveAspectRatio"), error);
}
}
void
SVGFragmentIdentifier::SaveOldViewBox(dom::SVGSVGElement* root)
SVGFragmentIdentifier::SaveOldViewBox(SVGSVGElement* root)
{
if (root->mViewBox.IsExplicitlySet()) {
root->SetViewBoxProperty(root->mViewBox.GetBaseValue());
@ -67,39 +69,39 @@ SVGFragmentIdentifier::SaveOldViewBox(dom::SVGSVGElement* root)
}
void
SVGFragmentIdentifier::RestoreOldViewBox(dom::SVGSVGElement* root)
SVGFragmentIdentifier::RestoreOldViewBox(SVGSVGElement* root)
{
const nsSVGViewBoxRect* oldViewBoxPtr = root->GetViewBoxProperty();
if (oldViewBoxPtr) {
root->mViewBox.SetBaseValue(*oldViewBoxPtr, root);
} else if (root->mViewBox.IsExplicitlySet()) {
mozilla::ErrorResult error;
ErrorResult error;
root->RemoveAttribute(NS_LITERAL_STRING("viewBox"), error);
}
}
void
SVGFragmentIdentifier::SaveOldZoomAndPan(dom::SVGSVGElement* root)
SVGFragmentIdentifier::SaveOldZoomAndPan(SVGSVGElement* root)
{
if (root->mEnumAttributes[dom::SVGSVGElement::ZOOMANDPAN].IsExplicitlySet()) {
root->SetZoomAndPanProperty(root->mEnumAttributes[dom::SVGSVGElement::ZOOMANDPAN].GetBaseValue());
if (root->mEnumAttributes[SVGSVGElement::ZOOMANDPAN].IsExplicitlySet()) {
root->SetZoomAndPanProperty(root->mEnumAttributes[SVGSVGElement::ZOOMANDPAN].GetBaseValue());
}
}
void
SVGFragmentIdentifier::RestoreOldZoomAndPan(dom::SVGSVGElement* root)
SVGFragmentIdentifier::RestoreOldZoomAndPan(SVGSVGElement* root)
{
uint16_t oldZoomAndPan = root->GetZoomAndPanProperty();
if (oldZoomAndPan != SVG_ZOOMANDPAN_UNKNOWN) {
root->mEnumAttributes[dom::SVGSVGElement::ZOOMANDPAN].SetBaseValue(oldZoomAndPan, root);
} else if (root->mEnumAttributes[dom::SVGSVGElement::ZOOMANDPAN].IsExplicitlySet()) {
mozilla::ErrorResult error;
root->mEnumAttributes[SVGSVGElement::ZOOMANDPAN].SetBaseValue(oldZoomAndPan, root);
} else if (root->mEnumAttributes[SVGSVGElement::ZOOMANDPAN].IsExplicitlySet()) {
ErrorResult error;
root->RemoveAttribute(NS_LITERAL_STRING("zoomAndPan"), error);
}
}
void
SVGFragmentIdentifier::SaveOldTransform(dom::SVGSVGElement* root)
SVGFragmentIdentifier::SaveOldTransform(SVGSVGElement* root)
{
nsSVGAnimatedTransformList* transformList = root->GetAnimatedTransformList();
@ -109,7 +111,7 @@ SVGFragmentIdentifier::SaveOldTransform(dom::SVGSVGElement* root)
}
void
SVGFragmentIdentifier::RestoreOldTransform(dom::SVGSVGElement* root)
SVGFragmentIdentifier::RestoreOldTransform(SVGSVGElement* root)
{
const SVGTransformList* oldTransformPtr = root->GetTransformProperty();
if (oldTransformPtr) {
@ -117,7 +119,7 @@ SVGFragmentIdentifier::RestoreOldTransform(dom::SVGSVGElement* root)
} else {
nsSVGAnimatedTransformList* transformList = root->GetAnimatedTransformList();
if (transformList && transformList->IsExplicitlySet()) {
mozilla::ErrorResult error;
ErrorResult error;
root->RemoveAttribute(NS_LITERAL_STRING("transform"), error);
}
}
@ -125,7 +127,7 @@ SVGFragmentIdentifier::RestoreOldTransform(dom::SVGSVGElement* root)
bool
SVGFragmentIdentifier::ProcessSVGViewSpec(const nsAString& aViewSpec,
dom::SVGSVGElement* root)
SVGSVGElement* root)
{
if (!IsMatchingParameter(aViewSpec, NS_LITERAL_STRING("svgView"))) {
return false;
@ -192,11 +194,11 @@ SVGFragmentIdentifier::ProcessSVGViewSpec(const nsAString& aViewSpec,
if (!valAtom) {
return false;
}
const nsSVGEnumMapping* mapping = dom::SVGSVGElement::sZoomAndPanMap;
const nsSVGEnumMapping* mapping = SVGSVGElement::sZoomAndPanMap;
while (mapping->mKey) {
if (valAtom == *(mapping->mKey)) {
// If we've got a valid zoomAndPan value, then set it on our root element.
if (NS_FAILED(root->mEnumAttributes[dom::SVGSVGElement::ZOOMANDPAN].SetBaseValue(
if (NS_FAILED(root->mEnumAttributes[SVGSVGElement::ZOOMANDPAN].SetBaseValue(
mapping->mVal, root))) {
return false;
}
@ -242,8 +244,8 @@ SVGFragmentIdentifier::ProcessFragmentIdentifier(nsIDocument* aDocument,
MOZ_ASSERT(aDocument->GetRootElement()->IsSVGElement(nsGkAtoms::svg),
"expecting an SVG root element");
dom::SVGSVGElement* rootElement =
static_cast<dom::SVGSVGElement*>(aDocument->GetRootElement());
SVGSVGElement* rootElement =
static_cast<SVGSVGElement*>(aDocument->GetRootElement());
if (!rootElement->mUseCurrentView) {
SaveOldViewBox(rootElement);
@ -251,7 +253,7 @@ SVGFragmentIdentifier::ProcessFragmentIdentifier(nsIDocument* aDocument,
SaveOldZoomAndPan(rootElement);
}
const dom::SVGViewElement* viewElement = GetViewElement(aDocument, aAnchorName);
const SVGViewElement* viewElement = GetViewElement(aDocument, aAnchorName);
if (viewElement) {
if (!rootElement->mCurrentViewID) {
@ -285,3 +287,5 @@ SVGFragmentIdentifier::ProcessFragmentIdentifier(nsIDocument* aDocument,
}
return false;
}
} // namespace mozilla

View File

@ -943,8 +943,8 @@ SVGSVGElement::GetLength(uint8_t aCtxType)
// nsSVGElement methods
/* virtual */ gfxMatrix
SVGSVGElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich) const
SVGSVGElement::PrependLocalTransformsTo(
const gfxMatrix &aMatrix, SVGTransformTypes aWhich) const
{
// 'transform' attribute:
gfxMatrix fromUserSpace =

View File

@ -138,8 +138,9 @@ public:
virtual bool IsEventAttributeName(nsIAtom* aName) override;
// nsSVGElement specializations:
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich = eAllTransforms) const override;
virtual gfxMatrix PrependLocalTransformsTo(
const gfxMatrix &aMatrix,
SVGTransformTypes aWhich = eAllTransforms) const override;
virtual bool HasValidDimensions() const override;
// SVGSVGElement methods:

View File

@ -90,34 +90,12 @@ SVGTransformableElement::IsEventAttributeName(nsIAtom* aName)
// nsSVGElement overrides
gfxMatrix
SVGTransformableElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich) const
SVGTransformableElement::PrependLocalTransformsTo(
const gfxMatrix &aMatrix,
SVGTransformTypes aWhich) const
{
gfxMatrix result(aMatrix);
if (aWhich == eChildToUserSpace) {
// We don't have anything to prepend.
// eChildToUserSpace is not the common case, which is why we return
// 'result' to benefit from NRVO rather than returning aMatrix before
// creating 'result'.
return result;
}
MOZ_ASSERT(aWhich == eAllTransforms || aWhich == eUserSpaceToParent,
"Unknown TransformTypes");
// animateMotion's resulting transform is supposed to apply *on top of*
// any transformations from the |transform| attribute. So since we're
// PRE-multiplying, we need to apply the animateMotion transform *first*.
if (mAnimateMotionTransform) {
result.PreMultiply(ThebesMatrix(*mAnimateMotionTransform));
}
if (mTransforms) {
result.PreMultiply(mTransforms->GetAnimValue().GetConsolidationMatrix());
}
return result;
return SVGContentUtils::PrependLocalTransformsTo(
aMatrix, aWhich, mAnimateMotionTransform, mTransforms);
}
const gfx::Matrix*

View File

@ -53,8 +53,9 @@ public:
virtual bool IsEventAttributeName(nsIAtom* aName) override;
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich = eAllTransforms) const override;
virtual gfxMatrix PrependLocalTransformsTo(
const gfxMatrix &aMatrix,
SVGTransformTypes aWhich = eAllTransforms) const override;
virtual const gfx::Matrix* GetAnimateMotionTransform() const override;
virtual void SetAnimateMotionTransform(const gfx::Matrix* aMatrix) override;

View File

@ -431,8 +431,8 @@ SVGUseElement::UnlinkSource()
// nsSVGElement methods
/* virtual */ gfxMatrix
SVGUseElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich) const
SVGUseElement::PrependLocalTransformsTo(
const gfxMatrix &aMatrix, SVGTransformTypes aWhich) const
{
// 'transform' attribute:
gfxMatrix fromUserSpace =

View File

@ -60,8 +60,9 @@ public:
void DestroyAnonymousContent();
// nsSVGElement specializations:
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich = eAllTransforms) const override;
virtual gfxMatrix PrependLocalTransformsTo(
const gfxMatrix &aMatrix,
SVGTransformTypes aWhich = eAllTransforms) const override;
virtual bool HasValidDimensions() const override;
// nsIContent interface

View File

@ -11,6 +11,7 @@ EXPORTS += [
'nsSVGElement.h',
'nsSVGFeatures.h',
'SVGAttrValueWrapper.h',
'SVGContentUtils.h',
'SVGPreserveAspectRatio.h',
'SVGStringList.h',
]

View File

@ -1554,8 +1554,8 @@ nsSVGElement::GetCtx() const
}
/* virtual */ gfxMatrix
nsSVGElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich) const
nsSVGElement::PrependLocalTransformsTo(
const gfxMatrix &aMatrix, SVGTransformTypes aWhich) const
{
return aMatrix;
}

View File

@ -25,6 +25,7 @@
#include "nsStyledElement.h"
#include "nsSVGClass.h"
#include "nsIDOMSVGElement.h"
#include "SVGContentUtils.h"
class nsSVGAngle;
class nsSVGBoolean;
@ -139,11 +140,6 @@ public:
// nullptr for outer <svg> or SVG without an <svg> parent (invalid SVG).
mozilla::dom::SVGSVGElement* GetCtx() const;
enum TransformTypes {
eAllTransforms
,eUserSpaceToParent
,eChildToUserSpace
};
/**
* Returns aMatrix pre-multiplied by (explicit or implicit) transforms that
* are introduced by attributes on this element.
@ -167,8 +163,8 @@ public:
* 'x'/'y' attributes, and any transform due to a 'viewBox' attribute, but
* does not include any transforms due to the 'transform' attribute.
*/
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich = eAllTransforms) const;
virtual gfxMatrix PrependLocalTransformsTo(
const gfxMatrix &aMatrix, SVGTransformTypes aWhich = eAllTransforms) const;
// Setter for to set the current <animateMotion> transformation
// Only visible for nsSVGGraphicElement, so it's a no-op here, and that

View File

@ -59,8 +59,7 @@ nsSVGClipPathFrame::ApplyClipOrPaintClipMask(gfxContext& aContext,
nsSVGPathGeometryElement* pathElement =
static_cast<nsSVGPathGeometryElement*>(pathFrame->GetContent());
gfxMatrix toChildsUserSpace = pathElement->
PrependLocalTransformsTo(mMatrixForChildren,
nsSVGElement::eUserSpaceToParent);
PrependLocalTransformsTo(mMatrixForChildren, eUserSpaceToParent);
gfxMatrix newMatrix =
aContext.CurrentMatrix().PreMultiply(toChildsUserSpace).NudgeToIntegers();
if (!newMatrix.IsSingular()) {
@ -137,8 +136,7 @@ nsSVGClipPathFrame::ApplyClipOrPaintClipMask(gfxContext& aContext,
if (childContent->IsSVGElement()) {
toChildsUserSpace =
static_cast<const nsSVGElement*>(childContent)->
PrependLocalTransformsTo(mMatrixForChildren,
nsSVGElement::eUserSpaceToParent);
PrependLocalTransformsTo(mMatrixForChildren, eUserSpaceToParent);
}
SVGFrame->PaintSVG(aContext, toChildsUserSpace);
@ -247,7 +245,7 @@ nsSVGClipPathFrame::PointIsInsideClipPath(nsIFrame* aClippedFrame,
if (SVGFrame) {
gfxPoint pointForChild = point;
gfxMatrix m = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(gfxMatrix(), nsSVGElement::eUserSpaceToParent);
PrependLocalTransformsTo(gfxMatrix(), eUserSpaceToParent);
if (!m.IsIdentity()) {
if (!m.Invert()) {
return false;

View File

@ -235,8 +235,9 @@ nsSVGDisplayContainerFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
if ((transformList && transformList->HasTransform()) ||
content->GetAnimateMotionTransform()) {
if (aOwnTransform) {
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent));
*aOwnTransform = gfx::ToMatrix(
content->PrependLocalTransformsTo(
gfxMatrix(), eUserSpaceToParent));
}
foundTransform = true;
}
@ -266,8 +267,7 @@ nsSVGDisplayContainerFrame::PaintSVG(gfxContext& aContext,
gfxMatrix matrix = aTransform;
if (GetContent()->IsSVGElement()) { // must check before cast
matrix = static_cast<const nsSVGElement*>(GetContent())->
PrependLocalTransformsTo(matrix,
nsSVGElement::eChildToUserSpace);
PrependLocalTransformsTo(matrix, eChildToUserSpace);
if (matrix.IsSingular()) {
return NS_OK;
}
@ -284,8 +284,7 @@ nsSVGDisplayContainerFrame::PaintSVG(gfxContext& aContext,
if (!element->HasValidDimensions()) {
continue; // nothing to paint for kid
}
m = element->
PrependLocalTransformsTo(m, nsSVGElement::eUserSpaceToParent);
m = element->PrependLocalTransformsTo(m, eUserSpaceToParent);
if (m.IsSingular()) {
continue;
}

View File

@ -189,8 +189,9 @@ nsSVGForeignObjectFrame::IsSVGTransformed(Matrix *aOwnTransform,
if ((transformList && transformList->HasTransform()) ||
content->GetAnimateMotionTransform()) {
if (aOwnTransform) {
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent));
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(
gfxMatrix(),
eUserSpaceToParent));
}
foundTransform = true;
}

View File

@ -982,8 +982,7 @@ nsSVGOuterSVGAnonChildFrame::HasChildrenOnlyTransform(gfx::Matrix *aTransform) c
// Outer-<svg> doesn't use x/y, so we can pass eChildToUserSpace here.
gfxMatrix identity;
*aTransform = gfx::ToMatrix(
content->PrependLocalTransformsTo(identity,
nsSVGElement::eChildToUserSpace));
content->PrependLocalTransformsTo(identity, eChildToUserSpace));
}
return hasTransform;

View File

@ -216,8 +216,10 @@ nsSVGPathGeometryFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
if ((transformList && transformList->HasTransform()) ||
content->GetAnimateMotionTransform()) {
if (aOwnTransform) {
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent));
*aOwnTransform = gfx::ToMatrix(
content->PrependLocalTransformsTo(
gfxMatrix(),
eUserSpaceToParent));
}
foundTransform = true;
}

View File

@ -407,7 +407,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
gfxMatrix tm = *(patternWithChildren->mCTM);
if (kid->GetContent()->IsSVGElement()) {
tm = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(tm, nsSVGElement::eUserSpaceToParent);
PrependLocalTransformsTo(tm, eUserSpaceToParent);
}
nsSVGUtils::PaintFrameWithEffects(kid, *gfx, tm);
}

View File

@ -122,7 +122,7 @@ nsSVGSwitchFrame::PaintSVG(gfxContext& aContext,
gfxMatrix tm = aTransform;
if (kid->GetContent()->IsSVGElement()) {
tm = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(tm, nsSVGElement::eUserSpaceToParent);
PrependLocalTransformsTo(tm, eUserSpaceToParent);
}
nsSVGUtils::PaintFrameWithEffects(kid, aContext, tm, aDirtyRect);
}
@ -145,9 +145,9 @@ nsSVGSwitchFrame::GetFrameForPoint(const gfxPoint& aPoint)
gfxPoint point = aPoint;
gfxMatrix m =
static_cast<const nsSVGElement*>(mContent)->
PrependLocalTransformsTo(gfxMatrix(), nsSVGElement::eChildToUserSpace);
PrependLocalTransformsTo(gfxMatrix(), eChildToUserSpace);
m = static_cast<const nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(m, nsSVGElement::eUserSpaceToParent);
PrependLocalTransformsTo(m, eUserSpaceToParent);
if (!m.IsIdentity()) {
if (!m.Invert()) {
return nullptr;

View File

@ -424,7 +424,7 @@ nsSVGUtils::GetUserToCanvasTM(nsIFrame *aFrame)
nsSVGElement *content = static_cast<nsSVGElement*>(aFrame->GetContent());
tm = content->PrependLocalTransformsTo(
GetCanvasTM(aFrame->GetParent()),
nsSVGElement::eUserSpaceToParent);
eUserSpaceToParent);
}
return tm;
}
@ -755,7 +755,7 @@ nsSVGUtils::HitTestChildren(nsSVGDisplayContainerFrame* aFrame,
if (aFrame->GetContent()->IsSVGElement()) { // must check before cast
gfxMatrix m = static_cast<const nsSVGElement*>(aFrame->GetContent())->
PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eChildToUserSpace);
eChildToUserSpace);
if (!m.IsIdentity()) {
if (!m.Invert()) {
return nullptr;
@ -783,7 +783,7 @@ nsSVGUtils::HitTestChildren(nsSVGDisplayContainerFrame* aFrame,
if (content->IsSVGElement()) { // must check before cast
gfxMatrix m = static_cast<const nsSVGElement*>(content)->
PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent);
eUserSpaceToParent);
if (!m.IsIdentity()) {
if (!m.Invert()) {
continue;
@ -970,8 +970,7 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags)
// also update nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset.
MOZ_ASSERT(content->IsSVGElement(), "bad cast");
nsSVGElement *element = static_cast<nsSVGElement*>(content);
matrix = element->PrependLocalTransformsTo(matrix,
nsSVGElement::eChildToUserSpace);
matrix = element->PrependLocalTransformsTo(matrix, eChildToUserSpace);
}
bbox = svg->GetBBoxContribution(ToMatrix(matrix), aFlags).ToThebesRect();
// Account for 'clipped'.
@ -1061,8 +1060,7 @@ nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame *aFrame)
if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame ||
aFrame->GetType() == nsGkAtoms::svgUseFrame) {
gfxMatrix transform = static_cast<nsSVGElement*>(aFrame->GetContent())->
PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eChildToUserSpace);
PrependLocalTransformsTo(gfxMatrix(), eChildToUserSpace);
NS_ASSERTION(!transform.HasNonTranslation(), "we're relying on this being an offset-only transform");
return transform.GetTranslation();
}
@ -1663,7 +1661,7 @@ nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
// PaintSVG() expects the passed transform to be the transform to its own
// SVG user space, so we need to account for any 'transform' attribute:
m = static_cast<nsSVGElement*>(frame->GetContent())->
PrependLocalTransformsTo(gfxMatrix(), nsSVGElement::eUserSpaceToParent);
PrependLocalTransformsTo(gfxMatrix(), eUserSpaceToParent);
}
nsresult rv = svgFrame->PaintSVG(*aContext, m);
return NS_SUCCEEDED(rv);