Bug 825147: Convert SVGAElement to WebIDL r=bz

--HG--
rename : content/svg/content/src/nsSVGAElement.cpp => content/svg/content/src/SVGAElement.cpp
rename : content/svg/content/src/nsSVGAElement.h => content/svg/content/src/SVGAElement.h
This commit is contained in:
David Zbarsky 2013-01-10 00:30:13 -05:00
parent 4074a8af76
commit cd990802cf
7 changed files with 138 additions and 67 deletions

View File

@ -36,7 +36,6 @@ CPPSRCS = \
DOMSVGTransformList.cpp \
nsDOMSVGZoomEvent.cpp \
nsDOMSVGEvent.cpp \
nsSVGAElement.cpp \
nsSVGAngle.cpp \
nsSVGBoolean.cpp \
nsSVGClass.cpp \
@ -67,6 +66,7 @@ CPPSRCS = \
nsSVGUnknownElement.cpp \
nsSVGUseElement.cpp \
nsSVGViewBox.cpp \
SVGAElement.cpp \
SVGAltGlyphElement.cpp \
SVGAngle.cpp \
SVGAnimatedAngle.cpp \
@ -153,6 +153,7 @@ EXPORTS = \
EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = \
SVGAElement.h \
SVGAltGlyphElement.h \
SVGAngle.h \
SVGAnimatedAngle.h \

View File

@ -5,7 +5,8 @@
#include "mozilla/Util.h"
#include "nsSVGAElement.h"
#include "mozilla/dom/SVGAElement.h"
#include "mozilla/dom/SVGAElementBinding.h"
#include "nsIDOMSVGAElement.h"
#include "nsIDOMSVGURIReference.h"
#include "nsILink.h"
@ -14,28 +15,34 @@
#include "nsGkAtoms.h"
#include "nsContentUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
DOMCI_NODE_DATA(SVGAElement, mozilla::dom::SVGAElement)
nsSVGElement::StringInfo nsSVGAElement::sStringInfo[2] =
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(A)
namespace mozilla {
namespace dom {
JSObject*
SVGAElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGAElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
nsSVGElement::StringInfo SVGAElement::sStringInfo[2] =
{
{ &nsGkAtoms::href, kNameSpaceID_XLink, true },
{ &nsGkAtoms::target, kNameSpaceID_None, true }
};
NS_IMPL_NS_NEW_SVG_ELEMENT(A)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGAElement, nsSVGAElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGAElement, nsSVGAElementBase)
NS_IMPL_ADDREF_INHERITED(SVGAElement, SVGAElementBase)
NS_IMPL_RELEASE_INHERITED(SVGAElement, SVGAElementBase)
DOMCI_NODE_DATA(SVGAElement, nsSVGAElement)
NS_INTERFACE_TABLE_HEAD(nsSVGAElement)
NS_NODE_INTERFACE_TABLE7(nsSVGAElement,
NS_INTERFACE_TABLE_HEAD(SVGAElement)
NS_NODE_INTERFACE_TABLE7(SVGAElement,
nsIDOMNode,
nsIDOMElement,
nsIDOMSVGElement,
@ -44,16 +51,17 @@ NS_INTERFACE_TABLE_HEAD(nsSVGAElement)
nsILink,
Link)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGAElementBase)
NS_INTERFACE_MAP_END_INHERITING(SVGAElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGAElement::nsSVGAElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGAElementBase(aNodeInfo),
SVGAElement::SVGAElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGAElementBase(aNodeInfo),
Link(this)
{
SetIsDOMBinding();
}
//----------------------------------------------------------------------
@ -61,18 +69,27 @@ nsSVGAElement::nsSVGAElement(already_AddRefed<nsINodeInfo> aNodeInfo)
/* readonly attribute nsIDOMSVGAnimatedString href; */
NS_IMETHODIMP
nsSVGAElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
SVGAElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
{
return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
*aHref = Href().get();
return NS_OK;
}
NS_IMPL_STRING_ATTR(nsSVGAElement, Download, download)
already_AddRefed<nsIDOMSVGAnimatedString>
SVGAElement::Href()
{
nsCOMPtr<nsIDOMSVGAnimatedString> href;
mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this);
return href.forget();
}
NS_IMPL_STRING_ATTR(SVGAElement, Download, download)
//----------------------------------------------------------------------
// nsINode methods
nsresult
nsSVGAElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
SVGAElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{
nsresult rv = Element::PreHandleEvent(aVisitor);
NS_ENSURE_SUCCESS(rv, rv);
@ -81,12 +98,12 @@ nsSVGAElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
nsresult
nsSVGAElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
SVGAElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
{
return PostHandleEventForLinks(aVisitor);
}
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAElement)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAElement)
//----------------------------------------------------------------------
@ -94,27 +111,37 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAElement)
/* readonly attribute nsIDOMSVGAnimatedString target; */
NS_IMETHODIMP
nsSVGAElement::GetTarget(nsIDOMSVGAnimatedString * *aTarget)
SVGAElement::GetTarget(nsIDOMSVGAnimatedString * *aTarget)
{
return mStringAttributes[TARGET].ToDOMAnimatedString(aTarget, this);
*aTarget = Target().get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedString>
SVGAElement::Target()
{
nsCOMPtr<nsIDOMSVGAnimatedString> target;
mStringAttributes[TARGET].ToDOMAnimatedString(getter_AddRefs(target), this);
return target.forget();
}
//----------------------------------------------------------------------
// nsIContent methods
nsresult
nsSVGAElement::BindToTree(nsIDocument *aDocument, nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers)
SVGAElement::BindToTree(nsIDocument *aDocument, nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers)
{
Link::ResetLinkState(false, Link::ElementHasHref());
nsresult rv = nsSVGAElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
nsresult rv = SVGAElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
aDocument->RegisterPendingLinkUpdate(this);
}
@ -123,28 +150,28 @@ nsSVGAElement::BindToTree(nsIDocument *aDocument, nsIContent *aParent,
}
void
nsSVGAElement::UnbindFromTree(bool aDeep, bool aNullParent)
SVGAElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
// If this link is ever reinserted into a document, it might
// be under a different xml:base, so forget the cached state now.
Link::ResetLinkState(false, Link::ElementHasHref());
nsIDocument* doc = GetCurrentDoc();
if (doc) {
doc->UnregisterPendingLinkUpdate(this);
}
nsSVGAElementBase::UnbindFromTree(aDeep, aNullParent);
SVGAElementBase::UnbindFromTree(aDeep, aNullParent);
}
nsLinkState
nsSVGAElement::GetLinkState() const
SVGAElement::GetLinkState() const
{
return Link::GetLinkState();
}
already_AddRefed<nsIURI>
nsSVGAElement::GetHrefURI() const
SVGAElement::GetHrefURI() const
{
nsCOMPtr<nsIURI> hrefURI;
return IsLink(getter_AddRefs(hrefURI)) ? hrefURI.forget() : nullptr;
@ -152,7 +179,7 @@ nsSVGAElement::GetHrefURI() const
NS_IMETHODIMP_(bool)
nsSVGAElement::IsAttributeMapped(const nsIAtom* name) const
SVGAElement::IsAttributeMapped(const nsIAtom* name) const
{
static const MappedAttributeEntry* const map[] = {
sFEFloodMap,
@ -166,11 +193,11 @@ nsSVGAElement::IsAttributeMapped(const nsIAtom* name) const
};
return FindAttributeDependence(name, map) ||
nsSVGAElementBase::IsAttributeMapped(name);
SVGAElementBase::IsAttributeMapped(name);
}
bool
nsSVGAElement::IsFocusable(int32_t *aTabIndex, bool aWithMouse)
SVGAElement::IsFocusable(int32_t *aTabIndex, bool aWithMouse)
{
nsCOMPtr<nsIURI> uri;
if (IsLink(getter_AddRefs(uri))) {
@ -188,7 +215,7 @@ nsSVGAElement::IsFocusable(int32_t *aTabIndex, bool aWithMouse)
}
bool
nsSVGAElement::IsLink(nsIURI** aURI) const
SVGAElement::IsLink(nsIURI** aURI) const
{
// To be a clickable XLink for styling and interaction purposes, we require:
//
@ -237,7 +264,7 @@ nsSVGAElement::IsLink(nsIURI** aURI) const
}
void
nsSVGAElement::GetLinkTarget(nsAString& aTarget)
SVGAElement::GetLinkTarget(nsAString& aTarget)
{
mStringAttributes[TARGET].GetAnimValue(aTarget, this);
if (aTarget.IsEmpty()) {
@ -261,18 +288,18 @@ nsSVGAElement::GetLinkTarget(nsAString& aTarget)
}
nsEventStates
nsSVGAElement::IntrinsicState() const
SVGAElement::IntrinsicState() const
{
return Link::LinkState() | nsSVGAElementBase::IntrinsicState();
return Link::LinkState() | SVGAElementBase::IntrinsicState();
}
nsresult
nsSVGAElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
SVGAElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
{
nsresult rv = nsSVGAElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
nsresult rv = SVGAElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
// The ordering of the parent class's SetAttr call and Link::ResetLinkState
// is important here! The attribute is not set until SetAttr returns, and
@ -287,8 +314,8 @@ nsSVGAElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
nsresult
nsSVGAElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
bool aNotify)
SVGAElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
bool aNotify)
{
nsresult rv = nsSVGElement::UnsetAttr(aNameSpaceID, aAttr, aNotify);
@ -308,8 +335,11 @@ nsSVGAElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
// nsSVGElement methods
nsSVGElement::StringAttributesInfo
nsSVGAElement::GetStringInfo()
SVGAElement::GetStringInfo()
{
return StringAttributesInfo(mStringAttributes, sStringInfo,
ArrayLength(sStringInfo));
}
} // namespace dom
} // namespace mozilla

View File

@ -3,28 +3,35 @@
* 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 NS_SVGAELEMENT_H_
#define NS_SVGAELEMENT_H_
#ifndef mozilla_dom_SVGAElement_h
#define mozilla_dom_SVGAElement_h
#include "Link.h"
#include "nsIDOMSVGAElement.h"
#include "nsIDOMSVGURIReference.h"
#include "nsILink.h"
#include "nsSVGString.h"
#include "SVGGraphicsElement.h"
#include "mozilla/dom/SVGGraphicsElement.h"
typedef mozilla::dom::SVGGraphicsElement nsSVGAElementBase;
nsresult NS_NewSVGAElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
class nsSVGAElement : public nsSVGAElementBase,
public nsIDOMSVGAElement,
public nsIDOMSVGURIReference,
public nsILink,
public mozilla::dom::Link
namespace mozilla {
namespace dom {
typedef SVGGraphicsElement SVGAElementBase;
class SVGAElement MOZ_FINAL : public SVGAElementBase,
public nsIDOMSVGAElement,
public nsIDOMSVGURIReference,
public nsILink,
public Link
{
protected:
friend nsresult NS_NewSVGAElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGAElement(already_AddRefed<nsINodeInfo> aNodeInfo);
SVGAElement(already_AddRefed<nsINodeInfo> aNodeInfo);
friend nsresult (::NS_NewSVGAElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
@ -36,7 +43,7 @@ public:
// XXX: I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAElementBase::)
NS_FORWARD_NSIDOMSVGELEMENT(SVGAElementBase::)
// nsINode interface methods
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
@ -74,6 +81,11 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
already_AddRefed<nsIDOMSVGAnimatedString> Href();
already_AddRefed<nsIDOMSVGAnimatedString> Target();
protected:
virtual StringAttributesInfo GetStringInfo();
@ -83,4 +95,7 @@ protected:
static StringInfo sStringInfo[2];
};
#endif // NS_SVGAELEMENT_H_
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGAElement_h

View File

@ -589,6 +589,10 @@ DOMInterfaces = {
'prefable': True,
},
'SVGAElement': {
'hasInstanceInterface': 'nsIDOMSVGAElement',
},
'SVGAnimatedLengthList': {
'nativeType': 'mozilla::DOMSVGAnimatedLengthList',
'headerFile': 'DOMSVGAnimatedLengthList.h'

View 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 SVGAnimatedString;
interface SVGAElement : SVGGraphicsElement {
readonly attribute SVGAnimatedString target;
};
SVGAElement implements SVGURIReference;

View File

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

View File

@ -5,7 +5,7 @@
// Keep in (case-insensitive) order:
#include "gfxMatrix.h"
#include "nsSVGAElement.h"
#include "mozilla/dom/SVGAElement.h"
#include "nsSVGIntegrationUtils.h"
#include "nsSVGTSpanFrame.h"
#include "nsSVGUtils.h"
@ -153,7 +153,7 @@ nsSVGAFrame::GetCanvasTM(uint32_t aFor)
NS_ASSERTION(mParent, "null parent");
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
nsSVGAElement *content = static_cast<nsSVGAElement*>(mContent);
dom::SVGAElement *content = static_cast<dom::SVGAElement*>(mContent);
gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM(aFor));