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