mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 830230 - Convert SVGPatternElement to WebIDL r=bz
This commit is contained in:
parent
a9dc213100
commit
1fd6f576ea
@ -10,6 +10,7 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "mozilla/dom/SVGPatternElement.h"
|
||||
#include "mozilla/dom/SVGPatternElementBinding.h"
|
||||
|
||||
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Pattern)
|
||||
|
||||
@ -18,6 +19,12 @@ DOMCI_NODE_DATA(SVGPatternElement, mozilla::dom::SVGPatternElement)
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
SVGPatternElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return SVGPatternElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
//--------------------- Patterns ------------------------
|
||||
|
||||
nsSVGElement::LengthInfo SVGPatternElement::sLengthInfo[4] =
|
||||
@ -65,6 +72,7 @@ NS_INTERFACE_MAP_END_INHERITING(SVGPatternElementBase)
|
||||
SVGPatternElement::SVGPatternElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: SVGPatternElementBase(aNodeInfo)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -78,18 +86,32 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPatternElement)
|
||||
/* readonly attribute nsIDOMSVGAnimatedRect viewBox; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox)
|
||||
{
|
||||
return mViewBox.ToDOMAnimatedRect(aViewBox, this);
|
||||
*aViewBox = ViewBox().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedRect>
|
||||
SVGPatternElement::ViewBox()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedRect> rect;
|
||||
mViewBox.ToDOMAnimatedRect(getter_AddRefs(rect), this);
|
||||
return rect.forget();
|
||||
}
|
||||
|
||||
/* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
|
||||
NS_IMETHODIMP
|
||||
SVGPatternElement::GetPreserveAspectRatio(nsISupports
|
||||
**aPreserveAspectRatio)
|
||||
SVGPatternElement::GetPreserveAspectRatio(nsISupports **aPreserveAspectRatio)
|
||||
{
|
||||
*aPreserveAspectRatio = PreserveAspectRatio().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
||||
SVGPatternElement::PreserveAspectRatio()
|
||||
{
|
||||
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
|
||||
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
|
||||
ratio.forget(aPreserveAspectRatio);
|
||||
return NS_OK;
|
||||
return ratio.forget();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -98,49 +120,96 @@ SVGPatternElement::GetPreserveAspectRatio(nsISupports
|
||||
/* readonly attribute nsIDOMSVGAnimatedEnumeration patternUnits; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetPatternUnits(nsIDOMSVGAnimatedEnumeration * *aPatternUnits)
|
||||
{
|
||||
return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(aPatternUnits, this);
|
||||
*aPatternUnits = PatternUnits().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedEnumeration>
|
||||
SVGPatternElement::PatternUnits()
|
||||
{
|
||||
return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedEnumeration patternContentUnits; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetPatternContentUnits(nsIDOMSVGAnimatedEnumeration * *aPatternUnits)
|
||||
{
|
||||
return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(aPatternUnits, this);
|
||||
*aPatternUnits = PatternContentUnits().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedEnumeration>
|
||||
SVGPatternElement::PatternContentUnits()
|
||||
{
|
||||
return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsISupports patternTransform; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetPatternTransform(nsISupports * *aPatternTransform)
|
||||
{
|
||||
*aPatternTransform = PatternTransform().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGAnimatedTransformList>
|
||||
SVGPatternElement::PatternTransform()
|
||||
{
|
||||
// We're creating a DOM wrapper, so we must tell GetAnimatedTransformList
|
||||
// to allocate the SVGAnimatedTransformList if it hasn't already done so:
|
||||
*aPatternTransform = DOMSVGAnimatedTransformList::GetDOMWrapper(
|
||||
GetAnimatedTransformList(DO_ALLOCATE), this).get();
|
||||
return NS_OK;
|
||||
return DOMSVGAnimatedTransformList::GetDOMWrapper(
|
||||
GetAnimatedTransformList(DO_ALLOCATE), this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength x; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetX(nsIDOMSVGAnimatedLength * *aX)
|
||||
{
|
||||
return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
|
||||
*aX = X().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGPatternElement::X()
|
||||
{
|
||||
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength y; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetY(nsIDOMSVGAnimatedLength * *aY)
|
||||
{
|
||||
return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
|
||||
*aY = Y().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGPatternElement::Y()
|
||||
{
|
||||
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength width; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
|
||||
{
|
||||
return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
|
||||
*aWidth = Width().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGPatternElement::Width()
|
||||
{
|
||||
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength height; */
|
||||
NS_IMETHODIMP SVGPatternElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
|
||||
{
|
||||
return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
|
||||
*aHeight = Height().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength>
|
||||
SVGPatternElement::Height()
|
||||
{
|
||||
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGURIReference methods:
|
||||
@ -149,7 +218,16 @@ NS_IMETHODIMP SVGPatternElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
|
||||
NS_IMETHODIMP
|
||||
SVGPatternElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
|
||||
{
|
||||
return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
|
||||
*aHref = Href().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedString>
|
||||
SVGPatternElement::Href()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedString> href;
|
||||
mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this);
|
||||
return href.forget();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -188,10 +266,10 @@ SVGPatternElement::GetAnimatedTransformList(uint32_t aFlags)
|
||||
/* virtual */ bool
|
||||
SVGPatternElement::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
|
||||
|
@ -24,6 +24,8 @@ nsresult NS_NewSVGPatternElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
namespace mozilla {
|
||||
class DOMSVGAnimatedTransformList;
|
||||
|
||||
namespace dom {
|
||||
|
||||
typedef nsSVGElement SVGPatternElementBase;
|
||||
@ -40,6 +42,7 @@ protected:
|
||||
friend nsresult (::NS_NewSVGPatternElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo));
|
||||
SVGPatternElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
|
||||
|
||||
public:
|
||||
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
|
||||
@ -77,6 +80,19 @@ public:
|
||||
virtual nsIAtom* GetTransformListAttrName() const {
|
||||
return nsGkAtoms::patternTransform;
|
||||
}
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<nsIDOMSVGAnimatedRect> ViewBox();
|
||||
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
|
||||
already_AddRefed<nsIDOMSVGAnimatedEnumeration> PatternUnits();
|
||||
already_AddRefed<nsIDOMSVGAnimatedEnumeration> PatternContentUnits();
|
||||
already_AddRefed<DOMSVGAnimatedTransformList> PatternTransform();
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength> X();
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength> Y();
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength> Width();
|
||||
already_AddRefed<nsIDOMSVGAnimatedLength> Height();
|
||||
already_AddRefed<nsIDOMSVGAnimatedString> Href();
|
||||
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
@ -86,7 +102,7 @@ protected:
|
||||
virtual StringAttributesInfo GetStringInfo();
|
||||
|
||||
// nsIDOMSVGPatternElement values
|
||||
enum { X, Y, WIDTH, HEIGHT };
|
||||
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
|
||||
nsSVGLength2 mLengthAttributes[4];
|
||||
static LengthInfo sLengthInfo[4];
|
||||
|
||||
|
35
dom/webidl/SVGPatternElement.webidl
Normal file
35
dom/webidl/SVGPatternElement.webidl
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- 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/pservers.html#InterfaceSVGPatternElement
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface SVGAnimatedEnumeration;
|
||||
interface SVGAnimatedLength;
|
||||
|
||||
interface SVGPatternElement : SVGElement {
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedEnumeration patternUnits;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedEnumeration patternContentUnits;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedTransformList patternTransform;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength x;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength y;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength width;
|
||||
[Constant]
|
||||
readonly attribute SVGAnimatedLength height;
|
||||
};
|
||||
|
||||
SVGPatternElement implements SVGFitToViewBox;
|
||||
SVGPatternElement implements SVGURIReference;
|
||||
SVGPatternElement implements SVGUnitTypes;
|
@ -135,6 +135,7 @@ webidl_files = \
|
||||
SVGPathElement.webidl \
|
||||
SVGPathSeg.webidl \
|
||||
SVGPathSegList.webidl \
|
||||
SVGPatternElement.webidl \
|
||||
SVGPoint.webidl \
|
||||
SVGPointList.webidl \
|
||||
SVGPolygonElement.webidl \
|
||||
|
@ -588,10 +588,10 @@ nsSVGPatternFrame::GetPatternRect(uint16_t aPatternUnits,
|
||||
|
||||
// Get the pattern x,y,width, and height
|
||||
const nsSVGLength2 *tmpX, *tmpY, *tmpHeight, *tmpWidth;
|
||||
tmpX = GetLengthValue(SVGPatternElement::X);
|
||||
tmpY = GetLengthValue(SVGPatternElement::Y);
|
||||
tmpHeight = GetLengthValue(SVGPatternElement::HEIGHT);
|
||||
tmpWidth = GetLengthValue(SVGPatternElement::WIDTH);
|
||||
tmpX = GetLengthValue(SVGPatternElement::ATTR_X);
|
||||
tmpY = GetLengthValue(SVGPatternElement::ATTR_Y);
|
||||
tmpHeight = GetLengthValue(SVGPatternElement::ATTR_HEIGHT);
|
||||
tmpWidth = GetLengthValue(SVGPatternElement::ATTR_WIDTH);
|
||||
|
||||
if (aPatternUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
||||
x = nsSVGUtils::ObjectSpace(aTargetBBox, tmpX);
|
||||
@ -647,15 +647,15 @@ nsSVGPatternFrame::ConstructCTM(const nsSVGViewBox& aViewBox,
|
||||
// Calling the nsIFrame* variant of GetAnimValue would look it up on
|
||||
// every call.
|
||||
viewportWidth =
|
||||
GetLengthValue(SVGPatternElement::WIDTH)->GetAnimValue(ctx);
|
||||
GetLengthValue(SVGPatternElement::ATTR_WIDTH)->GetAnimValue(ctx);
|
||||
viewportHeight =
|
||||
GetLengthValue(SVGPatternElement::HEIGHT)->GetAnimValue(ctx);
|
||||
GetLengthValue(SVGPatternElement::ATTR_HEIGHT)->GetAnimValue(ctx);
|
||||
} else {
|
||||
// No SVG target, call the nsIFrame* variant of GetAnimValue.
|
||||
viewportWidth =
|
||||
GetLengthValue(SVGPatternElement::WIDTH)->GetAnimValue(aTarget);
|
||||
GetLengthValue(SVGPatternElement::ATTR_WIDTH)->GetAnimValue(aTarget);
|
||||
viewportHeight =
|
||||
GetLengthValue(SVGPatternElement::HEIGHT)->GetAnimValue(aTarget);
|
||||
GetLengthValue(SVGPatternElement::ATTR_HEIGHT)->GetAnimValue(aTarget);
|
||||
}
|
||||
|
||||
if (viewportWidth <= 0.0f || viewportHeight <= 0.0f) {
|
||||
|
Loading…
Reference in New Issue
Block a user