2010-12-08 15:15:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/. */
|
2010-12-08 15:15:53 +03:00
|
|
|
|
|
|
|
#ifndef MOZILLA_DOMSVGPOINT_H__
|
|
|
|
#define MOZILLA_DOMSVGPOINT_H__
|
|
|
|
|
|
|
|
#include "DOMSVGPointList.h"
|
2013-11-18 05:29:06 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2010-12-08 15:15:53 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsDebug.h"
|
2012-12-23 08:54:20 +04:00
|
|
|
#include "nsISVGPoint.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "SVGPoint.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-10-01 13:26:00 +04:00
|
|
|
#include "mozilla/FloatingPoint.h"
|
2010-12-08 15:15:53 +03:00
|
|
|
|
|
|
|
class nsSVGElement;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-01-12 00:30:21 +04:00
|
|
|
namespace dom {
|
|
|
|
class SVGMatrix;
|
|
|
|
}
|
2012-12-23 08:54:20 +04:00
|
|
|
|
2010-12-08 15:15:53 +03:00
|
|
|
/**
|
|
|
|
* Class DOMSVGPoint
|
|
|
|
*
|
|
|
|
* This class creates the DOM objects that wrap internal SVGPoint objects that
|
|
|
|
* are in an SVGPointList. It is also used to create the objects returned by
|
|
|
|
* SVGSVGElement.createSVGPoint() and other functions that return DOM SVGPoint
|
|
|
|
* objects.
|
|
|
|
*
|
|
|
|
* See the architecture comment in DOMSVGPointList.h for an overview of the
|
|
|
|
* important points regarding these DOM wrapper structures.
|
|
|
|
*
|
|
|
|
* See the architecture comment in DOMSVGLength.h (yes, LENGTH) for an overview
|
|
|
|
* of the important points regarding how this specific class works.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class DOMSVGPoint final : public nsISVGPoint
|
2010-12-08 15:15:53 +03:00
|
|
|
{
|
2013-12-25 02:09:22 +04:00
|
|
|
friend class AutoChangePointNotifier;
|
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
typedef mozilla::gfx::Point Point;
|
|
|
|
|
2010-12-08 15:15:53 +03:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Generic ctor for DOMSVGPoint objects that are created for an attribute.
|
|
|
|
*/
|
|
|
|
DOMSVGPoint(DOMSVGPointList *aList,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aListIndex,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsAnimValItem)
|
2012-12-23 08:54:20 +04:00
|
|
|
: nsISVGPoint()
|
2010-12-08 15:15:53 +03:00
|
|
|
{
|
2013-01-17 05:35:24 +04:00
|
|
|
mList = aList;
|
|
|
|
mListIndex = aListIndex;
|
|
|
|
mIsAnimValItem = aIsAnimValItem;
|
|
|
|
|
2010-12-08 15:15:53 +03:00
|
|
|
// These shifts are in sync with the members.
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aList && aListIndex <= MaxListIndex(), "bad arg");
|
2010-12-08 15:15:53 +03:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGPoint!");
|
2010-12-08 15:15:53 +03:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:19 +04:00
|
|
|
explicit DOMSVGPoint(const DOMSVGPoint *aPt = nullptr)
|
2012-12-23 08:54:20 +04:00
|
|
|
: nsISVGPoint()
|
2010-12-08 15:15:53 +03:00
|
|
|
{
|
|
|
|
if (aPt) {
|
|
|
|
mPt = aPt->ToSVGPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMSVGPoint(float aX, float aY)
|
2012-12-23 08:54:20 +04:00
|
|
|
: nsISVGPoint()
|
2010-12-08 15:15:53 +03:00
|
|
|
{
|
|
|
|
mPt.mX = aX;
|
|
|
|
mPt.mY = aY;
|
|
|
|
}
|
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
explicit DOMSVGPoint(const Point& aPt)
|
|
|
|
: nsISVGPoint()
|
|
|
|
{
|
|
|
|
mPt.mX = aPt.x;
|
|
|
|
mPt.mY = aPt.y;
|
2014-10-01 13:26:00 +04:00
|
|
|
NS_ASSERTION(IsFinite(mPt.mX) && IsFinite(mPt.mX),
|
2013-11-18 05:29:06 +04:00
|
|
|
"DOMSVGPoint coords are not finite");
|
|
|
|
}
|
|
|
|
|
2010-12-08 15:15:53 +03:00
|
|
|
|
2012-12-23 08:54:19 +04:00
|
|
|
// WebIDL
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual float X() override;
|
|
|
|
virtual void SetX(float aX, ErrorResult& rv) override;
|
|
|
|
virtual float Y() override;
|
|
|
|
virtual void SetY(float aY, ErrorResult& rv) override;
|
|
|
|
virtual already_AddRefed<nsISVGPoint> MatrixTransform(dom::SVGMatrix& matrix) override;
|
|
|
|
nsISupports* GetParentObject() override {
|
2012-12-23 08:54:19 +04:00
|
|
|
return mList;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual DOMSVGPoint* Copy() override {
|
2010-12-08 15:15:53 +03:00
|
|
|
return new DOMSVGPoint(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
nsSVGElement* Element() {
|
|
|
|
return mList->Element();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_DOMSVGPOINT_H__
|