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/. */
|
2004-12-09 03:16:15 +00:00
|
|
|
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2004-12-09 03:16:15 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2010-12-20 00:45:29 +00:00
|
|
|
#include "SVGAnimatedPreserveAspectRatio.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2013-01-29 22:11:44 +00:00
|
|
|
#include "mozilla/dom/SVGAngle.h"
|
2013-01-29 22:11:44 +00:00
|
|
|
#include "mozilla/dom/SVGMarkerElement.h"
|
2013-01-29 22:11:44 +00:00
|
|
|
#include "mozilla/dom/SVGMarkerElementBinding.h"
|
2013-07-12 06:39:38 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-12-30 06:50:17 +00:00
|
|
|
#include "mozilla/gfx/Matrix.h"
|
2014-10-01 09:26:00 +00:00
|
|
|
#include "mozilla/FloatingPoint.h"
|
2012-09-22 19:26:05 +00:00
|
|
|
#include "SVGContentUtils.h"
|
2004-12-09 03:16:15 +00:00
|
|
|
|
2014-09-10 13:26:12 +00:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Marker)
|
2010-12-20 00:45:29 +00:00
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-01-29 22:11:44 +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
|
|
|
SVGMarkerElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-29 22:11:44 +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 SVGMarkerElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-29 22:11:44 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
nsSVGElement::LengthInfo SVGMarkerElement::sLengthInfo[4] =
|
2004-12-09 03:16:15 +00:00
|
|
|
{
|
2012-09-22 19:26:05 +00:00
|
|
|
{ &nsGkAtoms::refX, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::refY, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
|
|
|
{ &nsGkAtoms::markerWidth, 3, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::markerHeight, 3, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
2004-12-09 03:16:15 +00:00
|
|
|
};
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
nsSVGEnumMapping SVGMarkerElement::sUnitsMap[] = {
|
2013-02-18 22:48:54 +00:00
|
|
|
{&nsGkAtoms::strokeWidth, SVG_MARKERUNITS_STROKEWIDTH},
|
|
|
|
{&nsGkAtoms::userSpaceOnUse, SVG_MARKERUNITS_USERSPACEONUSE},
|
2012-07-30 14:20:58 +00:00
|
|
|
{nullptr, 0}
|
2007-08-27 23:11:14 +00:00
|
|
|
};
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
nsSVGElement::EnumInfo SVGMarkerElement::sEnumInfo[1] =
|
2007-08-27 23:11:14 +00:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::markerUnits,
|
|
|
|
sUnitsMap,
|
2013-02-18 22:48:54 +00:00
|
|
|
SVG_MARKERUNITS_STROKEWIDTH
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
nsSVGElement::AngleInfo SVGMarkerElement::sAngleInfo[1] =
|
2007-10-10 10:07:59 +00:00
|
|
|
{
|
2012-12-23 04:54:23 +00:00
|
|
|
{ &nsGkAtoms::orient, 0, SVG_ANGLETYPE_UNSPECIFIED }
|
2007-10-10 10:07:59 +00:00
|
|
|
};
|
|
|
|
|
2004-12-09 03:16:15 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2008-01-09 09:52:14 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGOrientType::SetBaseValue(uint16_t aValue,
|
2008-01-09 09:52:14 +00:00
|
|
|
nsSVGElement *aSVGElement)
|
|
|
|
{
|
2013-07-12 06:39:38 +00:00
|
|
|
if (aValue == SVG_MARKER_ORIENT_AUTO_START_REVERSE &&
|
|
|
|
!SVGMarkerElement::MarkerImprovementsPrefEnabled()) {
|
|
|
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aValue == SVG_MARKER_ORIENT_AUTO ||
|
|
|
|
aValue == SVG_MARKER_ORIENT_ANGLE ||
|
|
|
|
aValue == SVG_MARKER_ORIENT_AUTO_START_REVERSE) {
|
2008-01-09 09:52:14 +00:00
|
|
|
SetBaseValue(aValue);
|
|
|
|
aSVGElement->SetAttr(
|
2012-07-30 14:20:58 +00:00
|
|
|
kNameSpaceID_None, nsGkAtoms::orient, nullptr,
|
2013-02-18 22:48:54 +00:00
|
|
|
(aValue == SVG_MARKER_ORIENT_AUTO ?
|
2013-07-12 06:39:38 +00:00
|
|
|
NS_LITERAL_STRING("auto") :
|
|
|
|
aValue == SVG_MARKER_ORIENT_ANGLE ?
|
|
|
|
NS_LITERAL_STRING("0") :
|
|
|
|
NS_LITERAL_STRING("auto-start-reverse")),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2008-01-09 09:52:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-01-20 19:58:58 +00:00
|
|
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
2008-01-09 09:52:14 +00:00
|
|
|
}
|
|
|
|
|
2013-07-01 07:02:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-29 22:11:44 +00:00
|
|
|
nsSVGOrientType::ToDOMAnimatedEnum(nsSVGElement *aSVGElement)
|
2008-01-09 09:52:14 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SVGAnimatedEnumeration> toReturn =
|
2013-01-29 22:11:44 +00:00
|
|
|
new DOMAnimatedEnum(this, aSVGElement);
|
|
|
|
return toReturn.forget();
|
2008-01-09 09:52:14 +00:00
|
|
|
}
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
SVGMarkerElement::SVGMarkerElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-29 22:11:44 +00:00
|
|
|
: SVGMarkerElementBase(aNodeInfo), mCoordCtx(nullptr)
|
2004-12-09 03:16:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMarkerElement)
|
2004-12-09 03:16:15 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-29 22:11:44 +00:00
|
|
|
|
2013-05-09 17:42:12 +00:00
|
|
|
already_AddRefed<SVGAnimatedRect>
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::ViewBox()
|
|
|
|
{
|
2013-05-20 11:46:12 +00:00
|
|
|
return mViewBox.ToSVGAnimatedRect(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGMarkerElement::PreserveAspectRatio()
|
2004-12-09 03:16:15 +00:00
|
|
|
{
|
2015-01-27 09:51:34 +00:00
|
|
|
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-29 22:11:44 +00:00
|
|
|
|
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMarkerElement::RefX()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[REFX].ToDOMAnimatedLength(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMarkerElement::RefY()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[REFY].ToDOMAnimatedLength(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-07-01 07:02:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::MarkerUnits()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[MARKERUNITS].ToDOMAnimatedEnum(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMarkerElement::MarkerWidth()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[MARKERWIDTH].ToDOMAnimatedLength(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
SVGMarkerElement::MarkerHeight()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[MARKERHEIGHT].ToDOMAnimatedLength(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-07-01 07:02:46 +00:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::OrientType()
|
|
|
|
{
|
|
|
|
return mOrientType.ToDOMAnimatedEnum(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
already_AddRefed<SVGAnimatedAngle>
|
|
|
|
SVGMarkerElement::OrientAngle()
|
|
|
|
{
|
|
|
|
return mAngleAttributes[ORIENT].ToDOMAnimatedAngle(this);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 22:48:54 +00:00
|
|
|
void SVGMarkerElement::SetOrientToAuto()
|
2004-12-09 03:16:15 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
SetAttr(kNameSpaceID_None, nsGkAtoms::orient, nullptr,
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_LITERAL_STRING("auto"), true);
|
2013-01-29 22:11:44 +00:00
|
|
|
}
|
2013-01-29 09:45:50 +00:00
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
void
|
|
|
|
SVGMarkerElement::SetOrientToAngle(SVGAngle& angle, ErrorResult& rv)
|
|
|
|
{
|
|
|
|
float f = angle.Value();
|
2014-10-01 09:26:00 +00:00
|
|
|
if (!IsFinite(f)) {
|
2013-01-29 22:11:44 +00:00
|
|
|
rv.Throw(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR);
|
|
|
|
return;
|
|
|
|
}
|
2015-07-13 06:08:00 +00:00
|
|
|
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_ANGLE);
|
2013-01-29 22:11:44 +00:00
|
|
|
mAngleAttributes[ORIENT].SetBaseValue(f, this, true);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-26 21:02:25 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::IsAttributeMapped(const nsIAtom* name) const
|
2006-04-26 21:02:25 +00:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2007-01-19 15:20:11 +00:00
|
|
|
sFEFloodMap,
|
2007-01-30 13:19:55 +00:00
|
|
|
sFiltersMap,
|
2006-10-19 23:48:12 +00:00
|
|
|
sFontSpecificationMap,
|
|
|
|
sGradientStopMap,
|
2007-07-26 06:57:42 +00:00
|
|
|
sLightingEffectsMap,
|
2006-10-19 23:48:12 +00:00
|
|
|
sMarkersMap,
|
|
|
|
sTextContentElementsMap,
|
2013-01-29 22:11:44 +00:00
|
|
|
sViewportsMap,
|
|
|
|
sColorMap,
|
|
|
|
sFillStrokeMap,
|
|
|
|
sGraphicsMap
|
2006-04-26 21:02:25 +00:00
|
|
|
};
|
2006-10-19 23:48:12 +00:00
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElementBase::IsAttributeMapped(name);
|
2006-04-26 21:02:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2007-02-15 00:33:45 +00:00
|
|
|
// nsSVGElement methods
|
2006-04-26 21:02:25 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::ParseAttribute(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2007-08-27 23:11:14 +00:00
|
|
|
{
|
2007-09-14 22:12:20 +00:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::orient) {
|
2007-11-20 11:36:39 +00:00
|
|
|
if (aValue.EqualsLiteral("auto")) {
|
|
|
|
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO);
|
|
|
|
aResult.SetTo(aValue);
|
2015-07-13 06:08:00 +00:00
|
|
|
mAngleAttributes[ORIENT].SetBaseValue(0.f, this, false);
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2007-11-20 11:36:39 +00:00
|
|
|
}
|
2013-07-12 06:39:38 +00:00
|
|
|
if (aValue.EqualsLiteral("auto-start-reverse") &&
|
|
|
|
MarkerImprovementsPrefEnabled()) {
|
|
|
|
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO_START_REVERSE);
|
|
|
|
aResult.SetTo(aValue);
|
2015-07-13 06:08:00 +00:00
|
|
|
mAngleAttributes[ORIENT].SetBaseValue(0.f, this, false);
|
2013-07-12 06:39:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-11-20 11:36:39 +00:00
|
|
|
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_ANGLE);
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
2013-01-29 22:11:44 +00:00
|
|
|
return SVGMarkerElementBase::ParseAttribute(aNameSpaceID, aName,
|
|
|
|
aValue, aResult);
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
|
2006-04-26 21:02:25 +00:00
|
|
|
nsresult
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::UnsetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
|
|
|
bool aNotify)
|
2006-04-26 21:02:25 +00:00
|
|
|
{
|
2007-08-27 23:11:14 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2011-09-21 07:53:09 +00:00
|
|
|
if (aName == nsGkAtoms::orient) {
|
2007-10-10 10:07:59 +00:00
|
|
|
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_ANGLE);
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
2006-04-26 21:02:25 +00:00
|
|
|
}
|
|
|
|
|
2013-01-06 06:25:52 +00:00
|
|
|
return nsSVGElement::UnsetAttr(aNamespaceID, aName, aNotify);
|
2006-04-26 21:02:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
void
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::SetParentCoordCtxProvider(SVGSVGElement *aContext)
|
2006-07-26 12:33:24 +00:00
|
|
|
{
|
|
|
|
mCoordCtx = aContext;
|
2012-07-30 14:20:58 +00:00
|
|
|
mViewBoxToViewportTransform = nullptr;
|
2006-07-26 12:33:24 +00:00
|
|
|
}
|
|
|
|
|
2012-03-03 09:21:09 +00:00
|
|
|
/* virtual */ bool
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::HasValidDimensions() const
|
2012-03-03 09:21:09 +00:00
|
|
|
{
|
|
|
|
return (!mLengthAttributes[MARKERWIDTH].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[MARKERWIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
|
|
|
(!mLengthAttributes[MARKERHEIGHT].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[MARKERHEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
|
|
|
}
|
|
|
|
|
2006-04-26 21:02:25 +00:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::GetLengthInfo()
|
2006-04-26 21:02:25 +00:00
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sLengthInfo));
|
2006-04-26 21:02:25 +00:00
|
|
|
}
|
|
|
|
|
2007-10-10 10:07:59 +00:00
|
|
|
nsSVGElement::AngleAttributesInfo
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::GetAngleInfo()
|
2007-10-10 10:07:59 +00:00
|
|
|
{
|
|
|
|
return AngleAttributesInfo(mAngleAttributes, sAngleInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sAngleInfo));
|
2007-10-10 10:07:59 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 23:11:14 +00:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::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-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::GetViewBox()
|
2009-02-03 14:42:24 +00:00
|
|
|
{
|
|
|
|
return &mViewBox;
|
|
|
|
}
|
|
|
|
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::GetPreserveAspectRatio()
|
2009-01-05 01:19:38 +00:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2006-04-26 21:02:25 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// public helpers
|
|
|
|
|
2013-12-30 06:50:08 +00:00
|
|
|
gfx::Matrix
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
2013-07-12 06:39:38 +00:00
|
|
|
float aX, float aY, float aAutoAngle,
|
|
|
|
bool aIsStart)
|
2004-12-09 03:16:15 +00:00
|
|
|
{
|
2014-03-18 02:41:35 +00:00
|
|
|
float scale = mEnumAttributes[MARKERUNITS].GetAnimValue() ==
|
|
|
|
SVG_MARKERUNITS_STROKEWIDTH ? aStrokeWidth : 1.0f;
|
2004-12-09 03:16:15 +00:00
|
|
|
|
2014-03-18 02:41:35 +00:00
|
|
|
float angle;
|
2013-07-12 06:39:38 +00:00
|
|
|
switch (mOrientType.GetAnimValueInternal()) {
|
|
|
|
case SVG_MARKER_ORIENT_AUTO:
|
|
|
|
angle = aAutoAngle;
|
|
|
|
break;
|
|
|
|
case SVG_MARKER_ORIENT_AUTO_START_REVERSE:
|
2014-03-18 02:41:35 +00:00
|
|
|
angle = aAutoAngle + (aIsStart ? M_PI : 0.0f);
|
2013-07-12 06:39:38 +00:00
|
|
|
break;
|
|
|
|
default: // SVG_MARKER_ORIENT_ANGLE
|
2014-03-18 02:41:35 +00:00
|
|
|
angle = mAngleAttributes[ORIENT].GetAnimValue() * M_PI / 180.0f;
|
2013-07-12 06:39:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-12-09 03:16:15 +00:00
|
|
|
|
2013-12-30 06:50:08 +00:00
|
|
|
return gfx::Matrix(cos(angle) * scale, sin(angle) * scale,
|
|
|
|
-sin(angle) * scale, cos(angle) * scale,
|
|
|
|
aX, aY);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2011-09-21 07:53:09 +00:00
|
|
|
nsSVGViewBoxRect
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::GetViewBoxRect()
|
2011-09-21 07:53:09 +00:00
|
|
|
{
|
2013-02-26 16:58:06 +00:00
|
|
|
if (mViewBox.HasRect()) {
|
2011-09-21 07:53:09 +00:00
|
|
|
return mViewBox.GetAnimValue();
|
|
|
|
}
|
|
|
|
return nsSVGViewBoxRect(
|
|
|
|
0, 0,
|
|
|
|
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx),
|
|
|
|
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
|
|
|
|
}
|
|
|
|
|
2013-12-30 06:50:17 +00:00
|
|
|
gfx::Matrix
|
2013-01-29 22:11:44 +00:00
|
|
|
SVGMarkerElement::GetViewBoxTransform()
|
2004-12-09 03:16:15 +00:00
|
|
|
{
|
|
|
|
if (!mViewBoxToViewportTransform) {
|
2006-04-14 15:09:39 +00:00
|
|
|
float viewportWidth =
|
|
|
|
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
|
|
|
|
float viewportHeight =
|
|
|
|
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx);
|
2013-12-30 06:50:17 +00:00
|
|
|
|
2011-09-21 07:53:09 +00:00
|
|
|
nsSVGViewBoxRect viewbox = GetViewBoxRect();
|
2009-02-03 14:42:24 +00:00
|
|
|
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(viewbox.width > 0.0f && viewbox.height > 0.0f,
|
|
|
|
"Rendering should be disabled");
|
2004-12-09 03:16:15 +00:00
|
|
|
|
2013-12-30 06:50:17 +00:00
|
|
|
gfx::Matrix viewBoxTM =
|
2013-03-03 08:11:03 +00:00
|
|
|
SVGContentUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
2012-09-22 19:26:05 +00:00
|
|
|
viewbox.x, viewbox.y,
|
|
|
|
viewbox.width, viewbox.height,
|
|
|
|
mPreserveAspectRatio);
|
2009-07-23 08:35:59 +00:00
|
|
|
|
2011-09-21 07:53:09 +00:00
|
|
|
float refX = mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
|
|
|
|
float refY = mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
|
|
|
|
|
2016-09-08 16:26:03 +00:00
|
|
|
gfx::Point ref = viewBoxTM.TransformPoint(gfx::Point(refX, refY));
|
2009-07-23 08:35:59 +00:00
|
|
|
|
2014-09-10 13:26:12 +00:00
|
|
|
Matrix TM = viewBoxTM;
|
|
|
|
TM.PostTranslate(-ref.x, -ref.y);
|
2009-07-23 08:35:59 +00:00
|
|
|
|
2013-12-30 06:50:17 +00:00
|
|
|
mViewBoxToViewportTransform = new gfx::Matrix(TM);
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 21:04:31 +00:00
|
|
|
return *mViewBoxToViewportTransform;
|
2004-12-09 03:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-07-12 06:39:38 +00:00
|
|
|
/* static */ bool
|
|
|
|
SVGMarkerElement::MarkerImprovementsPrefEnabled()
|
|
|
|
{
|
|
|
|
return Preferences::GetBool("svg.marker-improvements.enabled", false);
|
|
|
|
}
|
|
|
|
|
2013-01-29 22:11:44 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|