зеркало из https://github.com/mozilla/pjs.git
Bug 730658 - use element does not display properly when animated with set. r=dholbert
This commit is contained in:
Родитель
4d32a0fd86
Коммит
b7cc93fd85
|
@ -392,9 +392,9 @@ void
|
|||
SMILPreserveAspectRatio::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValue(PackPreserveAspectRatio(mVal->GetBaseValue()),
|
||||
mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal = mVal->mBaseVal;
|
||||
mSVGElement->DidAnimatePreserveAspectRatio();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -510,8 +510,10 @@ nsSVGAngle::SMILOrient::ClearAnimValue()
|
|||
{
|
||||
if (mAngle->mIsAnimated) {
|
||||
mOrientType->SetAnimValue(mOrientType->GetBaseValue());
|
||||
mAngle->SetAnimValue(mAngle->mBaseVal, mAngle->mBaseValUnit, mSVGElement);
|
||||
mAngle->mIsAnimated = false;
|
||||
mAngle->mAnimVal = mAngle->mBaseVal;
|
||||
mAngle->mAnimValUnit = mAngle->mBaseValUnit;
|
||||
mSVGElement->DidAnimateAngle(mAngle->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,8 +190,9 @@ void
|
|||
nsSVGBoolean::SMILBool::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValue(mVal->mBaseVal, mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal = mVal->mBaseVal;
|
||||
mSVGElement->DidAnimateBoolean(mVal->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,9 @@ public:
|
|||
NS_FORWARD_NSIDOMELEMENT(nsSVGCircleElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::)
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
virtual void ConstructPath(gfxContext *aCtx);
|
||||
|
||||
|
@ -143,6 +146,13 @@ NS_IMETHODIMP nsSVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGCircleElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[R].IsExplicitlySet() &&
|
||||
mLengthAttributes[R].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGCircleElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -194,6 +194,9 @@ public:
|
|||
bool NumberAttrAllowsPercentage(PRUint8 aAttrEnum) {
|
||||
return GetNumberInfo().mNumberInfo[aAttrEnum].mPercentagesAllowed;
|
||||
}
|
||||
virtual bool HasValidDimensions() const {
|
||||
return true;
|
||||
}
|
||||
void SetLength(nsIAtom* aName, const nsSVGLength2 &aLength);
|
||||
|
||||
nsAttrValue WillChangeLength(PRUint8 aAttrEnum);
|
||||
|
|
|
@ -68,6 +68,9 @@ public:
|
|||
NS_FORWARD_NSIDOMELEMENT(nsSVGEllipseElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGEllipseElementBase::)
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
virtual void ConstructPath(gfxContext *aCtx);
|
||||
|
||||
|
@ -151,6 +154,15 @@ NS_IMETHODIMP nsSVGEllipseElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGEllipseElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[RX].IsExplicitlySet() &&
|
||||
mLengthAttributes[RX].GetAnimValInSpecifiedUnits() > 0 &&
|
||||
mLengthAttributes[RY].IsExplicitlySet() &&
|
||||
mLengthAttributes[RY].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGEllipseElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -200,8 +200,9 @@ void
|
|||
nsSVGEnum::SMILEnum::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValue(mVal->mBaseVal, mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal = mVal->mBaseVal;
|
||||
mSVGElement->DidAnimateEnum(mVal->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -219,6 +219,15 @@ nsSVGFilterElement::Invalidate()
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGFilterElement::HasValidDimensions() const
|
||||
{
|
||||
return (!mLengthAttributes[WIDTH].IsExplicitlySet() ||
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
||||
(!mLengthAttributes[HEIGHT].IsExplicitlySet() ||
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGFilterElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -83,6 +83,9 @@ public:
|
|||
void Invalidate();
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
|
|
|
@ -310,6 +310,15 @@ nsSVGFE::IsAttributeMapped(const nsIAtom* name) const
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGFE::HasValidDimensions() const
|
||||
{
|
||||
return (!mLengthAttributes[WIDTH].IsExplicitlySet() ||
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
||||
(!mLengthAttributes[HEIGHT].IsExplicitlySet() ||
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGFE::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -158,6 +158,9 @@ public:
|
|||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
|
||||
// nsSVGElement interface
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
virtual nsSVGString& GetResultImageName() = 0;
|
||||
// Return a list of all image names used as sources. Default is to
|
||||
// return no sources.
|
||||
|
|
|
@ -136,6 +136,15 @@ nsSVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
|||
return toUserSpace * fromUserSpace;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGForeignObjectElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[WIDTH].IsExplicitlySet() &&
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
||||
mLengthAttributes[HEIGHT].IsExplicitlySet() &&
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
||||
TransformTypes aWhich = eAllTransforms) const;
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
|
||||
|
|
|
@ -267,6 +267,15 @@ nsSVGImageElement::ConstructPath(gfxContext *aCtx)
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGImageElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[WIDTH].IsExplicitlySet() &&
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
||||
mLengthAttributes[HEIGHT].IsExplicitlySet() &&
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGImageElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -90,6 +90,9 @@ public:
|
|||
// nsSVGPathGeometryElement methods:
|
||||
virtual void ConstructPath(gfxContext *aCtx);
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
nsresult CopyInnerTo(nsGenericElement* aDest) const;
|
||||
|
|
|
@ -185,8 +185,9 @@ void
|
|||
nsSVGInteger::SMILInteger::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValue(mVal->mBaseVal, mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal = mVal->mBaseVal;
|
||||
mSVGElement->DidAnimateInteger(mVal->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,8 +241,10 @@ void
|
|||
nsSVGIntegerPair::SMILIntegerPair::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValue(mVal->mBaseVal, mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal[0] = mVal->mBaseVal[0];
|
||||
mVal->mAnimVal[1] = mVal->mBaseVal[1];
|
||||
mSVGElement->DidAnimateIntegerPair(mVal->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -570,8 +570,9 @@ void
|
|||
nsSVGLength2::SMILLength::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValueInSpecifiedUnits(mVal->mBaseVal, mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal = mVal->mBaseVal;
|
||||
mSVGElement->DidAnimateLength(mVal->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -306,6 +306,15 @@ nsSVGMarkerElement::SetParentCoordCtxProvider(nsSVGSVGElement *aContext)
|
|||
mViewBoxToViewportTransform = nsnull;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGMarkerElement::HasValidDimensions() const
|
||||
{
|
||||
return (!mLengthAttributes[MARKERWIDTH].IsExplicitlySet() ||
|
||||
mLengthAttributes[MARKERWIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
||||
(!mLengthAttributes[MARKERHEIGHT].IsExplicitlySet() ||
|
||||
mLengthAttributes[MARKERHEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGMarkerElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -133,6 +133,9 @@ public:
|
|||
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
bool aNotify);
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// public helpers
|
||||
gfxMatrix GetMarkerTransform(float aStrokeWidth,
|
||||
float aX, float aY, float aAutoAngle);
|
||||
|
|
|
@ -136,6 +136,15 @@ NS_IMETHODIMP nsSVGMaskElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGMaskElement::HasValidDimensions() const
|
||||
{
|
||||
return (!mLengthAttributes[WIDTH].IsExplicitlySet() ||
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
||||
(!mLengthAttributes[HEIGHT].IsExplicitlySet() ||
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGMaskElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -76,6 +76,9 @@ public:
|
|||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
|
|
|
@ -227,8 +227,9 @@ void
|
|||
nsSVGNumber2::SMILNumber::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValue(mVal->mBaseVal, mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal = mVal->mBaseVal;
|
||||
mSVGElement->DidAnimateNumber(mVal->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -239,8 +239,10 @@ void
|
|||
nsSVGNumberPair::SMILNumberPair::ClearAnimValue()
|
||||
{
|
||||
if (mVal->mIsAnimated) {
|
||||
mVal->SetAnimValue(mVal->mBaseVal, mSVGElement);
|
||||
mVal->mIsAnimated = false;
|
||||
mVal->mAnimVal[0] = mVal->mBaseVal[0];
|
||||
mVal->mAnimVal[1] = mVal->mBaseVal[1];
|
||||
mSVGElement->DidAnimateNumberPair(mVal->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -341,6 +341,12 @@ nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, ns
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGPathElement::HasValidDimensions() const
|
||||
{
|
||||
return !mD.GetAnimValue().IsEmpty();
|
||||
}
|
||||
|
||||
nsSVGElement::NumberAttributesInfo
|
||||
nsSVGPathElement::GetNumberInfo()
|
||||
{
|
||||
|
|
|
@ -76,6 +76,9 @@ public:
|
|||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
virtual bool AttributeDefinesGeometry(const nsIAtom *aName);
|
||||
virtual bool IsMarkable();
|
||||
|
|
|
@ -214,6 +214,15 @@ nsSVGPatternElement::GetAnimatedTransformList()
|
|||
return mPatternTransform;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGPatternElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[WIDTH].IsExplicitlySet() &&
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
||||
mLengthAttributes[HEIGHT].IsExplicitlySet() &&
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGPatternElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -96,6 +96,9 @@ public:
|
|||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
virtual mozilla::SVGAnimatedTransformList* GetAnimatedTransformList();
|
||||
virtual nsIAtom* GetTransformListAttrName() const {
|
||||
return nsGkAtoms::patternTransform;
|
||||
|
|
|
@ -67,6 +67,9 @@ public:
|
|||
NS_FORWARD_NSIDOMELEMENT(nsSVGRectElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::)
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
virtual void ConstructPath(gfxContext *aCtx);
|
||||
|
||||
|
@ -164,6 +167,15 @@ NS_IMETHODIMP nsSVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
|
|||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGRectElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[WIDTH].IsExplicitlySet() &&
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
||||
mLengthAttributes[HEIGHT].IsExplicitlySet() &&
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGRectElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -1189,6 +1189,16 @@ nsSVGSVGElement::GetLength(PRUint8 aCtxType)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGSVGElement::SyncWidthOrHeight(nsIAtom* aName, nsSVGElement *aTarget) const
|
||||
{
|
||||
NS_ASSERTION(aName == nsGkAtoms::width || aName == nsGkAtoms::height,
|
||||
"The clue is in the function name");
|
||||
|
||||
PRUint32 index = *sLengthInfo[WIDTH].mName == aName ? WIDTH : HEIGHT;
|
||||
aTarget->SetLength(aName, mLengthAttributes[index]);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
|
@ -1229,6 +1239,16 @@ nsSVGSVGElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
|||
return GetViewBoxTransform() * aMatrix;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGSVGElement::HasValidDimensions() const
|
||||
{
|
||||
return !IsInner() ||
|
||||
((!mLengthAttributes[WIDTH].IsExplicitlySet() ||
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
||||
(!mLengthAttributes[HEIGHT].IsExplicitlySet() ||
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0));
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGSVGElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -188,9 +188,12 @@ public:
|
|||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
||||
TransformTypes aWhich = eAllTransforms) const;
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
float GetLength(PRUint8 mCtxType);
|
||||
// Copy our width or height to the target
|
||||
void SyncWidthOrHeight(nsIAtom* aName, nsSVGElement *aTarget) const;
|
||||
|
||||
// public helpers:
|
||||
gfxMatrix GetViewBoxTransform() const;
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "nsIDOMSVGGElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "nsSVGSVGElement.h"
|
||||
#include "nsIDOMSVGSymbolElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -288,10 +288,6 @@ nsSVGUseElement::CreateAnonymousContent()
|
|||
tag != nsGkAtoms::use)
|
||||
return nsnull;
|
||||
|
||||
// Make sure the use attributes are valid
|
||||
if (!HasValidDimensions())
|
||||
return nsnull;
|
||||
|
||||
// circular loop detection
|
||||
|
||||
// check 1 - check if we're a document descendent of the target
|
||||
|
@ -299,8 +295,8 @@ nsSVGUseElement::CreateAnonymousContent()
|
|||
return nsnull;
|
||||
|
||||
// check 2 - check if we're a clone, and if we already exist in the hierarchy
|
||||
if (this->GetParent() && mOriginal) {
|
||||
for (nsCOMPtr<nsIContent> content = this->GetParent();
|
||||
if (GetParent() && mOriginal) {
|
||||
for (nsCOMPtr<nsIContent> content = GetParent();
|
||||
content;
|
||||
content = content->GetParent()) {
|
||||
nsCOMPtr<nsIDOMSVGUseElement> useElement = do_QueryInterface(content);
|
||||
|
@ -407,43 +403,43 @@ nsSVGUseElement::DestroyAnonymousContent()
|
|||
//----------------------------------------------------------------------
|
||||
// implementation helpers
|
||||
|
||||
bool nsSVGUseElement::HasValidDimensions()
|
||||
{
|
||||
nsSVGSVGElement *ctx = GetCtx();
|
||||
|
||||
return (!mLengthAttributes[WIDTH].IsExplicitlySet() ||
|
||||
mLengthAttributes[WIDTH].GetAnimValue(ctx) > 0) &&
|
||||
(!mLengthAttributes[HEIGHT].IsExplicitlySet() ||
|
||||
mLengthAttributes[HEIGHT].GetAnimValue(ctx) > 0);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGUseElement::SyncWidthHeight(nsIAtom* aName)
|
||||
nsSVGUseElement::SyncWidthOrHeight(nsIAtom* aName)
|
||||
{
|
||||
NS_ASSERTION(aName == nsGkAtoms::width || aName == nsGkAtoms::height,
|
||||
"The clue is in the function name");
|
||||
|
||||
if (HasValidDimensions() == !mClone) {
|
||||
TriggerReclone();
|
||||
if (!mClone) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mClone) {
|
||||
nsCOMPtr<nsIDOMSVGSymbolElement> symbol = do_QueryInterface(mClone);
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> svg = do_QueryInterface(mClone);
|
||||
nsCOMPtr<nsIDOMSVGSymbolElement> symbol = do_QueryInterface(mClone);
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> svg = do_QueryInterface(mClone);
|
||||
|
||||
if (symbol || svg) {
|
||||
PRUint32 index = *sLengthInfo[WIDTH].mName == aName ? WIDTH : HEIGHT;
|
||||
if (mLengthAttributes[index].IsExplicitlySet()) {
|
||||
static_cast<nsSVGElement*>(mClone.get())->
|
||||
SetLength(aName, mLengthAttributes[index]);
|
||||
} else {
|
||||
// Our width/height attribute is now no longer explicitly set, so we
|
||||
// need to revert the clone's width/height to the width/height of the
|
||||
// content that's being cloned.
|
||||
TriggerReclone();
|
||||
}
|
||||
if (symbol || svg) {
|
||||
nsSVGElement *target = static_cast<nsSVGElement*>(mClone.get());
|
||||
PRUint32 index = *sLengthInfo[WIDTH].mName == aName ? WIDTH : HEIGHT;
|
||||
|
||||
if (mLengthAttributes[index].IsExplicitlySet()) {
|
||||
target->SetLength(aName, mLengthAttributes[index]);
|
||||
return;
|
||||
}
|
||||
if (svg) {
|
||||
// Our width/height attribute is now no longer explicitly set, so we
|
||||
// need to revert the clone's width/height to the width/height of the
|
||||
// content that's being cloned.
|
||||
nsSVGSVGElement* svgElement =
|
||||
static_cast<nsSVGSVGElement*>(mSource.get());
|
||||
svgElement->SyncWidthOrHeight(aName, target);
|
||||
return;
|
||||
}
|
||||
// Our width/height attribute is now no longer explicitly set, so we
|
||||
// need to set the value to 100%
|
||||
nsSVGLength2 length;
|
||||
length.Init(nsSVGUtils::XY, 0xff,
|
||||
100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
|
||||
target->SetLength(aName, length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,6 +507,15 @@ nsSVGUseElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
|||
return toUserSpace * fromUserSpace;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGUseElement::HasValidDimensions() const
|
||||
{
|
||||
return (!mLengthAttributes[WIDTH].IsExplicitlySet() ||
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
||||
(!mLengthAttributes[HEIGHT].IsExplicitlySet() ||
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGUseElement::GetLengthInfo()
|
||||
{
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
||||
TransformTypes aWhich = eAllTransforms) const;
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsIContent interface
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
@ -130,8 +131,7 @@ protected:
|
|||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
virtual StringAttributesInfo GetStringInfo();
|
||||
|
||||
bool HasValidDimensions();
|
||||
void SyncWidthHeight(nsIAtom *aName);
|
||||
void SyncWidthOrHeight(nsIAtom *aName);
|
||||
void LookupHref();
|
||||
void TriggerReclone();
|
||||
void UnlinkSource();
|
||||
|
|
|
@ -215,6 +215,7 @@ random-if(gtk2Widget) == objectBoundingBox-and-fePointLight-02.svg objectBoundin
|
|||
== rect-01.svg pass.svg
|
||||
== rect-02.svg pass.svg
|
||||
== rect-03.svg pass.svg
|
||||
== rect-04.svg pass.svg
|
||||
== rect-with-rx-and-ry-01.svg pass.svg
|
||||
== rect-with-rx-or-ry-01.svg rect-with-rx-or-ry-01-ref.svg
|
||||
== rootElement-null-01.svg pass.svg
|
||||
|
|
|
@ -95,6 +95,7 @@ fails == anim-fillcolor-1.svg anim-standard-ref.svg # bug 436296
|
|||
== anim-length-reset-01.svg lime.svg
|
||||
== anim-nonpixel-length-reset-01.svg lime.svg
|
||||
== anim-use-length-01.svg lime.svg
|
||||
== anim-use-length-02.svg lime.svg
|
||||
|
||||
# animate some <number> attributes:
|
||||
== anim-feComponentTransfer-01.svg lime.svg
|
||||
|
|
|
@ -321,8 +321,8 @@ nsSVGImageFrame::PaintSVG(nsRenderingContext *aContext,
|
|||
float x, y, width, height;
|
||||
nsSVGImageElement *imgElem = static_cast<nsSVGImageElement*>(mContent);
|
||||
imgElem->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
|
||||
if (width <= 0 || height <= 0)
|
||||
return NS_OK;
|
||||
NS_ASSERTION(width > 0 && height > 0,
|
||||
"Should only be painting things with valid width/height");
|
||||
|
||||
if (!mImageContainer) {
|
||||
nsCOMPtr<imgIRequest> currentRequest;
|
||||
|
|
|
@ -164,14 +164,24 @@ nsSVGInnerSVGFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
|||
if (aAttribute == nsGkAtoms::width ||
|
||||
aAttribute == nsGkAtoms::height) {
|
||||
|
||||
if (static_cast<nsSVGSVGElement*>(mContent)->mViewBox.IsValid()) {
|
||||
nsSVGSVGElement* svg = static_cast<nsSVGSVGElement*>(mContent);
|
||||
if (svg->mViewBox.IsValid()) {
|
||||
|
||||
// make sure our cached transform matrix gets (lazily) updated
|
||||
mCanvasTM = nsnull;
|
||||
|
||||
nsSVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED);
|
||||
} else {
|
||||
nsSVGUtils::NotifyChildrenOfSVGChange(this, COORD_CONTEXT_CHANGED);
|
||||
|
||||
PRUint32 flags = COORD_CONTEXT_CHANGED;
|
||||
|
||||
if (mCanvasTM && mCanvasTM->IsSingular()) {
|
||||
|
||||
mCanvasTM = nsnull;
|
||||
|
||||
flags |= TRANSFORM_CHANGED;
|
||||
}
|
||||
nsSVGUtils::NotifyChildrenOfSVGChange(this, flags);
|
||||
}
|
||||
|
||||
} else if (aAttribute == nsGkAtoms::transform ||
|
||||
|
|
|
@ -51,7 +51,10 @@ class nsSVGUseFrame : public nsSVGUseFrameBase,
|
|||
NS_NewSVGUseFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
||||
|
||||
protected:
|
||||
nsSVGUseFrame(nsStyleContext* aContext) : nsSVGUseFrameBase(aContext) {}
|
||||
nsSVGUseFrame(nsStyleContext* aContext) :
|
||||
nsSVGUseFrameBase(aContext),
|
||||
mHasValidDimensions(true)
|
||||
{}
|
||||
|
||||
public:
|
||||
NS_DECL_QUERYFRAME
|
||||
|
@ -59,11 +62,9 @@ public:
|
|||
|
||||
|
||||
// nsIFrame interface:
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD Init(nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIFrame* aPrevInFlow);
|
||||
#endif
|
||||
|
||||
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
|
@ -94,6 +95,9 @@ public:
|
|||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
|
||||
private:
|
||||
bool mHasValidDimensions;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -123,18 +127,21 @@ NS_QUERYFRAME_TAIL_INHERITING(nsSVGUseFrameBase)
|
|||
//----------------------------------------------------------------------
|
||||
// nsIFrame methods:
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHODIMP
|
||||
nsSVGUseFrame::Init(nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsIDOMSVGUseElement> use = do_QueryInterface(aContent);
|
||||
NS_ASSERTION(use, "Content is not an SVG use!");
|
||||
#endif /* DEBUG */
|
||||
|
||||
mHasValidDimensions =
|
||||
static_cast<nsSVGUseElement*>(aContent)->HasValidDimensions();
|
||||
|
||||
return nsSVGUseFrameBase::Init(aContent, aParent, aPrevInFlow);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGUseFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
||||
|
@ -150,7 +157,14 @@ nsSVGUseFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
|||
nsSVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED);
|
||||
} else if (aAttribute == nsGkAtoms::width ||
|
||||
aAttribute == nsGkAtoms::height) {
|
||||
static_cast<nsSVGUseElement*>(mContent)->SyncWidthHeight(aAttribute);
|
||||
static_cast<nsSVGUseElement*>(mContent)->SyncWidthOrHeight(aAttribute);
|
||||
|
||||
if (mHasValidDimensions !=
|
||||
static_cast<nsSVGUseElement*>(mContent)->HasValidDimensions()) {
|
||||
|
||||
mHasValidDimensions = !mHasValidDimensions;
|
||||
nsSVGUtils::UpdateGraphic(this);
|
||||
}
|
||||
}
|
||||
} else if (aNameSpaceID == kNameSpaceID_XLink &&
|
||||
aAttribute == nsGkAtoms::href) {
|
||||
|
|
|
@ -1051,6 +1051,12 @@ nsSVGUtils::PaintFrameWithEffects(nsRenderingContext *aContext,
|
|||
if (opacity == 0.0f)
|
||||
return;
|
||||
|
||||
const nsIContent* content = aFrame->GetContent();
|
||||
if (content->IsSVG() &&
|
||||
!static_cast<const nsSVGElement*>(content)->HasValidDimensions()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Properties are added lazily and may have been removed by a restyle,
|
||||
so make sure all applicable ones are set again. */
|
||||
|
||||
|
@ -1209,9 +1215,9 @@ nsSVGUtils::HitTestChildren(nsIFrame *aFrame, const nsPoint &aPoint)
|
|||
current = current->GetPrevSibling()) {
|
||||
nsISVGChildFrame* SVGFrame = do_QueryFrame(current);
|
||||
if (SVGFrame) {
|
||||
result = SVGFrame->GetFrameForPoint(aPoint);
|
||||
if (result)
|
||||
break;
|
||||
result = SVGFrame->GetFrameForPoint(aPoint);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1443,13 +1449,18 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, PRUint32 aFlags)
|
|||
}
|
||||
svg = do_QueryFrame(aFrame);
|
||||
}
|
||||
nsIContent* content = aFrame->GetContent();
|
||||
if (content->IsSVG() &&
|
||||
!static_cast<const nsSVGElement*>(content)->HasValidDimensions()) {
|
||||
return bbox;
|
||||
}
|
||||
gfxMatrix matrix;
|
||||
if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame) {
|
||||
// The spec says getBBox "Returns the tight bounding box in *current user
|
||||
// space*". So we should really be doing this for all elements, but that
|
||||
// needs investigation to check that we won't break too much content.
|
||||
NS_ABORT_IF_FALSE(aFrame->GetContent()->IsSVG(), "bad cast");
|
||||
nsSVGElement *element = static_cast<nsSVGElement*>(aFrame->GetContent());
|
||||
NS_ABORT_IF_FALSE(content->IsSVG(), "bad cast");
|
||||
nsSVGElement *element = static_cast<nsSVGElement*>(content);
|
||||
matrix = element->PrependLocalTransformsTo(matrix,
|
||||
nsSVGElement::eChildToUserSpace);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче