|
@@ -0,0 +1,1616 @@
|
|
|
|
+# HG changeset patch
|
|
|
|
+# User Boris Zbarsky <bzbarsky@mit.edu>
|
|
|
|
+# Date 1517577693 18000
|
|
|
|
+# Fri Feb 02 08:21:33 2018 -0500
|
|
|
|
+# Node ID 5ebff8611e8e1d35e8e7fd98d412f1cf2beeb315
|
|
|
|
+# Parent 15a01be4e73ab2567e208d15900b51bcadc3b2a0
|
|
|
|
+Bug 1435138 part 3. Remove nsIDOMSVGLength's SVG_LENGTHTYPE_* constants. r=qdot
|
|
|
|
+
|
|
|
|
+MozReview-Commit-ID: GvzWbe6cr5r
|
|
|
|
+
|
|
|
|
+diff --git a/dom/interfaces/svg/nsIDOMSVGLength.idl b/dom/interfaces/svg/nsIDOMSVGLength.idl
|
|
|
|
+--- a/dom/interfaces/svg/nsIDOMSVGLength.idl
|
|
|
|
++++ b/dom/interfaces/svg/nsIDOMSVGLength.idl
|
|
|
|
+@@ -3,25 +3,13 @@
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "domstubs.idl"
|
|
|
|
+
|
|
|
|
+ [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
|
|
|
|
+--- a/dom/svg/DOMSVGLength.cpp
|
|
|
|
++++ b/dom/svg/DOMSVGLength.cpp
|
|
|
|
+@@ -17,16 +17,18 @@
|
|
|
|
+ #include "mozilla/dom/SVGLengthBinding.h"
|
|
|
|
+ #include "mozilla/FloatingPoint.h"
|
|
|
|
+ #include "nsSVGAttrTearoffTable.h"
|
|
|
|
+
|
|
|
|
+ // See the architecture comment in DOMSVGAnimatedLengthList.h.
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+
|
|
|
|
++using namespace dom;
|
|
|
|
++
|
|
|
|
+ static nsSVGAttrTearoffTable<nsSVGLength2, DOMSVGLength>
|
|
|
|
+ sBaseSVGLengthTearOffTable,
|
|
|
|
+ sAnimSVGLengthTearOffTable;
|
|
|
|
+
|
|
|
|
+ // We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to
|
|
|
|
+ // clear our list's weak ref to us to be safe. (The other option would be to
|
|
|
|
+ // not unlink and rely on the breaking of the other edges in the cycle, as
|
|
|
|
+ // NS_SVG_VAL_IMPL_CYCLE_COLLECTION does.)
|
|
|
|
+@@ -95,17 +97,17 @@ private:
|
|
|
|
+ DOMSVGLength::DOMSVGLength(DOMSVGLengthList *aList,
|
|
|
|
+ uint8_t aAttrEnum,
|
|
|
|
+ uint32_t aListIndex,
|
|
|
|
+ bool aIsAnimValItem)
|
|
|
|
+ : mList(aList)
|
|
|
|
+ , mListIndex(aListIndex)
|
|
|
|
+ , mAttrEnum(aAttrEnum)
|
|
|
|
+ , mIsAnimValItem(aIsAnimValItem)
|
|
|
|
+- , mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)
|
|
|
|
++ , mUnit(SVGLengthBinding::SVG_LENGTHTYPE_NUMBER)
|
|
|
|
+ , mValue(0.0f)
|
|
|
|
+ , mVal(nullptr)
|
|
|
|
+ {
|
|
|
|
+ // These shifts are in sync with the members in the header.
|
|
|
|
+ MOZ_ASSERT(aList &&
|
|
|
|
+ aAttrEnum < (1 << 4) &&
|
|
|
|
+ aListIndex <= MaxListIndex(),
|
|
|
|
+ "bad arg");
|
|
|
|
+@@ -113,29 +115,29 @@ DOMSVGLength::DOMSVGLength(DOMSVGLengthL
|
|
|
|
+ MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGNumber!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DOMSVGLength::DOMSVGLength()
|
|
|
|
+ : mList(nullptr)
|
|
|
|
+ , mListIndex(0)
|
|
|
|
+ , mAttrEnum(0)
|
|
|
|
+ , mIsAnimValItem(false)
|
|
|
|
+- , mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)
|
|
|
|
++ , mUnit(SVGLengthBinding::SVG_LENGTHTYPE_NUMBER)
|
|
|
|
+ , mValue(0.0f)
|
|
|
|
+ , mVal(nullptr)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DOMSVGLength::DOMSVGLength(nsSVGLength2* aVal, nsSVGElement* aSVGElement,
|
|
|
|
+ bool aAnimVal)
|
|
|
|
+ : mList(nullptr)
|
|
|
|
+ , mListIndex(0)
|
|
|
|
+ , mAttrEnum(0)
|
|
|
|
+ , mIsAnimValItem(aAnimVal)
|
|
|
|
+- , mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)
|
|
|
|
++ , mUnit(SVGLengthBinding::SVG_LENGTHTYPE_NUMBER)
|
|
|
|
+ , mValue(0.0f)
|
|
|
|
+ , mVal(aVal)
|
|
|
|
+ , mSVGElement(aSVGElement)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ DOMSVGLength::CleanupWeakRefs()
|
|
|
|
+@@ -227,18 +229,18 @@ DOMSVGLength::GetValue(ErrorResult& aRv)
|
|
|
|
+ Element()->FlushAnimations(); // May make HasOwner() == false
|
|
|
|
+ }
|
|
|
|
+ if (HasOwner()) {
|
|
|
|
+ float value = InternalItem().GetValueInUserUnits(Element(), Axis());
|
|
|
|
+ if (!IsFinite(value)) {
|
|
|
|
+ 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
|
|
|
|
+ // ReportToConsole
|
|
|
|
+ aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
+ return 0.0f;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+@@ -269,18 +271,18 @@ DOMSVGLength::SetValue(float aUserUnitVa
|
|
|
|
+ if (uuPerUnit > 0) {
|
|
|
|
+ float newValue = aUserUnitValue / uuPerUnit;
|
|
|
|
+ if (IsFinite(newValue)) {
|
|
|
|
+ AutoChangeLengthNotifier notifier(this);
|
|
|
|
+ InternalItem().SetValueAndUnit(newValue, InternalItem().GetUnit());
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ // else [SVGWG issue] Can't convert user unit value to this length's unit
|
|
|
|
+ // ReportToConsole
|
|
|
|
+ aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+@@ -449,17 +451,17 @@ DOMSVGLength::ConvertToSpecifiedUnits(ui
|
|
|
|
+ // else [SVGWG issue] Can't convert unit
|
|
|
|
+ // ReportToConsole
|
|
|
|
+ aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSObject*
|
|
|
|
+ DOMSVGLength::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+- return dom::SVGLengthBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
++ return SVGLengthBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ DOMSVGLength::InsertingIntoList(DOMSVGLengthList *aList,
|
|
|
|
+ uint8_t aAttrEnum,
|
|
|
|
+ uint32_t aListIndex,
|
|
|
|
+ bool aIsAnimValItem)
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGAnimatedLengthList.cpp b/dom/svg/SVGAnimatedLengthList.cpp
|
|
|
|
+--- a/dom/svg/SVGAnimatedLengthList.cpp
|
|
|
|
++++ b/dom/svg/SVGAnimatedLengthList.cpp
|
|
|
|
+@@ -7,19 +7,22 @@
|
|
|
|
+ #include "SVGAnimatedLengthList.h"
|
|
|
|
+
|
|
|
|
+ #include "DOMSVGAnimatedLengthList.h"
|
|
|
|
+ #include "mozilla/Move.h"
|
|
|
|
+ #include "nsSVGElement.h"
|
|
|
|
+ #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)
|
|
|
|
+ {
|
|
|
|
+ SVGLengthList newBaseValue;
|
|
|
|
+ nsresult rv = newBaseValue.SetValueFromString(aValue);
|
|
|
|
+ if (NS_FAILED(rv)) {
|
|
|
|
+ return rv;
|
|
|
|
+ }
|
|
|
|
+@@ -155,19 +158,19 @@ SVGAnimatedLengthList::
|
|
|
|
+ // recalculate the result of the sandwich if the context changes, so we
|
|
|
|
+ // take the (substantial) performance hit of preventing caching of the
|
|
|
|
+ // sandwich layer, causing the animation sandwich to be recalculated every
|
|
|
|
+ // single sample.
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rv;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+diff --git a/dom/svg/SVGCircleElement.cpp b/dom/svg/SVGCircleElement.cpp
|
|
|
|
+--- a/dom/svg/SVGCircleElement.cpp
|
|
|
|
++++ b/dom/svg/SVGCircleElement.cpp
|
|
|
|
+@@ -3,35 +3,36 @@
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/dom/SVGCircleElement.h"
|
|
|
|
+ #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)
|
|
|
|
+
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+ namespace dom {
|
|
|
|
+
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGCircleElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGCircleElementBinding::Wrap(aCx, this, 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 }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGCircleElement::SVGCircleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGCircleElementBase(aNodeInfo)
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGEllipseElement.cpp b/dom/svg/SVGEllipseElement.cpp
|
|
|
|
+--- a/dom/svg/SVGEllipseElement.cpp
|
|
|
|
++++ b/dom/svg/SVGEllipseElement.cpp
|
|
|
|
+@@ -1,16 +1,17 @@
|
|
|
|
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #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"
|
|
|
|
+
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Ellipse)
|
|
|
|
+
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
+
|
|
|
|
+@@ -20,20 +21,20 @@ namespace dom {
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGEllipseElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGEllipseElementBinding::Wrap(aCx, this, 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 },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGEllipseElement::SVGEllipseElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGEllipseElementBase(aNodeInfo)
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGFilterElement.cpp b/dom/svg/SVGFilterElement.cpp
|
|
|
|
+--- a/dom/svg/SVGFilterElement.cpp
|
|
|
|
++++ b/dom/svg/SVGFilterElement.cpp
|
|
|
|
+@@ -5,35 +5,36 @@
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+
|
|
|
|
+ #include "nsGkAtoms.h"
|
|
|
|
+ #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)
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+ namespace dom {
|
|
|
|
+
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGFilterElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGFilterElementBinding::Wrap(aCx, this, 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] =
|
|
|
|
+ {
|
|
|
|
+ { &nsGkAtoms::filterUnits,
|
|
|
|
+ sSVGUnitTypesMap,
|
|
|
|
+ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
|
|
|
+ },
|
|
|
|
+diff --git a/dom/svg/SVGForeignObjectElement.cpp b/dom/svg/SVGForeignObjectElement.cpp
|
|
|
|
+--- a/dom/svg/SVGForeignObjectElement.cpp
|
|
|
|
++++ b/dom/svg/SVGForeignObjectElement.cpp
|
|
|
|
+@@ -5,34 +5,35 @@
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+
|
|
|
|
+ #include "nsCOMPtr.h"
|
|
|
|
+ #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)
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+ namespace dom {
|
|
|
|
+
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGForeignObjectElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGForeignObjectElementBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGForeignObjectElement::SVGForeignObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGGraphicsElement(aNodeInfo)
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGGeometryElement.cpp b/dom/svg/SVGGeometryElement.cpp
|
|
|
|
+--- a/dom/svg/SVGGeometryElement.cpp
|
|
|
|
++++ b/dom/svg/SVGGeometryElement.cpp
|
|
|
|
+@@ -4,23 +4,25 @@
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "SVGGeometryElement.h"
|
|
|
|
+
|
|
|
|
+ #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"
|
|
|
|
+ #include "SVGContentUtils.h"
|
|
|
|
+
|
|
|
|
+ using namespace mozilla;
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
++using namespace mozilla::dom;
|
|
|
|
+
|
|
|
|
+ nsSVGElement::NumberInfo SVGGeometryElement::sNumberInfo =
|
|
|
|
+ { &nsGkAtoms::pathLength, 0, false };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGGeometryElement::SVGGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+@@ -71,17 +73,18 @@ SVGGeometryElement::AttributeDefinesGeom
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool
|
|
|
|
+ SVGGeometryElement::GeometryDependsOnCoordCtx()
|
|
|
|
+ {
|
|
|
|
+ // Check the nsSVGLength2 attribute
|
|
|
|
+ LengthAttributesInfo info = const_cast<SVGGeometryElement*>(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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool
|
|
|
|
+ SVGGeometryElement::IsMarkable()
|
|
|
|
+diff --git a/dom/svg/SVGGradientElement.cpp b/dom/svg/SVGGradientElement.cpp
|
|
|
|
+--- a/dom/svg/SVGGradientElement.cpp
|
|
|
|
++++ b/dom/svg/SVGGradientElement.cpp
|
|
|
|
+@@ -4,16 +4,17 @@
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/dom/SVGGradientElement.h"
|
|
|
|
+
|
|
|
|
+ #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"
|
|
|
|
+ #include "nsSVGElement.h"
|
|
|
|
+
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(LinearGradient)
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(RadialGradient)
|
|
|
|
+
|
|
|
|
+@@ -121,20 +122,20 @@ SVGGradientElement::IsAttributeMapped(co
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGLinearGradientElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGLinearGradientElementBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGLinearGradientElement::SVGLinearGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGLinearGradientElementBase(aNodeInfo)
|
|
|
|
+ {
|
|
|
|
+@@ -195,22 +196,22 @@ SVGLinearGradientElement::GetLengthInfo(
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGRadialGradientElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGRadialGradientElementBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGRadialGradientElement::SVGRadialGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGRadialGradientElementBase(aNodeInfo)
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp
|
|
|
|
+--- a/dom/svg/SVGImageElement.cpp
|
|
|
|
++++ b/dom/svg/SVGImageElement.cpp
|
|
|
|
+@@ -10,16 +10,17 @@
|
|
|
|
+
|
|
|
|
+ #include "mozilla/dom/SVGImageElement.h"
|
|
|
|
+ #include "mozilla/gfx/2D.h"
|
|
|
|
+ #include "nsCOMPtr.h"
|
|
|
|
+ #include "nsIURI.h"
|
|
|
|
+ #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)
|
|
|
|
+
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+ namespace dom {
|
|
|
|
+@@ -27,20 +28,20 @@ namespace dom {
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGImageElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGImageElementBinding::Wrap(aCx, this, 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] =
|
|
|
|
+ {
|
|
|
|
+ { &nsGkAtoms::href, kNameSpaceID_None, true },
|
|
|
|
+ { &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+diff --git a/dom/svg/SVGLength.cpp b/dom/svg/SVGLength.cpp
|
|
|
|
+--- a/dom/svg/SVGLength.cpp
|
|
|
|
++++ b/dom/svg/SVGLength.cpp
|
|
|
|
+@@ -11,16 +11,18 @@
|
|
|
|
+ #include "mozilla/dom/SVGSVGElement.h"
|
|
|
|
+ #include "nsTextFormatter.h"
|
|
|
|
+ #include "SVGContentUtils.h"
|
|
|
|
+ #include <limits>
|
|
|
|
+ #include <algorithm>
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ SVGLength::GetValueAsString(nsAString &aValue) const
|
|
|
|
+ {
|
|
|
|
+ nsTextFormatter::ssprintf(aValue, u"%g", (double)mValue);
|
|
|
|
+@@ -52,30 +54,30 @@ SVGLength::SetValueFromString(const nsAS
|
|
|
|
+ mValue = value;
|
|
|
|
+ mUnit = uint8_t(unitType);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Helper to convert between different CSS absolute units without the need for
|
|
|
|
+ * an element, which provides more flexibility at the DOM level (and without
|
|
|
|
+ * the need for an intermediary conversion to user units, which avoids
|
|
|
|
+ * unnecessary overhead and rounding error).
|
|
|
|
+ *
|
|
|
|
+ * 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)
|
|
|
|
+ {
|
|
|
|
+ MOZ_ASSERT(IsAbsoluteUnit(aUnits), "Not a CSS absolute unit");
|
|
|
|
+ MOZ_ASSERT(IsAbsoluteUnit(aPerUnit), "Not a CSS absolute unit");
|
|
|
|
+
|
|
|
|
+ float CSSAbsoluteUnitConversionFactors[5][5] = { // columns: cm, mm, in, pt, pc
|
|
|
|
+ // cm per...:
|
|
|
|
+@@ -97,20 +99,20 @@ inline static float GetAbsUnitsPerAbsUni
|
|
|
|
+ float
|
|
|
|
+ SVGLength::GetValueInSpecifiedUnit(uint8_t aUnit,
|
|
|
|
+ const nsSVGElement *aElement,
|
|
|
|
+ uint8_t aAxis) const
|
|
|
|
+ {
|
|
|
|
+ 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)) {
|
|
|
|
+ return mValue * GetAbsUnitsPerAbsUnit(aUnit, mUnit);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Otherwise we do a two step convertion via user units. This can only
|
|
|
|
+ // succeed if aElement is non-null (although that's not sufficent to
|
|
|
|
+@@ -139,34 +141,34 @@ SVGLength::GetValueInSpecifiedUnit(uint8
|
|
|
|
+
|
|
|
|
+ #define INCHES_PER_MM_FLOAT float(0.0393700787)
|
|
|
|
+ #define INCHES_PER_CM_FLOAT float(0.393700787)
|
|
|
|
+
|
|
|
|
+ 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<nsSVGElement*>(aElement));
|
|
|
|
+- case nsIDOMSVGLength::SVG_LENGTHTYPE_EXS:
|
|
|
|
++ case SVGLengthBinding::SVG_LENGTHTYPE_EXS:
|
|
|
|
+ return SVGContentUtils::GetFontXHeight(const_cast<nsSVGElement*>(aElement));
|
|
|
|
+ default:
|
|
|
|
+ NS_NOTREACHED("Unknown unit type");
|
|
|
|
+ return std::numeric_limits<float>::quiet_NaN();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* static */ float
|
|
|
|
+@@ -178,17 +180,17 @@ SVGLength::GetUserUnitsPerPercent(const
|
|
|
|
+ return std::max(viewportElement->GetLength(aAxis) / 100.0f, 0.0f);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return std::numeric_limits<float>::quiet_NaN();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 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 nsIAtom** const unitMap[] =
|
|
|
|
+ {
|
|
|
|
+ nullptr, /* SVG_LENGTHTYPE_UNKNOWN */
|
|
|
|
+ nullptr, /* SVG_LENGTHTYPE_NUMBER */
|
|
|
|
+ &nsGkAtoms::percentage,
|
|
|
|
+ &nsGkAtoms::em,
|
|
|
|
+ &nsGkAtoms::ex,
|
|
|
|
+ &nsGkAtoms::px,
|
|
|
|
+@@ -210,23 +212,23 @@ GetUnitString(nsAString& unit, uint16_t
|
|
|
|
+ }
|
|
|
|
+ NS_NOTREACHED("Unknown unit type"); // Someone's using an SVGLength with an invalid unit?
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static uint16_t
|
|
|
|
+ GetUnitTypeForString(const nsAString& unitStr)
|
|
|
|
+ {
|
|
|
|
+ if (unitStr.IsEmpty())
|
|
|
|
+- return nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER;
|
|
|
|
++ return SVGLengthBinding::SVG_LENGTHTYPE_NUMBER;
|
|
|
|
+
|
|
|
|
+ nsIAtom* unitAtom = NS_GetStaticAtom(unitStr);
|
|
|
|
+
|
|
|
|
+ if (unitAtom) {
|
|
|
|
+ for (uint32_t i = 1 ; i < ArrayLength(unitMap) ; i++) {
|
|
|
|
+ if (unitMap[i] && *unitMap[i] == unitAtom) {
|
|
|
|
+ return i;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+- return nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN;
|
|
|
|
++ return SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } // namespace mozilla
|
|
|
|
+diff --git a/dom/svg/SVGLength.h b/dom/svg/SVGLength.h
|
|
|
|
+--- a/dom/svg/SVGLength.h
|
|
|
|
++++ b/dom/svg/SVGLength.h
|
|
|
|
+@@ -6,16 +6,17 @@
|
|
|
|
+
|
|
|
|
+ #ifndef MOZILLA_SVGLENGTH_H__
|
|
|
|
+ #define MOZILLA_SVGLENGTH_H__
|
|
|
|
+
|
|
|
|
+ #include "nsDebug.h"
|
|
|
|
+ #include "nsIDOMSVGLength.h"
|
|
|
|
+ #include "nsMathUtils.h"
|
|
|
|
+ #include "mozilla/FloatingPoint.h"
|
|
|
|
++#include "mozilla/dom/SVGLengthBinding.h"
|
|
|
|
+
|
|
|
|
+ class nsSVGElement;
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This SVGLength class is currently used for SVGLength *list* attributes only.
|
|
|
|
+ * The class that is currently used for <length> attributes is nsSVGLength2.
|
|
|
|
+@@ -30,17 +31,17 @@ namespace mozilla {
|
|
|
|
+ */
|
|
|
|
+ class SVGLength
|
|
|
|
+ {
|
|
|
|
+ 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
|
|
|
|
+ {}
|
|
|
|
+
|
|
|
|
+ SVGLength(float aValue, uint8_t aUnit)
|
|
|
|
+ : mValue(aValue)
|
|
|
|
+ , mUnit(aUnit)
|
|
|
|
+ {
|
|
|
|
+ NS_ASSERTION(IsValid(), "Constructed an invalid length");
|
|
|
|
+@@ -115,22 +116,22 @@ public:
|
|
|
|
+ * This method returns numeric_limits<float>::quiet_NaN() if it is not
|
|
|
|
+ * possible to convert the value to the specified unit.
|
|
|
|
+ */
|
|
|
|
+ float GetValueInSpecifiedUnit(uint8_t aUnit,
|
|
|
|
+ const nsSVGElement *aElement,
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the number of user units per current unit.
|
|
|
|
+ *
|
|
|
|
+ * This method returns numeric_limits<float>::quiet_NaN() if the conversion
|
|
|
|
+ * factor between the length's current unit and user units is undefined (see
|
|
|
|
+ * the comments for GetUserUnitsPerInch and GetUserUnitsPerPercent).
|
|
|
|
+diff --git a/dom/svg/SVGLengthList.h b/dom/svg/SVGLengthList.h
|
|
|
|
+--- a/dom/svg/SVGLengthList.h
|
|
|
|
++++ b/dom/svg/SVGLengthList.h
|
|
|
|
+@@ -10,16 +10,17 @@
|
|
|
|
+ #include "nsCOMPtr.h"
|
|
|
|
+ #include "nsDebug.h"
|
|
|
|
+ #include "nsIContent.h"
|
|
|
|
+ #include "nsINode.h"
|
|
|
|
+ #include "nsIWeakReferenceUtils.h"
|
|
|
|
+ #include "nsSVGElement.h"
|
|
|
|
+ #include "nsTArray.h"
|
|
|
|
+ #include "SVGLength.h"
|
|
|
|
++#include "mozilla/dom/SVGLengthBinding.h"
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * ATTENTION! WARNING! WATCH OUT!!
|
|
|
|
+ *
|
|
|
|
+ * Consumers that modify objects of this type absolutely MUST keep the DOM
|
|
|
|
+ * wrappers for those lists (if any) in sync!! That's why this class is so
|
|
|
|
+@@ -332,17 +333,17 @@ public:
|
|
|
|
+
|
|
|
|
+ /// This may return a non-finite value
|
|
|
|
+ float operator[](uint32_t aIndex) const {
|
|
|
|
+ return (*mList)[aIndex].GetValueInUserUnits(mElement, mAxis);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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:
|
|
|
|
+ const SVGLengthList *mList;
|
|
|
|
+ nsSVGElement *mElement;
|
|
|
|
+ uint8_t mAxis;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+diff --git a/dom/svg/SVGLineElement.cpp b/dom/svg/SVGLineElement.cpp
|
|
|
|
+--- a/dom/svg/SVGLineElement.cpp
|
|
|
|
++++ b/dom/svg/SVGLineElement.cpp
|
|
|
|
+@@ -1,15 +1,16 @@
|
|
|
|
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * 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"
|
|
|
|
+
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Line)
|
|
|
|
+
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+@@ -18,20 +19,20 @@ namespace dom {
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGLineElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGLineElementBinding::Wrap(aCx, this, 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 },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGLineElement::SVGLineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGLineElementBase(aNodeInfo)
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGMarkerElement.cpp b/dom/svg/SVGMarkerElement.cpp
|
|
|
|
+--- a/dom/svg/SVGMarkerElement.cpp
|
|
|
|
++++ b/dom/svg/SVGMarkerElement.cpp
|
|
|
|
+@@ -6,16 +6,17 @@
|
|
|
|
+
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+
|
|
|
|
+ #include "nsGkAtoms.h"
|
|
|
|
+ #include "nsCOMPtr.h"
|
|
|
|
+ #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"
|
|
|
|
+ #include "mozilla/gfx/Matrix.h"
|
|
|
|
+ #include "mozilla/FloatingPoint.h"
|
|
|
|
+ #include "SVGContentUtils.h"
|
|
|
|
+
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
+@@ -28,20 +29,20 @@ namespace dom {
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGMarkerElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGMarkerElementBinding::Wrap(aCx, this, 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[] = {
|
|
|
|
+ {&nsGkAtoms::strokeWidth, SVG_MARKERUNITS_STROKEWIDTH},
|
|
|
|
+ {&nsGkAtoms::userSpaceOnUse, SVG_MARKERUNITS_USERSPACEONUSE},
|
|
|
|
+ {nullptr, 0}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+diff --git a/dom/svg/SVGMaskElement.cpp b/dom/svg/SVGMaskElement.cpp
|
|
|
|
+--- a/dom/svg/SVGMaskElement.cpp
|
|
|
|
++++ b/dom/svg/SVGMaskElement.cpp
|
|
|
|
+@@ -3,16 +3,17 @@
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+
|
|
|
|
+ #include "nsCOMPtr.h"
|
|
|
|
+ #include "nsGkAtoms.h"
|
|
|
|
++#include "mozilla/dom/SVGLengthBinding.h"
|
|
|
|
+ #include "mozilla/dom/SVGMaskElement.h"
|
|
|
|
+ #include "mozilla/dom/SVGMaskElementBinding.h"
|
|
|
|
+
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Mask)
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+ namespace dom {
|
|
|
|
+
|
|
|
|
+@@ -21,20 +22,20 @@ SVGMaskElement::WrapNode(JSContext *aCx,
|
|
|
|
+ {
|
|
|
|
+ return SVGMaskElementBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //--------------------- Masks ------------------------
|
|
|
|
+
|
|
|
|
+ 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] =
|
|
|
|
+ {
|
|
|
|
+ { &nsGkAtoms::maskUnits,
|
|
|
|
+ sSVGUnitTypesMap,
|
|
|
|
+ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
|
|
|
+ },
|
|
|
|
+diff --git a/dom/svg/SVGPatternElement.cpp b/dom/svg/SVGPatternElement.cpp
|
|
|
|
+--- a/dom/svg/SVGPatternElement.cpp
|
|
|
|
++++ b/dom/svg/SVGPatternElement.cpp
|
|
|
|
+@@ -4,16 +4,17 @@
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+
|
|
|
|
+ #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"
|
|
|
|
+
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Pattern)
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+ namespace dom {
|
|
|
|
+
|
|
|
|
+@@ -22,20 +23,20 @@ SVGPatternElement::WrapNode(JSContext *a
|
|
|
|
+ {
|
|
|
|
+ return SVGPatternElementBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //--------------------- Patterns ------------------------
|
|
|
|
+
|
|
|
|
+ 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] =
|
|
|
|
+ {
|
|
|
|
+ { &nsGkAtoms::patternUnits,
|
|
|
|
+ sSVGUnitTypesMap,
|
|
|
|
+ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
|
|
|
+ },
|
|
|
|
+diff --git a/dom/svg/SVGRectElement.cpp b/dom/svg/SVGRectElement.cpp
|
|
|
|
+--- a/dom/svg/SVGRectElement.cpp
|
|
|
|
++++ b/dom/svg/SVGRectElement.cpp
|
|
|
|
+@@ -1,16 +1,17 @@
|
|
|
|
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #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"
|
|
|
|
+ #include "mozilla/gfx/Rect.h"
|
|
|
|
+ #include "mozilla/gfx/PathHelpers.h"
|
|
|
|
+ #include <algorithm>
|
|
|
|
+
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Rect)
|
|
|
|
+@@ -25,22 +26,22 @@ class SVGAnimatedLength;
|
|
|
|
+ JSObject*
|
|
|
|
+ SVGRectElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGRectElementBinding::Wrap(aCx, this, 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 }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGRectElement::SVGRectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGRectElementBase(aNodeInfo)
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGTextContentElement.cpp b/dom/svg/SVGTextContentElement.cpp
|
|
|
|
+--- a/dom/svg/SVGTextContentElement.cpp
|
|
|
|
++++ b/dom/svg/SVGTextContentElement.cpp
|
|
|
|
+@@ -1,16 +1,17 @@
|
|
|
|
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/dom/SVGTextContentElement.h"
|
|
|
|
+
|
|
|
|
++#include "mozilla/dom/SVGLengthBinding.h"
|
|
|
|
+ #include "mozilla/dom/SVGIRect.h"
|
|
|
|
+ #include "nsBidiUtils.h"
|
|
|
|
+ #include "nsISVGPoint.h"
|
|
|
|
+ #include "nsTextFragment.h"
|
|
|
|
+ #include "nsTextFrameUtils.h"
|
|
|
|
+ #include "nsTextNode.h"
|
|
|
|
+ #include "SVGTextFrame.h"
|
|
|
|
+
|
|
|
|
+@@ -25,17 +26,17 @@ nsSVGEnumMapping SVGTextContentElement::
|
|
|
|
+
|
|
|
|
+ nsSVGElement::EnumInfo SVGTextContentElement::sEnumInfo[1] =
|
|
|
|
+ {
|
|
|
|
+ { &nsGkAtoms::lengthAdjust, sLengthAdjustMap, SVG_LENGTHADJUST_SPACING }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ nsSVGElement::LengthInfo SVGTextContentElement::sLengthInfo[1] =
|
|
|
|
+ {
|
|
|
|
+- { &nsGkAtoms::textLength, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }
|
|
|
|
++ { &nsGkAtoms::textLength, 0, SVGLengthBinding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ SVGTextFrame*
|
|
|
|
+ SVGTextContentElement::GetSVGTextFrame()
|
|
|
|
+ {
|
|
|
|
+ nsIFrame* frame = GetPrimaryFrame(FlushType::Layout);
|
|
|
|
+ nsIFrame* textFrame =
|
|
|
|
+ nsLayoutUtils::GetClosestFrameOfType(frame, LayoutFrameType::SVGText);
|
|
|
|
+diff --git a/dom/svg/SVGTextPathElement.cpp b/dom/svg/SVGTextPathElement.cpp
|
|
|
|
+--- a/dom/svg/SVGTextPathElement.cpp
|
|
|
|
++++ b/dom/svg/SVGTextPathElement.cpp
|
|
|
|
+@@ -1,15 +1,16 @@
|
|
|
|
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * 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"
|
|
|
|
+ #include "nsError.h"
|
|
|
|
+
|
|
|
|
+ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(TextPath)
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+@@ -21,19 +22,19 @@ JSObject*
|
|
|
|
+ SVGTextPathElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
+ {
|
|
|
|
+ return SVGTextPathElementBinding::Wrap(aCx, this, 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[] = {
|
|
|
|
+ {&nsGkAtoms::align, TEXTPATH_METHODTYPE_ALIGN},
|
|
|
|
+ {&nsGkAtoms::stretch, TEXTPATH_METHODTYPE_STRETCH},
|
|
|
|
+ {nullptr, 0}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+diff --git a/dom/svg/SVGUseElement.cpp b/dom/svg/SVGUseElement.cpp
|
|
|
|
+--- a/dom/svg/SVGUseElement.cpp
|
|
|
|
++++ b/dom/svg/SVGUseElement.cpp
|
|
|
|
+@@ -3,16 +3,17 @@
|
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+ #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"
|
|
|
|
+ #include "nsIDocument.h"
|
|
|
|
+ #include "nsIPresShell.h"
|
|
|
|
+ #include "mozilla/dom/Element.h"
|
|
|
|
+ #include "nsContentUtils.h"
|
|
|
|
+ #include "nsIURI.h"
|
|
|
|
+@@ -31,20 +32,20 @@ SVGUseElement::WrapNode(JSContext *aCx,
|
|
|
|
+ return SVGUseElementBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ////////////////////////////////////////////////////////////////////////
|
|
|
|
+ // implementation
|
|
|
|
+
|
|
|
|
+ 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] =
|
|
|
|
+ {
|
|
|
|
+ { &nsGkAtoms::href, kNameSpaceID_None, true },
|
|
|
|
+ { &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+@@ -345,17 +346,17 @@ SVGUseElement::SyncWidthOrHeight(nsIAtom
|
|
|
|
+ // content that's being cloned.
|
|
|
|
+ TriggerReclone();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Our width/height attribute is now no longer explicitly set, so we
|
|
|
|
+ // 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ SVGUseElement::LookupHref()
|
|
|
|
+ {
|
|
|
|
+diff --git a/dom/svg/SVGViewportElement.cpp b/dom/svg/SVGViewportElement.cpp
|
|
|
|
+--- a/dom/svg/SVGViewportElement.cpp
|
|
|
|
++++ b/dom/svg/SVGViewportElement.cpp
|
|
|
|
+@@ -4,16 +4,17 @@
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include <stdint.h>
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+ #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"
|
|
|
|
+
|
|
|
|
+ #include "DOMSVGLength.h"
|
|
|
|
+ #include "DOMSVGPoint.h"
|
|
|
|
+ #include "nsCOMPtr.h"
|
|
|
|
+ #include "nsContentUtils.h"
|
|
|
|
+@@ -34,20 +35,20 @@
|
|
|
|
+
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
+
|
|
|
|
+ namespace mozilla {
|
|
|
|
+ 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 },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // Implementation
|
|
|
|
+
|
|
|
|
+ SVGViewportElement::SVGViewportElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
|
|
+ : SVGGraphicsElement(aNodeInfo),
|
|
|
|
+ mViewportWidth(0),
|
|
|
|
+diff --git a/dom/svg/nsSVGElement.cpp b/dom/svg/nsSVGElement.cpp
|
|
|
|
+--- a/dom/svg/nsSVGElement.cpp
|
|
|
|
++++ b/dom/svg/nsSVGElement.cpp
|
|
|
|
+@@ -5,16 +5,17 @@
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #include "mozilla/ArrayUtils.h"
|
|
|
|
+ #include "mozilla/DebugOnly.h"
|
|
|
|
+ #include "mozilla/Unused.h"
|
|
|
|
+
|
|
|
|
+ #include "nsSVGElement.h"
|
|
|
|
+
|
|
|
|
++#include "mozilla/dom/SVGLengthBinding.h"
|
|
|
|
+ #include "mozilla/dom/SVGSVGElement.h"
|
|
|
|
+ #include "mozilla/dom/SVGTests.h"
|
|
|
|
+ #include "nsContentUtils.h"
|
|
|
|
+ #include "nsICSSDeclaration.h"
|
|
|
|
+ #include "nsIContentInlines.h"
|
|
|
|
+ #include "nsIDocument.h"
|
|
|
|
+ #include "nsIDOMMutationEvent.h"
|
|
|
|
+ #include "mozilla/InternalMutationEvent.h"
|
|
|
|
+@@ -1694,22 +1695,22 @@ nsSVGElement::GetAnimatedLengthValues(fl
|
|
|
|
+ uint32_t i = 0;
|
|
|
|
+
|
|
|
|
+ va_list args;
|
|
|
|
+ va_start(args, 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);
|
|
|
|
+ f = va_arg(args, float*);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ va_end(args);
|
|
|
|
+ }
|
|
|
|
+diff --git a/dom/svg/nsSVGFilters.cpp b/dom/svg/nsSVGFilters.cpp
|
|
|
|
+--- a/dom/svg/nsSVGFilters.cpp
|
|
|
|
++++ b/dom/svg/nsSVGFilters.cpp
|
|
|
|
+@@ -33,34 +33,35 @@
|
|
|
|
+ #include "mozilla/dom/SVGComponentTransferFunctionElement.h"
|
|
|
|
+ #include "mozilla/dom/SVGFEDistantLightElement.h"
|
|
|
|
+ #include "mozilla/dom/SVGFEFuncAElementBinding.h"
|
|
|
|
+ #include "mozilla/dom/SVGFEFuncBElementBinding.h"
|
|
|
|
+ #include "mozilla/dom/SVGFEFuncGElementBinding.h"
|
|
|
|
+ #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
|
|
|
|
+ #undef LoadImage
|
|
|
|
+ #endif
|
|
|
|
+
|
|
|
|
+ using namespace mozilla;
|
|
|
|
+ using namespace mozilla::dom;
|
|
|
|
+ using namespace mozilla::gfx;
|
|
|
|
+
|
|
|
|
+ //--------------------Filter Element Base Class-----------------------
|
|
|
|
+
|
|
|
|
+ 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 }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //----------------------------------------------------------------------
|
|
|
|
+ // nsISupports methods
|
|
|
|
+
|
|
|
|
+ NS_IMPL_ADDREF_INHERITED(nsSVGFE,nsSVGFEBase)
|
|
|
|
+ NS_IMPL_RELEASE_INHERITED(nsSVGFE,nsSVGFEBase)
|
|
|
|
+
|
|
|
|
+diff --git a/dom/svg/nsSVGLength2.cpp b/dom/svg/nsSVGLength2.cpp
|
|
|
|
+--- a/dom/svg/nsSVGLength2.cpp
|
|
|
|
++++ b/dom/svg/nsSVGLength2.cpp
|
|
|
|
+@@ -40,18 +40,18 @@ static nsIAtom** const unitMap[] =
|
|
|
|
+ static nsSVGAttrTearoffTable<nsSVGLength2, SVGAnimatedLength>
|
|
|
|
+ sSVGAnimatedLengthTearoffTable;
|
|
|
|
+
|
|
|
|
+ /* Helper functions */
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static void
|
|
|
|
+ GetUnitString(nsAString& unit, uint16_t unitType)
|
|
|
|
+ {
|
|
|
|
+@@ -64,28 +64,28 @@ GetUnitString(nsAString& unit, uint16_t
|
|
|
|
+
|
|
|
|
+ NS_NOTREACHED("Unknown unit type");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static uint16_t
|
|
|
|
+ GetUnitTypeForString(const nsAString& unitStr)
|
|
|
|
+ {
|
|
|
|
+ if (unitStr.IsEmpty())
|
|
|
|
+- return nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER;
|
|
|
|
++ return SVGLengthBinding::SVG_LENGTHTYPE_NUMBER;
|
|
|
|
+
|
|
|
|
+ nsIAtom *unitAtom = NS_GetStaticAtom(unitStr);
|
|
|
|
+ if (unitAtom) {
|
|
|
|
+ for (uint32_t i = 0 ; i < ArrayLength(unitMap) ; i++) {
|
|
|
|
+ if (unitMap[i] && *unitMap[i] == unitAtom) {
|
|
|
|
+ return i;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+- return nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN;
|
|
|
|
++ return SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static void
|
|
|
|
+ GetValueString(nsAString &aValueAsString, float aValue, uint16_t aUnitType)
|
|
|
|
+ {
|
|
|
|
+ nsTextFormatter::ssprintf(aValueAsString, u"%g", (double)aValue);
|
|
|
|
+
|
|
|
|
+ nsAutoString unitString;
|
|
|
|
+@@ -238,34 +238,34 @@ nsSVGLength2::GetPixelsPerUnit(nsIFrame*
|
|
|
|
+ // See https://www.w3.org/TR/css-values-3/#absolute-lengths
|
|
|
|
+ static const float DPI = 96.0f;
|
|
|
|
+
|
|
|
|
+ float
|
|
|
|
+ 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");
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+@@ -513,19 +513,19 @@ nsSVGLength2::SMILLength::ValueFromStrin
|
|
|
|
+ if (!GetValueFromString(aStr, value, &unitType)) {
|
|
|
|
+ return NS_ERROR_DOM_SYNTAX_ERR;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nsSMILValue val(nsSMILFloatType::Singleton());
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nsSMILValue
|
|
|
|
+ nsSVGLength2::SMILLength::GetBaseValue() const
|
|
|
|
+ {
|
|
|
|
+ nsSMILValue val(nsSMILFloatType::Singleton());
|
|
|
|
+diff --git a/dom/svg/nsSVGLength2.h b/dom/svg/nsSVGLength2.h
|
|
|
|
+--- a/dom/svg/nsSVGLength2.h
|
|
|
|
++++ b/dom/svg/nsSVGLength2.h
|
|
|
|
+@@ -4,16 +4,17 @@
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
+
|
|
|
|
+ #ifndef __NS_SVGLENGTH2_H__
|
|
|
|
+ #define __NS_SVGLENGTH2_H__
|
|
|
|
+
|
|
|
|
+ #include "mozilla/Attributes.h"
|
|
|
|
+ #include "mozilla/UniquePtr.h"
|
|
|
|
++#include "mozilla/dom/SVGLengthBinding.h"
|
|
|
|
+ #include "nsCoord.h"
|
|
|
|
+ #include "nsCycleCollectionParticipant.h"
|
|
|
|
+ #include "nsError.h"
|
|
|
|
+ #include "nsIDOMSVGLength.h"
|
|
|
|
+ #include "nsISMILAttr.h"
|
|
|
|
+ #include "nsMathUtils.h"
|
|
|
|
+ #include "nsSVGElement.h"
|
|
|
|
+ #include "SVGContentUtils.h"
|
|
|
|
+@@ -92,17 +93,18 @@ class nsSVGLength2
|
|
|
|
+ friend class mozilla::DOMSVGLength;
|
|
|
|
+ typedef mozilla::dom::UserSpaceMetrics UserSpaceMetrics;
|
|
|
|
+ typedef mozilla::dom::SVGViewportElement SVGViewportElement;
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ mCtxType = aCtxType;
|
|
|
|
+ mIsAnimated = false;
|
|
|
|
+ mIsBaseSet = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+@@ -131,17 +133,18 @@ public:
|
|
|
|
+ float GetAnimValue(SVGViewportElement* aCtx) const
|
|
|
|
+ { return mAnimVal * GetPixelsPerUnit(aCtx, mSpecifiedUnitType); }
|
|
|
|
+ float GetAnimValue(const UserSpaceMetrics& aMetrics) const
|
|
|
|
+ { return mAnimVal * GetPixelsPerUnit(aMetrics, mSpecifiedUnitType); }
|
|
|
|
+
|
|
|
|
+ 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; }
|
|
|
|
+
|
|
|
|
+ float GetBaseValue(SVGViewportElement* aCtx) const
|
|
|
|
+ { return mBaseVal * GetPixelsPerUnit(aCtx, mSpecifiedUnitType); }
|
|
|
|
+
|
|
|
|
+ bool HasBaseVal() const {
|
|
|
|
+ return mIsBaseSet;
|
|
|
|
+diff --git a/layout/svg/nsSVGFilterInstance.cpp b/layout/svg/nsSVGFilterInstance.cpp
|
|
|
|
+--- a/layout/svg/nsSVGFilterInstance.cpp
|
|
|
|
++++ b/layout/svg/nsSVGFilterInstance.cpp
|
|
|
|
+@@ -8,16 +8,17 @@
|
|
|
|
+ #include "nsSVGFilterInstance.h"
|
|
|
|
+
|
|
|
|
+ // Keep others in (case-insensitive) order:
|
|
|
|
+ #include "gfxPlatform.h"
|
|
|
|
+ #include "gfxUtils.h"
|
|
|
|
+ #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"
|
|
|
|
+ #include "nsSVGUtils.h"
|
|
|
|
+ #include "SVGContentUtils.h"
|
|
|
|
+ #include "FilterSupport.h"
|
|
|
|
+ #include "gfx2DGlue.h"
|
|
|
|
+
|
|
|
|
+@@ -156,17 +157,17 @@ nsSVGFilterInstance::GetFilterFrame(nsIF
|
|
|
|
+ return static_cast<nsSVGFilterFrame*>(frame);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ float
|
|
|
|
+ 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) {
|
|
|
|
+ value = nsSVGUtils::ObjectSpace(mTargetBBox, &val);
|
|
|
|
+ } else {
|
|
|
|
+ value = nsSVGUtils::UserSpace(mMetrics, &val);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+@@ -183,24 +184,24 @@ nsSVGFilterInstance::GetPrimitiveNumber(
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Point3D
|
|
|
|
+ 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);
|
|
|
|
+ gfxRect r = UserSpaceToFilterSpace(feArea);
|
|
|
|
+ return Point3D(r.x, r.y, GetPrimitiveNumber(SVGContentUtils::XY, aPoint.z));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ gfxRect
|