2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-01-11 12:43:01 +04:00
|
|
|
/* 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/SVGGradientElement.h"
|
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2013-04-15 02:56:34 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedTransformList.h"
|
2018-02-18 18:53:13 +03:00
|
|
|
#include "mozilla/dom/SVGGradientElementBinding.h"
|
2013-01-11 12:43:01 +04:00
|
|
|
#include "mozilla/dom/SVGRadialGradientElementBinding.h"
|
2018-02-02 16:21:33 +03:00
|
|
|
#include "mozilla/dom/SVGLengthBinding.h"
|
2013-01-11 12:43:01 +04:00
|
|
|
#include "mozilla/dom/SVGLinearGradientElementBinding.h"
|
2018-02-18 18:53:13 +03:00
|
|
|
#include "mozilla/dom/SVGUnitTypesBinding.h"
|
2013-01-11 12:43:01 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2018-12-21 11:58:14 +03:00
|
|
|
#include "SVGElement.h"
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(LinearGradient)
|
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(RadialGradient)
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-06-26 00:20:54 +03:00
|
|
|
using namespace SVGGradientElement_Binding;
|
|
|
|
using namespace SVGUnitTypes_Binding;
|
2018-02-18 18:53:13 +03:00
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
//--------------------- Gradients------------------------
|
|
|
|
|
|
|
|
nsSVGEnumMapping SVGGradientElement::sSpreadMethodMap[] = {
|
2018-03-29 12:45:28 +03:00
|
|
|
{nsGkAtoms::pad, SVG_SPREADMETHOD_PAD},
|
|
|
|
{nsGkAtoms::reflect, SVG_SPREADMETHOD_REFLECT},
|
|
|
|
{nsGkAtoms::repeat, SVG_SPREADMETHOD_REPEAT},
|
2013-01-11 12:43:01 +04:00
|
|
|
{nullptr, 0}};
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::EnumInfo SVGGradientElement::sEnumInfo[2] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::gradientUnits, sSVGUnitTypesMap,
|
2013-02-18 06:14:02 +04:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX},
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::spreadMethod, sSpreadMethodMap, SVG_SPREADMETHOD_PAD}};
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringInfo SVGGradientElement::sStringInfo[2] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::href, kNameSpaceID_None, true},
|
|
|
|
{nsGkAtoms::href, kNameSpaceID_XLink, true}};
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGGradientElement::SVGGradientElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGGradientElementBase(std::move(aNodeInfo)) {}
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::EnumAttributesInfo SVGGradientElement::GetEnumInfo() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringAttributesInfo SVGGradientElement::GetStringInfo() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
|
|
|
ArrayLength(sStringInfo));
|
|
|
|
}
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration> SVGGradientElement::GradientUnits() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mEnumAttributes[GRADIENTUNITS].ToDOMAnimatedEnum(this);
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
already_AddRefed<SVGAnimatedTransformList>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGGradientElement::GradientTransform() {
|
|
|
|
// We're creating a DOM wrapper, so we must tell GetAnimatedTransformList
|
|
|
|
// to allocate the SVGAnimatedTransformList if it hasn't already done so:
|
2013-04-15 02:56:34 +04:00
|
|
|
return SVGAnimatedTransformList::GetDOMWrapper(
|
2013-01-11 12:43:01 +04:00
|
|
|
GetAnimatedTransformList(DO_ALLOCATE), this);
|
|
|
|
}
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration> SVGGradientElement::SpreadMethod() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mEnumAttributes[SPREADMETHOD].ToDOMAnimatedEnum(this);
|
|
|
|
}
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString> SVGGradientElement::Href() {
|
2016-07-07 09:26:57 +03:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
|
2013-01-11 12:43:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGGradientElement::IsAttributeMapped(const nsAtom* name) const {
|
2013-01-11 12:43:01 +04:00
|
|
|
static const MappedAttributeEntry* const map[] = {sColorMap,
|
|
|
|
sGradientStopMap};
|
2013-03-12 02:05:57 +04:00
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
|
|
|
SVGGradientElementBase::IsAttributeMapped(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------Linear Gradients------------------------
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* SVGLinearGradientElement::WrapNode(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGLinearGradientElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-11 12:43:01 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthInfo SVGLinearGradientElement::sLengthInfo[4] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::x1, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::y1, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y},
|
|
|
|
{nsGkAtoms::x2, 100, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::y2, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y},
|
2013-01-11 12:43:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGLinearGradientElement::SVGLinearGradientElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGLinearGradientElementBase(std::move(aNodeInfo)) {}
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-05-30 05:58:49 +03:00
|
|
|
// nsINode methods
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGLinearGradientElement)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGLinearGradientElement::X1() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_X1].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGLinearGradientElement::Y1() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_Y1].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGLinearGradientElement::X2() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_X2].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGLinearGradientElement::Y2() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_Y2].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
nsSVGAnimatedTransformList* SVGGradientElement::GetAnimatedTransformList(
|
|
|
|
uint32_t aFlags) {
|
|
|
|
if (!mGradientTransform && (aFlags & DO_ALLOCATE)) {
|
2013-04-15 02:56:34 +04:00
|
|
|
mGradientTransform = new nsSVGAnimatedTransformList();
|
2013-01-11 12:43:01 +04:00
|
|
|
}
|
|
|
|
return mGradientTransform;
|
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthAttributesInfo SVGLinearGradientElement::GetLengthInfo() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
|
|
|
ArrayLength(sLengthInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------- Radial Gradients ----------------------------
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* SVGRadialGradientElement::WrapNode(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGRadialGradientElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-11 12:43:01 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthInfo SVGRadialGradientElement::sLengthInfo[6] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::cx, 50, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::cy, 50, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y},
|
|
|
|
{nsGkAtoms::r, 50, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::XY},
|
|
|
|
{nsGkAtoms::fx, 50, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::fy, 50, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y},
|
|
|
|
{nsGkAtoms::fr, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::XY},
|
2013-01-11 12:43:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGRadialGradientElement::SVGRadialGradientElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGRadialGradientElementBase(std::move(aNodeInfo)) {}
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-05-30 05:58:49 +03:00
|
|
|
// nsINode methods
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGRadialGradientElement)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGRadialGradientElement::Cx() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_CX].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGRadialGradientElement::Cy() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_CY].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGRadialGradientElement::R() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_R].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGRadialGradientElement::Fx() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_FX].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGRadialGradientElement::Fy() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return mLengthAttributes[ATTR_FY].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2017-05-23 09:15:02 +03:00
|
|
|
already_AddRefed<SVGAnimatedLength> SVGRadialGradientElement::Fr() {
|
|
|
|
return mLengthAttributes[ATTR_FR].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthAttributesInfo SVGRadialGradientElement::GetLengthInfo() {
|
2013-01-11 12:43:01 +04:00
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
|
|
|
ArrayLength(sLengthInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|