From 3afbe4d69990dac6a1dc6e8f00cccb23eb677c8b Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 2 Feb 2018 08:21:33 -0500 Subject: [PATCH] Bug 1435138 part 3. Remove nsIDOMSVGLength's SVG_LENGTHTYPE_* constants. r=qdot MozReview-Commit-ID: GvzWbe6cr5r --- dom/interfaces/svg/nsIDOMSVGLength.idl | 12 ------- dom/svg/DOMSVGLength.cpp | 18 ++++++----- dom/svg/SVGAnimatedLengthList.cpp | 9 ++++-- dom/svg/SVGCircleElement.cpp | 7 ++-- dom/svg/SVGEllipseElement.cpp | 9 +++--- dom/svg/SVGFilterElement.cpp | 9 +++--- dom/svg/SVGForeignObjectElement.cpp | 9 +++--- dom/svg/SVGGeometryElement.cpp | 5 ++- dom/svg/SVGGradientElement.cpp | 21 ++++++------ dom/svg/SVGImageElement.cpp | 9 +++--- dom/svg/SVGLength.cpp | 44 ++++++++++++++------------ dom/svg/SVGLength.h | 9 +++--- dom/svg/SVGLengthList.h | 3 +- dom/svg/SVGLineElement.cpp | 9 +++--- dom/svg/SVGMarkerElement.cpp | 9 +++--- dom/svg/SVGMaskElement.cpp | 9 +++--- dom/svg/SVGPatternElement.cpp | 9 +++--- dom/svg/SVGRectElement.cpp | 13 ++++---- dom/svg/SVGTextContentElement.cpp | 3 +- dom/svg/SVGTextPathElement.cpp | 5 +-- dom/svg/SVGUseElement.cpp | 11 ++++--- dom/svg/SVGViewportElement.cpp | 9 +++--- dom/svg/nsSVGElement.cpp | 9 +++--- dom/svg/nsSVGFilters.cpp | 9 +++--- dom/svg/nsSVGLength2.cpp | 34 ++++++++++---------- dom/svg/nsSVGLength2.h | 7 ++-- layout/svg/nsSVGFilterInstance.cpp | 11 ++++--- 27 files changed, 166 insertions(+), 145 deletions(-) diff --git a/dom/interfaces/svg/nsIDOMSVGLength.idl b/dom/interfaces/svg/nsIDOMSVGLength.idl index 0c81464f2bd0..2f4003c98ab0 100644 --- a/dom/interfaces/svg/nsIDOMSVGLength.idl +++ b/dom/interfaces/svg/nsIDOMSVGLength.idl @@ -8,18 +8,6 @@ [uuid(2596325c-aed0-487e-96a1-0a6d589b9c6b)] interface nsIDOMSVGLength : nsISupports { - // Length Unit Types - const unsigned short SVG_LENGTHTYPE_UNKNOWN = 0; - const unsigned short SVG_LENGTHTYPE_NUMBER = 1; - const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2; - const unsigned short SVG_LENGTHTYPE_EMS = 3; - const unsigned short SVG_LENGTHTYPE_EXS = 4; - const unsigned short SVG_LENGTHTYPE_PX = 5; - const unsigned short SVG_LENGTHTYPE_CM = 6; - const unsigned short SVG_LENGTHTYPE_MM = 7; - const unsigned short SVG_LENGTHTYPE_IN = 8; - const unsigned short SVG_LENGTHTYPE_PT = 9; - const unsigned short SVG_LENGTHTYPE_PC = 10; }; diff --git a/dom/svg/DOMSVGLength.cpp b/dom/svg/DOMSVGLength.cpp index 5d15b2817cd5..36405cf4bd57 100644 --- a/dom/svg/DOMSVGLength.cpp +++ b/dom/svg/DOMSVGLength.cpp @@ -22,6 +22,8 @@ namespace mozilla { +using namespace dom; + static nsSVGAttrTearoffTable sBaseSVGLengthTearOffTable, sAnimSVGLengthTearOffTable; @@ -100,7 +102,7 @@ DOMSVGLength::DOMSVGLength(DOMSVGLengthList *aList, , mListIndex(aListIndex) , mAttrEnum(aAttrEnum) , mIsAnimValItem(aIsAnimValItem) - , mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER) + , mUnit(SVGLengthBinding::SVG_LENGTHTYPE_NUMBER) , mValue(0.0f) , mVal(nullptr) { @@ -118,7 +120,7 @@ DOMSVGLength::DOMSVGLength() , mListIndex(0) , mAttrEnum(0) , mIsAnimValItem(false) - , mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER) + , mUnit(SVGLengthBinding::SVG_LENGTHTYPE_NUMBER) , mValue(0.0f) , mVal(nullptr) { @@ -130,7 +132,7 @@ DOMSVGLength::DOMSVGLength(nsSVGLength2* aVal, nsSVGElement* aSVGElement, , mListIndex(0) , mAttrEnum(0) , mIsAnimValItem(aAnimVal) - , mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER) + , mUnit(SVGLengthBinding::SVG_LENGTHTYPE_NUMBER) , mValue(0.0f) , mVal(aVal) , mSVGElement(aSVGElement) @@ -232,8 +234,8 @@ DOMSVGLength::GetValue(ErrorResult& aRv) aRv.Throw(NS_ERROR_FAILURE); } return value; - } else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER || - mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) { + } else if (mUnit == SVGLengthBinding::SVG_LENGTHTYPE_NUMBER || + mUnit == SVGLengthBinding::SVG_LENGTHTYPE_PX) { return mValue; } // else [SVGWG issue] Can't convert this length's value to user units @@ -274,8 +276,8 @@ DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv) return; } } - } else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER || - mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) { + } else if (mUnit == SVGLengthBinding::SVG_LENGTHTYPE_NUMBER || + mUnit == SVGLengthBinding::SVG_LENGTHTYPE_PX) { mValue = aUserUnitValue; return; } @@ -454,7 +456,7 @@ DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv) JSObject* DOMSVGLength::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { - return dom::SVGLengthBinding::Wrap(aCx, this, aGivenProto); + return SVGLengthBinding::Wrap(aCx, this, aGivenProto); } void diff --git a/dom/svg/SVGAnimatedLengthList.cpp b/dom/svg/SVGAnimatedLengthList.cpp index 6b1b2b00975e..f79266b62c62 100644 --- a/dom/svg/SVGAnimatedLengthList.cpp +++ b/dom/svg/SVGAnimatedLengthList.cpp @@ -12,9 +12,12 @@ #include "nsSVGAttrTearoffTable.h" #include "nsSMILValue.h" #include "SVGLengthListSMILType.h" +#include "mozilla/dom/SVGLengthBinding.h" namespace mozilla { +using namespace dom; + nsresult SVGAnimatedLengthList::SetBaseValueString(const nsAString& aValue) { @@ -160,9 +163,9 @@ SVGAnimatedLengthList:: aPreventCachingOfSandwich = false; for (uint32_t i = 0; i < llai->Length(); ++i) { uint8_t unit = (*llai)[i].GetUnit(); - if (unit == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE || - unit == nsIDOMSVGLength::SVG_LENGTHTYPE_EMS || - unit == nsIDOMSVGLength::SVG_LENGTHTYPE_EXS) { + if (unit == SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE || + unit == SVGLengthBinding::SVG_LENGTHTYPE_EMS || + unit == SVGLengthBinding::SVG_LENGTHTYPE_EXS) { aPreventCachingOfSandwich = true; break; } diff --git a/dom/svg/SVGCircleElement.cpp b/dom/svg/SVGCircleElement.cpp index 5d74e0f254fb..5a456ed245d0 100644 --- a/dom/svg/SVGCircleElement.cpp +++ b/dom/svg/SVGCircleElement.cpp @@ -8,6 +8,7 @@ #include "mozilla/gfx/2D.h" #include "nsGkAtoms.h" #include "mozilla/dom/SVGCircleElementBinding.h" +#include "mozilla/dom/SVGLengthBinding.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Circle) @@ -24,9 +25,9 @@ SVGCircleElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGCircleElement::sLengthInfo[3] = { - { &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::r, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY } + { &nsGkAtoms::cx, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::cy, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::r, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY } }; //---------------------------------------------------------------------- diff --git a/dom/svg/SVGEllipseElement.cpp b/dom/svg/SVGEllipseElement.cpp index 1f2bf5c42cf4..9c3bd39b79cd 100644 --- a/dom/svg/SVGEllipseElement.cpp +++ b/dom/svg/SVGEllipseElement.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/SVGEllipseElement.h" #include "mozilla/dom/SVGEllipseElementBinding.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/PathHelpers.h" #include "mozilla/RefPtr.h" @@ -25,10 +26,10 @@ SVGEllipseElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGEllipseElement::sLengthInfo[4] = { - { &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::cx, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::cy, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::rx, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::ry, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, }; //---------------------------------------------------------------------- diff --git a/dom/svg/SVGFilterElement.cpp b/dom/svg/SVGFilterElement.cpp index a9192bd6341a..0eef637049ef 100644 --- a/dom/svg/SVGFilterElement.cpp +++ b/dom/svg/SVGFilterElement.cpp @@ -10,6 +10,7 @@ #include "nsCOMPtr.h" #include "mozilla/dom/SVGFilterElement.h" #include "mozilla/dom/SVGFilterElementBinding.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "nsSVGUtils.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Filter) @@ -25,10 +26,10 @@ SVGFilterElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGFilterElement::sLengthInfo[4] = { - { &nsGkAtoms::x, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::y, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, - { &nsGkAtoms::width, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::height, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::x, -10, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::y, -10, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::width, 120, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::height, 120, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, }; nsSVGElement::EnumInfo SVGFilterElement::sEnumInfo[2] = diff --git a/dom/svg/SVGForeignObjectElement.cpp b/dom/svg/SVGForeignObjectElement.cpp index dd878463ddb1..7fcc536c0257 100644 --- a/dom/svg/SVGForeignObjectElement.cpp +++ b/dom/svg/SVGForeignObjectElement.cpp @@ -10,6 +10,7 @@ #include "mozilla/dom/SVGDocument.h" #include "mozilla/dom/SVGForeignObjectElement.h" #include "mozilla/dom/SVGForeignObjectElementBinding.h" +#include "mozilla/dom/SVGLengthBinding.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(ForeignObject) @@ -24,10 +25,10 @@ SVGForeignObjectElement::WrapNode(JSContext *aCx, JS::Handle aGivenPr nsSVGElement::LengthInfo SVGForeignObjectElement::sLengthInfo[4] = { - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::x, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::y, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::width, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::height, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, }; //---------------------------------------------------------------------- diff --git a/dom/svg/SVGGeometryElement.cpp b/dom/svg/SVGGeometryElement.cpp index 78e7187c9f8b..e3b0a30f253f 100644 --- a/dom/svg/SVGGeometryElement.cpp +++ b/dom/svg/SVGGeometryElement.cpp @@ -9,6 +9,7 @@ #include "DOMSVGPoint.h" #include "gfxPlatform.h" #include "mozilla/gfx/2D.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "nsComputedDOMStyle.h" #include "nsSVGUtils.h" #include "nsSVGLength2.h" @@ -16,6 +17,7 @@ using namespace mozilla; using namespace mozilla::gfx; +using namespace mozilla::dom; nsSVGElement::NumberInfo SVGGeometryElement::sNumberInfo = { &nsGkAtoms::pathLength, 0, false }; @@ -76,7 +78,8 @@ SVGGeometryElement::GeometryDependsOnCoordCtx() // Check the nsSVGLength2 attribute LengthAttributesInfo info = const_cast(this)->GetLengthInfo(); for (uint32_t i = 0; i < info.mLengthCount; i++) { - if (info.mLengths[i].GetSpecifiedUnitType() == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE) { + if (info.mLengths[i].GetSpecifiedUnitType() == + SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE) { return true; } } diff --git a/dom/svg/SVGGradientElement.cpp b/dom/svg/SVGGradientElement.cpp index a8bbcc2dba21..7757ec3549cc 100644 --- a/dom/svg/SVGGradientElement.cpp +++ b/dom/svg/SVGGradientElement.cpp @@ -9,6 +9,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/dom/SVGAnimatedTransformList.h" #include "mozilla/dom/SVGRadialGradientElementBinding.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGLinearGradientElementBinding.h" #include "nsCOMPtr.h" #include "nsGkAtoms.h" @@ -126,10 +127,10 @@ SVGLinearGradientElement::WrapNode(JSContext* aCx, JS::Handle aGivenP nsSVGElement::LengthInfo SVGLinearGradientElement::sLengthInfo[4] = { - { &nsGkAtoms::x1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::y1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, - { &nsGkAtoms::x2, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::y2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::x1, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::y1, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::x2, 100, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::y2, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, }; //---------------------------------------------------------------------- @@ -200,12 +201,12 @@ SVGRadialGradientElement::WrapNode(JSContext* aCx, JS::Handle aGivenP nsSVGElement::LengthInfo SVGRadialGradientElement::sLengthInfo[6] = { - { &nsGkAtoms::cx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::cy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, - { &nsGkAtoms::r, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY }, - { &nsGkAtoms::fx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::fy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, - { &nsGkAtoms::fr, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY }, + { &nsGkAtoms::cx, 50, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::cy, 50, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::r, 50, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY }, + { &nsGkAtoms::fx, 50, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::fy, 50, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::fr, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY }, }; //---------------------------------------------------------------------- diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp index cbc9402d3a1f..8e2530965043 100644 --- a/dom/svg/SVGImageElement.cpp +++ b/dom/svg/SVGImageElement.cpp @@ -15,6 +15,7 @@ #include "nsNetUtil.h" #include "imgINotificationObserver.h" #include "mozilla/dom/SVGImageElementBinding.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "nsContentUtils.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Image) @@ -32,10 +33,10 @@ SVGImageElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGImageElement::sLengthInfo[4] = { - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::x, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::y, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::width, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::height, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, }; nsSVGElement::StringInfo SVGImageElement::sStringInfo[2] = diff --git a/dom/svg/SVGLength.cpp b/dom/svg/SVGLength.cpp index 5212cfdf528b..0891e842fa72 100644 --- a/dom/svg/SVGLength.cpp +++ b/dom/svg/SVGLength.cpp @@ -16,6 +16,8 @@ namespace mozilla { +using namespace mozilla; + // Declare some helpers defined below: static void GetUnitString(nsAString& unit, uint16_t unitType); static uint16_t GetUnitTypeForString(const nsAString& unitStr); @@ -57,8 +59,8 @@ SVGLength::SetValueFromString(const nsAString &aString) inline static bool IsAbsoluteUnit(uint8_t aUnit) { - return aUnit >= nsIDOMSVGLength::SVG_LENGTHTYPE_CM && - aUnit <= nsIDOMSVGLength::SVG_LENGTHTYPE_PC; + return aUnit >= SVGLengthBinding::SVG_LENGTHTYPE_CM && + aUnit <= SVGLengthBinding::SVG_LENGTHTYPE_PC; } /** @@ -69,8 +71,8 @@ IsAbsoluteUnit(uint8_t aUnit) * * Example usage: to find out how many centimeters there are per inch: * - * GetAbsUnitsPerAbsUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_CM, - * nsIDOMSVGLength::SVG_LENGTHTYPE_IN) + * GetAbsUnitsPerAbsUnit(SVGLengthBinding::SVG_LENGTHTYPE_CM, + * SVGLengthBinding::SVG_LENGTHTYPE_IN) */ inline static float GetAbsUnitsPerAbsUnit(uint8_t aUnits, uint8_t aPerUnit) { @@ -102,10 +104,10 @@ SVGLength::GetValueInSpecifiedUnit(uint8_t aUnit, if (aUnit == mUnit) { return mValue; } - if ((aUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER && - mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) || - (aUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX && - mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)) { + if ((aUnit == SVGLengthBinding::SVG_LENGTHTYPE_NUMBER && + mUnit == SVGLengthBinding::SVG_LENGTHTYPE_PX) || + (aUnit == SVGLengthBinding::SVG_LENGTHTYPE_PX && + mUnit == SVGLengthBinding::SVG_LENGTHTYPE_NUMBER)) { return mValue; } if (IsAbsoluteUnit(aUnit) && IsAbsoluteUnit(mUnit)) { @@ -144,24 +146,24 @@ float SVGLength::GetUserUnitsPerUnit(const nsSVGElement *aElement, uint8_t aAxis) const { switch (mUnit) { - case nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER: - case nsIDOMSVGLength::SVG_LENGTHTYPE_PX: + case SVGLengthBinding::SVG_LENGTHTYPE_NUMBER: + case SVGLengthBinding::SVG_LENGTHTYPE_PX: return 1.0f; - case nsIDOMSVGLength::SVG_LENGTHTYPE_MM: + case SVGLengthBinding::SVG_LENGTHTYPE_MM: return INCHES_PER_MM_FLOAT * GetUserUnitsPerInch(); - case nsIDOMSVGLength::SVG_LENGTHTYPE_CM: + case SVGLengthBinding::SVG_LENGTHTYPE_CM: return INCHES_PER_CM_FLOAT * GetUserUnitsPerInch(); - case nsIDOMSVGLength::SVG_LENGTHTYPE_IN: + case SVGLengthBinding::SVG_LENGTHTYPE_IN: return GetUserUnitsPerInch(); - case nsIDOMSVGLength::SVG_LENGTHTYPE_PT: + case SVGLengthBinding::SVG_LENGTHTYPE_PT: return (1.0f/POINTS_PER_INCH_FLOAT) * GetUserUnitsPerInch(); - case nsIDOMSVGLength::SVG_LENGTHTYPE_PC: + case SVGLengthBinding::SVG_LENGTHTYPE_PC: return (12.0f/POINTS_PER_INCH_FLOAT) * GetUserUnitsPerInch(); - case nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE: + case SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE: return GetUserUnitsPerPercent(aElement, aAxis); - case nsIDOMSVGLength::SVG_LENGTHTYPE_EMS: + case SVGLengthBinding::SVG_LENGTHTYPE_EMS: return SVGContentUtils::GetFontSize(const_cast(aElement)); - case nsIDOMSVGLength::SVG_LENGTHTYPE_EXS: + case SVGLengthBinding::SVG_LENGTHTYPE_EXS: return SVGContentUtils::GetFontXHeight(const_cast(aElement)); default: NS_NOTREACHED("Unknown unit type"); @@ -183,7 +185,7 @@ SVGLength::GetUserUnitsPerPercent(const nsSVGElement *aElement, uint8_t aAxis) // Helpers: -// These items must be at the same index as the nsIDOMSVGLength constants! +// These items must be at the same index as the SVGLength constants! static nsStaticAtom** const unitMap[] = { nullptr, /* SVG_LENGTHTYPE_UNKNOWN */ @@ -215,7 +217,7 @@ static uint16_t GetUnitTypeForString(const nsAString& unitStr) { if (unitStr.IsEmpty()) - return nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER; + return SVGLengthBinding::SVG_LENGTHTYPE_NUMBER; nsAtom* unitAtom = NS_GetStaticAtom(unitStr); @@ -226,7 +228,7 @@ GetUnitTypeForString(const nsAString& unitStr) } } } - return nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN; + return SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN; } } // namespace mozilla diff --git a/dom/svg/SVGLength.h b/dom/svg/SVGLength.h index 5cfcf9472b2e..154a26b51d03 100644 --- a/dom/svg/SVGLength.h +++ b/dom/svg/SVGLength.h @@ -11,6 +11,7 @@ #include "nsIDOMSVGLength.h" #include "nsMathUtils.h" #include "mozilla/FloatingPoint.h" +#include "mozilla/dom/SVGLengthBinding.h" class nsSVGElement; @@ -35,7 +36,7 @@ public: SVGLength() #ifdef DEBUG : mValue(0.0f) - , mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN) // caught by IsValid() + , mUnit(dom::SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN) // caught by IsValid() #endif {} @@ -120,12 +121,12 @@ public: uint8_t aAxis) const; bool IsPercentage() const { - return mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE; + return mUnit == dom::SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE; } static bool IsValidUnitType(uint16_t unit) { - return unit > nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN && - unit <= nsIDOMSVGLength::SVG_LENGTHTYPE_PC; + return unit > dom::SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN && + unit <= dom::SVGLengthBinding::SVG_LENGTHTYPE_PC; } /** diff --git a/dom/svg/SVGLengthList.h b/dom/svg/SVGLengthList.h index 7ca07d1da358..8beeb3343adb 100644 --- a/dom/svg/SVGLengthList.h +++ b/dom/svg/SVGLengthList.h @@ -15,6 +15,7 @@ #include "nsSVGElement.h" #include "nsTArray.h" #include "SVGLength.h" +#include "mozilla/dom/SVGLengthBinding.h" namespace mozilla { @@ -337,7 +338,7 @@ public: bool HasPercentageValueAt(uint32_t aIndex) const { const SVGLength& length = (*mList)[aIndex]; - return length.GetUnit() == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE; + return length.GetUnit() == dom::SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE; } private: diff --git a/dom/svg/SVGLineElement.cpp b/dom/svg/SVGLineElement.cpp index 561d4fce6ac7..8201ecfa65cc 100644 --- a/dom/svg/SVGLineElement.cpp +++ b/dom/svg/SVGLineElement.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/SVGLineElement.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGLineElementBinding.h" #include "mozilla/gfx/2D.h" @@ -23,10 +24,10 @@ SVGLineElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGLineElement::sLengthInfo[4] = { - { &nsGkAtoms::x1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::y1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::x2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::y2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::x1, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::y1, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::x2, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::y2, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, }; //---------------------------------------------------------------------- diff --git a/dom/svg/SVGMarkerElement.cpp b/dom/svg/SVGMarkerElement.cpp index ead1344a2268..369ec0698289 100644 --- a/dom/svg/SVGMarkerElement.cpp +++ b/dom/svg/SVGMarkerElement.cpp @@ -11,6 +11,7 @@ #include "SVGAnimatedPreserveAspectRatio.h" #include "nsError.h" #include "mozilla/dom/SVGAngle.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGMarkerElement.h" #include "mozilla/dom/SVGMarkerElementBinding.h" #include "mozilla/Preferences.h" @@ -33,10 +34,10 @@ SVGMarkerElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGMarkerElement::sLengthInfo[4] = { - { &nsGkAtoms::refX, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::refY, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::markerWidth, 3, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::markerHeight, 3, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::refX, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::refY, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::markerWidth, 3, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::markerHeight, 3, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, }; nsSVGEnumMapping SVGMarkerElement::sUnitsMap[] = { diff --git a/dom/svg/SVGMaskElement.cpp b/dom/svg/SVGMaskElement.cpp index 58a9c8215667..364fb17a0a36 100644 --- a/dom/svg/SVGMaskElement.cpp +++ b/dom/svg/SVGMaskElement.cpp @@ -8,6 +8,7 @@ #include "nsCOMPtr.h" #include "nsGkAtoms.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGMaskElement.h" #include "mozilla/dom/SVGMaskElementBinding.h" @@ -26,10 +27,10 @@ SVGMaskElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGMaskElement::sLengthInfo[4] = { - { &nsGkAtoms::x, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::y, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, - { &nsGkAtoms::width, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::height, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::x, -10, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::y, -10, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::width, 120, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::height, 120, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, }; nsSVGElement::EnumInfo SVGMaskElement::sEnumInfo[2] = diff --git a/dom/svg/SVGPatternElement.cpp b/dom/svg/SVGPatternElement.cpp index 85988cbed609..9c06460992d4 100644 --- a/dom/svg/SVGPatternElement.cpp +++ b/dom/svg/SVGPatternElement.cpp @@ -9,6 +9,7 @@ #include "nsCOMPtr.h" #include "nsGkAtoms.h" #include "mozilla/dom/SVGAnimatedTransformList.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGPatternElement.h" #include "mozilla/dom/SVGPatternElementBinding.h" @@ -27,10 +28,10 @@ SVGPatternElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGPatternElement::sLengthInfo[4] = { - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, - { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::x, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::y, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::width, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::height, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, }; nsSVGElement::EnumInfo SVGPatternElement::sEnumInfo[2] = diff --git a/dom/svg/SVGRectElement.cpp b/dom/svg/SVGRectElement.cpp index a33e00dcb251..89fc34c1a2eb 100644 --- a/dom/svg/SVGRectElement.cpp +++ b/dom/svg/SVGRectElement.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/SVGRectElement.h" #include "nsGkAtoms.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGRectElementBinding.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/Matrix.h" @@ -30,12 +31,12 @@ SVGRectElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGRectElement::sLengthInfo[6] = { - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y } + { &nsGkAtoms::x, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::y, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::width, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::height, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::rx, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::ry, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y } }; //---------------------------------------------------------------------- diff --git a/dom/svg/SVGTextContentElement.cpp b/dom/svg/SVGTextContentElement.cpp index ac0d639dd979..d0f2919ab424 100644 --- a/dom/svg/SVGTextContentElement.cpp +++ b/dom/svg/SVGTextContentElement.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/SVGTextContentElement.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGIRect.h" #include "nsBidiUtils.h" #include "nsISVGPoint.h" @@ -30,7 +31,7 @@ nsSVGElement::EnumInfo SVGTextContentElement::sEnumInfo[1] = nsSVGElement::LengthInfo SVGTextContentElement::sLengthInfo[1] = { - { &nsGkAtoms::textLength, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY } + { &nsGkAtoms::textLength, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY } }; SVGTextFrame* diff --git a/dom/svg/SVGTextPathElement.cpp b/dom/svg/SVGTextPathElement.cpp index a45c09056bc0..fa0cdfc13f73 100644 --- a/dom/svg/SVGTextPathElement.cpp +++ b/dom/svg/SVGTextPathElement.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/SVGTextPathElement.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGTextPathElementBinding.h" #include "nsSVGElement.h" #include "nsGkAtoms.h" @@ -26,9 +27,9 @@ SVGTextPathElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGTextPathElement::sLengthInfo[2] = { // from SVGTextContentElement: - { &nsGkAtoms::textLength, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }, + { &nsGkAtoms::textLength, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }, // from SVGTextPathElement: - { &nsGkAtoms::startOffset, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X } + { &nsGkAtoms::startOffset, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X } }; nsSVGEnumMapping SVGTextPathElement::sMethodMap[] = { diff --git a/dom/svg/SVGUseElement.cpp b/dom/svg/SVGUseElement.cpp index 343b580b4c12..ed6aad7ce33e 100644 --- a/dom/svg/SVGUseElement.cpp +++ b/dom/svg/SVGUseElement.cpp @@ -8,6 +8,7 @@ #include "mozilla/ErrorResult.h" #include "mozilla/dom/SVGUseElement.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGUseElementBinding.h" #include "nsGkAtoms.h" #include "mozilla/dom/SVGSVGElement.h" @@ -36,10 +37,10 @@ SVGUseElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) nsSVGElement::LengthInfo SVGUseElement::sLengthInfo[4] = { - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::x, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::y, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::width, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::height, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, }; nsSVGElement::StringInfo SVGUseElement::sStringInfo[2] = @@ -350,7 +351,7 @@ SVGUseElement::SyncWidthOrHeight(nsAtom* aName) // need to set the value to 100% nsSVGLength2 length; length.Init(SVGContentUtils::XY, 0xff, - 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE); + 100, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE); target->SetLength(aName, length); return; } diff --git a/dom/svg/SVGViewportElement.cpp b/dom/svg/SVGViewportElement.cpp index 7c74a358e7dc..7292f3ac6646 100644 --- a/dom/svg/SVGViewportElement.cpp +++ b/dom/svg/SVGViewportElement.cpp @@ -9,6 +9,7 @@ #include "mozilla/ContentEvents.h" #include "mozilla/EventDispatcher.h" #include "mozilla/Likely.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGMatrix.h" #include "mozilla/dom/SVGViewportElement.h" #include "mozilla/dom/SVGViewElement.h" @@ -39,10 +40,10 @@ namespace dom { nsSVGElement::LengthInfo SVGViewportElement::sLengthInfo[4] = { - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, - { &nsGkAtoms::width, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::x, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X }, + { &nsGkAtoms::y, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, + { &nsGkAtoms::width, 100, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::height, 100, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, }; //---------------------------------------------------------------------- diff --git a/dom/svg/nsSVGElement.cpp b/dom/svg/nsSVGElement.cpp index 575407c812f7..db83a4ce307e 100644 --- a/dom/svg/nsSVGElement.cpp +++ b/dom/svg/nsSVGElement.cpp @@ -10,6 +10,7 @@ #include "nsSVGElement.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGSVGElement.h" #include "mozilla/dom/SVGTests.h" #include "nsContentUtils.h" @@ -1692,12 +1693,12 @@ nsSVGElement::GetAnimatedLengthValues(float *aFirst, ...) while (f && i < info.mLengthCount) { uint8_t type = info.mLengths[i].GetSpecifiedUnitType(); if (!ctx) { - if (type != nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER && - type != nsIDOMSVGLength::SVG_LENGTHTYPE_PX) + if (type != SVGLengthBinding::SVG_LENGTHTYPE_NUMBER && + type != SVGLengthBinding::SVG_LENGTHTYPE_PX) ctx = GetCtx(); } - if (type == nsIDOMSVGLength::SVG_LENGTHTYPE_EMS || - type == nsIDOMSVGLength::SVG_LENGTHTYPE_EXS) + if (type == SVGLengthBinding::SVG_LENGTHTYPE_EMS || + type == SVGLengthBinding::SVG_LENGTHTYPE_EXS) *f = info.mLengths[i++].GetAnimValue(this); else *f = info.mLengths[i++].GetAnimValue(ctx); diff --git a/dom/svg/nsSVGFilters.cpp b/dom/svg/nsSVGFilters.cpp index a2aa27a1b1cf..58ec57255154 100644 --- a/dom/svg/nsSVGFilters.cpp +++ b/dom/svg/nsSVGFilters.cpp @@ -38,6 +38,7 @@ #include "mozilla/dom/SVGFEFuncRElementBinding.h" #include "mozilla/dom/SVGFEPointLightElement.h" #include "mozilla/dom/SVGFESpotLightElement.h" +#include "mozilla/dom/SVGLengthBinding.h" #if defined(XP_WIN) // Prevent Windows redefining LoadImage @@ -52,10 +53,10 @@ using namespace mozilla::gfx; nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] = { - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, - { &nsGkAtoms::width, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, - { &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y } + { &nsGkAtoms::x, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::y, 0, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, + { &nsGkAtoms::width, 100, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, + { &nsGkAtoms::height, 100, SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y } }; //---------------------------------------------------------------------- diff --git a/dom/svg/nsSVGLength2.cpp b/dom/svg/nsSVGLength2.cpp index 1a484c99e10b..f4b22bd7bf36 100644 --- a/dom/svg/nsSVGLength2.cpp +++ b/dom/svg/nsSVGLength2.cpp @@ -45,8 +45,8 @@ static nsSVGAttrTearoffTable static bool IsValidUnitType(uint16_t unit) { - if (unit > nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN && - unit <= nsIDOMSVGLength::SVG_LENGTHTYPE_PC) + if (unit > SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN && + unit <= SVGLengthBinding::SVG_LENGTHTYPE_PC) return true; return false; @@ -69,7 +69,7 @@ static uint16_t GetUnitTypeForString(const nsAString& unitStr) { if (unitStr.IsEmpty()) - return nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER; + return SVGLengthBinding::SVG_LENGTHTYPE_NUMBER; nsAtom *unitAtom = NS_GetStaticAtom(unitStr); if (unitAtom) { @@ -80,7 +80,7 @@ GetUnitTypeForString(const nsAString& unitStr) } } - return nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN; + return SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN; } static void @@ -243,24 +243,24 @@ nsSVGLength2::GetPixelsPerUnit(const UserSpaceMetrics& aMetrics, uint8_t aUnitType) const { switch (aUnitType) { - case nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER: - case nsIDOMSVGLength::SVG_LENGTHTYPE_PX: + case SVGLengthBinding::SVG_LENGTHTYPE_NUMBER: + case SVGLengthBinding::SVG_LENGTHTYPE_PX: return 1; - case nsIDOMSVGLength::SVG_LENGTHTYPE_MM: + case SVGLengthBinding::SVG_LENGTHTYPE_MM: return DPI / MM_PER_INCH_FLOAT; - case nsIDOMSVGLength::SVG_LENGTHTYPE_CM: + case SVGLengthBinding::SVG_LENGTHTYPE_CM: return 10.0f * DPI / MM_PER_INCH_FLOAT; - case nsIDOMSVGLength::SVG_LENGTHTYPE_IN: + case SVGLengthBinding::SVG_LENGTHTYPE_IN: return DPI; - case nsIDOMSVGLength::SVG_LENGTHTYPE_PT: + case SVGLengthBinding::SVG_LENGTHTYPE_PT: return DPI / POINTS_PER_INCH_FLOAT; - case nsIDOMSVGLength::SVG_LENGTHTYPE_PC: + case SVGLengthBinding::SVG_LENGTHTYPE_PC: return 12.0f * DPI / POINTS_PER_INCH_FLOAT; - case nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE: + case SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE: return aMetrics.GetAxisLength(mCtxType) / 100.0f; - case nsIDOMSVGLength::SVG_LENGTHTYPE_EMS: + case SVGLengthBinding::SVG_LENGTHTYPE_EMS: return aMetrics.GetEmLength(); - case nsIDOMSVGLength::SVG_LENGTHTYPE_EXS: + case SVGLengthBinding::SVG_LENGTHTYPE_EXS: return aMetrics.GetExLength(); default: NS_NOTREACHED("Unknown unit type"); @@ -518,9 +518,9 @@ nsSVGLength2::SMILLength::ValueFromString(const nsAString& aStr, val.mU.mDouble = value * mVal->GetPixelsPerUnit(mSVGElement, unitType); aValue = val; aPreventCachingOfSandwich = - (unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE || - unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_EMS || - unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_EXS); + (unitType == SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE || + unitType == SVGLengthBinding::SVG_LENGTHTYPE_EMS || + unitType == SVGLengthBinding::SVG_LENGTHTYPE_EXS); return NS_OK; } diff --git a/dom/svg/nsSVGLength2.h b/dom/svg/nsSVGLength2.h index a1b6be7852cb..f9646bd5358c 100644 --- a/dom/svg/nsSVGLength2.h +++ b/dom/svg/nsSVGLength2.h @@ -9,6 +9,7 @@ #include "mozilla/Attributes.h" #include "mozilla/UniquePtr.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "nsCoord.h" #include "nsCycleCollectionParticipant.h" #include "nsError.h" @@ -97,7 +98,8 @@ public: void Init(uint8_t aCtxType = SVGContentUtils::XY, uint8_t aAttrEnum = 0xff, float aValue = 0, - uint8_t aUnitType = nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER) { + uint8_t aUnitType = + mozilla::dom::SVGLengthBinding::SVG_LENGTHTYPE_NUMBER) { mAnimVal = mBaseVal = aValue; mSpecifiedUnitType = aUnitType; mAttrEnum = aAttrEnum; @@ -136,7 +138,8 @@ public: uint8_t GetCtxType() const { return mCtxType; } uint8_t GetSpecifiedUnitType() const { return mSpecifiedUnitType; } bool IsPercentage() const - { return mSpecifiedUnitType == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE; } + { return mSpecifiedUnitType == + mozilla::dom::SVGLengthBinding::SVG_LENGTHTYPE_PERCENTAGE; } float GetAnimValInSpecifiedUnits() const { return mAnimVal; } float GetBaseValInSpecifiedUnits() const { return mBaseVal; } diff --git a/layout/svg/nsSVGFilterInstance.cpp b/layout/svg/nsSVGFilterInstance.cpp index 66dbfbc4de35..a996f142b8a7 100644 --- a/layout/svg/nsSVGFilterInstance.cpp +++ b/layout/svg/nsSVGFilterInstance.cpp @@ -13,6 +13,7 @@ #include "nsSVGDisplayableFrame.h" #include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/dom/IDTracker.h" +#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGFilterElement.h" #include "SVGObserverUtils.h" #include "nsSVGFilterFrame.h" @@ -161,7 +162,7 @@ nsSVGFilterInstance::GetPrimitiveNumber(uint8_t aCtxType, float aValue) const { nsSVGLength2 val; val.Init(aCtxType, 0xff, aValue, - nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); + SVGLengthBinding::SVG_LENGTHTYPE_NUMBER); float value; if (mPrimitiveUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { @@ -188,14 +189,14 @@ nsSVGFilterInstance::ConvertLocation(const Point3D& aPoint) const { nsSVGLength2 val[4]; val[0].Init(SVGContentUtils::X, 0xff, aPoint.x, - nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); + SVGLengthBinding::SVG_LENGTHTYPE_NUMBER); val[1].Init(SVGContentUtils::Y, 0xff, aPoint.y, - nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); + SVGLengthBinding::SVG_LENGTHTYPE_NUMBER); // Dummy width/height values val[2].Init(SVGContentUtils::X, 0xff, 0, - nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); + SVGLengthBinding::SVG_LENGTHTYPE_NUMBER); val[3].Init(SVGContentUtils::Y, 0xff, 0, - nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); + SVGLengthBinding::SVG_LENGTHTYPE_NUMBER); gfxRect feArea = nsSVGUtils::GetRelativeRect(mPrimitiveUnits, val, mTargetBBox, mMetrics);