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