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