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 "nsCOMPtr.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2013-04-14 15:56:34 -07:00
|
|
|
#include "mozilla/dom/SVGAnimatedTransformList.h"
|
2013-01-16 12:51:00 -08:00
|
|
|
#include "mozilla/dom/SVGPatternElement.h"
|
2013-01-16 12:51:00 -08:00
|
|
|
#include "mozilla/dom/SVGPatternElementBinding.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-16 12:51:00 -08:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Pattern)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-12-19 16:45:29 -08:00
|
|
|
|
2013-01-16 12:51:00 -08:00
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
SVGPatternElement::WrapNode(JSContext *aCx)
|
2013-01-16 12:51:00 -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 SVGPatternElementBinding::Wrap(aCx, this);
|
2013-01-16 12:51:00 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//--------------------- Patterns ------------------------
|
|
|
|
|
2013-01-16 12:51:00 -08:00
|
|
|
nsSVGElement::LengthInfo SVGPatternElement::sLengthInfo[4] =
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-09-22 12:26:05 -07:00
|
|
|
{ &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
|
|
|
|
{ &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-01-16 12:51:00 -08:00
|
|
|
nsSVGElement::EnumInfo SVGPatternElement::sEnumInfo[2] =
|
2007-08-27 16:11:14 -07:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::patternUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-17 18:14:02 -08:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
2007-08-27 16:11:14 -07:00
|
|
|
},
|
|
|
|
{ &nsGkAtoms::patternContentUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-17 18:14:02 -08:00
|
|
|
SVG_UNIT_TYPE_USERSPACEONUSE
|
2007-08-27 16:11:14 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-16 12:51:00 -08:00
|
|
|
nsSVGElement::StringInfo SVGPatternElement::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
|
|
|
SVGPatternElement::SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-16 12:51:00 -08:00
|
|
|
: SVGPatternElementBase(aNodeInfo)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode method
|
|
|
|
|
2013-01-16 12:51:00 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPatternElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-16 12:51:00 -08:00
|
|
|
|
2013-05-09 10:42:12 -07:00
|
|
|
already_AddRefed<SVGAnimatedRect>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::ViewBox()
|
|
|
|
{
|
2013-05-20 04:46:12 -07:00
|
|
|
return mViewBox.ToSVGAnimatedRect(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-16 12:51:00 -08:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGPatternElement::PreserveAspectRatio()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-06 01:32:01 -08:00
|
|
|
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
|
|
|
|
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
|
2013-01-16 12:51:00 -08:00
|
|
|
return ratio.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-16 12:51:00 -08:00
|
|
|
|
2013-07-01 00:02:46 -07:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::PatternUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-01 00:02:46 -07:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::PatternContentUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
already_AddRefed<SVGAnimatedTransformList>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::PatternTransform()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-29 17:35:26 -07: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-14 15:56:34 -07:00
|
|
|
return SVGAnimatedTransformList::GetDOMWrapper(
|
2013-01-16 12:51:00 -08:00
|
|
|
GetAnimatedTransformList(DO_ALLOCATE), this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::X()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::Y()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::Width()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::Height()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-06-14 15:37:27 -07:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::Href()
|
|
|
|
{
|
2013-03-09 23:58:53 -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-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::IsAttributeMapped(const nsIAtom* name) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2014-04-15 03:48:02 -07:00
|
|
|
sColorMap,
|
2007-03-22 10:30:00 -07:00
|
|
|
sFEFloodMap,
|
2014-04-15 03:48:02 -07:00
|
|
|
sFillStrokeMap,
|
2007-03-22 10:30:00 -07:00
|
|
|
sFiltersMap,
|
|
|
|
sFontSpecificationMap,
|
|
|
|
sGradientStopMap,
|
2014-04-15 03:48:02 -07:00
|
|
|
sGraphicsMap,
|
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-01-16 12:51:00 -08:00
|
|
|
SVGPatternElementBase::IsAttributeMapped(name);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
nsSVGAnimatedTransformList*
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::GetAnimatedTransformList(uint32_t aFlags)
|
2010-05-28 05:15:56 -07:00
|
|
|
{
|
2012-07-29 17:35:26 -07:00
|
|
|
if (!mPatternTransform && (aFlags & DO_ALLOCATE)) {
|
2013-04-14 15:56:34 -07:00
|
|
|
mPatternTransform = new nsSVGAnimatedTransformList();
|
2010-05-28 05:15:56 -07:00
|
|
|
}
|
2011-09-25 14:04:31 -07:00
|
|
|
return mPatternTransform;
|
2010-05-28 05:15:56 -07:00
|
|
|
}
|
|
|
|
|
2012-03-03 01:21:09 -08:00
|
|
|
/* virtual */ bool
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::HasValidDimensions() const
|
2012-03-03 01:21:09 -08:00
|
|
|
{
|
2013-01-16 12:51:00 -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-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::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-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::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
|
|
|
}
|
|
|
|
|
2009-02-03 06:42:24 -08:00
|
|
|
nsSVGViewBox *
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::GetViewBox()
|
2009-02-03 06:42:24 -08:00
|
|
|
{
|
|
|
|
return &mViewBox;
|
|
|
|
}
|
|
|
|
|
2010-12-19 16:45:29 -08:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::GetPreserveAspectRatio()
|
2009-01-04 17:19:38 -08:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2008-06-14 02:01:02 -07:00
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-01-16 12:51:00 -08:00
|
|
|
SVGPatternElement::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-01-16 12:51:00 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|