mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 825147: Convert SVGCircleElement to WebIDL r=bz
--HG-- rename : content/svg/content/src/nsSVGCircleElement.cpp => content/svg/content/src/SVGCircleElement.cpp rename : content/svg/content/src/nsSVGCircleElement.cpp => content/svg/content/src/SVGCircleElement.h
This commit is contained in:
parent
35bca1a8dc
commit
20828e38ac
@ -40,7 +40,6 @@ CPPSRCS = \
|
||||
nsSVGAltGlyphElement.cpp \
|
||||
nsSVGAngle.cpp \
|
||||
nsSVGBoolean.cpp \
|
||||
nsSVGCircleElement.cpp \
|
||||
nsSVGClass.cpp \
|
||||
nsSVGClipPathElement.cpp \
|
||||
nsSVGDataParser.cpp \
|
||||
@ -110,6 +109,7 @@ CPPSRCS = \
|
||||
nsSVGAnimationElement.cpp \
|
||||
nsSVGSetElement.cpp \
|
||||
SVGAttrValueWrapper.cpp \
|
||||
SVGCircleElement.cpp \
|
||||
SVGContentUtils.cpp \
|
||||
SVGDefsElement.cpp \
|
||||
SVGDescElement.cpp \
|
||||
@ -156,6 +156,7 @@ EXPORTS_mozilla/dom = \
|
||||
SVGAngle.h \
|
||||
SVGAnimatedAngle.h \
|
||||
SVGAnimatedBoolean.h \
|
||||
SVGCircleElement.h \
|
||||
SVGDefsElement.h \
|
||||
SVGDescElement.h \
|
||||
SVGForeignObjectElement.h \
|
||||
|
138
content/svg/content/src/SVGCircleElement.cpp
Normal file
138
content/svg/content/src/SVGCircleElement.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/dom/SVGCircleElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "gfxContext.h"
|
||||
#include "mozilla/dom/SVGCircleElementBinding.h"
|
||||
|
||||
DOMCI_NODE_DATA(SVGCircleElement, mozilla::dom::SVGCircleElement)
|
||||
|
||||
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Circle)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
SVGCircleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return SVGCircleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
nsSVGElement::LengthInfo SVGCircleElement::sLengthInfo[3] =
|
||||
{
|
||||
{ &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
||||
{ &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
||||
{ &nsGkAtoms::r, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(SVGCircleElement,SVGCircleElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(SVGCircleElement,SVGCircleElementBase)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(SVGCircleElement)
|
||||
NS_NODE_INTERFACE_TABLE4(SVGCircleElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement,
|
||||
nsIDOMSVGCircleElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGCircleElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(SVGCircleElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
SVGCircleElement::SVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: SVGCircleElementBase(aNodeInfo)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGCircleElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGCircleElement methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cx; */
|
||||
NS_IMETHODIMP SVGCircleElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
|
||||
{
|
||||
*aCx = Cx().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGCircleElement::Cx()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> cx;
|
||||
mLengthAttributes[ATTR_CX].ToDOMAnimatedLength(getter_AddRefs(cx), this);
|
||||
return cx.forget();
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cy; */
|
||||
NS_IMETHODIMP SVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
|
||||
{
|
||||
*aCy = Cy().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGCircleElement::Cy()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> cy;
|
||||
mLengthAttributes[ATTR_CY].ToDOMAnimatedLength(getter_AddRefs(cy), this);
|
||||
return cy.forget();
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength r; */
|
||||
NS_IMETHODIMP SVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
|
||||
{
|
||||
*aR = R().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGCircleElement::R()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> r;
|
||||
mLengthAttributes[ATTR_R].ToDOMAnimatedLength(getter_AddRefs(r), this);
|
||||
return r.forget();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
SVGCircleElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[ATTR_R].IsExplicitlySet() &&
|
||||
mLengthAttributes[ATTR_R].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
SVGCircleElement::GetLengthInfo()
|
||||
{
|
||||
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
||||
ArrayLength(sLengthInfo));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
|
||||
void
|
||||
SVGCircleElement::ConstructPath(gfxContext *aCtx)
|
||||
{
|
||||
float x, y, r;
|
||||
|
||||
GetAnimatedLengthValues(&x, &y, &r, nullptr);
|
||||
|
||||
if (r > 0.0f)
|
||||
aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
69
content/svg/content/src/SVGCircleElement.h
Normal file
69
content/svg/content/src/SVGCircleElement.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_SVGCircleElement_h
|
||||
#define mozilla_dom_SVGCircleElement_h
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "nsIDOMSVGCircleElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
nsresult NS_NewSVGCircleElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
typedef nsSVGPathGeometryElement SVGCircleElementBase;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class SVGCircleElement MOZ_FINAL : public SVGCircleElementBase,
|
||||
public nsIDOMSVGCircleElement
|
||||
{
|
||||
protected:
|
||||
SVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
|
||||
friend nsresult (::NS_NewSVGCircleElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo));
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGCIRCLEELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(SVGCircleElementBase::)
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
virtual void ConstructPath(gfxContext *aCtx);
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength> Cx();
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength> Cy();
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength> R();
|
||||
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
|
||||
enum { ATTR_CX, ATTR_CY, ATTR_R };
|
||||
nsSVGLength2 mLengthAttributes[3];
|
||||
static LengthInfo sLengthInfo[3];
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_SVGCircleElement_h
|
@ -1,143 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
#include "nsIDOMSVGCircleElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "gfxContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
typedef nsSVGPathGeometryElement nsSVGCircleElementBase;
|
||||
|
||||
class nsSVGCircleElement : public nsSVGCircleElementBase,
|
||||
public nsIDOMSVGCircleElement
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGCircleElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGCIRCLEELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::)
|
||||
|
||||
// nsSVGSVGElement methods:
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsSVGPathGeometryElement methods:
|
||||
virtual void ConstructPath(gfxContext *aCtx);
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
|
||||
enum { CX, CY, R };
|
||||
nsSVGLength2 mLengthAttributes[3];
|
||||
static LengthInfo sLengthInfo[3];
|
||||
};
|
||||
|
||||
nsSVGElement::LengthInfo nsSVGCircleElement::sLengthInfo[3] =
|
||||
{
|
||||
{ &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
||||
{ &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
||||
{ &nsGkAtoms::r, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }
|
||||
};
|
||||
|
||||
NS_IMPL_NS_NEW_SVG_ELEMENT(Circle)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
|
||||
|
||||
DOMCI_NODE_DATA(SVGCircleElement, nsSVGCircleElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGCircleElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGCircleElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement,
|
||||
nsIDOMSVGCircleElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGCircleElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGCircleElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGCircleElement::nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsSVGCircleElementBase(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGCircleElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGCircleElement methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cx; */
|
||||
NS_IMETHODIMP nsSVGCircleElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
|
||||
{
|
||||
return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cy; */
|
||||
NS_IMETHODIMP nsSVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
|
||||
{
|
||||
return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength r; */
|
||||
NS_IMETHODIMP nsSVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
|
||||
{
|
||||
return mLengthAttributes[R].ToDOMAnimatedLength(aR, this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGCircleElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[R].IsExplicitlySet() &&
|
||||
mLengthAttributes[R].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGCircleElement::GetLengthInfo()
|
||||
{
|
||||
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
||||
ArrayLength(sLengthInfo));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGPathGeometryElement methods
|
||||
|
||||
void
|
||||
nsSVGCircleElement::ConstructPath(gfxContext *aCtx)
|
||||
{
|
||||
float x, y, r;
|
||||
|
||||
GetAnimatedLengthValues(&x, &y, &r, nullptr);
|
||||
|
||||
if (r > 0.0f)
|
||||
aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI);
|
||||
}
|
23
dom/webidl/SVGCircleElement.webidl
Normal file
23
dom/webidl/SVGCircleElement.webidl
Normal file
@ -0,0 +1,23 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.w3.org/TR/SVG2/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface SVGAnimatedLength;
|
||||
|
||||
interface SVGCircleElement : SVGGraphicsElement {
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength cx;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength cy;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength r;
|
||||
};
|
||||
|
@ -104,6 +104,7 @@ webidl_files = \
|
||||
SVGAnimatedPoints.webidl \
|
||||
SVGAnimatedPreserveAspectRatio.webidl \
|
||||
SVGAnimatedTransformList.webidl \
|
||||
SVGCircleElement.webidl \
|
||||
SVGDefsElement.webidl \
|
||||
SVGDescElement.webidl \
|
||||
SVGElement.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user