mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-03 05:47:29 +09:00
Issue #2737 - Part 1: Base implementation of SVGGeometryElement.
Mostly mechanical changes to generalize path geometry for all SVG draw elements. No user-exposed changes.
This commit is contained in:
parent
8ae2b45691
commit
fd4a224d1d
45 changed files with 368 additions and 319 deletions
|
|
@ -79,7 +79,7 @@ SVGCircleElement::GetLengthInfo()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
bool
|
||||
SVGCircleElement::GetGeometryBounds(Rect* aBounds,
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@
|
|||
#ifndef mozilla_dom_SVGCircleElement_h
|
||||
#define mozilla_dom_SVGCircleElement_h
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
nsresult NS_NewSVGCircleElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
||||
|
||||
typedef nsSVGPathGeometryElement SVGCircleElementBase;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef SVGGeometryElement SVGCircleElementBase;
|
||||
|
||||
class SVGCircleElement final : public SVGCircleElementBase
|
||||
{
|
||||
protected:
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const override;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aToBoundsSpace,
|
||||
const Matrix* aToNonScalingStrokeSpace = nullptr) override;
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ SVGEllipseElement::GetLengthInfo()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
bool
|
||||
SVGEllipseElement::GetGeometryBounds(Rect* aBounds,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef mozilla_dom_SVGEllipseElement_h
|
||||
#define mozilla_dom_SVGEllipseElement_h
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
nsresult NS_NewSVGEllipseElement(nsIContent **aResult,
|
||||
|
|
@ -15,7 +15,7 @@ nsresult NS_NewSVGEllipseElement(nsIContent **aResult,
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef nsSVGPathGeometryElement SVGEllipseElementBase;
|
||||
typedef SVGGeometryElement SVGEllipseElementBase;
|
||||
|
||||
class SVGEllipseElement final : public SVGEllipseElementBase
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const override;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aToBoundsSpace,
|
||||
const Matrix* aToNonScalingStrokeSpace = nullptr) override;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
* 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/. */
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
|
||||
#include "DOMSVGPoint.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
|
|
@ -15,16 +16,25 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
nsSVGElement::NumberInfo SVGGeometryElement::sNumberInfo =
|
||||
{ &nsGkAtoms::pathLength, 0, false };
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGPathGeometryElement::nsSVGPathGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: nsSVGPathGeometryElementBase(aNodeInfo)
|
||||
SVGGeometryElement::SVGGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: SVGGeometryElementBase(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
nsSVGElement::NumberAttributesInfo
|
||||
SVGGeometryElement::GetNumberInfo()
|
||||
{
|
||||
return NumberAttributesInfo(&mPathLength, &sNumberInfo, 1);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGPathGeometryElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
SVGGeometryElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue,
|
||||
const nsAttrValue* aOldValue, bool aNotify)
|
||||
{
|
||||
|
|
@ -33,13 +43,17 @@ nsSVGPathGeometryElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
|||
AttributeDefinesGeometry(aName)) {
|
||||
mCachedPath = nullptr;
|
||||
}
|
||||
return nsSVGPathGeometryElementBase::AfterSetAttr(aNamespaceID, aName,
|
||||
aValue, aOldValue, aNotify);
|
||||
return SVGGeometryElementBase::AfterSetAttr(aNamespaceID, aName,
|
||||
aValue, aOldValue, aNotify);
|
||||
}
|
||||
|
||||
bool
|
||||
nsSVGPathGeometryElement::AttributeDefinesGeometry(const nsIAtom *aName)
|
||||
SVGGeometryElement::AttributeDefinesGeometry(const nsIAtom *aName)
|
||||
{
|
||||
if (aName == nsGkAtoms::pathLength) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for nsSVGLength2 attribute
|
||||
LengthAttributesInfo info = GetLengthInfo();
|
||||
for (uint32_t i = 0; i < info.mLengthCount; i++) {
|
||||
|
|
@ -52,10 +66,10 @@ nsSVGPathGeometryElement::AttributeDefinesGeometry(const nsIAtom *aName)
|
|||
}
|
||||
|
||||
bool
|
||||
nsSVGPathGeometryElement::GeometryDependsOnCoordCtx()
|
||||
SVGGeometryElement::GeometryDependsOnCoordCtx()
|
||||
{
|
||||
// Check the nsSVGLength2 attribute
|
||||
LengthAttributesInfo info = const_cast<nsSVGPathGeometryElement*>(this)->GetLengthInfo();
|
||||
LengthAttributesInfo info = const_cast<SVGGeometryElement*>(this)->GetLengthInfo();
|
||||
for (uint32_t i = 0; i < info.mLengthCount; i++) {
|
||||
if (info.mLengths[i].GetSpecifiedUnitType() == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE) {
|
||||
return true;
|
||||
|
|
@ -65,19 +79,19 @@ nsSVGPathGeometryElement::GeometryDependsOnCoordCtx()
|
|||
}
|
||||
|
||||
bool
|
||||
nsSVGPathGeometryElement::IsMarkable()
|
||||
SVGGeometryElement::IsMarkable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPathGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||
SVGGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<Path>
|
||||
nsSVGPathGeometryElement::GetOrBuildPath(const DrawTarget& aDrawTarget,
|
||||
FillRule aFillRule)
|
||||
SVGGeometryElement::GetOrBuildPath(const DrawTarget& aDrawTarget,
|
||||
FillRule aFillRule)
|
||||
{
|
||||
// We only cache the path if it matches the backend used for screen painting:
|
||||
bool cacheable = aDrawTarget.GetBackendType() ==
|
||||
|
|
@ -102,13 +116,13 @@ nsSVGPathGeometryElement::GetOrBuildPath(const DrawTarget& aDrawTarget,
|
|||
}
|
||||
|
||||
already_AddRefed<Path>
|
||||
nsSVGPathGeometryElement::GetOrBuildPathForMeasuring()
|
||||
SVGGeometryElement::GetOrBuildPathForMeasuring()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FillRule
|
||||
nsSVGPathGeometryElement::GetFillRule()
|
||||
SVGGeometryElement::GetFillRule()
|
||||
{
|
||||
FillRule fillRule = FillRule::FILL_WINDING; // Equivalent to StyleFillRule::Nonzero
|
||||
|
||||
|
|
@ -130,3 +144,42 @@ nsSVGPathGeometryElement::GetFillRule()
|
|||
|
||||
return fillRule;
|
||||
}
|
||||
|
||||
float
|
||||
SVGGeometryElement::GetTotalLength()
|
||||
{
|
||||
RefPtr<Path> flat = GetOrBuildPathForMeasuring();
|
||||
return flat ? flat->ComputeLength() : 0.f;
|
||||
}
|
||||
|
||||
already_AddRefed<nsISVGPoint>
|
||||
SVGGeometryElement::GetPointAtLength(float distance, ErrorResult& rv)
|
||||
{
|
||||
RefPtr<Path> path = GetOrBuildPathForMeasuring();
|
||||
if (!path) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float totalLength = path->ComputeLength();
|
||||
if (mPathLength.IsExplicitlySet()) {
|
||||
float pathLength = mPathLength.GetAnimValue();
|
||||
if (pathLength <= 0) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
distance *= totalLength / pathLength;
|
||||
}
|
||||
distance = std::max(0.f, distance);
|
||||
distance = std::min(totalLength, distance);
|
||||
|
||||
nsCOMPtr<nsISVGPoint> point =
|
||||
new DOMSVGPoint(path->ComputePointAtLength(distance));
|
||||
return point.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<SVGAnimatedNumber>
|
||||
SVGGeometryElement::PathLength()
|
||||
{
|
||||
return mPathLength.ToDOMAnimatedNumber(this);
|
||||
}
|
||||
|
|
@ -3,11 +3,13 @@
|
|||
* 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/. */
|
||||
|
||||
#ifndef __NS_SVGPATHGEOMETRYELEMENT_H__
|
||||
#define __NS_SVGPATHGEOMETRYELEMENT_H__
|
||||
#ifndef mozilla_dom_SVGGeometryElement_h
|
||||
#define mozilla_dom_SVGGeometryElement_h
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "SVGGraphicsElement.h"
|
||||
#include "nsISVGPoint.h"
|
||||
#include "nsSVGNumber2.h"
|
||||
|
||||
struct nsSVGMark {
|
||||
enum Type {
|
||||
|
|
@ -24,9 +26,14 @@ struct nsSVGMark {
|
|||
x(aX), y(aY), angle(aAngle), type(aType) {}
|
||||
};
|
||||
|
||||
typedef mozilla::dom::SVGGraphicsElement nsSVGPathGeometryElementBase;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class nsSVGPathGeometryElement : public nsSVGPathGeometryElementBase
|
||||
class SVGAnimatedNumber;
|
||||
|
||||
typedef mozilla::dom::SVGGraphicsElement SVGGeometryElementBase;
|
||||
|
||||
class SVGGeometryElement : public SVGGeometryElementBase
|
||||
{
|
||||
protected:
|
||||
typedef mozilla::gfx::CapStyle CapStyle;
|
||||
|
|
@ -41,7 +48,7 @@ protected:
|
|||
typedef mozilla::gfx::StrokeOptions StrokeOptions;
|
||||
|
||||
public:
|
||||
explicit nsSVGPathGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
||||
explicit SVGGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
||||
|
||||
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue,
|
||||
|
|
@ -160,7 +167,7 @@ public:
|
|||
* that is created may be cached and returned on subsequent calls.
|
||||
*/
|
||||
virtual already_AddRefed<Path> GetOrBuildPath(const DrawTarget& aDrawTarget,
|
||||
FillRule fillRule);
|
||||
FillRule fillRule);
|
||||
|
||||
/**
|
||||
* The same as GetOrBuildPath, but bypasses the cache (neither returns any
|
||||
|
|
@ -192,8 +199,22 @@ public:
|
|||
*/
|
||||
FillRule GetFillRule();
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<SVGAnimatedNumber> PathLength();
|
||||
float GetTotalLength();
|
||||
already_AddRefed<nsISVGPoint>
|
||||
GetPointAtLength(float distance, ErrorResult& rv);
|
||||
|
||||
protected:
|
||||
// nsSVGElement method
|
||||
virtual NumberAttributesInfo GetNumberInfo() override;
|
||||
|
||||
nsSVGNumber2 mPathLength;
|
||||
static NumberInfo sNumberInfo;
|
||||
mutable RefPtr<Path> mCachedPath;
|
||||
};
|
||||
|
||||
#endif
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_SVGGeometryElement_h
|
||||
|
|
@ -235,7 +235,7 @@ SVGImageElement::IsAttributeMapped(const nsIAtom* name) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
/* For the purposes of the update/invalidation logic pretend to
|
||||
be a rectangle. */
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@
|
|||
|
||||
#include "nsImageLoadingContent.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "nsSVGString.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
#include "SVGAnimatedPreserveAspectRatio.h"
|
||||
|
||||
nsresult NS_NewSVGImageElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
||||
|
||||
typedef nsSVGPathGeometryElement SVGImageElementBase;
|
||||
|
||||
class nsSVGImageFrame;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class DOMSVGAnimatedPreserveAspectRatio;
|
||||
|
||||
typedef SVGGeometryElement SVGImageElementBase;
|
||||
|
||||
class SVGImageElement : public SVGImageElementBase,
|
||||
public nsImageLoadingContent
|
||||
{
|
||||
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aToBoundsSpace,
|
||||
const Matrix* aToNonScalingStrokeSpace = nullptr) override;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ SVGLineElement::GetLengthInfo()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
void
|
||||
SVGLineElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef mozilla_dom_SVGLineElement_h
|
||||
#define mozilla_dom_SVGLineElement_h
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
nsresult NS_NewSVGLineElement(nsIContent **aResult,
|
||||
|
|
@ -15,7 +15,7 @@ nsresult NS_NewSVGLineElement(nsIContent **aResult,
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef nsSVGPathGeometryElement SVGLineElementBase;
|
||||
typedef SVGGeometryElement SVGLineElementBase;
|
||||
|
||||
class SVGLineElement final : public SVGLineElementBase
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual bool IsMarkable() override { return true; }
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
|
||||
virtual void GetAsSimplePath(SimplePath* aSimplePath) override;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@
|
|||
#include "nsError.h"
|
||||
#include "nsString.h"
|
||||
#include "nsSVGPathDataParser.h"
|
||||
#include "nsSVGPathGeometryElement.h" // for nsSVGMark
|
||||
#include <stdarg.h>
|
||||
#include "nsStyleConsts.h"
|
||||
#include "SVGContentUtils.h"
|
||||
#include "SVGGeometryElement.h" // for nsSVGMark
|
||||
#include "SVGPathSegUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "DOMSVGPathSeg.h"
|
||||
#include "DOMSVGPathSegList.h"
|
||||
#include "DOMSVGPoint.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "mozilla/dom/SVGPathElementBinding.h"
|
||||
|
|
@ -35,9 +34,6 @@ SVGPathElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
return SVGPathElementBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
nsSVGElement::NumberInfo SVGPathElement::sNumberInfo =
|
||||
{ &nsGkAtoms::pathLength, 0, false };
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
|
|
@ -61,45 +57,6 @@ SVGPathElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
|||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPathElement)
|
||||
|
||||
already_AddRefed<SVGAnimatedNumber>
|
||||
SVGPathElement::PathLength()
|
||||
{
|
||||
return mPathLength.ToDOMAnimatedNumber(this);
|
||||
}
|
||||
|
||||
float
|
||||
SVGPathElement::GetTotalLength()
|
||||
{
|
||||
RefPtr<Path> flat = GetOrBuildPathForMeasuring();
|
||||
return flat ? flat->ComputeLength() : 0.f;
|
||||
}
|
||||
|
||||
already_AddRefed<nsISVGPoint>
|
||||
SVGPathElement::GetPointAtLength(float distance, ErrorResult& rv)
|
||||
{
|
||||
RefPtr<Path> path = GetOrBuildPathForMeasuring();
|
||||
if (!path) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float totalLength = path->ComputeLength();
|
||||
if (mPathLength.IsExplicitlySet()) {
|
||||
float pathLength = mPathLength.GetAnimValue();
|
||||
if (pathLength <= 0) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
distance *= totalLength / pathLength;
|
||||
}
|
||||
distance = std::max(0.f, distance);
|
||||
distance = std::min(totalLength, distance);
|
||||
|
||||
nsCOMPtr<nsISVGPoint> point =
|
||||
new DOMSVGPoint(path->ComputePointAtLength(distance));
|
||||
return point.forget();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SVGPathElement::GetPathSegAtLength(float distance)
|
||||
{
|
||||
|
|
@ -284,12 +241,6 @@ SVGPathElement::HasValidDimensions() const
|
|||
return !mD.GetAnimValue().IsEmpty();
|
||||
}
|
||||
|
||||
nsSVGElement::NumberAttributesInfo
|
||||
SVGPathElement::GetNumberInfo()
|
||||
{
|
||||
return NumberAttributesInfo(&mPathLength, &sNumberInfo, 1);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
|
|
@ -311,7 +262,7 @@ SVGPathElement::GetOrBuildPathForMeasuring()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
bool
|
||||
SVGPathElement::AttributeDefinesGeometry(const nsIAtom *aName)
|
||||
|
|
|
|||
|
|
@ -8,22 +8,21 @@
|
|||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsSVGNumber2.h"
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "SVGAnimatedPathSegList.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
#include "DOMSVGPathSeg.h"
|
||||
|
||||
nsresult NS_NewSVGPathElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
||||
|
||||
typedef nsSVGPathGeometryElement SVGPathElementBase;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class nsISVGPoint;
|
||||
|
||||
namespace dom {
|
||||
|
||||
typedef SVGGeometryElement SVGPathElementBase;
|
||||
|
||||
class SVGPathElement final : public SVGPathElementBase
|
||||
{
|
||||
friend class nsSVGPathFrame;
|
||||
|
|
@ -46,7 +45,7 @@ public:
|
|||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const override;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual bool AttributeDefinesGeometry(const nsIAtom *aName) override;
|
||||
virtual bool IsMarkable() override;
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
|
||||
|
|
@ -83,9 +82,6 @@ public:
|
|||
float GetPathLengthScale(PathLengthScaleForType aFor);
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<SVGAnimatedNumber> PathLength();
|
||||
float GetTotalLength();
|
||||
already_AddRefed<nsISVGPoint> GetPointAtLength(float distance, ErrorResult& rv);
|
||||
uint32_t GetPathSegAtLength(float distance);
|
||||
already_AddRefed<DOMSVGPathSegClosePath> CreateSVGPathSegClosePath();
|
||||
already_AddRefed<DOMSVGPathSegMovetoAbs> CreateSVGPathSegMovetoAbs(float x, float y);
|
||||
|
|
@ -121,12 +117,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
// nsSVGElement method
|
||||
virtual NumberAttributesInfo GetNumberInfo() override;
|
||||
|
||||
SVGAnimatedPathSegList mD;
|
||||
nsSVGNumber2 mPathLength;
|
||||
static NumberInfo sNumberInfo;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* 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/. */
|
||||
|
||||
#include "nsSVGPolyElement.h"
|
||||
#include "SVGPolyElement.h"
|
||||
#include "DOMSVGPointList.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "SVGContentUtils.h"
|
||||
|
|
@ -14,26 +14,26 @@ using namespace mozilla::gfx;
|
|||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGPolyElement,nsSVGPolyElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGPolyElement,nsSVGPolyElementBase)
|
||||
NS_IMPL_ADDREF_INHERITED(SVGPolyElement,SVGPolyElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(SVGPolyElement,SVGPolyElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPolyElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPolyElementBase)
|
||||
NS_INTERFACE_MAP_BEGIN(SVGPolyElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(SVGPolyElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGPolyElement::nsSVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: nsSVGPolyElementBase(aNodeInfo)
|
||||
SVGPolyElement::SVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: SVGPolyElementBase(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
nsSVGPolyElement::~nsSVGPolyElement()
|
||||
SVGPolyElement::~SVGPolyElement()
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGPointList>
|
||||
nsSVGPolyElement::Points()
|
||||
SVGPolyElement::Points()
|
||||
{
|
||||
void *key = mPoints.GetBaseValKey();
|
||||
RefPtr<DOMSVGPointList> points = DOMSVGPointList::GetDOMWrapper(key, this, false);
|
||||
|
|
@ -41,7 +41,7 @@ nsSVGPolyElement::Points()
|
|||
}
|
||||
|
||||
already_AddRefed<DOMSVGPointList>
|
||||
nsSVGPolyElement::AnimatedPoints()
|
||||
SVGPolyElement::AnimatedPoints()
|
||||
{
|
||||
void *key = mPoints.GetAnimValKey();
|
||||
RefPtr<DOMSVGPointList> points = DOMSVGPointList::GetDOMWrapper(key, this, true);
|
||||
|
|
@ -53,30 +53,30 @@ nsSVGPolyElement::AnimatedPoints()
|
|||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsSVGPolyElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
SVGPolyElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sMarkersMap
|
||||
};
|
||||
|
||||
return FindAttributeDependence(name, map) ||
|
||||
nsSVGPolyElementBase::IsAttributeMapped(name);
|
||||
SVGPolyElementBase::IsAttributeMapped(name);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGPolyElement::HasValidDimensions() const
|
||||
SVGPolyElement::HasValidDimensions() const
|
||||
{
|
||||
return !mPoints.GetAnimValue().IsEmpty();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
bool
|
||||
nsSVGPolyElement::AttributeDefinesGeometry(const nsIAtom *aName)
|
||||
SVGPolyElement::AttributeDefinesGeometry(const nsIAtom *aName)
|
||||
{
|
||||
if (aName == nsGkAtoms::points)
|
||||
return true;
|
||||
|
|
@ -85,7 +85,7 @@ nsSVGPolyElement::AttributeDefinesGeometry(const nsIAtom *aName)
|
|||
}
|
||||
|
||||
void
|
||||
nsSVGPolyElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||
SVGPolyElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||
{
|
||||
const SVGPointList &points = mPoints.GetAnimValue();
|
||||
|
||||
|
|
@ -121,10 +121,10 @@ nsSVGPolyElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
|||
}
|
||||
|
||||
bool
|
||||
nsSVGPolyElement::GetGeometryBounds(Rect* aBounds,
|
||||
const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aToBoundsSpace,
|
||||
const Matrix* aToNonScalingStrokeSpace)
|
||||
SVGPolyElement::GetGeometryBounds(Rect* aBounds,
|
||||
const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aToBoundsSpace,
|
||||
const Matrix* aToNonScalingStrokeSpace)
|
||||
{
|
||||
const SVGPointList &points = mPoints.GetAnimValue();
|
||||
|
||||
|
|
@ -3,25 +3,26 @@
|
|||
* 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/. */
|
||||
|
||||
#ifndef NS_SVGPOLYELEMENT_H_
|
||||
#define NS_SVGPOLYELEMENT_H_
|
||||
#ifndef __SVGPOLYELEMENT_H_
|
||||
#define __SVGPOLYELEMENT_H_
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "SVGAnimatedPointList.h"
|
||||
|
||||
typedef nsSVGPathGeometryElement nsSVGPolyElementBase;
|
||||
#include "SVGGeometryElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
class DOMSVGPointList;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsSVGPolyElement : public nsSVGPolyElementBase
|
||||
namespace dom {
|
||||
|
||||
typedef SVGGeometryElement SVGPolyElementBase;
|
||||
|
||||
class SVGPolyElement : public SVGPolyElementBase
|
||||
{
|
||||
protected:
|
||||
explicit nsSVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
||||
explicit SVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
||||
|
||||
virtual ~nsSVGPolyElement();
|
||||
virtual ~SVGPolyElement();
|
||||
|
||||
public:
|
||||
//interfaces
|
||||
|
|
@ -41,7 +42,7 @@ public:
|
|||
// nsSVGElement methods:
|
||||
virtual bool HasValidDimensions() const override;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual bool AttributeDefinesGeometry(const nsIAtom *aName) override;
|
||||
virtual bool IsMarkable() override { return true; }
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
|
||||
|
|
@ -57,4 +58,7 @@ protected:
|
|||
SVGAnimatedPointList mPoints;
|
||||
};
|
||||
|
||||
#endif //NS_SVGPOLYELEMENT_H_
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif //__SVGPOLYELEMENT_H_
|
||||
|
|
@ -36,12 +36,12 @@ SVGPolygonElement::SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>& a
|
|||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolygonElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
void
|
||||
SVGPolygonElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||
{
|
||||
nsSVGPolyElement::GetMarkPoints(aMarks);
|
||||
SVGPolyElement::GetMarkPoints(aMarks);
|
||||
|
||||
if (aMarks->IsEmpty() || aMarks->LastElement().type != nsSVGMark::eEnd) {
|
||||
return;
|
||||
|
|
@ -55,7 +55,7 @@ SVGPolygonElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
|||
endMark->angle = SVGContentUtils::AngleBisect(angle, endMark->angle);
|
||||
startMark->angle = SVGContentUtils::AngleBisect(angle, startMark->angle);
|
||||
// for a polygon (as opposed to a polyline) there's an implicit extra point
|
||||
// co-located with the start point that nsSVGPolyElement::GetMarkPoints
|
||||
// co-located with the start point that SVGPolyElement::GetMarkPoints
|
||||
// doesn't return
|
||||
aMarks->AppendElement(nsSVGMark(startMark->x, startMark->y, startMark->angle,
|
||||
nsSVGMark::eEnd));
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@
|
|||
#define mozilla_dom_SVGPolygonElement_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsSVGPolyElement.h"
|
||||
#include "SVGPolyElement.h"
|
||||
|
||||
nsresult NS_NewSVGPolygonElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
||||
|
||||
typedef nsSVGPolyElement SVGPolygonElementBase;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef SVGPolyElement SVGPolygonElementBase;
|
||||
|
||||
class SVGPolygonElement final : public SVGPolygonElementBase
|
||||
{
|
||||
protected:
|
||||
|
|
@ -26,7 +26,7 @@ protected:
|
|||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
||||
|
||||
public:
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
|
||||
virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ SVGPolylineElement::SVGPolylineElement(already_AddRefed<mozilla::dom::NodeInfo>&
|
|||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolylineElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
already_AddRefed<Path>
|
||||
SVGPolylineElement::BuildPath(PathBuilder* aBuilder)
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@
|
|||
#ifndef mozilla_dom_SVGPolylineElement_h
|
||||
#define mozilla_dom_SVGPolylineElement_h
|
||||
|
||||
#include "nsSVGPolyElement.h"
|
||||
#include "SVGPolyElement.h"
|
||||
|
||||
nsresult NS_NewSVGPolylineElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
||||
|
||||
typedef nsSVGPolyElement SVGPolylineElementBase;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef SVGPolyElement SVGPolylineElementBase;
|
||||
|
||||
class SVGPolylineElement final : public SVGPolylineElementBase
|
||||
{
|
||||
protected:
|
||||
|
|
@ -24,7 +24,7 @@ protected:
|
|||
friend nsresult (::NS_NewSVGPolylineElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ SVGRectElement::GetLengthInfo()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
// SVGGeometryElement methods
|
||||
|
||||
bool
|
||||
SVGRectElement::GetGeometryBounds(Rect* aBounds,
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@
|
|||
#ifndef mozilla_dom_SVGRectElement_h
|
||||
#define mozilla_dom_SVGRectElement_h
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
|
||||
nsresult NS_NewSVGRectElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
||||
|
||||
typedef nsSVGPathGeometryElement SVGRectElementBase;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef SVGGeometryElement SVGRectElementBase;
|
||||
|
||||
class SVGRectElement final : public SVGRectElementBase
|
||||
{
|
||||
protected:
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const override;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
// SVGGeometryElement methods:
|
||||
virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aToBoundsSpace,
|
||||
const Matrix* aToNonScalingStrokeSpace = nullptr) override;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ EXPORTS.mozilla.dom += [
|
|||
'SVGFilterElement.h',
|
||||
'SVGForeignObjectElement.h',
|
||||
'SVGGElement.h',
|
||||
'SVGGeometryElement.h',
|
||||
'SVGGradientElement.h',
|
||||
'SVGGraphicsElement.h',
|
||||
'SVGImageElement.h',
|
||||
|
|
@ -131,8 +132,6 @@ UNIFIED_SOURCES += [
|
|||
'nsSVGNumber2.cpp',
|
||||
'nsSVGNumberPair.cpp',
|
||||
'nsSVGPathDataParser.cpp',
|
||||
'nsSVGPathGeometryElement.cpp',
|
||||
'nsSVGPolyElement.cpp',
|
||||
'nsSVGString.cpp',
|
||||
'nsSVGTransform.cpp',
|
||||
'nsSVGViewBox.cpp',
|
||||
|
|
@ -190,6 +189,7 @@ UNIFIED_SOURCES += [
|
|||
'SVGForeignObjectElement.cpp',
|
||||
'SVGFragmentIdentifier.cpp',
|
||||
'SVGGElement.cpp',
|
||||
'SVGGeometryElement.cpp',
|
||||
'SVGGradientElement.cpp',
|
||||
'SVGGraphicsElement.cpp',
|
||||
'SVGImageElement.cpp',
|
||||
|
|
@ -218,6 +218,7 @@ UNIFIED_SOURCES += [
|
|||
'SVGPatternElement.cpp',
|
||||
'SVGPointList.cpp',
|
||||
'SVGPointListSMILType.cpp',
|
||||
'SVGPolyElement.cpp',
|
||||
'SVGPolygonElement.cpp',
|
||||
'SVGPolylineElement.cpp',
|
||||
'SVGPreserveAspectRatio.cpp',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
#include "nsICSSDeclaration.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "mozilla/InternalMutationEvent.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsError.h"
|
||||
|
|
@ -45,6 +44,7 @@
|
|||
#include "SVGAnimatedPointList.h"
|
||||
#include "SVGAnimatedPathSegList.h"
|
||||
#include "SVGContentUtils.h"
|
||||
#include "SVGGeometryElement.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include <stdarg.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue