mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 825147: Convert SVGForeignObjectElement to WebIDL r=bz
--HG-- rename : content/svg/content/src/nsSVGForeignObjectElement.cpp => content/svg/content/src/SVGForeignObjectElement.cpp
This commit is contained in:
parent
49bb7ff199
commit
4494fc67d8
@ -51,7 +51,6 @@ CPPSRCS = \
|
||||
nsSVGFeatures.cpp \
|
||||
nsSVGFilterElement.cpp \
|
||||
nsSVGFilters.cpp \
|
||||
nsSVGForeignObjectElement.cpp \
|
||||
nsSVGGElement.cpp \
|
||||
nsSVGGradientElement.cpp \
|
||||
nsSVGImageElement.cpp \
|
||||
@ -116,6 +115,7 @@ CPPSRCS = \
|
||||
SVGContentUtils.cpp \
|
||||
SVGDefsElement.cpp \
|
||||
SVGDescElement.cpp \
|
||||
SVGForeignObjectElement.cpp \
|
||||
SVGIntegerPairSMILType.cpp \
|
||||
SVGLengthListSMILType.cpp \
|
||||
SVGLocatableElement.cpp \
|
||||
@ -158,6 +158,7 @@ EXPORTS_mozilla/dom = \
|
||||
SVGAnimatedBoolean.h \
|
||||
SVGDefsElement.h \
|
||||
SVGDescElement.h \
|
||||
SVGForeignObjectElement.h \
|
||||
SVGGraphicsElement.h \
|
||||
SVGLocatableElement.h \
|
||||
SVGMetadataElement.h \
|
||||
|
195
content/svg/content/src/SVGForeignObjectElement.cpp
Normal file
195
content/svg/content/src/SVGForeignObjectElement.cpp
Normal file
@ -0,0 +1,195 @@
|
||||
/* -*- 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 "nsCOMPtr.h"
|
||||
#include "mozilla/dom/SVGForeignObjectElement.h"
|
||||
#include "mozilla/dom/SVGForeignObjectElementBinding.h"
|
||||
|
||||
DOMCI_NODE_DATA(SVGForeignObjectElement, mozilla::dom::SVGForeignObjectElement)
|
||||
|
||||
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(ForeignObject)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
SVGForeignObjectElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return SVGForeignObjectElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
nsSVGElement::LengthInfo SVGForeignObjectElement::sLengthInfo[4] =
|
||||
{
|
||||
{ &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
||||
{ &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
||||
{ &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
||||
{ &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(SVGForeignObjectElement, SVGGraphicsElement)
|
||||
NS_IMPL_RELEASE_INHERITED(SVGForeignObjectElement, SVGGraphicsElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(SVGForeignObjectElement)
|
||||
NS_NODE_INTERFACE_TABLE4(SVGForeignObjectElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement,
|
||||
nsIDOMSVGForeignObjectElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGForeignObjectElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(SVGGraphicsElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
SVGForeignObjectElement::SVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: SVGGraphicsElement(aNodeInfo)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGForeignObjectElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGForeignObjectElement methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength x; */
|
||||
NS_IMETHODIMP SVGForeignObjectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
|
||||
{
|
||||
*aX = X().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGForeignObjectElement::X()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> x;
|
||||
mLengthAttributes[ATTR_X].ToDOMAnimatedLength(getter_AddRefs(x), this);
|
||||
return x.forget();
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength y; */
|
||||
NS_IMETHODIMP SVGForeignObjectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
|
||||
{
|
||||
*aY = Y().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGForeignObjectElement::Y()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> y;
|
||||
mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(getter_AddRefs(y), this);
|
||||
return y.forget();
|
||||
}
|
||||
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength width; */
|
||||
NS_IMETHODIMP SVGForeignObjectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
|
||||
{
|
||||
*aWidth = Width().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGForeignObjectElement::Width()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> width;
|
||||
mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(getter_AddRefs(width), this);
|
||||
return width.forget();
|
||||
}
|
||||
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength height; */
|
||||
NS_IMETHODIMP SVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
|
||||
{
|
||||
*aHeight = Height().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGForeignObjectElement::Height()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> height;
|
||||
mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(getter_AddRefs(height), this);
|
||||
return height.forget();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ gfxMatrix
|
||||
SVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
||||
TransformTypes aWhich) const
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aWhich != eChildToUserSpace || aMatrix.IsIdentity(),
|
||||
"Skipping eUserSpaceToParent transforms makes no sense");
|
||||
|
||||
// 'transform' attribute:
|
||||
gfxMatrix fromUserSpace =
|
||||
SVGGraphicsElement::PrependLocalTransformsTo(aMatrix, aWhich);
|
||||
if (aWhich == eUserSpaceToParent) {
|
||||
return fromUserSpace;
|
||||
}
|
||||
// our 'x' and 'y' attributes:
|
||||
float x, y;
|
||||
const_cast<SVGForeignObjectElement*>(this)->
|
||||
GetAnimatedLengthValues(&x, &y, nullptr);
|
||||
gfxMatrix toUserSpace = gfxMatrix().Translate(gfxPoint(x, y));
|
||||
if (aWhich == eChildToUserSpace) {
|
||||
return toUserSpace;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(aWhich == eAllTransforms, "Unknown TransformTypes");
|
||||
return toUserSpace * fromUserSpace;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
SVGForeignObjectElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
|
||||
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
||||
mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
|
||||
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
SVGForeignObjectElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sFEFloodMap,
|
||||
sFiltersMap,
|
||||
sFontSpecificationMap,
|
||||
sGradientStopMap,
|
||||
sLightingEffectsMap,
|
||||
sMarkersMap,
|
||||
sTextContentElementsMap,
|
||||
sViewportsMap
|
||||
};
|
||||
|
||||
return FindAttributeDependence(name, map) ||
|
||||
SVGGraphicsElement::IsAttributeMapped(name);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
SVGForeignObjectElement::GetLengthInfo()
|
||||
{
|
||||
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
||||
ArrayLength(sLengthInfo));
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
76
content/svg/content/src/SVGForeignObjectElement.h
Normal file
76
content/svg/content/src/SVGForeignObjectElement.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* -*- 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_SVGForeignObjectElement_h
|
||||
#define mozilla_dom_SVGForeignObjectElement_h
|
||||
|
||||
#include "mozilla/dom/SVGGraphicsElement.h"
|
||||
#include "nsIDOMSVGForeignObjectElem.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
nsresult NS_NewSVGForeignObjectElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
class nsSVGForeignObjectFrame;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class SVGForeignObjectElement MOZ_FINAL : public SVGGraphicsElement,
|
||||
public nsIDOMSVGForeignObjectElement
|
||||
{
|
||||
friend class ::nsSVGForeignObjectFrame;
|
||||
|
||||
protected:
|
||||
friend nsresult (::NS_NewSVGForeignObjectElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo));
|
||||
SVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGFOREIGNOBJECTELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(SVGGraphicsElement::)
|
||||
|
||||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
||||
TransformTypes aWhich = eAllTransforms) const;
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
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();
|
||||
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
|
||||
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
|
||||
nsSVGLength2 mLengthAttributes[4];
|
||||
static LengthInfo sLengthInfo[4];
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_SVGForeignObjectElement_h
|
||||
|
@ -1,144 +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 "nsCOMPtr.h"
|
||||
#include "nsSVGForeignObjectElement.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
nsSVGElement::LengthInfo nsSVGForeignObjectElement::sLengthInfo[4] =
|
||||
{
|
||||
{ &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
||||
{ &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
||||
{ &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
||||
{ &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
||||
};
|
||||
|
||||
NS_IMPL_NS_NEW_SVG_ELEMENT(ForeignObject)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
|
||||
|
||||
DOMCI_NODE_DATA(SVGForeignObjectElement, nsSVGForeignObjectElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGForeignObjectElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGForeignObjectElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement,
|
||||
nsIDOMSVGForeignObjectElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGForeignObjectElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGForeignObjectElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGForeignObjectElement::nsSVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsSVGForeignObjectElementBase(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGForeignObjectElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGForeignObjectElement methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength x; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
|
||||
{
|
||||
return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength y; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
|
||||
{
|
||||
return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength width; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
|
||||
{
|
||||
return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength height; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
|
||||
{
|
||||
return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ gfxMatrix
|
||||
nsSVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
||||
TransformTypes aWhich) const
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aWhich != eChildToUserSpace || aMatrix.IsIdentity(),
|
||||
"Skipping eUserSpaceToParent transforms makes no sense");
|
||||
|
||||
// 'transform' attribute:
|
||||
gfxMatrix fromUserSpace =
|
||||
nsSVGForeignObjectElementBase::PrependLocalTransformsTo(aMatrix, aWhich);
|
||||
if (aWhich == eUserSpaceToParent) {
|
||||
return fromUserSpace;
|
||||
}
|
||||
// our 'x' and 'y' attributes:
|
||||
float x, y;
|
||||
const_cast<nsSVGForeignObjectElement*>(this)->
|
||||
GetAnimatedLengthValues(&x, &y, nullptr);
|
||||
gfxMatrix toUserSpace = gfxMatrix().Translate(gfxPoint(x, y));
|
||||
if (aWhich == eChildToUserSpace) {
|
||||
return toUserSpace;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(aWhich == eAllTransforms, "Unknown TransformTypes");
|
||||
return toUserSpace * fromUserSpace;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsSVGForeignObjectElement::HasValidDimensions() const
|
||||
{
|
||||
return mLengthAttributes[WIDTH].IsExplicitlySet() &&
|
||||
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
||||
mLengthAttributes[HEIGHT].IsExplicitlySet() &&
|
||||
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsSVGForeignObjectElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sFEFloodMap,
|
||||
sFiltersMap,
|
||||
sFontSpecificationMap,
|
||||
sGradientStopMap,
|
||||
sLightingEffectsMap,
|
||||
sMarkersMap,
|
||||
sTextContentElementsMap,
|
||||
sViewportsMap
|
||||
};
|
||||
|
||||
return FindAttributeDependence(name, map) ||
|
||||
nsSVGForeignObjectElementBase::IsAttributeMapped(name);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
nsSVGElement::LengthAttributesInfo
|
||||
nsSVGForeignObjectElement::GetLengthInfo()
|
||||
{
|
||||
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
||||
ArrayLength(sLengthInfo));
|
||||
}
|
@ -1,58 +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/. */
|
||||
|
||||
#ifndef __NS_SVGFOREIGNOBJECTELEMENT_H__
|
||||
#define __NS_SVGFOREIGNOBJECTELEMENT_H__
|
||||
|
||||
#include "SVGGraphicsElement.h"
|
||||
#include "nsIDOMSVGForeignObjectElem.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
typedef mozilla::dom::SVGGraphicsElement nsSVGForeignObjectElementBase;
|
||||
|
||||
class nsSVGForeignObjectElement : public nsSVGForeignObjectElementBase,
|
||||
public nsIDOMSVGForeignObjectElement
|
||||
{
|
||||
friend class nsSVGForeignObjectFrame;
|
||||
|
||||
protected:
|
||||
friend nsresult NS_NewSVGForeignObjectElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
nsSVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGFOREIGNOBJECTELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGForeignObjectElementBase::)
|
||||
|
||||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
||||
TransformTypes aWhich = eAllTransforms) const;
|
||||
virtual bool HasValidDimensions() const;
|
||||
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
|
||||
enum { X, Y, WIDTH, HEIGHT };
|
||||
nsSVGLength2 mLengthAttributes[4];
|
||||
static LengthInfo sLengthInfo[4];
|
||||
};
|
||||
|
||||
#endif
|
25
dom/webidl/SVGForeignObjectElement.webidl
Normal file
25
dom/webidl/SVGForeignObjectElement.webidl
Normal file
@ -0,0 +1,25 @@
|
||||
/* -*- 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 SVGAnimatedLength;
|
||||
|
||||
interface SVGForeignObjectElement : SVGGraphicsElement {
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength x;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength y;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength width;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength height;
|
||||
};
|
||||
|
@ -106,6 +106,7 @@ webidl_files = \
|
||||
SVGDefsElement.webidl \
|
||||
SVGDescElement.webidl \
|
||||
SVGElement.webidl \
|
||||
SVGForeignObjectElement.webidl \
|
||||
SVGGraphicsElement.webidl \
|
||||
SVGLengthList.webidl \
|
||||
SVGLocatableElement.webidl \
|
||||
|
@ -17,13 +17,14 @@
|
||||
#include "nsRenderingContext.h"
|
||||
#include "nsSVGContainerFrame.h"
|
||||
#include "nsSVGEffects.h"
|
||||
#include "nsSVGForeignObjectElement.h"
|
||||
#include "mozilla/dom/SVGForeignObjectElement.h"
|
||||
#include "nsSVGIntegrationUtils.h"
|
||||
#include "nsSVGOuterSVGFrame.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
@ -357,7 +358,7 @@ NS_IMETHODIMP_(nsRect)
|
||||
nsSVGForeignObjectFrame::GetCoveredRegion()
|
||||
{
|
||||
float x, y, w, h;
|
||||
static_cast<nsSVGForeignObjectElement*>(mContent)->
|
||||
static_cast<SVGForeignObjectElement*>(mContent)->
|
||||
GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
||||
if (w < 0.0f) w = 0.0f;
|
||||
if (h < 0.0f) h = 0.0f;
|
||||
@ -383,7 +384,7 @@ nsSVGForeignObjectFrame::ReflowSVG()
|
||||
// correct dimensions:
|
||||
|
||||
float x, y, w, h;
|
||||
static_cast<nsSVGForeignObjectElement*>(mContent)->
|
||||
static_cast<SVGForeignObjectElement*>(mContent)->
|
||||
GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
||||
|
||||
// If mRect's width or height are negative, reflow blows up! We must clamp!
|
||||
@ -433,19 +434,19 @@ nsSVGForeignObjectFrame::NotifySVGChanged(uint32_t aFlags)
|
||||
bool needNewCanvasTM = false;
|
||||
|
||||
if (aFlags & COORD_CONTEXT_CHANGED) {
|
||||
nsSVGForeignObjectElement *fO =
|
||||
static_cast<nsSVGForeignObjectElement*>(mContent);
|
||||
SVGForeignObjectElement *fO =
|
||||
static_cast<SVGForeignObjectElement*>(mContent);
|
||||
// Coordinate context changes affect mCanvasTM if we have a
|
||||
// percentage 'x' or 'y'
|
||||
if (fO->mLengthAttributes[nsSVGForeignObjectElement::X].IsPercentage() ||
|
||||
fO->mLengthAttributes[nsSVGForeignObjectElement::Y].IsPercentage()) {
|
||||
if (fO->mLengthAttributes[SVGForeignObjectElement::ATTR_X].IsPercentage() ||
|
||||
fO->mLengthAttributes[SVGForeignObjectElement::ATTR_Y].IsPercentage()) {
|
||||
needNewBounds = true;
|
||||
needNewCanvasTM = true;
|
||||
}
|
||||
// Our coordinate context's width/height has changed. If we have a
|
||||
// percentage width/height our dimensions will change so we must reflow.
|
||||
if (fO->mLengthAttributes[nsSVGForeignObjectElement::WIDTH].IsPercentage() ||
|
||||
fO->mLengthAttributes[nsSVGForeignObjectElement::HEIGHT].IsPercentage()) {
|
||||
if (fO->mLengthAttributes[SVGForeignObjectElement::ATTR_WIDTH].IsPercentage() ||
|
||||
fO->mLengthAttributes[SVGForeignObjectElement::ATTR_HEIGHT].IsPercentage()) {
|
||||
needNewBounds = true;
|
||||
needReflow = true;
|
||||
}
|
||||
@ -496,8 +497,8 @@ SVGBBox
|
||||
nsSVGForeignObjectFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
nsSVGForeignObjectElement *content =
|
||||
static_cast<nsSVGForeignObjectElement*>(mContent);
|
||||
SVGForeignObjectElement *content =
|
||||
static_cast<SVGForeignObjectElement*>(mContent);
|
||||
|
||||
float x, y, w, h;
|
||||
content->GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
||||
@ -527,8 +528,8 @@ nsSVGForeignObjectFrame::GetCanvasTM(uint32_t aFor)
|
||||
NS_ASSERTION(mParent, "null parent");
|
||||
|
||||
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
||||
nsSVGForeignObjectElement *content =
|
||||
static_cast<nsSVGForeignObjectElement*>(mContent);
|
||||
SVGForeignObjectElement *content =
|
||||
static_cast<SVGForeignObjectElement*>(mContent);
|
||||
|
||||
gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM(aFor));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user