2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-12-08 18:52:54 -08:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-10 22:50:08 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2013-02-17 15:28:47 -08:00
|
|
|
#include "mozilla/dom/SVGFilterElement.h"
|
2013-02-17 18:14:02 -08:00
|
|
|
#include "mozilla/dom/SVGFilterElementBinding.h"
|
2013-03-11 15:05:58 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-17 15:28:47 -08:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Filter)
|
2011-10-10 22:50:08 -07:00
|
|
|
|
2013-02-17 15:28:47 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-02-17 18:14:02 -08:00
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
SVGFilterElement::WrapNode(JSContext *aCx)
|
2013-02-17 18:14:02 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return SVGFilterElementBinding::Wrap(aCx, this);
|
2013-02-17 18:14:02 -08:00
|
|
|
}
|
|
|
|
|
2013-02-17 15:28:47 -08:00
|
|
|
nsSVGElement::LengthInfo SVGFilterElement::sLengthInfo[4] =
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-09-22 12:26:05 -07: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 },
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-02-17 15:28:47 -08:00
|
|
|
nsSVGElement::EnumInfo SVGFilterElement::sEnumInfo[2] =
|
2007-08-27 16:11:14 -07:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::filterUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-17 18:14:02 -08:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
2007-08-27 16:11:14 -07:00
|
|
|
},
|
|
|
|
{ &nsGkAtoms::primitiveUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-17 18:14:02 -08:00
|
|
|
SVG_UNIT_TYPE_USERSPACEONUSE
|
2007-08-27 16:11:14 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-17 15:28:47 -08:00
|
|
|
nsSVGElement::StringInfo SVGFilterElement::sStringInfo[1] =
|
2008-06-14 02:01:02 -07:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
2008-06-14 02:01:02 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
SVGFilterElement::SVGFilterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-02-17 15:28:47 -08:00
|
|
|
: SVGFilterElementBase(aNodeInfo)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
|
|
|
|
2013-02-17 15:28:47 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFilterElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-02-17 18:14:02 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::X()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-17 18:14:02 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::Y()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-17 18:14:02 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::Width()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-17 18:14:02 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGFilterElement::Height()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-01 00:02:46 -07:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-02-17 18:14:02 -08:00
|
|
|
SVGFilterElement::FilterUnits()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return mEnumAttributes[FILTERUNITS].ToDOMAnimatedEnum(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-01 00:02:46 -07:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-02-17 18:14:02 -08:00
|
|
|
SVGFilterElement::PrimitiveUnits()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return mEnumAttributes[PRIMITIVEUNITS].ToDOMAnimatedEnum(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-06-14 15:37:27 -07:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-02-17 18:14:02 -08:00
|
|
|
SVGFilterElement::Href()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return mStringAttributes[HREF].ToDOMAnimatedString(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-02-17 15:28:47 -08:00
|
|
|
SVGFilterElement::IsAttributeMapped(const nsIAtom* name) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sFEFloodMap,
|
|
|
|
sFiltersMap,
|
|
|
|
sFontSpecificationMap,
|
|
|
|
sGradientStopMap,
|
2007-07-25 23:57:42 -07:00
|
|
|
sLightingEffectsMap,
|
2007-03-22 10:30:00 -07:00
|
|
|
sMarkersMap,
|
|
|
|
sTextContentElementsMap,
|
|
|
|
sViewportsMap
|
|
|
|
};
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-02-17 15:28:47 -08:00
|
|
|
SVGFilterElementBase::IsAttributeMapped(name);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-01-02 12:49:13 -08:00
|
|
|
void
|
2013-02-17 15:28:47 -08:00
|
|
|
SVGFilterElement::Invalidate()
|
2008-01-02 12:49:13 -08:00
|
|
|
{
|
|
|
|
nsTObserverArray<nsIMutationObserver*> *observers = GetMutationObservers();
|
|
|
|
|
|
|
|
if (observers && !observers->IsEmpty()) {
|
|
|
|
nsTObserverArray<nsIMutationObserver*>::ForwardIterator iter(*observers);
|
|
|
|
while (iter.HasMore()) {
|
|
|
|
nsCOMPtr<nsIMutationObserver> obs(iter.GetNext());
|
2014-02-09 20:31:03 -08:00
|
|
|
nsCOMPtr<nsISVGFilterReference> filter = do_QueryInterface(obs);
|
2008-01-02 12:49:13 -08:00
|
|
|
if (filter)
|
|
|
|
filter->Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2012-03-03 01:21:09 -08:00
|
|
|
/* virtual */ bool
|
2013-02-17 15:28:47 -08:00
|
|
|
SVGFilterElement::HasValidDimensions() const
|
2012-03-03 01:21:09 -08:00
|
|
|
{
|
2013-02-17 18:14:02 -08:00
|
|
|
return (!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
|
|
|
(!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
2012-03-03 01:21:09 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
2013-02-17 15:28:47 -08:00
|
|
|
SVGFilterElement::GetLengthInfo()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sLengthInfo));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-08-27 16:11:14 -07:00
|
|
|
|
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-02-17 15:28:47 -08:00
|
|
|
SVGFilterElement::GetEnumInfo()
|
2007-08-27 16:11:14 -07:00
|
|
|
{
|
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sEnumInfo));
|
2007-08-27 16:11:14 -07:00
|
|
|
}
|
2008-06-14 02:01:02 -07:00
|
|
|
|
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-02-17 15:28:47 -08:00
|
|
|
SVGFilterElement::GetStringInfo()
|
2008-06-14 02:01:02 -07:00
|
|
|
{
|
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 02:01:02 -07:00
|
|
|
}
|
2013-02-17 15:28:47 -08:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|