mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 825834 - Convert SVGViewElement to webidl r=bz
This commit is contained in:
parent
a3aaae810c
commit
1d879bd0c9
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/SVGViewElement.h"
|
||||
#include "mozilla/dom/SVGViewElementBinding.h"
|
||||
#include "DOMSVGStringList.h"
|
||||
|
||||
DOMCI_NODE_DATA(SVGViewElement, mozilla::dom::SVGViewElement)
|
||||
@ -13,6 +14,12 @@ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(View)
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
SVGViewElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return SVGViewElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
nsSVGElement::StringListInfo SVGViewElement::sStringListInfo[1] =
|
||||
{
|
||||
{ &nsGkAtoms::viewTarget }
|
||||
@ -66,20 +73,28 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGViewElement)
|
||||
NS_IMETHODIMP
|
||||
SVGViewElement::GetZoomAndPan(uint16_t *aZoomAndPan)
|
||||
{
|
||||
*aZoomAndPan = mEnumAttributes[ZOOMANDPAN].GetAnimValue();
|
||||
*aZoomAndPan = ZoomAndPan();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SVGViewElement::SetZoomAndPan(uint16_t aZoomAndPan)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetZoomAndPan(aZoomAndPan, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
SVGViewElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv)
|
||||
{
|
||||
if (aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE ||
|
||||
aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
|
||||
mEnumAttributes[ZOOMANDPAN].SetBaseValue(aZoomAndPan, this);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
return NS_ERROR_RANGE_ERR;
|
||||
rv.Throw(NS_ERROR_RANGE_ERR);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -89,18 +104,33 @@ SVGViewElement::SetZoomAndPan(uint16_t aZoomAndPan)
|
||||
NS_IMETHODIMP
|
||||
SVGViewElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox)
|
||||
{
|
||||
return mViewBox.ToDOMAnimatedRect(aViewBox, this);
|
||||
*aViewBox = ViewBox().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedRect>
|
||||
SVGViewElement::ViewBox()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedRect> box;
|
||||
mViewBox.ToDOMAnimatedRect(getter_AddRefs(box), this);
|
||||
return box.forget();
|
||||
}
|
||||
|
||||
/* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
|
||||
NS_IMETHODIMP
|
||||
SVGViewElement::GetPreserveAspectRatio(nsISupports
|
||||
**aPreserveAspectRatio)
|
||||
{
|
||||
*aPreserveAspectRatio = PreserveAspectRatio().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
||||
SVGViewElement::PreserveAspectRatio()
|
||||
{
|
||||
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
|
||||
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
|
||||
ratio.forget(aPreserveAspectRatio);
|
||||
return NS_OK;
|
||||
return ratio.forget();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -109,11 +139,17 @@ SVGViewElement::GetPreserveAspectRatio(nsISupports
|
||||
/* readonly attribute nsIDOMSVGStringList viewTarget; */
|
||||
NS_IMETHODIMP SVGViewElement::GetViewTarget(nsIDOMSVGStringList * *aViewTarget)
|
||||
{
|
||||
*aViewTarget = DOMSVGStringList::GetDOMWrapper(
|
||||
&mStringListAttributes[VIEW_TARGET], this, false, VIEW_TARGET).get();
|
||||
*aViewTarget = ViewTarget().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGStringList>
|
||||
SVGViewElement::ViewTarget()
|
||||
{
|
||||
return DOMSVGStringList::GetDOMWrapper(
|
||||
&mStringListAttributes[VIEW_TARGET], this, false, VIEW_TARGET);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
|
@ -33,12 +33,14 @@ class SVGViewElement : public SVGViewElementBase,
|
||||
public nsIDOMSVGFitToViewBox,
|
||||
public nsIDOMSVGZoomAndPan
|
||||
{
|
||||
protected:
|
||||
friend class mozilla::SVGFragmentIdentifier;
|
||||
friend class ::nsSVGSVGElement;
|
||||
friend class ::nsSVGOuterSVGFrame;
|
||||
SVGViewElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
friend nsresult (::NS_NewSVGViewElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo));
|
||||
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
@ -59,6 +61,14 @@ public:
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
// WebIDL
|
||||
uint16_t ZoomAndPan() { return mEnumAttributes[ZOOMANDPAN].GetAnimValue(); }
|
||||
void SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv);
|
||||
already_AddRefed<nsIDOMSVGAnimatedRect> ViewBox();
|
||||
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
|
||||
already_AddRefed<nsIDOMSVGStringList> ViewTarget();
|
||||
|
||||
private:
|
||||
|
||||
// nsSVGElement overrides
|
||||
|
20
dom/webidl/SVGFitToViewBox.webidl
Normal file
20
dom/webidl/SVGFitToViewBox.webidl
Normal file
@ -0,0 +1,20 @@
|
||||
/* -*- 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 SVGAnimatedRect;
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface SVGFitToViewBox {
|
||||
readonly attribute SVGAnimatedRect viewBox;
|
||||
readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
|
||||
};
|
||||
|
21
dom/webidl/SVGViewElement.webidl
Normal file
21
dom/webidl/SVGViewElement.webidl
Normal file
@ -0,0 +1,21 @@
|
||||
/* -*- 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 SVGStringList;
|
||||
|
||||
interface SVGViewElement : SVGElement {
|
||||
readonly attribute SVGStringList viewTarget;
|
||||
};
|
||||
|
||||
SVGViewElement implements SVGFitToViewBox;
|
||||
SVGViewElement implements SVGZoomAndPan;
|
||||
|
24
dom/webidl/SVGZoomAndPan.webidl
Normal file
24
dom/webidl/SVGZoomAndPan.webidl
Normal file
@ -0,0 +1,24 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface SVGZoomAndPan {
|
||||
|
||||
// Zoom and Pan Types
|
||||
const unsigned short SVG_ZOOMANDPAN_UNKNOWN = 0;
|
||||
const unsigned short SVG_ZOOMANDPAN_DISABLE = 1;
|
||||
const unsigned short SVG_ZOOMANDPAN_MAGNIFY = 2;
|
||||
|
||||
[SetterThrows]
|
||||
attribute unsigned short zoomAndPan;
|
||||
};
|
||||
|
@ -114,6 +114,7 @@ webidl_files = \
|
||||
SVGDescElement.webidl \
|
||||
SVGElement.webidl \
|
||||
SVGEllipseElement.webidl \
|
||||
SVGFitToViewBox.webidl \
|
||||
SVGForeignObjectElement.webidl \
|
||||
SVGGElement.webidl \
|
||||
SVGGraphicsElement.webidl \
|
||||
@ -149,6 +150,8 @@ webidl_files = \
|
||||
SVGTransformList.webidl \
|
||||
SVGTSpanElement.webidl \
|
||||
SVGURIReference.webidl \
|
||||
SVGViewElement.webidl \
|
||||
SVGZoomAndPan.webidl \
|
||||
Text.webidl \
|
||||
TextDecoder.webidl \
|
||||
TextEncoder.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user