Bug 825732: Convert SVGAltGlyphElement to WebIDL r=bz

--HG--
rename : content/svg/content/src/nsSVGAltGlyphElement.cpp => content/svg/content/src/SVGAltGlyphElement.cpp
rename : content/svg/content/src/nsSVGAltGlyphElement.cpp => content/svg/content/src/SVGAltGlyphElement.h
This commit is contained in:
David Zbarsky 2013-01-06 09:14:44 -05:00
parent 30cda6d591
commit 66be4382c0
9 changed files with 241 additions and 183 deletions

View File

@ -37,7 +37,6 @@ CPPSRCS = \
nsDOMSVGZoomEvent.cpp \
nsDOMSVGEvent.cpp \
nsSVGAElement.cpp \
nsSVGAltGlyphElement.cpp \
nsSVGAngle.cpp \
nsSVGBoolean.cpp \
nsSVGClass.cpp \
@ -70,6 +69,7 @@ CPPSRCS = \
nsSVGUseElement.cpp \
nsSVGViewBox.cpp \
nsSVGViewElement.cpp \
SVGAltGlyphElement.cpp \
SVGAngle.cpp \
SVGAnimatedAngle.cpp \
SVGAnimatedBoolean.cpp \
@ -153,6 +153,7 @@ EXPORTS = \
EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = \
SVGAltGlyphElement.h \
SVGAngle.h \
SVGAnimatedAngle.h \
SVGAnimatedBoolean.h \

View File

@ -0,0 +1,140 @@
/* -*- 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/SVGAltGlyphElement.h"
#include "mozilla/dom/SVGAltGlyphElementBinding.h"
#include "nsContentUtils.h"
DOMCI_NODE_DATA(SVGAltGlyphElement, mozilla::dom::SVGAltGlyphElement)
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(AltGlyph)
namespace mozilla {
namespace dom {
JSObject*
SVGAltGlyphElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGAltGlyphElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
nsSVGElement::StringInfo SVGAltGlyphElement::sStringInfo[1] =
{
{ &nsGkAtoms::href, kNameSpaceID_XLink, false }
};
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGAltGlyphElement,SVGAltGlyphElementBase)
NS_IMPL_RELEASE_INHERITED(SVGAltGlyphElement,SVGAltGlyphElementBase)
NS_INTERFACE_TABLE_HEAD(SVGAltGlyphElement)
NS_NODE_INTERFACE_TABLE7(SVGAltGlyphElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGAltGlyphElement,
nsIDOMSVGTextPositioningElement, nsIDOMSVGTextContentElement,
nsIDOMSVGURIReference)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAltGlyphElement)
NS_INTERFACE_MAP_END_INHERITING(SVGAltGlyphElementBase)
//----------------------------------------------------------------------
// Implementation
SVGAltGlyphElement::SVGAltGlyphElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGAltGlyphElementBase(aNodeInfo)
{
SetIsDOMBinding();
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAltGlyphElement)
//----------------------------------------------------------------------
// nsIDOMSVGURIReference methods
/* readonly attribute nsIDOMSVGAnimatedString href; */
NS_IMETHODIMP SVGAltGlyphElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
{
*aHref = Href().get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedString>
SVGAltGlyphElement::Href()
{
nsCOMPtr<nsIDOMSVGAnimatedString> href;
mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this);
return href.forget();
}
//----------------------------------------------------------------------
// nsIDOMSVGAltGlyphElement methods
/* attribute DOMString glyphRef; */
NS_IMETHODIMP SVGAltGlyphElement::GetGlyphRef(nsAString & aGlyphRef)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::glyphRef, aGlyphRef);
return NS_OK;
}
NS_IMETHODIMP SVGAltGlyphElement::SetGlyphRef(const nsAString & aGlyphRef)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::glyphRef, aGlyphRef, true);
}
/* attribute DOMString format; */
NS_IMETHODIMP SVGAltGlyphElement::GetFormat(nsAString & aFormat)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::format, aFormat);
return NS_OK;
}
NS_IMETHODIMP SVGAltGlyphElement::SetFormat(const nsAString & aFormat)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::format, aFormat, true);
}
//----------------------------------------------------------------------
// nsIContent methods
NS_IMETHODIMP_(bool)
SVGAltGlyphElement::IsAttributeMapped(const nsIAtom* name) const
{
static const MappedAttributeEntry* const map[] = {
sColorMap,
sFillStrokeMap,
sFontSpecificationMap,
sGraphicsMap,
sTextContentElementsMap
};
return FindAttributeDependence(name, map) ||
SVGAltGlyphElementBase::IsAttributeMapped(name);
}
//----------------------------------------------------------------------
// nsSVGElement overrides
bool
SVGAltGlyphElement::IsEventName(nsIAtom* aName)
{
return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic);
}
nsSVGElement::StringAttributesInfo
SVGAltGlyphElement::GetStringInfo()
{
return StringAttributesInfo(mStringAttributes, sStringInfo,
ArrayLength(sStringInfo));
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,75 @@
/* -*- 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_SVGAltGlyphElement_h
#define mozilla_dom_SVGAltGlyphElement_h
#include "nsIDOMSVGAltGlyphElement.h"
#include "nsIDOMSVGURIReference.h"
#include "mozilla/dom/SVGTextPositioningElement.h"
#include "nsSVGString.h"
nsresult NS_NewSVGAltGlyphElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
namespace mozilla {
namespace dom {
typedef SVGTextPositioningElement SVGAltGlyphElementBase;
class SVGAltGlyphElement MOZ_FINAL : public SVGAltGlyphElementBase, // = nsIDOMSVGTextPositioningElement
public nsIDOMSVGAltGlyphElement,
public nsIDOMSVGURIReference
{
protected:
friend nsresult (::NS_NewSVGAltGlyphElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
SVGAltGlyphElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGALTGLYPHELEMENT
NS_DECL_NSIDOMSVGURIREFERENCE
// xxx If xpcom allowed virtual inheritance we wouldn't need to
// forward here :-(
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(SVGAltGlyphElementBase::)
NS_FORWARD_NSIDOMSVGTEXTCONTENTELEMENT(SVGAltGlyphElementBase::)
NS_FORWARD_NSIDOMSVGTEXTPOSITIONINGELEMENT(SVGAltGlyphElementBase::)
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
already_AddRefed<nsIDOMSVGAnimatedString> Href();
protected:
// nsSVGElement overrides
virtual StringAttributesInfo GetStringInfo();
virtual bool IsEventName(nsIAtom* aName);
enum { HREF };
nsSVGString mStringAttributes[1];
static StringInfo sStringInfo[1];
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGAltGlyphElement_h

View File

@ -6,7 +6,6 @@
#include "mozilla/Util.h"
#include "mozilla/dom/SVGTextPositioningElement.h"
#include "mozilla/dom/SVGTextPositioningElementBinding.h"
#include "SVGAnimatedLengthList.h"
#include "DOMSVGAnimatedLengthList.h"
#include "DOMSVGAnimatedNumberList.h"
@ -16,12 +15,6 @@
namespace mozilla {
namespace dom {
JSObject*
SVGTextPositioningElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGTextPositioningElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
nsSVGElement::LengthListInfo SVGTextPositioningElement::sLengthListInfo[4] =
{
{ &nsGkAtoms::x, SVGContentUtils::X, false },

View File

@ -38,7 +38,6 @@ protected:
SVGTextPositioningElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGTextPositioningElementBase(aNodeInfo)
{}
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
virtual LengthListAttributesInfo GetLengthListInfo();
virtual NumberListAttributesInfo GetNumberListInfo();

View File

@ -1,174 +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 "nsGkAtoms.h"
#include "nsIDOMSVGAltGlyphElement.h"
#include "nsIDOMSVGURIReference.h"
#include "nsSVGString.h"
#include "SVGTextPositioningElement.h"
#include "nsContentUtils.h"
using namespace mozilla;
typedef dom::SVGTextPositioningElement nsSVGAltGlyphElementBase;
class nsSVGAltGlyphElement : public nsSVGAltGlyphElementBase, // = nsIDOMSVGTextPositioningElement
public nsIDOMSVGAltGlyphElement,
public nsIDOMSVGURIReference
{
protected:
friend nsresult NS_NewSVGAltGlyphElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGAltGlyphElement(already_AddRefed<nsINodeInfo> aNodeInfo);
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGALTGLYPHELEMENT
NS_DECL_NSIDOMSVGURIREFERENCE
// xxx If xpcom allowed virtual inheritance we wouldn't need to
// forward here :-(
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAltGlyphElementBase::)
NS_FORWARD_NSIDOMSVGTEXTCONTENTELEMENT(nsSVGAltGlyphElementBase::)
NS_FORWARD_NSIDOMSVGTEXTPOSITIONINGELEMENT(nsSVGAltGlyphElementBase::)
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
protected:
// nsSVGElement overrides
virtual StringAttributesInfo GetStringInfo();
enum { HREF };
nsSVGString mStringAttributes[1];
static StringInfo sStringInfo[1];
};
nsSVGElement::StringInfo nsSVGAltGlyphElement::sStringInfo[1] =
{
{ &nsGkAtoms::href, kNameSpaceID_XLink, false }
};
NS_IMPL_NS_NEW_SVG_ELEMENT(AltGlyph)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGAltGlyphElement,nsSVGAltGlyphElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGAltGlyphElement,nsSVGAltGlyphElementBase)
DOMCI_NODE_DATA(SVGAltGlyphElement, nsSVGAltGlyphElement)
NS_INTERFACE_TABLE_HEAD(nsSVGAltGlyphElement)
NS_NODE_INTERFACE_TABLE7(nsSVGAltGlyphElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGAltGlyphElement,
nsIDOMSVGTextPositioningElement, nsIDOMSVGTextContentElement,
nsIDOMSVGURIReference)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAltGlyphElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGAltGlyphElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGAltGlyphElement::nsSVGAltGlyphElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGAltGlyphElementBase(aNodeInfo)
{
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAltGlyphElement)
//----------------------------------------------------------------------
// nsIDOMSVGURIReference methods
/* readonly attribute nsIDOMSVGAnimatedString href; */
NS_IMETHODIMP nsSVGAltGlyphElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
{
return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
}
//----------------------------------------------------------------------
// nsIDOMSVGAltGlyphElement methods
/* attribute DOMString glyphRef; */
NS_IMETHODIMP nsSVGAltGlyphElement::GetGlyphRef(nsAString & aGlyphRef)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::glyphRef, aGlyphRef);
return NS_OK;
}
NS_IMETHODIMP nsSVGAltGlyphElement::SetGlyphRef(const nsAString & aGlyphRef)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::glyphRef, aGlyphRef, true);
}
/* attribute DOMString format; */
NS_IMETHODIMP nsSVGAltGlyphElement::GetFormat(nsAString & aFormat)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::format, aFormat);
return NS_OK;
}
NS_IMETHODIMP nsSVGAltGlyphElement::SetFormat(const nsAString & aFormat)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::format, aFormat, true);
}
//----------------------------------------------------------------------
// nsIContent methods
NS_IMETHODIMP_(bool)
nsSVGAltGlyphElement::IsAttributeMapped(const nsIAtom* name) const
{
static const MappedAttributeEntry* const map[] = {
sColorMap,
sFillStrokeMap,
sFontSpecificationMap,
sGraphicsMap,
sTextContentElementsMap
};
return FindAttributeDependence(name, map) ||
nsSVGAltGlyphElementBase::IsAttributeMapped(name);
}
bool
nsSVGAltGlyphElement::IsEventAttributeName(nsIAtom* aName)
{
return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic);
}
//----------------------------------------------------------------------
// nsSVGElement overrides
nsSVGElement::StringAttributesInfo
nsSVGAltGlyphElement::GetStringInfo()
{
return StringAttributesInfo(mStringAttributes, sStringInfo,
ArrayLength(sStringInfo));
}

View File

@ -772,6 +772,10 @@ DOMInterfaces = {
'concrete': False
},
'SVGTextPositioningElement': {
'concrete': False
},
'SVGTitleElement': {
'hasInstanceInterface': 'nsIDOMSVGTitleElement',
},

View File

@ -0,0 +1,19 @@
/* -*- 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 SVGAltGlyphElement : SVGTextPositioningElement {
attribute DOMString glyphRef;
attribute DOMString format;
};
SVGAltGlyphElement implements SVGURIReference;

View File

@ -96,6 +96,7 @@ webidl_files = \
Rect.webidl \
RGBColor.webidl \
Screen.webidl \
SVGAltGlyphElement.webidl \
SVGAngle.webidl \
SVGAnimatedAngle.webidl \
SVGAnimatedBoolean.webidl \