From 8ff56e186ff8bd3ce8e515617a0c7e6160659c0b Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Wed, 16 Jan 2013 15:50:59 -0500 Subject: [PATCH] Bug 830181 - Convert SVGSymbolElement to WebIDL r=bz --- content/svg/content/src/SVGSymbolElement.cpp | 29 ++++++++++++++++++-- content/svg/content/src/SVGSymbolElement.h | 6 ++++ dom/webidl/SVGFitToViewBox.webidl | 2 ++ dom/webidl/SVGSymbolElement.webidl | 17 ++++++++++++ dom/webidl/WebIDL.mk | 1 + 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 dom/webidl/SVGSymbolElement.webidl diff --git a/content/svg/content/src/SVGSymbolElement.cpp b/content/svg/content/src/SVGSymbolElement.cpp index 05bf430095ba..61354c65d0bc 100644 --- a/content/svg/content/src/SVGSymbolElement.cpp +++ b/content/svg/content/src/SVGSymbolElement.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/SVGSymbolElement.h" +#include "mozilla/dom/SVGSymbolElementBinding.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Symbol) @@ -12,6 +13,12 @@ DOMCI_NODE_DATA(SVGSymbolElement, mozilla::dom::SVGSymbolElement) namespace mozilla { namespace dom { +JSObject* +SVGSymbolElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGSymbolElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + //---------------------------------------------------------------------- // nsISupports methods @@ -31,6 +38,7 @@ NS_INTERFACE_MAP_END_INHERITING(SVGSymbolElementBase) SVGSymbolElement::SVGSymbolElement(already_AddRefed aNodeInfo) : SVGSymbolElementBase(aNodeInfo) { + SetIsDOMBinding(); } @@ -45,18 +53,33 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGSymbolElement) /* readonly attribute nsIDOMSVGAnimatedRect viewBox; */ NS_IMETHODIMP SVGSymbolElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox) { - return mViewBox.ToDOMAnimatedRect(aViewBox, this); + *aViewBox = ViewBox().get(); + return NS_OK; +} + +already_AddRefed +SVGSymbolElement::ViewBox() +{ + nsCOMPtr rect; + mViewBox.ToDOMAnimatedRect(getter_AddRefs(rect), this); + return rect.forget(); } /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */ NS_IMETHODIMP SVGSymbolElement::GetPreserveAspectRatio(nsISupports **aPreserveAspectRatio) +{ + *aPreserveAspectRatio = PreserveAspectRatio().get(); + return NS_OK; +} + +already_AddRefed +SVGSymbolElement::PreserveAspectRatio() { nsRefPtr ratio; mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this); - ratio.forget(aPreserveAspectRatio); - return NS_OK; + return ratio.forget(); } //---------------------------------------------------------------------- diff --git a/content/svg/content/src/SVGSymbolElement.h b/content/svg/content/src/SVGSymbolElement.h index b4ab8ac14672..f016bc883532 100644 --- a/content/svg/content/src/SVGSymbolElement.h +++ b/content/svg/content/src/SVGSymbolElement.h @@ -31,6 +31,7 @@ protected: friend nsresult (::NS_NewSVGSymbolElement(nsIContent **aResult, already_AddRefed aNodeInfo)); SVGSymbolElement(already_AddRefed aNodeInfo); + virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE; public: // interfaces: @@ -52,6 +53,11 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + already_AddRefed ViewBox(); + already_AddRefed PreserveAspectRatio(); + protected: virtual nsSVGViewBox *GetViewBox(); virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio(); diff --git a/dom/webidl/SVGFitToViewBox.webidl b/dom/webidl/SVGFitToViewBox.webidl index 7b8450cd5ff9..c9b925427609 100644 --- a/dom/webidl/SVGFitToViewBox.webidl +++ b/dom/webidl/SVGFitToViewBox.webidl @@ -14,7 +14,9 @@ interface SVGAnimatedRect; [NoInterfaceObject] interface SVGFitToViewBox { + [Constant] readonly attribute SVGAnimatedRect viewBox; + [Constant] readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio; }; diff --git a/dom/webidl/SVGSymbolElement.webidl b/dom/webidl/SVGSymbolElement.webidl new file mode 100644 index 000000000000..ece2c5a3f046 --- /dev/null +++ b/dom/webidl/SVGSymbolElement.webidl @@ -0,0 +1,17 @@ +/* -*- 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/struct.html#InterfaceSVGSymbolElement + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGSymbolElement : SVGElement { +}; + +SVGSymbolElement implements SVGFitToViewBox; +SVGSymbolElement implements SVGTests; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index db89529f0758..abefc8640925 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -148,6 +148,7 @@ webidl_files = \ SVGStyleElement.webidl \ SVGSVGElement.webidl \ SVGSwitchElement.webidl \ + SVGSymbolElement.webidl \ SVGTests.webidl \ SVGTextContentElement.webidl \ SVGTextElement.webidl \