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"
|
|
|
|
#include "nsSVGElement.h"
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(LinearGradient)
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(RadialGradient)
|
|
|
|
|
|
|
|
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[] = {
|
2013-02-03 00:23:16 +04: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}
|
|
|
|
};
|
|
|
|
|
|
|
|
nsSVGElement::EnumInfo SVGGradientElement::sEnumInfo[2] =
|
|
|
|
{
|
|
|
|
{ &nsGkAtoms::gradientUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 06:14:02 +04:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
2013-01-11 12:43:01 +04:00
|
|
|
},
|
|
|
|
{ &nsGkAtoms::spreadMethod,
|
|
|
|
sSpreadMethodMap,
|
2013-02-03 00:23:16 +04:00
|
|
|
SVG_SPREADMETHOD_PAD
|
2013-01-11 12:43:01 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-07-07 09:26:57 +03:00
|
|
|
nsSVGElement::StringInfo SVGGradientElement::sStringInfo[2] =
|
2013-01-11 12:43:01 +04:00
|
|
|
{
|
2016-07-07 09:26:57 +03:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_None, true },
|
2013-01-11 12:43:01 +04:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
|
|
|
nsSVGElement::EnumAttributesInfo
|
|
|
|
SVGGradientElement::GetEnumInfo()
|
|
|
|
{
|
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
|
|
|
|
ArrayLength(sEnumInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::StringAttributesInfo
|
|
|
|
SVGGradientElement::GetStringInfo()
|
|
|
|
{
|
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
|
|
|
ArrayLength(sStringInfo));
|
|
|
|
}
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGGradientElement::GradientUnits()
|
|
|
|
{
|
|
|
|
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>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGGradientElement::SpreadMethod()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[SPREADMETHOD].ToDOMAnimatedEnum(this);
|
|
|
|
}
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-01-11 12:43:01 +04:00
|
|
|
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------------------------
|
|
|
|
|
|
|
|
JSObject*
|
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
|
|
|
SVGLinearGradientElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-11 12:43:01 +04:00
|
|
|
{
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGLinearGradientElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-11 12:43:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::LengthInfo SVGLinearGradientElement::sLengthInfo[4] =
|
|
|
|
{
|
2018-06-26 00:20:54 +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>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGLinearGradientElement::X1()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X1].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGLinearGradientElement::Y1()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y1].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGLinearGradientElement::X2()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X2].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGLinearGradientElement::Y2()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y2].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList*
|
2013-01-11 12:43:01 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::LengthAttributesInfo
|
|
|
|
SVGLinearGradientElement::GetLengthInfo()
|
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
|
|
|
ArrayLength(sLengthInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------- Radial Gradients ----------------------------
|
|
|
|
|
|
|
|
JSObject*
|
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
|
|
|
SVGRadialGradientElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-11 12:43:01 +04:00
|
|
|
{
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGRadialGradientElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-11 12:43:01 +04:00
|
|
|
}
|
|
|
|
|
2017-05-23 09:15:02 +03:00
|
|
|
nsSVGElement::LengthInfo SVGRadialGradientElement::sLengthInfo[6] =
|
2013-01-11 12:43:01 +04:00
|
|
|
{
|
2018-06-26 00:20:54 +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>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGRadialGradientElement::Cx()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_CX].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGRadialGradientElement::Cy()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_CY].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGRadialGradientElement::R()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_R].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGRadialGradientElement::Fx()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_FX].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-11 12:43:01 +04:00
|
|
|
SVGRadialGradientElement::Fy()
|
|
|
|
{
|
|
|
|
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
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
|
|
|
nsSVGElement::LengthAttributesInfo
|
|
|
|
SVGRadialGradientElement::GetLengthInfo()
|
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
|
|
|
ArrayLength(sLengthInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|