Bug 825147: Convert SVGImageElement to WebIDL r=bz

--HG--
rename : content/svg/content/src/nsSVGImageElement.cpp => content/svg/content/src/SVGImageElement.cpp
rename : content/svg/content/src/nsSVGImageElement.h => content/svg/content/src/SVGImageElement.h
This commit is contained in:
David Zbarsky 2013-01-06 04:32:01 -05:00
parent f391a152cf
commit 35604d01d3
15 changed files with 270 additions and 95 deletions

View File

@ -52,7 +52,6 @@ CPPSRCS = \
nsSVGFilterElement.cpp \
nsSVGFilters.cpp \
nsSVGGradientElement.cpp \
nsSVGImageElement.cpp \
nsSVGInteger.cpp \
nsSVGIntegerPair.cpp \
nsSVGLength2.cpp \
@ -94,6 +93,7 @@ CPPSRCS = \
SVGFragmentIdentifier.cpp \
SVGGElement.cpp \
SVGGraphicsElement.cpp \
SVGImageElement.cpp \
SVGLength.cpp \
SVGLengthList.cpp \
SVGNumberList.cpp \
@ -161,6 +161,7 @@ EXPORTS_mozilla/dom = \
SVGForeignObjectElement.h \
SVGGElement.h \
SVGGraphicsElement.h \
SVGImageElement.h \
SVGLocatableElement.h \
SVGMetadataElement.h \
SVGMPathElement.h \

View File

@ -283,7 +283,7 @@ SVGAnimatedPreserveAspectRatio::SetAnimValue(uint64_t aPackedValue,
nsresult
SVGAnimatedPreserveAspectRatio::ToDOMAnimatedPreserveAspectRatio(
nsISupports **aResult,
DOMSVGAnimatedPreserveAspectRatio **aResult,
nsSVGElement *aSVGElement)
{
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> domAnimatedPAspectRatio =

View File

@ -18,6 +18,9 @@ class nsISMILAnimationElement;
class nsSMILValue;
namespace mozilla {
namespace dom {
class DOMSVGAnimatedPreserveAspectRatio;
}
class SVGAnimatedPreserveAspectRatio MOZ_FINAL
{
@ -72,7 +75,7 @@ public:
{ return mIsAnimated || mIsBaseSet; }
nsresult ToDOMAnimatedPreserveAspectRatio(
nsISupports **aResult,
mozilla::dom::DOMSVGAnimatedPreserveAspectRatio **aResult,
nsSVGElement* aSVGElement);
// Returns a new nsISMILAttr object that the caller must delete
nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);

View File

@ -5,18 +5,29 @@
#include "mozilla/Util.h"
#include "nsSVGImageElement.h"
#include "mozilla/dom/SVGImageElement.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "imgIContainer.h"
#include "imgINotificationObserver.h"
#include "gfxContext.h"
#include "mozilla/dom/SVGImageElementBinding.h"
using namespace mozilla;
using namespace mozilla::dom;
DOMCI_NODE_DATA(SVGImageElement, mozilla::dom::SVGImageElement)
nsSVGElement::LengthInfo nsSVGImageElement::sLengthInfo[4] =
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Image)
namespace mozilla {
namespace dom {
JSObject*
SVGImageElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGImageElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
nsSVGElement::LengthInfo SVGImageElement::sLengthInfo[4] =
{
{ &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
{ &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
@ -24,41 +35,38 @@ nsSVGElement::LengthInfo nsSVGImageElement::sLengthInfo[4] =
{ &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
};
nsSVGElement::StringInfo nsSVGImageElement::sStringInfo[1] =
nsSVGElement::StringInfo SVGImageElement::sStringInfo[1] =
{
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Image)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGImageElement,nsSVGImageElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGImageElement,nsSVGImageElementBase)
NS_IMPL_ADDREF_INHERITED(SVGImageElement,SVGImageElementBase)
NS_IMPL_RELEASE_INHERITED(SVGImageElement,SVGImageElementBase)
DOMCI_NODE_DATA(SVGImageElement, nsSVGImageElement)
NS_INTERFACE_TABLE_HEAD(nsSVGImageElement)
NS_NODE_INTERFACE_TABLE8(nsSVGImageElement, nsIDOMNode, nsIDOMElement,
NS_INTERFACE_TABLE_HEAD(SVGImageElement)
NS_NODE_INTERFACE_TABLE8(SVGImageElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement,
nsIDOMSVGImageElement,
nsIDOMSVGURIReference, imgINotificationObserver,
nsIImageLoadingContent, imgIOnloadBlocker)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGImageElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGImageElementBase)
NS_INTERFACE_MAP_END_INHERITING(SVGImageElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGImageElement::nsSVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGImageElementBase(aNodeInfo)
SVGImageElement::SVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGImageElementBase(aNodeInfo)
{
SetIsDOMBinding();
// We start out broken
AddStatesSilently(NS_EVENT_STATE_BROKEN);
}
nsSVGImageElement::~nsSVGImageElement()
SVGImageElement::~SVGImageElement()
{
DestroyImageLoadingContent();
}
@ -67,42 +75,87 @@ nsSVGImageElement::~nsSVGImageElement()
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGImageElement)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGImageElement)
//----------------------------------------------------------------------
// nsIDOMSVGImageElement methods:
/* readonly attribute nsIDOMSVGAnimatedLength x; */
NS_IMETHODIMP nsSVGImageElement::GetX(nsIDOMSVGAnimatedLength * *aX)
NS_IMETHODIMP SVGImageElement::GetX(nsIDOMSVGAnimatedLength * *aX)
{
return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
*aX = X().get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedLength>
SVGImageElement::X()
{
nsCOMPtr<nsIDOMSVGAnimatedLength> x;
mLengthAttributes[ATTR_X].ToDOMAnimatedLength(getter_AddRefs(x), this);
return x.forget();
}
/* readonly attribute nsIDOMSVGAnimatedLength y; */
NS_IMETHODIMP nsSVGImageElement::GetY(nsIDOMSVGAnimatedLength * *aY)
NS_IMETHODIMP SVGImageElement::GetY(nsIDOMSVGAnimatedLength * *aY)
{
return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
*aY = Y().get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedLength>
SVGImageElement::Y()
{
nsCOMPtr<nsIDOMSVGAnimatedLength> y;
mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(getter_AddRefs(y), this);
return y.forget();
}
/* readonly attribute nsIDOMSVGAnimatedLength width; */
NS_IMETHODIMP nsSVGImageElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
NS_IMETHODIMP SVGImageElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
{
return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
*aWidth = Width().get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedLength>
SVGImageElement::Width()
{
nsCOMPtr<nsIDOMSVGAnimatedLength> width;
mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(getter_AddRefs(width), this);
return width.forget();
}
/* readonly attribute nsIDOMSVGAnimatedLength height; */
NS_IMETHODIMP nsSVGImageElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
NS_IMETHODIMP SVGImageElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
{
return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
*aHeight = Height().get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedLength>
SVGImageElement::Height()
{
nsCOMPtr<nsIDOMSVGAnimatedLength> height;
mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(getter_AddRefs(height), this);
return height.forget();
}
/* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
NS_IMETHODIMP
nsSVGImageElement::GetPreserveAspectRatio(nsISupports
**aPreserveAspectRatio)
SVGImageElement::GetPreserveAspectRatio(nsISupports
**aPreserveAspectRatio)
{
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
*aPreserveAspectRatio = PreserveAspectRatio().get();
return NS_OK;
}
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
SVGImageElement::PreserveAspectRatio()
{
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
return ratio.forget();
}
//----------------------------------------------------------------------
@ -110,15 +163,24 @@ nsSVGImageElement::GetPreserveAspectRatio(nsISupports
/* readonly attribute nsIDOMSVGAnimatedString href; */
NS_IMETHODIMP
nsSVGImageElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
SVGImageElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
{
return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
*aHref = Href().get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedString>
SVGImageElement::Href()
{
nsCOMPtr<nsIDOMSVGAnimatedString> href;
mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this);
return href.forget();;
}
//----------------------------------------------------------------------
nsresult
nsSVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
SVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
{
// resolve href attribute
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
@ -137,8 +199,8 @@ nsSVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
// nsIContent methods:
nsresult
nsSVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
SVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
@ -160,12 +222,12 @@ nsSVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
}
}
}
return nsSVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
aValue, aNotify);
return SVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
aValue, aNotify);
}
void
nsSVGImageElement::MaybeLoadSVGImage()
SVGImageElement::MaybeLoadSVGImage()
{
if (mStringAttributes[HREF].IsExplicitlySet() &&
(NS_FAILED(LoadSVGImage(false, true)) ||
@ -175,13 +237,13 @@ nsSVGImageElement::MaybeLoadSVGImage()
}
nsresult
nsSVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
SVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsSVGImageElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
nsresult rv = SVGImageElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
@ -193,35 +255,35 @@ nsSVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
ClearBrokenState();
RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsSVGImageElement::MaybeLoadSVGImage));
NS_NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage));
}
return rv;
}
void
nsSVGImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
SVGImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
nsSVGImageElementBase::UnbindFromTree(aDeep, aNullParent);
SVGImageElementBase::UnbindFromTree(aDeep, aNullParent);
}
nsEventStates
nsSVGImageElement::IntrinsicState() const
SVGImageElement::IntrinsicState() const
{
return nsSVGImageElementBase::IntrinsicState() |
return SVGImageElementBase::IntrinsicState() |
nsImageLoadingContent::ImageState();
}
NS_IMETHODIMP_(bool)
nsSVGImageElement::IsAttributeMapped(const nsIAtom* name) const
SVGImageElement::IsAttributeMapped(const nsIAtom* name) const
{
static const MappedAttributeEntry* const map[] = {
sViewportsMap,
};
return FindAttributeDependence(name, map) ||
nsSVGImageElementBase::IsAttributeMapped(name);
SVGImageElementBase::IsAttributeMapped(name);
}
//----------------------------------------------------------------------
@ -230,7 +292,7 @@ nsSVGImageElement::IsAttributeMapped(const nsIAtom* name) const
/* For the purposes of the update/invalidation logic pretend to
be a rectangle. */
void
nsSVGImageElement::ConstructPath(gfxContext *aCtx)
SVGImageElement::ConstructPath(gfxContext *aCtx)
{
float x, y, width, height;
@ -246,39 +308,43 @@ nsSVGImageElement::ConstructPath(gfxContext *aCtx)
// nsSVGElement methods
/* virtual */ bool
nsSVGImageElement::HasValidDimensions() const
SVGImageElement::HasValidDimensions() const
{
return mLengthAttributes[WIDTH].IsExplicitlySet() &&
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
mLengthAttributes[HEIGHT].IsExplicitlySet() &&
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
}
nsSVGElement::LengthAttributesInfo
nsSVGImageElement::GetLengthInfo()
SVGImageElement::GetLengthInfo()
{
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
ArrayLength(sLengthInfo));
}
SVGAnimatedPreserveAspectRatio *
nsSVGImageElement::GetPreserveAspectRatio()
SVGImageElement::GetPreserveAspectRatio()
{
return &mPreserveAspectRatio;
}
nsSVGElement::StringAttributesInfo
nsSVGImageElement::GetStringInfo()
SVGImageElement::GetStringInfo()
{
return StringAttributesInfo(mStringAttributes, sStringInfo,
ArrayLength(sStringInfo));
}
nsresult
nsSVGImageElement::CopyInnerTo(Element* aDest)
SVGImageElement::CopyInnerTo(Element* aDest)
{
if (aDest->OwnerDoc()->IsStaticDocument()) {
CreateStaticImageClone(static_cast<nsSVGImageElement*>(aDest));
CreateStaticImageClone(static_cast<SVGImageElement*>(aDest));
}
return nsSVGImageElementBase::CopyInnerTo(aDest);
return SVGImageElementBase::CopyInnerTo(aDest);
}
} // namespace dom
} // namespace mozilla

View File

@ -3,8 +3,8 @@
* 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_SVGIMAGEELEMENT_H__
#define __NS_SVGIMAGEELEMENT_H__
#ifndef mozilla_dom_SVGImageElement_h
#define mozilla_dom_SVGImageElement_h
#include "nsIDOMSVGImageElement.h"
#include "nsIDOMSVGURIReference.h"
@ -14,26 +14,34 @@
#include "nsSVGString.h"
#include "SVGAnimatedPreserveAspectRatio.h"
typedef nsSVGPathGeometryElement nsSVGImageElementBase;
nsresult NS_NewSVGImageElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
class nsSVGImageElement : public nsSVGImageElementBase,
public nsIDOMSVGImageElement,
public nsIDOMSVGURIReference,
public nsImageLoadingContent
typedef nsSVGPathGeometryElement SVGImageElementBase;
class nsSVGImageFrame;
namespace mozilla {
namespace dom {
class DOMSVGAnimatedPreserveAspectRatio;
class SVGImageElement : public SVGImageElementBase,
public nsIDOMSVGImageElement,
public nsIDOMSVGURIReference,
public nsImageLoadingContent
{
friend class nsSVGImageFrame;
friend class ::nsSVGImageFrame;
protected:
friend nsresult NS_NewSVGImageElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual ~nsSVGImageElement();
SVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual ~SVGImageElement();
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
friend nsresult (::NS_NewSVGImageElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
public:
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGIMAGEELEMENT
NS_DECL_NSIDOMSVGURIREFERENCE
@ -41,7 +49,7 @@ public:
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGImageElementBase::)
NS_FORWARD_NSIDOMSVGELEMENT(SVGImageElementBase::)
// nsIContent interface
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
@ -72,6 +80,15 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
already_AddRefed<nsIDOMSVGAnimatedLength> X();
already_AddRefed<nsIDOMSVGAnimatedLength> Y();
already_AddRefed<nsIDOMSVGAnimatedLength> Width();
already_AddRefed<nsIDOMSVGAnimatedLength> Height();
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
already_AddRefed<nsIDOMSVGAnimatedString> Href();
protected:
nsresult LoadSVGImage(bool aForce, bool aNotify);
@ -79,7 +96,7 @@ protected:
virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio();
virtual StringAttributesInfo GetStringInfo();
enum { X, Y, WIDTH, HEIGHT };
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
@ -90,4 +107,7 @@ protected:
static StringInfo sStringInfo[1];
};
#endif
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGImageElement_h

View File

@ -16,6 +16,7 @@
#include "SVGAngle.h"
using namespace mozilla;
using namespace mozilla::dom;
nsSVGElement::LengthInfo nsSVGMarkerElement::sLengthInfo[4] =
{
@ -128,7 +129,10 @@ NS_IMETHODIMP
nsSVGMarkerElement::GetPreserveAspectRatio(nsISupports
**aPreserveAspectRatio)
{
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
ratio.forget(aPreserveAspectRatio);
return NS_OK;
}
//----------------------------------------------------------------------

View File

@ -12,6 +12,7 @@
#include "nsSVGPatternElement.h"
using namespace mozilla;
using namespace mozilla::dom;
//--------------------- Patterns ------------------------
@ -85,7 +86,10 @@ NS_IMETHODIMP
nsSVGPatternElement::GetPreserveAspectRatio(nsISupports
**aPreserveAspectRatio)
{
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
ratio.forget(aPreserveAspectRatio);
return NS_OK;
}
//----------------------------------------------------------------------

View File

@ -595,7 +595,10 @@ NS_IMETHODIMP
nsSVGSVGElement::GetPreserveAspectRatio(nsISupports
**aPreserveAspectRatio)
{
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
ratio.forget(aPreserveAspectRatio);
return NS_OK;
}
//----------------------------------------------------------------------

View File

@ -14,6 +14,8 @@
#include "nsGkAtoms.h"
using namespace mozilla;
using namespace mozilla::dom;
typedef nsSVGElement nsSVGSymbolElementBase;
class nsSVGSymbolElement : public nsSVGSymbolElementBase,
@ -99,7 +101,10 @@ NS_IMETHODIMP
nsSVGSymbolElement::GetPreserveAspectRatio(nsISupports
**aPreserveAspectRatio)
{
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
ratio.forget(aPreserveAspectRatio);
return NS_OK;
}
//----------------------------------------------------------------------

View File

@ -7,6 +7,7 @@
#include "DOMSVGStringList.h"
using namespace mozilla;
using namespace mozilla::dom;
nsSVGElement::StringListInfo nsSVGViewElement::sStringListInfo[1] =
{
@ -96,7 +97,10 @@ NS_IMETHODIMP
nsSVGViewElement::GetPreserveAspectRatio(nsISupports
**aPreserveAspectRatio)
{
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
ratio.forget(aPreserveAspectRatio);
return NS_OK;
}
//----------------------------------------------------------------------

View File

@ -3271,6 +3271,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(SVGImageElement, nsIDOMSVGImageElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGImageElement)
DOM_CLASSINFO_MAP_ENTRY(nsIImageLoadingContent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END

View File

@ -613,6 +613,10 @@ DOMInterfaces = {
'hasXPConnectImpls': True,
},
'SVGImageElement': {
'hasInstanceInterface': 'nsIDOMSVGImageElement',
},
'SVGLocatableElement': {
'hasXPConnectImpls': True,
'concrete': False,

View File

@ -0,0 +1,57 @@
/* -*- 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 SVGImageElement : SVGGraphicsElement {
[Constant]
readonly attribute SVGAnimatedLength x;
[Constant]
readonly attribute SVGAnimatedLength y;
[Constant]
readonly attribute SVGAnimatedLength width;
[Constant]
readonly attribute SVGAnimatedLength height;
[Constant]
readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
// Mirrored chrome-only nsIImageLoadingContent methods. Please make sure
// to update this list if nsIImageLoadingContent changes.
[ChromeOnly]
const long UNKNOWN_REQUEST = -1;
[ChromeOnly]
const long CURRENT_REQUEST = 0;
[ChromeOnly]
const long PENDING_REQUEST = 1;
[ChromeOnly]
attribute boolean loadingEnabled;
[ChromeOnly]
readonly attribute short imageBlockingStatus;
[ChromeOnly]
void addObserver(imgINotificationObserver aObserver);
[ChromeOnly]
void removeObserver(imgINotificationObserver aObserver);
[ChromeOnly,Throws]
imgIRequest? getRequest(long aRequestType);
[ChromeOnly,Throws]
long getRequestType(imgIRequest aRequest);
[ChromeOnly,Throws]
readonly attribute URI? currentURI;
[ChromeOnly,Throws]
nsIStreamListener? loadImageWithChannel(MozChannel aChannel);
[ChromeOnly,Throws]
void forceReload();
[ChromeOnly]
void forceImageState(boolean aForce, unsigned long long aState);
};
SVGImageElement implements SVGURIReference;

View File

@ -109,6 +109,7 @@ webidl_files = \
SVGForeignObjectElement.webidl \
SVGGElement.webidl \
SVGGraphicsElement.webidl \
SVGImageElement.webidl \
SVGLengthList.webidl \
SVGLocatableElement.webidl \
SVGMatrix.webidl \

View File

@ -9,17 +9,19 @@
#include "gfxPlatform.h"
#include "imgIContainer.h"
#include "nsIDOMSVGImageElement.h"
#include "nsIImageLoadingContent.h"
#include "nsLayoutUtils.h"
#include "nsRenderingContext.h"
#include "imgINotificationObserver.h"
#include "nsSVGEffects.h"
#include "nsSVGImageElement.h"
#include "nsSVGPathGeometryFrame.h"
#include "nsSVGSVGElement.h"
#include "nsSVGUtils.h"
#include "SVGContentUtils.h"
#include "mozilla/dom/SVGImageElement.h"
using namespace mozilla;
using namespace mozilla::dom;
class nsSVGImageFrame;
@ -201,9 +203,9 @@ nsSVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
if (nsContentUtils::IsImageSrcSetDisabled()) {
return NS_OK;
}
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
if (element->mStringAttributes[nsSVGImageElement::HREF].IsExplicitlySet()) {
if (element->mStringAttributes[SVGImageElement::HREF].IsExplicitlySet()) {
element->LoadSVGImage(true, true);
} else {
element->CancelImageRequests(true);
@ -220,7 +222,7 @@ nsSVGImageFrame::GetRasterImageTransform(int32_t aNativeWidth,
uint32_t aFor)
{
float x, y, width, height;
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
gfxMatrix viewBoxTM =
@ -236,7 +238,7 @@ gfxMatrix
nsSVGImageFrame::GetVectorImageTransform(uint32_t aFor)
{
float x, y, width, height;
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
// No viewBoxTM needed here -- our height/width overrides any concept of
@ -289,7 +291,7 @@ nsSVGImageFrame::PaintSVG(nsRenderingContext *aContext,
return NS_OK;
float x, y, width, height;
nsSVGImageElement *imgElem = static_cast<nsSVGImageElement*>(mContent);
SVGImageElement *imgElem = static_cast<SVGImageElement*>(mContent);
imgElem->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
NS_ASSERTION(width > 0 && height > 0,
"Should only be painting things with valid width/height");