2015-05-03 19:32:37 +00: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: */
|
2012-05-21 11:12:37 +00: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/. */
|
2005-09-13 22:38:36 +00:00
|
|
|
|
2018-12-27 17:30:38 +00:00
|
|
|
#include "mozilla/dom/SVGPatternElement.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2019-01-24 23:40:25 +00:00
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
2018-12-27 17:30:38 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2018-02-02 13:21:33 +00:00
|
|
|
#include "mozilla/dom/SVGLengthBinding.h"
|
2013-01-16 20:51:00 +00:00
|
|
|
#include "mozilla/dom/SVGPatternElementBinding.h"
|
2018-02-18 15:53:13 +00:00
|
|
|
#include "mozilla/dom/SVGUnitTypesBinding.h"
|
2018-12-27 17:30:38 +00:00
|
|
|
#include "DOMSVGAnimatedTransformList.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2005-09-13 22:38:36 +00:00
|
|
|
|
2018-12-21 11:43:29 +00:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(Pattern)
|
2013-01-16 20:51:00 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-12-20 00:45:29 +00:00
|
|
|
|
2018-06-25 21:20:54 +00:00
|
|
|
using namespace SVGUnitTypes_Binding;
|
2018-02-18 15:53:13 +00:00
|
|
|
|
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 14:13:33 +00:00
|
|
|
JSObject* SVGPatternElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-25 21:20:54 +00:00
|
|
|
return SVGPatternElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-16 20:51:00 +00:00
|
|
|
}
|
|
|
|
|
2005-09-13 22:38:36 +00:00
|
|
|
//--------------------- Patterns ------------------------
|
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
SVGElement::LengthInfo SVGPatternElement::sLengthInfo[4] = {
|
2018-03-29 09:45:24 +00:00
|
|
|
{nsGkAtoms::x, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::y, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y},
|
|
|
|
{nsGkAtoms::width, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::height, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y},
|
2005-09-13 22:38:36 +00:00
|
|
|
};
|
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
SVGElement::EnumInfo SVGPatternElement::sEnumInfo[2] = {
|
2018-03-29 09:45:24 +00:00
|
|
|
{nsGkAtoms::patternUnits, sSVGUnitTypesMap,
|
2013-02-18 02:14:02 +00:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX},
|
2018-03-29 09:45:24 +00:00
|
|
|
{nsGkAtoms::patternContentUnits, sSVGUnitTypesMap,
|
2013-02-18 02:14:02 +00:00
|
|
|
SVG_UNIT_TYPE_USERSPACEONUSE}};
|
2007-08-27 23:11:14 +00:00
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
SVGElement::StringInfo SVGPatternElement::sStringInfo[2] = {
|
2018-03-29 09:45:24 +00:00
|
|
|
{nsGkAtoms::href, kNameSpaceID_None, true},
|
|
|
|
{nsGkAtoms::href, kNameSpaceID_XLink, true}};
|
2008-06-14 09:01:02 +00:00
|
|
|
|
2005-09-13 22:38:36 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2018-09-21 20:45:49 +00:00
|
|
|
SVGPatternElement::SVGPatternElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGPatternElementBase(std::move(aNodeInfo)) {}
|
2005-09-13 22:38:36 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-05-30 02:58:49 +00:00
|
|
|
// nsINode method
|
2005-09-13 22:38:36 +00:00
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPatternElement)
|
2005-09-13 22:38:36 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-16 20:51:00 +00:00
|
|
|
|
2013-05-09 17:42:12 +00:00
|
|
|
already_AddRefed<SVGAnimatedRect> SVGPatternElement::ViewBox() {
|
2013-05-20 11:46:12 +00:00
|
|
|
return mViewBox.ToSVGAnimatedRect(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGPatternElement::PreserveAspectRatio() {
|
2015-01-27 09:51:34 +00:00
|
|
|
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-16 20:51:00 +00:00
|
|
|
|
2019-03-19 00:01:03 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration> SVGPatternElement::PatternUnits() {
|
2013-01-16 20:51:00 +00:00
|
|
|
return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 00:01:03 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::PatternContentUnits() {
|
|
|
|
return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-12-23 11:08:14 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedTransformList>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::PatternTransform() {
|
2012-07-30 00:35:26 +00:00
|
|
|
// We're creating a DOM wrapper, so we must tell GetAnimatedTransformList
|
2018-12-23 11:08:14 +00:00
|
|
|
// to allocate the DOMSVGAnimatedTransformList if it hasn't already done so:
|
|
|
|
return DOMSVGAnimatedTransformList::GetDOMWrapper(
|
2013-01-16 20:51:00 +00:00
|
|
|
GetAnimatedTransformList(DO_ALLOCATE), this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 00:01:03 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGPatternElement::X() {
|
2013-01-16 20:51:00 +00:00
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 00:01:03 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGPatternElement::Y() {
|
2013-01-16 20:51:00 +00:00
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 00:01:03 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGPatternElement::Width() {
|
2013-01-16 20:51:00 +00:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 00:01:03 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGPatternElement::Height() {
|
2013-01-16 20:51:00 +00:00
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
|
|
|
}
|
2005-09-13 22:38:36 +00:00
|
|
|
|
2019-03-19 00:01:03 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedString> SVGPatternElement::Href() {
|
2016-07-06 09:00:41 +00:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 17:39:46 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-02 22:05:19 +00:00
|
|
|
SVGPatternElement::IsAttributeMapped(const nsAtom* name) const {
|
2006-01-12 17:39:46 +00:00
|
|
|
static const MappedAttributeEntry* const map[] = {sColorMap,
|
2007-01-19 15:20:11 +00:00
|
|
|
sFEFloodMap,
|
2014-04-15 10:48:02 +00:00
|
|
|
sFillStrokeMap,
|
2007-01-30 13:19:55 +00:00
|
|
|
sFiltersMap,
|
2006-10-19 23:48:12 +00:00
|
|
|
sFontSpecificationMap,
|
|
|
|
sGradientStopMap,
|
2014-04-15 10:48:02 +00:00
|
|
|
sGraphicsMap,
|
2007-07-26 06:57:42 +00:00
|
|
|
sLightingEffectsMap,
|
2006-10-19 23:48:12 +00:00
|
|
|
sMarkersMap,
|
|
|
|
sTextContentElementsMap,
|
2007-01-19 15:20:11 +00:00
|
|
|
sViewportsMap};
|
2006-10-19 23:48:12 +00:00
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElementBase::IsAttributeMapped(name);
|
2006-01-12 17:39:46 +00:00
|
|
|
}
|
2006-04-14 15:09:39 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 08:58:14 +00:00
|
|
|
// SVGElement methods
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2018-12-26 23:46:38 +00:00
|
|
|
SVGAnimatedTransformList* SVGPatternElement::GetAnimatedTransformList(
|
2013-01-16 20:51:00 +00:00
|
|
|
uint32_t aFlags) {
|
2012-07-30 00:35:26 +00:00
|
|
|
if (!mPatternTransform && (aFlags & DO_ALLOCATE)) {
|
2018-12-26 23:46:38 +00:00
|
|
|
mPatternTransform = new SVGAnimatedTransformList();
|
2010-05-28 12:15:56 +00:00
|
|
|
}
|
2011-09-25 21:04:31 +00:00
|
|
|
return mPatternTransform;
|
2010-05-28 12:15:56 +00:00
|
|
|
}
|
|
|
|
|
2019-02-25 22:05:29 +00:00
|
|
|
/* virtual */
|
|
|
|
bool SVGPatternElement::HasValidDimensions() const {
|
2013-01-16 20:51:00 +00:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
|
|
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
2012-03-03 09:21:09 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
SVGElement::LengthAttributesInfo SVGPatternElement::GetLengthInfo() {
|
2006-04-14 15:09:39 +00:00
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sLengthInfo));
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
2006-07-19 15:31:40 +00:00
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
SVGElement::EnumAttributesInfo SVGPatternElement::GetEnumInfo() {
|
2007-08-27 23:11:14 +00:00
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
|
|
|
}
|
|
|
|
|
2019-04-10 04:08:14 +00:00
|
|
|
SVGAnimatedViewBox* SVGPatternElement::GetAnimatedViewBox() {
|
|
|
|
return &mViewBox;
|
|
|
|
}
|
2009-02-03 14:42:24 +00:00
|
|
|
|
2019-04-10 04:08:14 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio*
|
|
|
|
SVGPatternElement::GetAnimatedPreserveAspectRatio() {
|
2009-01-05 01:19:38 +00:00
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
SVGElement::StringAttributesInfo SVGPatternElement::GetStringInfo() {
|
2008-06-14 09:01:02 +00:00
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|