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-07 02:30:40 +04:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2005-09-07 02:30:40 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2013-02-18 03:28:47 +04:00
|
|
|
#include "mozilla/dom/SVGFilterElement.h"
|
2013-02-18 06:14:02 +04:00
|
|
|
#include "mozilla/dom/SVGFilterElementBinding.h"
|
2013-03-12 02:05:58 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-18 03:28:47 +04:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Filter)
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2013-02-18 03:28:47 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-02-18 06:14:02 +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
|
|
|
SVGFilterElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-02-18 06:14:02 +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 SVGFilterElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-18 06:14:02 +04:00
|
|
|
}
|
|
|
|
|
2013-02-18 03:28:47 +04:00
|
|
|
nsSVGElement::LengthInfo SVGFilterElement::sLengthInfo[4] =
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
2012-09-22 23:26:05 +04: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 },
|
2005-09-07 02:30:40 +04:00
|
|
|
};
|
|
|
|
|
2013-02-18 03:28:47 +04:00
|
|
|
nsSVGElement::EnumInfo SVGFilterElement::sEnumInfo[2] =
|
2007-08-28 03:11:14 +04:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::filterUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 06:14:02 +04:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
2007-08-28 03:11:14 +04:00
|
|
|
},
|
|
|
|
{ &nsGkAtoms::primitiveUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 06:14:02 +04:00
|
|
|
SVG_UNIT_TYPE_USERSPACEONUSE
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-07-05 13:18:51 +03:00
|
|
|
nsSVGElement::StringInfo SVGFilterElement::sStringInfo[2] =
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
2016-07-05 13:18:51 +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-07 02:30:40 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
SVGFilterElement::SVGFilterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-02-18 03:28:47 +04:00
|
|
|
: SVGFilterElementBase(aNodeInfo)
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
|
|
|
|
2013-02-18 03:28:47 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFilterElement)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-02-18 06:14:02 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::X()
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
2013-02-18 06:14:02 +04:00
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:14:02 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::Y()
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
2013-02-18 06:14:02 +04:00
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:14:02 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::Width()
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
2013-02-18 06:14:02 +04:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:14:02 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::Height()
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
2013-02-18 06:14:02 +04:00
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-02-18 06:14:02 +04:00
|
|
|
SVGFilterElement::FilterUnits()
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
2013-02-18 06:14:02 +04:00
|
|
|
return mEnumAttributes[FILTERUNITS].ToDOMAnimatedEnum(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-02-18 06:14:02 +04:00
|
|
|
SVGFilterElement::PrimitiveUnits()
|
2005-09-07 02:30:40 +04:00
|
|
|
{
|
2013-02-18 06:14:02 +04:00
|
|
|
return mEnumAttributes[PRIMITIVEUNITS].ToDOMAnimatedEnum(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-02-18 06:14:02 +04:00
|
|
|
SVGFilterElement::Href()
|
2007-02-19 16:23:54 +03:00
|
|
|
{
|
2016-07-05 13:18:51 +03:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
|
2007-02-19 16:23:54 +03:00
|
|
|
}
|
|
|
|
|
2005-09-07 02:30:40 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-02-18 03:28:47 +04:00
|
|
|
SVGFilterElement::IsAttributeMapped(const nsIAtom* name) const
|
2006-10-20 03:48:12 +04:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2007-01-19 18:20:11 +03:00
|
|
|
sFEFloodMap,
|
2007-01-30 16:19:55 +03:00
|
|
|
sFiltersMap,
|
2006-10-20 03:48:12 +04:00
|
|
|
sFontSpecificationMap,
|
|
|
|
sGradientStopMap,
|
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-10-20 03:48:12 +04:00
|
|
|
};
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-02-18 03:28:47 +04:00
|
|
|
SVGFilterElementBase::IsAttributeMapped(name);
|
2006-10-20 03:48:12 +04:00
|
|
|
}
|
|
|
|
|
2008-01-02 23:49:13 +03:00
|
|
|
void
|
2013-02-18 03:28:47 +04:00
|
|
|
SVGFilterElement::Invalidate()
|
2008-01-02 23:49:13 +03:00
|
|
|
{
|
|
|
|
nsTObserverArray<nsIMutationObserver*> *observers = GetMutationObservers();
|
|
|
|
|
|
|
|
if (observers && !observers->IsEmpty()) {
|
|
|
|
nsTObserverArray<nsIMutationObserver*>::ForwardIterator iter(*observers);
|
|
|
|
while (iter.HasMore()) {
|
|
|
|
nsCOMPtr<nsIMutationObserver> obs(iter.GetNext());
|
2014-02-10 08:31:03 +04:00
|
|
|
nsCOMPtr<nsISVGFilterReference> filter = do_QueryInterface(obs);
|
2008-01-02 23:49:13 +03:00
|
|
|
if (filter)
|
|
|
|
filter->Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2012-03-03 13:21:09 +04:00
|
|
|
/* virtual */ bool
|
2013-02-18 03:28:47 +04:00
|
|
|
SVGFilterElement::HasValidDimensions() const
|
2012-03-03 13:21:09 +04:00
|
|
|
{
|
2013-02-18 06:14:02 +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-02-18 03:28:47 +04:00
|
|
|
SVGFilterElement::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
|
|
|
}
|
2007-08-28 03:11:14 +04:00
|
|
|
|
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-02-18 03:28:47 +04:00
|
|
|
SVGFilterElement::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
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
|
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-02-18 03:28:47 +04:00
|
|
|
SVGFilterElement::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-02-18 03:28:47 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|