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
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2005-09-14 02:38:36 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2013-04-15 02:56:34 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedTransformList.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/SVGPatternElement.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"
|
2005-09-14 02:38:36 +04:00
|
|
|
|
2013-01-17 00:51:00 +04:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Pattern)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-12-20 03:45:29 +03:00
|
|
|
|
2018-02-18 18:53:13 +03:00
|
|
|
using namespace SVGUnitTypesBinding;
|
|
|
|
|
2013-01-17 00:51:00 +04:00
|
|
|
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
|
|
|
SVGPatternElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-17 00:51:00 +04: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
|
|
|
return SVGPatternElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-17 00:51:00 +04:00
|
|
|
}
|
|
|
|
|
2005-09-14 02:38:36 +04:00
|
|
|
//--------------------- Patterns ------------------------
|
|
|
|
|
2013-01-17 00:51:00 +04:00
|
|
|
nsSVGElement::LengthInfo SVGPatternElement::sLengthInfo[4] =
|
2005-09-14 02:38:36 +04:00
|
|
|
{
|
2018-02-02 16:21:33 +03:00
|
|
|
{ &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 },
|
2005-09-14 02:38:36 +04:00
|
|
|
};
|
|
|
|
|
2013-01-17 00:51:00 +04:00
|
|
|
nsSVGElement::EnumInfo SVGPatternElement::sEnumInfo[2] =
|
2007-08-28 03:11:14 +04:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::patternUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 06:14:02 +04:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
2007-08-28 03:11:14 +04:00
|
|
|
},
|
|
|
|
{ &nsGkAtoms::patternContentUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 06:14:02 +04:00
|
|
|
SVG_UNIT_TYPE_USERSPACEONUSE
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-07-06 12:00:41 +03:00
|
|
|
nsSVGElement::StringInfo SVGPatternElement::sStringInfo[2] =
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
2016-07-06 12:00:41 +03:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_None, true },
|
2011-10-17 18:59:28 +04:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
2008-06-14 13:01:02 +04:00
|
|
|
};
|
|
|
|
|
2005-09-14 02:38:36 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
SVGPatternElement::SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-17 00:51:00 +04:00
|
|
|
: SVGPatternElementBase(aNodeInfo)
|
2005-09-14 02:38:36 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode method
|
|
|
|
|
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>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::ViewBox()
|
|
|
|
{
|
2013-05-20 15:46:12 +04:00
|
|
|
return mViewBox.ToSVGAnimatedRect(this);
|
2005-09-14 02:38:36 +04:00
|
|
|
}
|
|
|
|
|
2013-01-17 00:51:00 +04:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGPatternElement::PreserveAspectRatio()
|
2005-09-14 02:38:36 +04:00
|
|
|
{
|
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
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::PatternUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(this);
|
2005-09-14 02:38:36 +04:00
|
|
|
}
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::PatternContentUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(this);
|
2005-09-14 02:38:36 +04:00
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
already_AddRefed<SVGAnimatedTransformList>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::PatternTransform()
|
2005-09-14 02:38:36 +04:00
|
|
|
{
|
2012-07-30 04:35:26 +04:00
|
|
|
// 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-17 00:51:00 +04:00
|
|
|
GetAnimatedTransformList(DO_ALLOCATE), this);
|
2005-09-14 02:38:36 +04:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::X()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2005-09-14 02:38:36 +04:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::Y()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2005-09-14 02:38:36 +04:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::Width()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2005-09-14 02:38:36 +04:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::Height()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
|
|
|
}
|
2005-09-14 02:38:36 +04:00
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-01-17 00:51:00 +04:00
|
|
|
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-01-12 20:39:46 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGPatternElement::IsAttributeMapped(const nsAtom* name) const
|
2006-01-12 20:39:46 +03:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2014-04-15 14:48:02 +04:00
|
|
|
sColorMap,
|
2007-01-19 18:20:11 +03:00
|
|
|
sFEFloodMap,
|
2014-04-15 14:48:02 +04:00
|
|
|
sFillStrokeMap,
|
2007-01-30 16:19:55 +03:00
|
|
|
sFiltersMap,
|
2006-10-20 03:48:12 +04:00
|
|
|
sFontSpecificationMap,
|
|
|
|
sGradientStopMap,
|
2014-04-15 14:48:02 +04:00
|
|
|
sGraphicsMap,
|
2007-07-26 10:57:42 +04:00
|
|
|
sLightingEffectsMap,
|
2006-10-20 03:48:12 +04:00
|
|
|
sMarkersMap,
|
|
|
|
sTextContentElementsMap,
|
2007-01-19 18:20:11 +03:00
|
|
|
sViewportsMap
|
2006-01-12 20:39:46 +03:00
|
|
|
};
|
2006-10-20 03:48:12 +04:00
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElementBase::IsAttributeMapped(name);
|
2006-01-12 20:39:46 +03:00
|
|
|
}
|
2006-04-14 19:09:39 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList*
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::GetAnimatedTransformList(uint32_t aFlags)
|
2010-05-28 16:15:56 +04:00
|
|
|
{
|
2012-07-30 04:35:26 +04:00
|
|
|
if (!mPatternTransform && (aFlags & DO_ALLOCATE)) {
|
2013-04-15 02:56:34 +04:00
|
|
|
mPatternTransform = new nsSVGAnimatedTransformList();
|
2010-05-28 16:15:56 +04:00
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
return mPatternTransform;
|
2010-05-28 16:15:56 +04:00
|
|
|
}
|
|
|
|
|
2012-03-03 13:21:09 +04:00
|
|
|
/* virtual */ bool
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::HasValidDimensions() const
|
2012-03-03 13:21:09 +04:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
2013-01-17 00:51:00 +04:00
|
|
|
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
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::GetEnumInfo()
|
2007-08-28 03:11:14 +04:00
|
|
|
{
|
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sEnumInfo));
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
|
2009-02-03 17:42:24 +03:00
|
|
|
nsSVGViewBox *
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::GetViewBox()
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
|
|
|
return &mViewBox;
|
|
|
|
}
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-01-17 00:51:00 +04:00
|
|
|
SVGPatternElement::GetPreserveAspectRatio()
|
2009-01-05 04:19:38 +03:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-01-17 00:51:00 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-01-17 00:51:00 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|