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/. */
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2006-01-20 17:00:43 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2013-01-23 20:59:06 +00:00
|
|
|
#include "mozilla/dom/SVGMaskElement.h"
|
2013-01-23 20:59:46 +00:00
|
|
|
#include "mozilla/dom/SVGMaskElementBinding.h"
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2013-01-23 20:59:06 +00:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Mask)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2013-01-23 20:59:46 +00: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 14:13:33 +00:00
|
|
|
SVGMaskElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-23 20:59:46 +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
|
|
|
return SVGMaskElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-23 20:59:46 +00:00
|
|
|
}
|
|
|
|
|
2006-01-20 17:00:43 +00:00
|
|
|
//--------------------- Masks ------------------------
|
|
|
|
|
2013-01-23 20:59:06 +00:00
|
|
|
nsSVGElement::LengthInfo SVGMaskElement::sLengthInfo[4] =
|
2006-01-20 17:00:43 +00:00
|
|
|
{
|
2012-09-22 19:26:05 +00:00
|
|
|
{ &nsGkAtoms::x, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::y, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
|
|
|
|
{ &nsGkAtoms::width, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::height, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
|
2006-01-20 17:00:43 +00:00
|
|
|
};
|
|
|
|
|
2013-01-23 20:59:06 +00:00
|
|
|
nsSVGElement::EnumInfo SVGMaskElement::sEnumInfo[2] =
|
2007-08-27 23:11:14 +00:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::maskUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 02:14:02 +00:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
2007-08-27 23:11:14 +00:00
|
|
|
},
|
|
|
|
{ &nsGkAtoms::maskContentUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 02:14:02 +00:00
|
|
|
SVG_UNIT_TYPE_USERSPACEONUSE
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-01-20 17:00:43 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
SVGMaskElement::SVGMaskElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-23 20:59:06 +00:00
|
|
|
: SVGMaskElementBase(aNodeInfo)
|
2006-01-20 17:00:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode method
|
|
|
|
|
2013-01-23 20:59:06 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMaskElement)
|
2006-01-20 17:00:43 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-23 20:59:46 +00:00
|
|
|
|
2013-07-01 07:02:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-23 20:59:46 +00:00
|
|
|
SVGMaskElement::MaskUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[MASKUNITS].ToDOMAnimatedEnum(this);
|
2006-01-20 17:00:43 +00:00
|
|
|
}
|
|
|
|
|
2013-07-01 07:02:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-23 20:59:46 +00:00
|
|
|
SVGMaskElement::MaskContentUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[MASKCONTENTUNITS].ToDOMAnimatedEnum(this);
|
2006-01-20 17:00:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 20:59:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMaskElement::X()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2006-01-20 17:00:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 20:59:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMaskElement::Y()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2006-01-20 17:00:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 20:59:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMaskElement::Width()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2006-01-20 17:00:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 20:59:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMaskElement::Height()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2012-03-03 09:21:09 +00:00
|
|
|
/* virtual */ bool
|
2013-01-23 20:59:06 +00:00
|
|
|
SVGMaskElement::HasValidDimensions() const
|
2012-03-03 09:21:09 +00:00
|
|
|
{
|
2013-01-23 20:59:46 +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
|
|
|
}
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
2013-01-23 20:59:06 +00:00
|
|
|
SVGMaskElement::GetLengthInfo()
|
2006-04-14 15:09:39 +00:00
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sLengthInfo));
|
2006-01-20 17:00:43 +00:00
|
|
|
}
|
2006-10-19 23:48:12 +00:00
|
|
|
|
2007-08-27 23:11:14 +00:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-01-23 20:59:06 +00:00
|
|
|
SVGMaskElement::GetEnumInfo()
|
2007-08-27 23:11:14 +00:00
|
|
|
{
|
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sEnumInfo));
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
|
2006-10-19 23:48:12 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-23 20:59:06 +00:00
|
|
|
SVGMaskElement::IsAttributeMapped(const nsIAtom* name) const
|
2006-10-19 23:48:12 +00:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2014-04-15 10:48:02 +00:00
|
|
|
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,
|
2011-09-29 14:03:21 +00:00
|
|
|
sGraphicsMap,
|
2006-10-19 23:48:12 +00:00
|
|
|
sMarkersMap,
|
2012-12-21 00:15:22 +00:00
|
|
|
sMaskMap,
|
2006-10-19 23:48:12 +00:00
|
|
|
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-23 20:59:06 +00:00
|
|
|
SVGMaskElementBase::IsAttributeMapped(name);
|
2006-10-19 23:48:12 +00:00
|
|
|
}
|
2013-01-23 20:59:06 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|