2005-09-13 22:38:36 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/. */
|
2005-09-13 22:38:36 +00:00
|
|
|
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2005-09-13 22:38:36 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2013-04-14 22:56:34 +00:00
|
|
|
#include "mozilla/dom/SVGAnimatedTransformList.h"
|
2013-01-16 20:51:00 +00:00
|
|
|
#include "mozilla/dom/SVGPatternElement.h"
|
2013-01-16 20:51:00 +00:00
|
|
|
#include "mozilla/dom/SVGPatternElementBinding.h"
|
2005-09-13 22:38:36 +00:00
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Pattern)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-12-20 00:45:29 +00:00
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:17 +00:00
|
|
|
SVGPatternElement::WrapNode(JSContext *aCx)
|
2013-01-16 20:51:00 +00: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 22:27:17 +00:00
|
|
|
return SVGPatternElementBinding::Wrap(aCx, this);
|
2013-01-16 20:51:00 +00:00
|
|
|
}
|
|
|
|
|
2005-09-13 22:38:36 +00:00
|
|
|
//--------------------- Patterns ------------------------
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
nsSVGElement::LengthInfo SVGPatternElement::sLengthInfo[4] =
|
2005-09-13 22:38:36 +00:00
|
|
|
{
|
2012-09-22 19:26:05 +00: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 },
|
2005-09-13 22:38:36 +00:00
|
|
|
};
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
nsSVGElement::EnumInfo SVGPatternElement::sEnumInfo[2] =
|
2007-08-27 23:11:14 +00:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::patternUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 02:14:02 +00:00
|
|
|
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
|
2007-08-27 23:11:14 +00:00
|
|
|
},
|
|
|
|
{ &nsGkAtoms::patternContentUnits,
|
|
|
|
sSVGUnitTypesMap,
|
2013-02-18 02:14:02 +00:00
|
|
|
SVG_UNIT_TYPE_USERSPACEONUSE
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
nsSVGElement::StringInfo SVGPatternElement::sStringInfo[1] =
|
2008-06-14 09:01:02 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
2008-06-14 09:01:02 +00:00
|
|
|
};
|
|
|
|
|
2005-09-13 22:38:36 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
SVGPatternElement::SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-16 20:51:00 +00:00
|
|
|
: SVGPatternElementBase(aNodeInfo)
|
2005-09-13 22:38:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode method
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPatternElement)
|
2005-09-13 22:38:36 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-16 20:51:00 +00:00
|
|
|
|
2013-05-09 17:42:12 +00:00
|
|
|
already_AddRefed<SVGAnimatedRect>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::ViewBox()
|
|
|
|
{
|
2013-05-20 11:46:12 +00:00
|
|
|
return mViewBox.ToSVGAnimatedRect(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGPatternElement::PreserveAspectRatio()
|
2005-09-13 22:38:36 +00:00
|
|
|
{
|
2013-01-06 09:32:01 +00:00
|
|
|
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
|
|
|
|
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
|
2013-01-16 20:51:00 +00:00
|
|
|
return ratio.forget();
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-16 20:51:00 +00:00
|
|
|
|
2013-07-01 07:02:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::PatternUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-07-01 07:02:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::PatternContentUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-04-14 22:56:34 +00:00
|
|
|
already_AddRefed<SVGAnimatedTransformList>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::PatternTransform()
|
2005-09-13 22:38:36 +00:00
|
|
|
{
|
2012-07-30 00:35:26 +00: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 22:56:34 +00:00
|
|
|
return SVGAnimatedTransformList::GetDOMWrapper(
|
2013-01-16 20:51:00 +00:00
|
|
|
GetAnimatedTransformList(DO_ALLOCATE), this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::X()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::Y()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::Width()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::Height()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
|
|
|
}
|
2005-09-13 22:38:36 +00:00
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::Href()
|
|
|
|
{
|
2013-03-10 07:58:53 +00:00
|
|
|
return mStringAttributes[HREF].ToDOMAnimatedString(this);
|
2005-09-13 22:38:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 17:39:46 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::IsAttributeMapped(const nsIAtom* name) const
|
2006-01-12 17:39:46 +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,
|
2014-04-15 10:48:02 +00:00
|
|
|
sGraphicsMap,
|
2007-07-26 06:57:42 +00:00
|
|
|
sLightingEffectsMap,
|
2006-10-19 23:48:12 +00:00
|
|
|
sMarkersMap,
|
|
|
|
sTextContentElementsMap,
|
2007-01-19 15:20:11 +00:00
|
|
|
sViewportsMap
|
2006-01-12 17:39:46 +00:00
|
|
|
};
|
2006-10-19 23:48:12 +00:00
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElementBase::IsAttributeMapped(name);
|
2006-01-12 17:39:46 +00:00
|
|
|
}
|
2006-04-14 15:09:39 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-04-14 22:56:34 +00:00
|
|
|
nsSVGAnimatedTransformList*
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::GetAnimatedTransformList(uint32_t aFlags)
|
2010-05-28 12:15:56 +00:00
|
|
|
{
|
2012-07-30 00:35:26 +00:00
|
|
|
if (!mPatternTransform && (aFlags & DO_ALLOCATE)) {
|
2013-04-14 22:56:34 +00:00
|
|
|
mPatternTransform = new nsSVGAnimatedTransformList();
|
2010-05-28 12:15:56 +00:00
|
|
|
}
|
2011-09-25 21:04:31 +00:00
|
|
|
return mPatternTransform;
|
2010-05-28 12:15:56 +00:00
|
|
|
}
|
|
|
|
|
2012-03-03 09:21:09 +00:00
|
|
|
/* virtual */ bool
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::HasValidDimensions() const
|
2012-03-03 09:21:09 +00:00
|
|
|
{
|
2013-01-16 20:51:00 +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-16 20:51:00 +00:00
|
|
|
SVGPatternElement::GetLengthInfo()
|
2006-04-14 15:09:39 +00:00
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sLengthInfo));
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
2006-07-19 15:31:40 +00:00
|
|
|
|
2007-08-27 23:11:14 +00:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::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
|
|
|
}
|
|
|
|
|
2009-02-03 14:42:24 +00:00
|
|
|
nsSVGViewBox *
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::GetViewBox()
|
2009-02-03 14:42:24 +00:00
|
|
|
{
|
|
|
|
return &mViewBox;
|
|
|
|
}
|
|
|
|
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::GetPreserveAspectRatio()
|
2009-01-05 01:19:38 +00:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-01-16 20:51:00 +00:00
|
|
|
SVGPatternElement::GetStringInfo()
|
2008-06-14 09:01:02 +00:00
|
|
|
{
|
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 20:51:00 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|