Bug 1540408 Part 3 - Rename SVGViewBoxRect to SVGViewBox r=dholbert
This commit is contained in:
@@ -19,9 +19,9 @@ namespace mozilla {
|
|||||||
|
|
||||||
#define NUM_VIEWBOX_COMPONENTS 4
|
#define NUM_VIEWBOX_COMPONENTS 4
|
||||||
|
|
||||||
/* Implementation of SVGViewBoxRect methods */
|
/* Implementation of SVGViewBox methods */
|
||||||
|
|
||||||
bool SVGViewBoxRect::operator==(const SVGViewBoxRect& aOther) const {
|
bool SVGViewBox::operator==(const SVGViewBox& aOther) const {
|
||||||
if (&aOther == this) return true;
|
if (&aOther == this) return true;
|
||||||
|
|
||||||
return (none && aOther.none) ||
|
return (none && aOther.none) ||
|
||||||
@@ -30,8 +30,7 @@ bool SVGViewBoxRect::operator==(const SVGViewBoxRect& aOther) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
nsresult SVGViewBoxRect::FromString(const nsAString& aStr,
|
nsresult SVGViewBox::FromString(const nsAString& aStr, SVGViewBox* aViewBox) {
|
||||||
SVGViewBoxRect* aViewBox) {
|
|
||||||
if (aStr.EqualsLiteral("none")) {
|
if (aStr.EqualsLiteral("none")) {
|
||||||
aViewBox->none = true;
|
aViewBox->none = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@@ -107,7 +106,7 @@ void SVGAnimatedViewBox::Init() {
|
|||||||
bool SVGAnimatedViewBox::HasRect() const {
|
bool SVGAnimatedViewBox::HasRect() const {
|
||||||
// Check mAnimVal if we have one; otherwise, check mBaseVal if we have one;
|
// Check mAnimVal if we have one; otherwise, check mBaseVal if we have one;
|
||||||
// otherwise, just return false (we clearly do not have a rect).
|
// otherwise, just return false (we clearly do not have a rect).
|
||||||
const SVGViewBoxRect* rect = mAnimVal;
|
const SVGViewBox* rect = mAnimVal;
|
||||||
if (!rect) {
|
if (!rect) {
|
||||||
if (!mHasBaseVal) {
|
if (!mHasBaseVal) {
|
||||||
// no anim val, no base val --> no viewbox rect
|
// no anim val, no base val --> no viewbox rect
|
||||||
@@ -119,11 +118,11 @@ bool SVGAnimatedViewBox::HasRect() const {
|
|||||||
return !rect->none && rect->width >= 0 && rect->height >= 0;
|
return !rect->none && rect->width >= 0 && rect->height >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGAnimatedViewBox::SetAnimValue(const SVGViewBoxRect& aRect,
|
void SVGAnimatedViewBox::SetAnimValue(const SVGViewBox& aRect,
|
||||||
SVGElement* aSVGElement) {
|
SVGElement* aSVGElement) {
|
||||||
if (!mAnimVal) {
|
if (!mAnimVal) {
|
||||||
// it's okay if allocation fails - and no point in reporting that
|
// it's okay if allocation fails - and no point in reporting that
|
||||||
mAnimVal = new SVGViewBoxRect(aRect);
|
mAnimVal = new SVGViewBox(aRect);
|
||||||
} else {
|
} else {
|
||||||
if (aRect == *mAnimVal) {
|
if (aRect == *mAnimVal) {
|
||||||
return;
|
return;
|
||||||
@@ -133,7 +132,7 @@ void SVGAnimatedViewBox::SetAnimValue(const SVGViewBoxRect& aRect,
|
|||||||
aSVGElement->DidAnimateViewBox();
|
aSVGElement->DidAnimateViewBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGAnimatedViewBox::SetBaseValue(const SVGViewBoxRect& aRect,
|
void SVGAnimatedViewBox::SetBaseValue(const SVGViewBox& aRect,
|
||||||
SVGElement* aSVGElement) {
|
SVGElement* aSVGElement) {
|
||||||
if (!mHasBaseVal || mBaseVal == aRect) {
|
if (!mHasBaseVal || mBaseVal == aRect) {
|
||||||
// This method is used to set a single x, y, width
|
// This method is used to set a single x, y, width
|
||||||
@@ -158,9 +157,9 @@ void SVGAnimatedViewBox::SetBaseValue(const SVGViewBoxRect& aRect,
|
|||||||
nsresult SVGAnimatedViewBox::SetBaseValueString(const nsAString& aValue,
|
nsresult SVGAnimatedViewBox::SetBaseValueString(const nsAString& aValue,
|
||||||
SVGElement* aSVGElement,
|
SVGElement* aSVGElement,
|
||||||
bool aDoSetAttr) {
|
bool aDoSetAttr) {
|
||||||
SVGViewBoxRect viewBox;
|
SVGViewBox viewBox;
|
||||||
|
|
||||||
nsresult rv = SVGViewBoxRect::FromString(aValue, &viewBox);
|
nsresult rv = SVGViewBox::FromString(aValue, &viewBox);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -247,26 +246,26 @@ SVGAnimatedViewBox::DOMAnimVal::~DOMAnimVal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SVGAnimatedViewBox::DOMBaseVal::SetX(float aX, ErrorResult& aRv) {
|
void SVGAnimatedViewBox::DOMBaseVal::SetX(float aX, ErrorResult& aRv) {
|
||||||
SVGViewBoxRect rect = mVal->GetBaseValue();
|
SVGViewBox rect = mVal->GetBaseValue();
|
||||||
rect.x = aX;
|
rect.x = aX;
|
||||||
mVal->SetBaseValue(rect, mSVGElement);
|
mVal->SetBaseValue(rect, mSVGElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGAnimatedViewBox::DOMBaseVal::SetY(float aY, ErrorResult& aRv) {
|
void SVGAnimatedViewBox::DOMBaseVal::SetY(float aY, ErrorResult& aRv) {
|
||||||
SVGViewBoxRect rect = mVal->GetBaseValue();
|
SVGViewBox rect = mVal->GetBaseValue();
|
||||||
rect.y = aY;
|
rect.y = aY;
|
||||||
mVal->SetBaseValue(rect, mSVGElement);
|
mVal->SetBaseValue(rect, mSVGElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGAnimatedViewBox::DOMBaseVal::SetWidth(float aWidth, ErrorResult& aRv) {
|
void SVGAnimatedViewBox::DOMBaseVal::SetWidth(float aWidth, ErrorResult& aRv) {
|
||||||
SVGViewBoxRect rect = mVal->GetBaseValue();
|
SVGViewBox rect = mVal->GetBaseValue();
|
||||||
rect.width = aWidth;
|
rect.width = aWidth;
|
||||||
mVal->SetBaseValue(rect, mSVGElement);
|
mVal->SetBaseValue(rect, mSVGElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGAnimatedViewBox::DOMBaseVal::SetHeight(float aHeight,
|
void SVGAnimatedViewBox::DOMBaseVal::SetHeight(float aHeight,
|
||||||
ErrorResult& aRv) {
|
ErrorResult& aRv) {
|
||||||
SVGViewBoxRect rect = mVal->GetBaseValue();
|
SVGViewBox rect = mVal->GetBaseValue();
|
||||||
rect.height = aHeight;
|
rect.height = aHeight;
|
||||||
mVal->SetBaseValue(rect, mSVGElement);
|
mVal->SetBaseValue(rect, mSVGElement);
|
||||||
}
|
}
|
||||||
@@ -278,13 +277,13 @@ UniquePtr<SMILAttr> SVGAnimatedViewBox::ToSMILAttr(SVGElement* aSVGElement) {
|
|||||||
nsresult SVGAnimatedViewBox::SMILViewBox ::ValueFromString(
|
nsresult SVGAnimatedViewBox::SMILViewBox ::ValueFromString(
|
||||||
const nsAString& aStr, const SVGAnimationElement* /*aSrcElement*/,
|
const nsAString& aStr, const SVGAnimationElement* /*aSrcElement*/,
|
||||||
SMILValue& aValue, bool& aPreventCachingOfSandwich) const {
|
SMILValue& aValue, bool& aPreventCachingOfSandwich) const {
|
||||||
SVGViewBoxRect viewBox;
|
SVGViewBox viewBox;
|
||||||
nsresult res = SVGViewBoxRect::FromString(aStr, &viewBox);
|
nsresult res = SVGViewBox::FromString(aStr, &viewBox);
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
SMILValue val(&SVGViewBoxSMILType::sSingleton);
|
SMILValue val(&SVGViewBoxSMILType::sSingleton);
|
||||||
*static_cast<SVGViewBoxRect*>(val.mU.mPtr) = viewBox;
|
*static_cast<SVGViewBox*>(val.mU.mPtr) = viewBox;
|
||||||
aValue = std::move(val);
|
aValue = std::move(val);
|
||||||
aPreventCachingOfSandwich = false;
|
aPreventCachingOfSandwich = false;
|
||||||
|
|
||||||
@@ -293,7 +292,7 @@ nsresult SVGAnimatedViewBox::SMILViewBox ::ValueFromString(
|
|||||||
|
|
||||||
SMILValue SVGAnimatedViewBox::SMILViewBox::GetBaseValue() const {
|
SMILValue SVGAnimatedViewBox::SMILViewBox::GetBaseValue() const {
|
||||||
SMILValue val(&SVGViewBoxSMILType::sSingleton);
|
SMILValue val(&SVGViewBoxSMILType::sSingleton);
|
||||||
*static_cast<SVGViewBoxRect*>(val.mU.mPtr) = mVal->mBaseVal;
|
*static_cast<SVGViewBox*>(val.mU.mPtr) = mVal->mBaseVal;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +308,7 @@ nsresult SVGAnimatedViewBox::SMILViewBox::SetAnimValue(
|
|||||||
NS_ASSERTION(aValue.mType == &SVGViewBoxSMILType::sSingleton,
|
NS_ASSERTION(aValue.mType == &SVGViewBoxSMILType::sSingleton,
|
||||||
"Unexpected type to assign animated value");
|
"Unexpected type to assign animated value");
|
||||||
if (aValue.mType == &SVGViewBoxSMILType::sSingleton) {
|
if (aValue.mType == &SVGViewBoxSMILType::sSingleton) {
|
||||||
SVGViewBoxRect& vb = *static_cast<SVGViewBoxRect*>(aValue.mU.mPtr);
|
SVGViewBox& vb = *static_cast<SVGViewBox*>(aValue.mU.mPtr);
|
||||||
mVal->SetAnimValue(vb, mSVGElement);
|
mVal->SetAnimValue(vb, mSVGElement);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -26,23 +26,23 @@ class SVGAnimationElement;
|
|||||||
class SVGElement;
|
class SVGElement;
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
||||||
struct SVGViewBoxRect {
|
struct SVGViewBox {
|
||||||
float x, y;
|
float x, y;
|
||||||
float width, height;
|
float width, height;
|
||||||
bool none;
|
bool none;
|
||||||
|
|
||||||
SVGViewBoxRect() : x(0.0), y(0.0), width(0.0), height(0.0), none(true) {}
|
SVGViewBox() : x(0.0), y(0.0), width(0.0), height(0.0), none(true) {}
|
||||||
SVGViewBoxRect(float aX, float aY, float aWidth, float aHeight)
|
SVGViewBox(float aX, float aY, float aWidth, float aHeight)
|
||||||
: x(aX), y(aY), width(aWidth), height(aHeight), none(false) {}
|
: x(aX), y(aY), width(aWidth), height(aHeight), none(false) {}
|
||||||
SVGViewBoxRect(const SVGViewBoxRect& rhs)
|
SVGViewBox(const SVGViewBox& rhs)
|
||||||
: x(rhs.x),
|
: x(rhs.x),
|
||||||
y(rhs.y),
|
y(rhs.y),
|
||||||
width(rhs.width),
|
width(rhs.width),
|
||||||
height(rhs.height),
|
height(rhs.height),
|
||||||
none(rhs.none) {}
|
none(rhs.none) {}
|
||||||
bool operator==(const SVGViewBoxRect& aOther) const;
|
bool operator==(const SVGViewBox& aOther) const;
|
||||||
|
|
||||||
static nsresult FromString(const nsAString& aStr, SVGViewBoxRect* aViewBox);
|
static nsresult FromString(const nsAString& aStr, SVGViewBox* aViewBox);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SVGAnimatedViewBox {
|
class SVGAnimatedViewBox {
|
||||||
@@ -66,18 +66,18 @@ class SVGAnimatedViewBox {
|
|||||||
*/
|
*/
|
||||||
bool IsExplicitlySet() const {
|
bool IsExplicitlySet() const {
|
||||||
if (mAnimVal || mHasBaseVal) {
|
if (mAnimVal || mHasBaseVal) {
|
||||||
const SVGViewBoxRect& rect = GetAnimValue();
|
const SVGViewBox& rect = GetAnimValue();
|
||||||
return rect.none || (rect.width >= 0 && rect.height >= 0);
|
return rect.none || (rect.width >= 0 && rect.height >= 0);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SVGViewBoxRect& GetBaseValue() const { return mBaseVal; }
|
const SVGViewBox& GetBaseValue() const { return mBaseVal; }
|
||||||
void SetBaseValue(const SVGViewBoxRect& aRect, SVGElement* aSVGElement);
|
void SetBaseValue(const SVGViewBox& aRect, SVGElement* aSVGElement);
|
||||||
const SVGViewBoxRect& GetAnimValue() const {
|
const SVGViewBox& GetAnimValue() const {
|
||||||
return mAnimVal ? *mAnimVal : mBaseVal;
|
return mAnimVal ? *mAnimVal : mBaseVal;
|
||||||
}
|
}
|
||||||
void SetAnimValue(const SVGViewBoxRect& aRect, SVGElement* aSVGElement);
|
void SetAnimValue(const SVGViewBox& aRect, SVGElement* aSVGElement);
|
||||||
|
|
||||||
nsresult SetBaseValueString(const nsAString& aValue, SVGElement* aSVGElement,
|
nsresult SetBaseValueString(const nsAString& aValue, SVGElement* aSVGElement,
|
||||||
bool aDoSetAttr);
|
bool aDoSetAttr);
|
||||||
@@ -95,8 +95,8 @@ class SVGAnimatedViewBox {
|
|||||||
mozilla::UniquePtr<SMILAttr> ToSMILAttr(SVGElement* aSVGElement);
|
mozilla::UniquePtr<SMILAttr> ToSMILAttr(SVGElement* aSVGElement);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SVGViewBoxRect mBaseVal;
|
SVGViewBox mBaseVal;
|
||||||
nsAutoPtr<SVGViewBoxRect> mAnimVal;
|
nsAutoPtr<SVGViewBox> mAnimVal;
|
||||||
bool mHasBaseVal;
|
bool mHasBaseVal;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -173,20 +173,20 @@ nsresult SVGElement::Init() {
|
|||||||
enumInfo.Reset(i);
|
enumInfo.Reset(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedOrient* orient = GetOrient();
|
SVGAnimatedOrient* orient = GetAnimatedOrient();
|
||||||
|
|
||||||
if (orient) {
|
if (orient) {
|
||||||
orient->Init();
|
orient->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedViewBox* viewBox = GetViewBox();
|
SVGAnimatedViewBox* viewBox = GetAnimatedViewBox();
|
||||||
|
|
||||||
if (viewBox) {
|
if (viewBox) {
|
||||||
viewBox->Init();
|
viewBox->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
||||||
GetPreserveAspectRatio();
|
GetAnimatedPreserveAspectRatio();
|
||||||
|
|
||||||
if (preserveAspectRatio) {
|
if (preserveAspectRatio) {
|
||||||
preserveAspectRatio->Init();
|
preserveAspectRatio->Init();
|
||||||
@@ -532,7 +532,7 @@ bool SVGElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|||||||
if (!foundMatch) {
|
if (!foundMatch) {
|
||||||
// Check for orient attribute
|
// Check for orient attribute
|
||||||
if (aAttribute == nsGkAtoms::orient) {
|
if (aAttribute == nsGkAtoms::orient) {
|
||||||
SVGAnimatedOrient* orient = GetOrient();
|
SVGAnimatedOrient* orient = GetAnimatedOrient();
|
||||||
if (orient) {
|
if (orient) {
|
||||||
rv = orient->SetBaseValueString(aValue, this, false);
|
rv = orient->SetBaseValueString(aValue, this, false);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@@ -545,7 +545,7 @@ bool SVGElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|||||||
}
|
}
|
||||||
// Check for viewBox attribute
|
// Check for viewBox attribute
|
||||||
} else if (aAttribute == nsGkAtoms::viewBox) {
|
} else if (aAttribute == nsGkAtoms::viewBox) {
|
||||||
SVGAnimatedViewBox* viewBox = GetViewBox();
|
SVGAnimatedViewBox* viewBox = GetAnimatedViewBox();
|
||||||
if (viewBox) {
|
if (viewBox) {
|
||||||
rv = viewBox->SetBaseValueString(aValue, this, false);
|
rv = viewBox->SetBaseValueString(aValue, this, false);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@@ -559,7 +559,7 @@ bool SVGElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|||||||
// Check for preserveAspectRatio attribute
|
// Check for preserveAspectRatio attribute
|
||||||
} else if (aAttribute == nsGkAtoms::preserveAspectRatio) {
|
} else if (aAttribute == nsGkAtoms::preserveAspectRatio) {
|
||||||
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
||||||
GetPreserveAspectRatio();
|
GetAnimatedPreserveAspectRatio();
|
||||||
if (preserveAspectRatio) {
|
if (preserveAspectRatio) {
|
||||||
rv = preserveAspectRatio->SetBaseValueString(aValue, this, false);
|
rv = preserveAspectRatio->SetBaseValueString(aValue, this, false);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@@ -768,7 +768,7 @@ void SVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsAtom* aName,
|
|||||||
|
|
||||||
// Check if this is an orient attribute going away
|
// Check if this is an orient attribute going away
|
||||||
if (aName == nsGkAtoms::orient) {
|
if (aName == nsGkAtoms::orient) {
|
||||||
SVGAnimatedOrient* orient = GetOrient();
|
SVGAnimatedOrient* orient = GetAnimatedOrient();
|
||||||
if (orient) {
|
if (orient) {
|
||||||
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
||||||
orient->Init();
|
orient->Init();
|
||||||
@@ -778,7 +778,7 @@ void SVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsAtom* aName,
|
|||||||
|
|
||||||
// Check if this is a viewBox attribute going away
|
// Check if this is a viewBox attribute going away
|
||||||
if (aName == nsGkAtoms::viewBox) {
|
if (aName == nsGkAtoms::viewBox) {
|
||||||
SVGAnimatedViewBox* viewBox = GetViewBox();
|
SVGAnimatedViewBox* viewBox = GetAnimatedViewBox();
|
||||||
if (viewBox) {
|
if (viewBox) {
|
||||||
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
||||||
viewBox->Init();
|
viewBox->Init();
|
||||||
@@ -789,7 +789,7 @@ void SVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsAtom* aName,
|
|||||||
// Check if this is a preserveAspectRatio attribute going away
|
// Check if this is a preserveAspectRatio attribute going away
|
||||||
if (aName == nsGkAtoms::preserveAspectRatio) {
|
if (aName == nsGkAtoms::preserveAspectRatio) {
|
||||||
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
||||||
GetPreserveAspectRatio();
|
GetAnimatedPreserveAspectRatio();
|
||||||
if (preserveAspectRatio) {
|
if (preserveAspectRatio) {
|
||||||
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
||||||
preserveAspectRatio->Init();
|
preserveAspectRatio->Init();
|
||||||
@@ -1885,14 +1885,14 @@ void SVGElement::DidAnimateEnum(uint8_t aAttrEnum) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedOrient* SVGElement::GetOrient() { return nullptr; }
|
SVGAnimatedOrient* SVGElement::GetAnimatedOrient() { return nullptr; }
|
||||||
|
|
||||||
nsAttrValue SVGElement::WillChangeOrient() {
|
nsAttrValue SVGElement::WillChangeOrient() {
|
||||||
return WillChangeValue(nsGkAtoms::orient);
|
return WillChangeValue(nsGkAtoms::orient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGElement::DidChangeOrient(const nsAttrValue& aEmptyOrOldValue) {
|
void SVGElement::DidChangeOrient(const nsAttrValue& aEmptyOrOldValue) {
|
||||||
SVGAnimatedOrient* orient = GetOrient();
|
SVGAnimatedOrient* orient = GetAnimatedOrient();
|
||||||
|
|
||||||
NS_ASSERTION(orient, "DidChangeOrient on element with no orient attrib");
|
NS_ASSERTION(orient, "DidChangeOrient on element with no orient attrib");
|
||||||
|
|
||||||
@@ -1911,14 +1911,14 @@ void SVGElement::DidAnimateOrient() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedViewBox* SVGElement::GetViewBox() { return nullptr; }
|
SVGAnimatedViewBox* SVGElement::GetAnimatedViewBox() { return nullptr; }
|
||||||
|
|
||||||
nsAttrValue SVGElement::WillChangeViewBox() {
|
nsAttrValue SVGElement::WillChangeViewBox() {
|
||||||
return WillChangeValue(nsGkAtoms::viewBox);
|
return WillChangeValue(nsGkAtoms::viewBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGElement::DidChangeViewBox(const nsAttrValue& aEmptyOrOldValue) {
|
void SVGElement::DidChangeViewBox(const nsAttrValue& aEmptyOrOldValue) {
|
||||||
SVGAnimatedViewBox* viewBox = GetViewBox();
|
SVGAnimatedViewBox* viewBox = GetAnimatedViewBox();
|
||||||
|
|
||||||
NS_ASSERTION(viewBox, "DidChangeViewBox on element with no viewBox attrib");
|
NS_ASSERTION(viewBox, "DidChangeViewBox on element with no viewBox attrib");
|
||||||
|
|
||||||
@@ -1937,7 +1937,7 @@ void SVGElement::DidAnimateViewBox() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* SVGElement::GetPreserveAspectRatio() {
|
SVGAnimatedPreserveAspectRatio* SVGElement::GetAnimatedPreserveAspectRatio() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1948,7 +1948,7 @@ nsAttrValue SVGElement::WillChangePreserveAspectRatio() {
|
|||||||
void SVGElement::DidChangePreserveAspectRatio(
|
void SVGElement::DidChangePreserveAspectRatio(
|
||||||
const nsAttrValue& aEmptyOrOldValue) {
|
const nsAttrValue& aEmptyOrOldValue) {
|
||||||
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
||||||
GetPreserveAspectRatio();
|
GetAnimatedPreserveAspectRatio();
|
||||||
|
|
||||||
NS_ASSERTION(preserveAspectRatio,
|
NS_ASSERTION(preserveAspectRatio,
|
||||||
"DidChangePreserveAspectRatio on element with no "
|
"DidChangePreserveAspectRatio on element with no "
|
||||||
@@ -2222,20 +2222,20 @@ UniquePtr<SMILAttr> SVGElement::GetAnimatedAttr(int32_t aNamespaceID,
|
|||||||
|
|
||||||
// orient:
|
// orient:
|
||||||
if (aName == nsGkAtoms::orient) {
|
if (aName == nsGkAtoms::orient) {
|
||||||
SVGAnimatedOrient* orient = GetOrient();
|
SVGAnimatedOrient* orient = GetAnimatedOrient();
|
||||||
return orient ? orient->ToSMILAttr(this) : nullptr;
|
return orient ? orient->ToSMILAttr(this) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// viewBox:
|
// viewBox:
|
||||||
if (aName == nsGkAtoms::viewBox) {
|
if (aName == nsGkAtoms::viewBox) {
|
||||||
SVGAnimatedViewBox* viewBox = GetViewBox();
|
SVGAnimatedViewBox* viewBox = GetAnimatedViewBox();
|
||||||
return viewBox ? viewBox->ToSMILAttr(this) : nullptr;
|
return viewBox ? viewBox->ToSMILAttr(this) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// preserveAspectRatio:
|
// preserveAspectRatio:
|
||||||
if (aName == nsGkAtoms::preserveAspectRatio) {
|
if (aName == nsGkAtoms::preserveAspectRatio) {
|
||||||
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
SVGAnimatedPreserveAspectRatio* preserveAspectRatio =
|
||||||
GetPreserveAspectRatio();
|
GetAnimatedPreserveAspectRatio();
|
||||||
return preserveAspectRatio ? preserveAspectRatio->ToSMILAttr(this)
|
return preserveAspectRatio ? preserveAspectRatio->ToSMILAttr(this)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,9 +567,9 @@ class SVGElement : public SVGElementBase // nsIContent
|
|||||||
virtual EnumAttributesInfo GetEnumInfo();
|
virtual EnumAttributesInfo GetEnumInfo();
|
||||||
// We assume all orients, viewboxes and preserveAspectRatios are alike
|
// We assume all orients, viewboxes and preserveAspectRatios are alike
|
||||||
// so we don't need to wrap the class
|
// so we don't need to wrap the class
|
||||||
virtual SVGAnimatedOrient* GetOrient();
|
virtual SVGAnimatedOrient* GetAnimatedOrient();
|
||||||
virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio();
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio();
|
||||||
virtual SVGAnimatedViewBox* GetViewBox();
|
virtual SVGAnimatedViewBox* GetAnimatedViewBox();
|
||||||
virtual NumberListAttributesInfo GetNumberListInfo();
|
virtual NumberListAttributesInfo GetNumberListInfo();
|
||||||
virtual LengthListAttributesInfo GetLengthListInfo();
|
virtual LengthListAttributesInfo GetLengthListInfo();
|
||||||
virtual StringAttributesInfo GetStringInfo();
|
virtual StringAttributesInfo GetStringInfo();
|
||||||
|
|||||||
@@ -284,7 +284,8 @@ SVGFEImageElement::PreserveAspectRatio() {
|
|||||||
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this);
|
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* SVGFEImageElement::GetPreserveAspectRatio() {
|
SVGAnimatedPreserveAspectRatio*
|
||||||
|
SVGFEImageElement::GetAnimatedPreserveAspectRatio() {
|
||||||
return &mPreserveAspectRatio;
|
return &mPreserveAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ class SVGFEImageElement final : public SVGFEImageElementBase,
|
|||||||
protected:
|
protected:
|
||||||
virtual bool ProducesSRGB() override { return true; }
|
virtual bool ProducesSRGB() override { return true; }
|
||||||
|
|
||||||
virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override;
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
|
||||||
|
override;
|
||||||
virtual StringAttributesInfo GetStringInfo() override;
|
virtual StringAttributesInfo GetStringInfo() override;
|
||||||
|
|
||||||
// Override for nsImageLoadingContent.
|
// Override for nsImageLoadingContent.
|
||||||
|
|||||||
@@ -279,7 +279,8 @@ SVGElement::LengthAttributesInfo SVGImageElement::GetLengthInfo() {
|
|||||||
ArrayLength(sLengthInfo));
|
ArrayLength(sLengthInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* SVGImageElement::GetPreserveAspectRatio() {
|
SVGAnimatedPreserveAspectRatio*
|
||||||
|
SVGImageElement::GetAnimatedPreserveAspectRatio() {
|
||||||
return &mPreserveAspectRatio;
|
return &mPreserveAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ class SVGImageElement : public SVGImageElementBase,
|
|||||||
nsresult LoadSVGImage(bool aForce, bool aNotify);
|
nsresult LoadSVGImage(bool aForce, bool aNotify);
|
||||||
|
|
||||||
virtual LengthAttributesInfo GetLengthInfo() override;
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
||||||
virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override;
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
|
||||||
|
override;
|
||||||
virtual StringAttributesInfo GetStringInfo() override;
|
virtual StringAttributesInfo GetStringInfo() override;
|
||||||
|
|
||||||
// Override for nsImageLoadingContent.
|
// Override for nsImageLoadingContent.
|
||||||
|
|||||||
@@ -165,11 +165,12 @@ SVGElement::EnumAttributesInfo SVGMarkerElement::GetEnumInfo() {
|
|||||||
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedOrient* SVGMarkerElement::GetOrient() { return &mOrient; }
|
SVGAnimatedOrient* SVGMarkerElement::GetAnimatedOrient() { return &mOrient; }
|
||||||
|
|
||||||
SVGAnimatedViewBox* SVGMarkerElement::GetViewBox() { return &mViewBox; }
|
SVGAnimatedViewBox* SVGMarkerElement::GetAnimatedViewBox() { return &mViewBox; }
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* SVGMarkerElement::GetPreserveAspectRatio() {
|
SVGAnimatedPreserveAspectRatio*
|
||||||
|
SVGMarkerElement::GetAnimatedPreserveAspectRatio() {
|
||||||
return &mPreserveAspectRatio;
|
return &mPreserveAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,13 +201,13 @@ gfx::Matrix SVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
|||||||
-sin(angle) * scale, cos(angle) * scale, aMark.x, aMark.y);
|
-sin(angle) * scale, cos(angle) * scale, aMark.x, aMark.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGViewBoxRect SVGMarkerElement::GetViewBoxRect() {
|
SVGViewBox SVGMarkerElement::GetViewBox() {
|
||||||
if (mViewBox.HasRect()) {
|
if (mViewBox.HasRect()) {
|
||||||
return mViewBox.GetAnimValue();
|
return mViewBox.GetAnimValue();
|
||||||
}
|
}
|
||||||
return SVGViewBoxRect(
|
return SVGViewBox(0, 0,
|
||||||
0, 0, mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx),
|
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx),
|
||||||
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
|
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Matrix SVGMarkerElement::GetViewBoxTransform() {
|
gfx::Matrix SVGMarkerElement::GetViewBoxTransform() {
|
||||||
@@ -216,7 +217,7 @@ gfx::Matrix SVGMarkerElement::GetViewBoxTransform() {
|
|||||||
float viewportHeight =
|
float viewportHeight =
|
||||||
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx);
|
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx);
|
||||||
|
|
||||||
SVGViewBoxRect viewbox = GetViewBoxRect();
|
SVGViewBox viewbox = GetViewBox();
|
||||||
|
|
||||||
MOZ_ASSERT(viewbox.width > 0.0f && viewbox.height > 0.0f,
|
MOZ_ASSERT(viewbox.width > 0.0f && viewbox.height > 0.0f,
|
||||||
"Rendering should be disabled");
|
"Rendering should be disabled");
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class SVGMarkerElement : public SVGMarkerElementBase {
|
|||||||
|
|
||||||
// public helpers
|
// public helpers
|
||||||
gfx::Matrix GetMarkerTransform(float aStrokeWidth, const SVGMark& aMark);
|
gfx::Matrix GetMarkerTransform(float aStrokeWidth, const SVGMark& aMark);
|
||||||
SVGViewBoxRect GetViewBoxRect();
|
SVGViewBox GetViewBox();
|
||||||
gfx::Matrix GetViewBoxTransform();
|
gfx::Matrix GetViewBoxTransform();
|
||||||
|
|
||||||
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
||||||
@@ -79,9 +79,10 @@ class SVGMarkerElement : public SVGMarkerElementBase {
|
|||||||
|
|
||||||
virtual LengthAttributesInfo GetLengthInfo() override;
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
||||||
virtual EnumAttributesInfo GetEnumInfo() override;
|
virtual EnumAttributesInfo GetEnumInfo() override;
|
||||||
virtual SVGAnimatedOrient* GetOrient() override;
|
virtual SVGAnimatedOrient* GetAnimatedOrient() override;
|
||||||
virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override;
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
|
||||||
virtual SVGAnimatedViewBox* GetViewBox() override;
|
override;
|
||||||
|
virtual SVGAnimatedViewBox* GetAnimatedViewBox() override;
|
||||||
|
|
||||||
enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT };
|
enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT };
|
||||||
SVGAnimatedLength mLengthAttributes[4];
|
SVGAnimatedLength mLengthAttributes[4];
|
||||||
|
|||||||
@@ -162,9 +162,12 @@ SVGElement::EnumAttributesInfo SVGPatternElement::GetEnumInfo() {
|
|||||||
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedViewBox* SVGPatternElement::GetViewBox() { return &mViewBox; }
|
SVGAnimatedViewBox* SVGPatternElement::GetAnimatedViewBox() {
|
||||||
|
return &mViewBox;
|
||||||
|
}
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* SVGPatternElement::GetPreserveAspectRatio() {
|
SVGAnimatedPreserveAspectRatio*
|
||||||
|
SVGPatternElement::GetAnimatedPreserveAspectRatio() {
|
||||||
return &mPreserveAspectRatio;
|
return &mPreserveAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,9 @@ class SVGPatternElement final : public SVGPatternElementBase {
|
|||||||
virtual LengthAttributesInfo GetLengthInfo() override;
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
||||||
virtual EnumAttributesInfo GetEnumInfo() override;
|
virtual EnumAttributesInfo GetEnumInfo() override;
|
||||||
virtual StringAttributesInfo GetStringInfo() override;
|
virtual StringAttributesInfo GetStringInfo() override;
|
||||||
virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override;
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
|
||||||
virtual SVGAnimatedViewBox* GetViewBox() override;
|
override;
|
||||||
|
virtual SVGAnimatedViewBox* GetAnimatedViewBox() override;
|
||||||
|
|
||||||
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
|
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
|
||||||
SVGAnimatedLength mLengthAttributes[4];
|
SVGAnimatedLength mLengthAttributes[4];
|
||||||
|
|||||||
@@ -524,15 +524,15 @@ void SVGSVGElement::SetImageOverridePreserveAspectRatio(
|
|||||||
MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(),
|
MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(),
|
||||||
"should only override preserveAspectRatio in images");
|
"should only override preserveAspectRatio in images");
|
||||||
|
|
||||||
bool hasViewBoxRect = HasViewBoxRect();
|
bool hasViewBox = HasViewBox();
|
||||||
if (!hasViewBoxRect && ShouldSynthesizeViewBox()) {
|
if (!hasViewBox && ShouldSynthesizeViewBox()) {
|
||||||
// My non-<svg:image> clients will have been painting me with a synthesized
|
// My non-<svg:image> clients will have been painting me with a synthesized
|
||||||
// viewBox, but my <svg:image> client that's about to paint me now does NOT
|
// viewBox, but my <svg:image> client that's about to paint me now does NOT
|
||||||
// want that. Need to tell ourselves to flush our transform.
|
// want that. Need to tell ourselves to flush our transform.
|
||||||
mImageNeedsTransformInvalidation = true;
|
mImageNeedsTransformInvalidation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasViewBoxRect) {
|
if (!hasViewBox) {
|
||||||
return; // preserveAspectRatio irrelevant (only matters if we have viewBox)
|
return; // preserveAspectRatio irrelevant (only matters if we have viewBox)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ void SVGSVGElement::ClearImageOverridePreserveAspectRatio() {
|
|||||||
MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(),
|
MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(),
|
||||||
"should only override image preserveAspectRatio in images");
|
"should only override image preserveAspectRatio in images");
|
||||||
|
|
||||||
if (!HasViewBoxRect() && ShouldSynthesizeViewBox()) {
|
if (!HasViewBox() && ShouldSynthesizeViewBox()) {
|
||||||
// My non-<svg:image> clients will want to paint me with a synthesized
|
// My non-<svg:image> clients will want to paint me with a synthesized
|
||||||
// viewBox, but my <svg:image> client that just painted me did NOT
|
// viewBox, but my <svg:image> client that just painted me did NOT
|
||||||
// use that. Need to tell ourselves to flush our transform.
|
// use that. Need to tell ourselves to flush our transform.
|
||||||
@@ -603,9 +603,9 @@ SVGPreserveAspectRatio SVGSVGElement::GetPreserveAspectRatioWithOverride()
|
|||||||
|
|
||||||
SVGViewElement* viewElement = GetCurrentViewElement();
|
SVGViewElement* viewElement = GetCurrentViewElement();
|
||||||
|
|
||||||
// This check is equivalent to "!HasViewBoxRect() &&
|
// This check is equivalent to "!HasViewBox() &&
|
||||||
// ShouldSynthesizeViewBox()". We're just holding onto the viewElement that
|
// ShouldSynthesizeViewBox()". We're just holding onto the viewElement that
|
||||||
// HasViewBoxRect() would look up, so that we don't have to look it up again
|
// HasViewBox() would look up, so that we don't have to look it up again
|
||||||
// later.
|
// later.
|
||||||
if (!((viewElement && viewElement->mViewBox.HasRect()) ||
|
if (!((viewElement && viewElement->mViewBox.HasRect()) ||
|
||||||
(mSVGView && mSVGView->mViewBox.HasRect()) || mViewBox.HasRect()) &&
|
(mSVGView && mSVGView->mViewBox.HasRect()) || mViewBox.HasRect()) &&
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ SVGViewBoxSMILType SVGViewBoxSMILType::sSingleton;
|
|||||||
void SVGViewBoxSMILType::Init(SMILValue& aValue) const {
|
void SVGViewBoxSMILType::Init(SMILValue& aValue) const {
|
||||||
MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
|
MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
|
||||||
|
|
||||||
aValue.mU.mPtr = new SVGViewBoxRect();
|
aValue.mU.mPtr = new SVGViewBox();
|
||||||
aValue.mType = this;
|
aValue.mType = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVGViewBoxSMILType::Destroy(SMILValue& aValue) const {
|
void SVGViewBoxSMILType::Destroy(SMILValue& aValue) const {
|
||||||
MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
|
MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
|
||||||
delete static_cast<SVGViewBoxRect*>(aValue.mU.mPtr);
|
delete static_cast<SVGViewBox*>(aValue.mU.mPtr);
|
||||||
aValue.mU.mPtr = nullptr;
|
aValue.mU.mPtr = nullptr;
|
||||||
aValue.mType = SMILNullType::Singleton();
|
aValue.mType = SMILNullType::Singleton();
|
||||||
}
|
}
|
||||||
@@ -35,8 +35,8 @@ nsresult SVGViewBoxSMILType::Assign(SMILValue& aDest,
|
|||||||
MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
|
MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
|
||||||
MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
|
MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
|
||||||
|
|
||||||
const SVGViewBoxRect* src = static_cast<const SVGViewBoxRect*>(aSrc.mU.mPtr);
|
const SVGViewBox* src = static_cast<const SVGViewBox*>(aSrc.mU.mPtr);
|
||||||
SVGViewBoxRect* dst = static_cast<SVGViewBoxRect*>(aDest.mU.mPtr);
|
SVGViewBox* dst = static_cast<SVGViewBox*>(aDest.mU.mPtr);
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -46,9 +46,8 @@ bool SVGViewBoxSMILType::IsEqual(const SMILValue& aLeft,
|
|||||||
MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
|
MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
|
||||||
MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
|
MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
|
||||||
|
|
||||||
const SVGViewBoxRect* leftBox =
|
const SVGViewBox* leftBox = static_cast<const SVGViewBox*>(aLeft.mU.mPtr);
|
||||||
static_cast<const SVGViewBoxRect*>(aLeft.mU.mPtr);
|
const SVGViewBox* rightBox = static_cast<SVGViewBox*>(aRight.mU.mPtr);
|
||||||
const SVGViewBoxRect* rightBox = static_cast<SVGViewBoxRect*>(aRight.mU.mPtr);
|
|
||||||
return *leftBox == *rightBox;
|
return *leftBox == *rightBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,9 +69,8 @@ nsresult SVGViewBoxSMILType::ComputeDistance(const SMILValue& aFrom,
|
|||||||
MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
|
MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
|
||||||
MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
|
MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
|
||||||
|
|
||||||
const SVGViewBoxRect* from =
|
const SVGViewBox* from = static_cast<const SVGViewBox*>(aFrom.mU.mPtr);
|
||||||
static_cast<const SVGViewBoxRect*>(aFrom.mU.mPtr);
|
const SVGViewBox* to = static_cast<const SVGViewBox*>(aTo.mU.mPtr);
|
||||||
const SVGViewBoxRect* to = static_cast<const SVGViewBoxRect*>(aTo.mU.mPtr);
|
|
||||||
|
|
||||||
if (from->none || to->none) {
|
if (from->none || to->none) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
@@ -104,16 +102,14 @@ nsresult SVGViewBoxSMILType::Interpolate(const SMILValue& aStartVal,
|
|||||||
MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation");
|
MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation");
|
||||||
MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
|
MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
|
||||||
|
|
||||||
const SVGViewBoxRect* start =
|
const SVGViewBox* start = static_cast<const SVGViewBox*>(aStartVal.mU.mPtr);
|
||||||
static_cast<const SVGViewBoxRect*>(aStartVal.mU.mPtr);
|
const SVGViewBox* end = static_cast<const SVGViewBox*>(aEndVal.mU.mPtr);
|
||||||
const SVGViewBoxRect* end =
|
|
||||||
static_cast<const SVGViewBoxRect*>(aEndVal.mU.mPtr);
|
|
||||||
|
|
||||||
if (start->none || end->none) {
|
if (start->none || end->none) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGViewBoxRect* current = static_cast<SVGViewBoxRect*>(aResult.mU.mPtr);
|
SVGViewBox* current = static_cast<SVGViewBox*>(aResult.mU.mPtr);
|
||||||
|
|
||||||
float x = (start->x + (end->x - start->x) * aUnitDistance);
|
float x = (start->x + (end->x - start->x) * aUnitDistance);
|
||||||
float y = (start->y + (end->y - start->y) * aUnitDistance);
|
float y = (start->y + (end->y - start->y) * aUnitDistance);
|
||||||
@@ -121,7 +117,7 @@ nsresult SVGViewBoxSMILType::Interpolate(const SMILValue& aStartVal,
|
|||||||
float height =
|
float height =
|
||||||
(start->height + (end->height - start->height) * aUnitDistance);
|
(start->height + (end->height - start->height) * aUnitDistance);
|
||||||
|
|
||||||
*current = SVGViewBoxRect(x, y, width, height);
|
*current = SVGViewBox(x, y, width, height);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,9 +67,10 @@ SVGElement::EnumAttributesInfo SVGViewElement::GetEnumInfo() {
|
|||||||
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedViewBox* SVGViewElement::GetViewBox() { return &mViewBox; }
|
SVGAnimatedViewBox* SVGViewElement::GetAnimatedViewBox() { return &mViewBox; }
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* SVGViewElement::GetPreserveAspectRatio() {
|
SVGAnimatedPreserveAspectRatio*
|
||||||
|
SVGViewElement::GetAnimatedPreserveAspectRatio() {
|
||||||
return &mPreserveAspectRatio;
|
return &mPreserveAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,9 @@ class SVGViewElement : public SVGViewElementBase {
|
|||||||
static SVGEnumMapping sZoomAndPanMap[];
|
static SVGEnumMapping sZoomAndPanMap[];
|
||||||
static EnumInfo sEnumInfo[1];
|
static EnumInfo sEnumInfo[1];
|
||||||
|
|
||||||
virtual SVGAnimatedViewBox* GetViewBox() override;
|
virtual SVGAnimatedViewBox* GetAnimatedViewBox() override;
|
||||||
virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override;
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
|
||||||
|
override;
|
||||||
|
|
||||||
SVGAnimatedViewBox mViewBox;
|
SVGAnimatedViewBox mViewBox;
|
||||||
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
|
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
|
||||||
|
|||||||
@@ -185,8 +185,7 @@ gfx::Matrix SVGViewportElement::GetViewBoxTransform() const {
|
|||||||
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGViewBoxRect viewBox =
|
SVGViewBox viewBox = GetViewBoxWithSynthesis(viewportWidth, viewportHeight);
|
||||||
GetViewBoxWithSynthesis(viewportWidth, viewportHeight);
|
|
||||||
|
|
||||||
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
||||||
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||||
@@ -200,9 +199,9 @@ gfx::Matrix SVGViewportElement::GetViewBoxTransform() const {
|
|||||||
// SVGViewportElement
|
// SVGViewportElement
|
||||||
|
|
||||||
float SVGViewportElement::GetLength(uint8_t aCtxType) {
|
float SVGViewportElement::GetLength(uint8_t aCtxType) {
|
||||||
const SVGViewBoxRect* viewbox = GetViewBoxInternal().HasRect()
|
const SVGViewBox* viewbox = GetViewBoxInternal().HasRect()
|
||||||
? &GetViewBoxInternal().GetAnimValue()
|
? &GetViewBoxInternal().GetAnimValue()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
float h = 0.0f, w = 0.0f;
|
float h = 0.0f, w = 0.0f;
|
||||||
bool shouldComputeWidth =
|
bool shouldComputeWidth =
|
||||||
@@ -310,14 +309,17 @@ bool SVGViewportElement::HasValidDimensions() const {
|
|||||||
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0));
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGAnimatedViewBox* SVGViewportElement::GetViewBox() { return &mViewBox; }
|
SVGAnimatedViewBox* SVGViewportElement::GetAnimatedViewBox() {
|
||||||
|
return &mViewBox;
|
||||||
|
}
|
||||||
|
|
||||||
SVGAnimatedPreserveAspectRatio* SVGViewportElement::GetPreserveAspectRatio() {
|
SVGAnimatedPreserveAspectRatio*
|
||||||
|
SVGViewportElement::GetAnimatedPreserveAspectRatio() {
|
||||||
return &mPreserveAspectRatio;
|
return &mPreserveAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SVGViewportElement::ShouldSynthesizeViewBox() const {
|
bool SVGViewportElement::ShouldSynthesizeViewBox() const {
|
||||||
MOZ_ASSERT(!HasViewBoxRect(), "Should only be called if we lack a viewBox");
|
MOZ_ASSERT(!HasViewBox(), "Should only be called if we lack a viewBox");
|
||||||
|
|
||||||
return IsRoot() && OwnerDoc()->IsBeingUsedAsImage();
|
return IsRoot() && OwnerDoc()->IsBeingUsedAsImage();
|
||||||
}
|
}
|
||||||
@@ -325,7 +327,7 @@ bool SVGViewportElement::ShouldSynthesizeViewBox() const {
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// implementation helpers
|
// implementation helpers
|
||||||
|
|
||||||
SVGViewBoxRect SVGViewportElement::GetViewBoxWithSynthesis(
|
SVGViewBox SVGViewportElement::GetViewBoxWithSynthesis(
|
||||||
float aViewportWidth, float aViewportHeight) const {
|
float aViewportWidth, float aViewportHeight) const {
|
||||||
if (GetViewBoxInternal().HasRect()) {
|
if (GetViewBoxInternal().HasRect()) {
|
||||||
return GetViewBoxInternal().GetAnimValue();
|
return GetViewBoxInternal().GetAnimValue();
|
||||||
@@ -334,7 +336,7 @@ SVGViewBoxRect SVGViewportElement::GetViewBoxWithSynthesis(
|
|||||||
if (ShouldSynthesizeViewBox()) {
|
if (ShouldSynthesizeViewBox()) {
|
||||||
// Special case -- fake a viewBox, using height & width attrs.
|
// Special case -- fake a viewBox, using height & width attrs.
|
||||||
// (Use |this| as context, since if we get here, we're outermost <svg>.)
|
// (Use |this| as context, since if we get here, we're outermost <svg>.)
|
||||||
return SVGViewBoxRect(
|
return SVGViewBox(
|
||||||
0, 0,
|
0, 0,
|
||||||
ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_WIDTH],
|
ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_WIDTH],
|
||||||
mViewportWidth, this),
|
mViewportWidth, this),
|
||||||
@@ -344,7 +346,7 @@ SVGViewBoxRect SVGViewportElement::GetViewBoxWithSynthesis(
|
|||||||
|
|
||||||
// No viewBox attribute, so we shouldn't auto-scale. This is equivalent
|
// No viewBox attribute, so we shouldn't auto-scale. This is equivalent
|
||||||
// to having a viewBox that exactly matches our viewport size.
|
// to having a viewBox that exactly matches our viewport size.
|
||||||
return SVGViewBoxRect(0, 0, aViewportWidth, aViewportHeight);
|
return SVGViewBox(0, 0, aViewportWidth, aViewportHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGElement::LengthAttributesInfo SVGViewportElement::GetLengthInfo() {
|
SVGElement::LengthAttributesInfo SVGViewportElement::GetLengthInfo() {
|
||||||
|
|||||||
@@ -79,19 +79,19 @@ class SVGViewportElement : public SVGGraphicsElement {
|
|||||||
* Note also that this method does not pay attention to whether the width or
|
* Note also that this method does not pay attention to whether the width or
|
||||||
* height values of the viewBox rect are positive!
|
* height values of the viewBox rect are positive!
|
||||||
*/
|
*/
|
||||||
bool HasViewBoxRect() const { return GetViewBoxInternal().HasRect(); }
|
bool HasViewBox() const { return GetViewBoxInternal().HasRect(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we should synthesize a viewBox for ourselves (that is, if
|
* Returns true if we should synthesize a viewBox for ourselves (that is, if
|
||||||
* we're the root element in an image document, and we're not currently being
|
* we're the root element in an image document, and we're not currently being
|
||||||
* painted for an <svg:image> element).
|
* painted for an <svg:image> element).
|
||||||
*
|
*
|
||||||
* Only call this method if HasViewBoxRect() returns false.
|
* Only call this method if HasViewBox() returns false.
|
||||||
*/
|
*/
|
||||||
bool ShouldSynthesizeViewBox() const;
|
bool ShouldSynthesizeViewBox() const;
|
||||||
|
|
||||||
bool HasViewBoxOrSyntheticViewBox() const {
|
bool HasViewBoxOrSyntheticViewBox() const {
|
||||||
return HasViewBoxRect() || ShouldSynthesizeViewBox();
|
return HasViewBox() || ShouldSynthesizeViewBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasChildrenOnlyTransform() const { return mHasChildrenOnlyTransform; }
|
bool HasChildrenOnlyTransform() const { return mHasChildrenOnlyTransform; }
|
||||||
@@ -126,7 +126,7 @@ class SVGViewportElement : public SVGGraphicsElement {
|
|||||||
// WebIDL
|
// WebIDL
|
||||||
already_AddRefed<SVGAnimatedRect> ViewBox();
|
already_AddRefed<SVGAnimatedRect> ViewBox();
|
||||||
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
|
||||||
virtual SVGAnimatedViewBox* GetViewBox() override;
|
virtual SVGAnimatedViewBox* GetAnimatedViewBox() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// implementation helpers:
|
// implementation helpers:
|
||||||
@@ -162,8 +162,8 @@ class SVGViewportElement : public SVGGraphicsElement {
|
|||||||
* viewBox, if appropriate, or else a viewBox matching the dimensions of the
|
* viewBox, if appropriate, or else a viewBox matching the dimensions of the
|
||||||
* SVG viewport.
|
* SVG viewport.
|
||||||
*/
|
*/
|
||||||
SVGViewBoxRect GetViewBoxWithSynthesis(float aViewportWidth,
|
SVGViewBox GetViewBoxWithSynthesis(float aViewportWidth,
|
||||||
float aViewportHeight) const;
|
float aViewportHeight) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the value of currentScale and currentTranslate.
|
* Retrieve the value of currentScale and currentTranslate.
|
||||||
@@ -176,7 +176,8 @@ class SVGViewportElement : public SVGGraphicsElement {
|
|||||||
static LengthInfo sLengthInfo[4];
|
static LengthInfo sLengthInfo[4];
|
||||||
virtual LengthAttributesInfo GetLengthInfo() override;
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
||||||
|
|
||||||
virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override;
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
|
||||||
|
override;
|
||||||
|
|
||||||
virtual const SVGAnimatedViewBox& GetViewBoxInternal() const {
|
virtual const SVGAnimatedViewBox& GetViewBoxInternal() const {
|
||||||
return mViewBox;
|
return mViewBox;
|
||||||
|
|||||||
@@ -9589,14 +9589,15 @@ static nsRect ComputeSVGReferenceRect(nsIFrame* aFrame,
|
|||||||
SVGViewportElement* svgElement = element->GetCtx();
|
SVGViewportElement* svgElement = element->GetCtx();
|
||||||
MOZ_ASSERT(svgElement);
|
MOZ_ASSERT(svgElement);
|
||||||
|
|
||||||
if (svgElement && svgElement->HasViewBoxRect()) {
|
if (svgElement && svgElement->HasViewBox()) {
|
||||||
// If a `viewBox` attribute is specified for the SVG viewport creating
|
// If a `viewBox` attribute is specified for the SVG viewport creating
|
||||||
// element:
|
// element:
|
||||||
// 1. The reference box is positioned at the origin of the coordinate
|
// 1. The reference box is positioned at the origin of the coordinate
|
||||||
// system established by the `viewBox` attribute.
|
// system established by the `viewBox` attribute.
|
||||||
// 2. The dimension of the reference box is set to the width and height
|
// 2. The dimension of the reference box is set to the width and height
|
||||||
// values of the `viewBox` attribute.
|
// values of the `viewBox` attribute.
|
||||||
const SVGViewBoxRect& value = svgElement->GetViewBox()->GetAnimValue();
|
const SVGViewBox& value =
|
||||||
|
svgElement->GetAnimatedViewBox()->GetAnimValue();
|
||||||
r = nsRect(nsPresContext::CSSPixelsToAppUnits(value.x),
|
r = nsRect(nsPresContext::CSSPixelsToAppUnits(value.x),
|
||||||
nsPresContext::CSSPixelsToAppUnits(value.y),
|
nsPresContext::CSSPixelsToAppUnits(value.y),
|
||||||
nsPresContext::CSSPixelsToAppUnits(value.width),
|
nsPresContext::CSSPixelsToAppUnits(value.width),
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void nsSVGMarkerFrame::PaintMark(gfxContext& aContext,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SVGViewBoxRect viewBox = marker->GetViewBoxRect();
|
const SVGViewBox viewBox = marker->GetViewBox();
|
||||||
|
|
||||||
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
||||||
// We must disable rendering if the viewBox width or height are zero.
|
// We must disable rendering if the viewBox width or height are zero.
|
||||||
@@ -154,7 +154,7 @@ SVGBBox nsSVGMarkerFrame::GetMarkBBoxContribution(
|
|||||||
return bbox;
|
return bbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SVGViewBoxRect viewBox = content->GetViewBoxRect();
|
const SVGViewBox viewBox = content->GetViewBox();
|
||||||
|
|
||||||
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
||||||
return bbox;
|
return bbox;
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ nsSize nsSVGOuterSVGFrame::GetIntrinsicRatio() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SVGViewElement* viewElement = content->GetCurrentViewElement();
|
SVGViewElement* viewElement = content->GetCurrentViewElement();
|
||||||
const SVGViewBoxRect* viewbox = nullptr;
|
const SVGViewBox* viewbox = nullptr;
|
||||||
|
|
||||||
// The logic here should match HasViewBox().
|
// The logic here should match HasViewBox().
|
||||||
if (viewElement && viewElement->mViewBox.HasRect()) {
|
if (viewElement && viewElement->mViewBox.HasRect()) {
|
||||||
@@ -781,7 +781,7 @@ void nsSVGOuterSVGFrame::NotifyViewportOrTransformChanged(uint32_t aFlags) {
|
|||||||
SVGSVGElement* content = static_cast<SVGSVGElement*>(GetContent());
|
SVGSVGElement* content = static_cast<SVGSVGElement*>(GetContent());
|
||||||
|
|
||||||
if (aFlags & COORD_CONTEXT_CHANGED) {
|
if (aFlags & COORD_CONTEXT_CHANGED) {
|
||||||
if (content->HasViewBoxRect()) {
|
if (content->HasViewBox()) {
|
||||||
// Percentage lengths on children resolve against the viewBox rect so we
|
// Percentage lengths on children resolve against the viewBox rect so we
|
||||||
// don't need to notify them of the viewport change, but the viewBox
|
// don't need to notify them of the viewport change, but the viewBox
|
||||||
// transform will have changed, so we need to notify them of that instead.
|
// transform will have changed, so we need to notify them of that instead.
|
||||||
|
|||||||
@@ -636,9 +636,9 @@ gfxMatrix nsSVGPatternFrame::ConstructCTM(const SVGAnimatedViewBox &aViewBox,
|
|||||||
if (!aViewBox.IsExplicitlySet()) {
|
if (!aViewBox.IsExplicitlySet()) {
|
||||||
return gfxMatrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0);
|
return gfxMatrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
const SVGViewBoxRect viewBoxRect = aViewBox.GetAnimValue();
|
const SVGViewBox viewBox = aViewBox.GetAnimValue();
|
||||||
|
|
||||||
if (viewBoxRect.height <= 0.0f || viewBoxRect.width <= 0.0f) {
|
if (viewBox.height <= 0.0f || viewBox.width <= 0.0f) {
|
||||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,9 +664,8 @@ gfxMatrix nsSVGPatternFrame::ConstructCTM(const SVGAnimatedViewBox &aViewBox,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Matrix tm = SVGContentUtils::GetViewBoxTransform(
|
Matrix tm = SVGContentUtils::GetViewBoxTransform(
|
||||||
viewportWidth * scaleX, viewportHeight * scaleY, viewBoxRect.x,
|
viewportWidth * scaleX, viewportHeight * scaleY, viewBox.x, viewBox.y,
|
||||||
viewBoxRect.y, viewBoxRect.width, viewBoxRect.height,
|
viewBox.width, viewBox.height, GetPreserveAspectRatio());
|
||||||
GetPreserveAspectRatio());
|
|
||||||
|
|
||||||
return ThebesMatrix(tm);
|
return ThebesMatrix(tm);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,11 +102,11 @@ void nsSVGViewportFrame::NotifySVGChanged(uint32_t aFlags) {
|
|||||||
|
|
||||||
if (!(aFlags & TRANSFORM_CHANGED) &&
|
if (!(aFlags & TRANSFORM_CHANGED) &&
|
||||||
(xOrYIsPercentage ||
|
(xOrYIsPercentage ||
|
||||||
(widthOrHeightIsPercentage && svg->HasViewBoxRect()))) {
|
(widthOrHeightIsPercentage && svg->HasViewBox()))) {
|
||||||
aFlags |= TRANSFORM_CHANGED;
|
aFlags |= TRANSFORM_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (svg->HasViewBoxRect() || !widthOrHeightIsPercentage) {
|
if (svg->HasViewBox() || !widthOrHeightIsPercentage) {
|
||||||
// Remove COORD_CONTEXT_CHANGED, since we establish the coordinate
|
// Remove COORD_CONTEXT_CHANGED, since we establish the coordinate
|
||||||
// context for our descendants and this notification won't change its
|
// context for our descendants and this notification won't change its
|
||||||
// dimensions:
|
// dimensions:
|
||||||
|
|||||||
Reference in New Issue
Block a user