mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1518676 - Part 2 Ensure DOMSVGAngle and DOMSVGNumber are passed an SVGSVGElement and simplify SVGSVGElement create calls. r=jwatt
This commit is contained in:
parent
1191520084
commit
50ca026ed1
@ -7,6 +7,7 @@
|
||||
#include "DOMSVGAngle.h"
|
||||
#include "SVGAngle.h"
|
||||
#include "mozilla/dom/SVGAngleBinding.h"
|
||||
#include "mozilla/dom/SVGSVGElement.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -16,7 +17,7 @@ NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAngle, mSVGElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGAngle, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGAngle, Release)
|
||||
|
||||
DOMSVGAngle::DOMSVGAngle(SVGElement* aSVGElement)
|
||||
DOMSVGAngle::DOMSVGAngle(SVGSVGElement* aSVGElement)
|
||||
: mSVGElement(aSVGElement), mType(DOMSVGAngle::CreatedValue) {
|
||||
mVal = new SVGAngle();
|
||||
mVal->Init();
|
||||
|
@ -15,6 +15,7 @@ class SVGAngle;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class SVGSVGElement;
|
||||
|
||||
class DOMSVGAngle final : public nsWrapperCache {
|
||||
public:
|
||||
@ -33,7 +34,7 @@ class DOMSVGAngle final : public nsWrapperCache {
|
||||
* Ctor for creating the objects returned by SVGSVGElement.createSVGAngle(),
|
||||
* which do not initially belong to an attribute.
|
||||
*/
|
||||
explicit DOMSVGAngle(SVGElement* aSVGElement);
|
||||
explicit DOMSVGAngle(SVGSVGElement* aSVGElement);
|
||||
|
||||
// WebIDL
|
||||
SVGElement* GetParentObject() { return mSVGElement; }
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsError.h"
|
||||
#include "nsContentUtils.h" // for NS_ENSURE_FINITE
|
||||
#include "mozilla/dom/SVGNumberBinding.h"
|
||||
#include "mozilla/dom/SVGSVGElement.h"
|
||||
|
||||
// See the architecture comment in DOMSVGAnimatedNumberList.h.
|
||||
|
||||
@ -105,6 +106,14 @@ DOMSVGNumber::DOMSVGNumber(nsISupports* aParent)
|
||||
mIsAnimValItem(false),
|
||||
mValue(0.0f) {}
|
||||
|
||||
DOMSVGNumber::DOMSVGNumber(SVGSVGElement* aParent)
|
||||
: mList(nullptr),
|
||||
mParent(ToSupports(aParent)),
|
||||
mListIndex(0),
|
||||
mAttrEnum(0),
|
||||
mIsAnimValItem(false),
|
||||
mValue(0.0f) {}
|
||||
|
||||
float DOMSVGNumber::Value() {
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
|
@ -22,6 +22,7 @@ namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class SVGElement;
|
||||
class SVGSVGElement;
|
||||
|
||||
/**
|
||||
* Class DOMSVGNumber
|
||||
@ -62,8 +63,12 @@ class DOMSVGNumber final : public nsISupports, public nsWrapperCache {
|
||||
* Ctor for creating the objects returned by SVGSVGElement.createSVGNumber(),
|
||||
* which do not initially belong to an attribute.
|
||||
*/
|
||||
explicit DOMSVGNumber(SVGSVGElement* aParent);
|
||||
|
||||
private:
|
||||
explicit DOMSVGNumber(nsISupports* aParent);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create an unowned copy. The caller is responsible for the first AddRef().
|
||||
*/
|
||||
|
@ -252,13 +252,11 @@ void SVGSVGElement::DeselectAll() {
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGNumber> SVGSVGElement::CreateSVGNumber() {
|
||||
RefPtr<DOMSVGNumber> number = new DOMSVGNumber(ToSupports(this));
|
||||
return number.forget();
|
||||
return do_AddRef(new DOMSVGNumber(this));
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGLength> SVGSVGElement::CreateSVGLength() {
|
||||
nsCOMPtr<DOMSVGLength> length = new DOMSVGLength();
|
||||
return length.forget();
|
||||
return do_AddRef(new DOMSVGLength());
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGAngle> SVGSVGElement::CreateSVGAngle() {
|
||||
@ -266,13 +264,11 @@ already_AddRefed<DOMSVGAngle> SVGSVGElement::CreateSVGAngle() {
|
||||
}
|
||||
|
||||
already_AddRefed<nsISVGPoint> SVGSVGElement::CreateSVGPoint() {
|
||||
nsCOMPtr<nsISVGPoint> point = new DOMSVGPoint(0, 0);
|
||||
return point.forget();
|
||||
return do_AddRef(new DOMSVGPoint(0, 0));
|
||||
}
|
||||
|
||||
already_AddRefed<SVGMatrix> SVGSVGElement::CreateSVGMatrix() {
|
||||
RefPtr<SVGMatrix> matrix = new SVGMatrix();
|
||||
return matrix.forget();
|
||||
return do_AddRef(new SVGMatrix());
|
||||
}
|
||||
|
||||
already_AddRefed<SVGIRect> SVGSVGElement::CreateSVGRect() {
|
||||
@ -280,14 +276,12 @@ already_AddRefed<SVGIRect> SVGSVGElement::CreateSVGRect() {
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGTransform> SVGSVGElement::CreateSVGTransform() {
|
||||
RefPtr<DOMSVGTransform> transform = new DOMSVGTransform();
|
||||
return transform.forget();
|
||||
return do_AddRef(new DOMSVGTransform());
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGTransform> SVGSVGElement::CreateSVGTransformFromMatrix(
|
||||
SVGMatrix& matrix) {
|
||||
RefPtr<DOMSVGTransform> transform = new DOMSVGTransform(matrix.GetMatrix());
|
||||
return transform.forget();
|
||||
return do_AddRef(new DOMSVGTransform(matrix.GetMatrix()));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user