Bug 392928 - new style nsSVGEnum. r=longsonr, sr=roc, a=roc

This commit is contained in:
tor@cs.brown.edu 2007-08-27 16:11:14 -07:00
parent 972ce584c2
commit 085f1967a7
39 changed files with 858 additions and 1175 deletions

View File

@ -73,7 +73,6 @@ CPPSRCS = \
nsSVGAngle.cpp \
nsSVGAnimatedAngle.cpp \
nsSVGAnimatedBoolean.cpp \
nsSVGAnimatedEnumeration.cpp \
nsSVGAnimatedInteger.cpp \
nsSVGAnimatedLengthList.cpp \
nsSVGAnimatedNumberList.cpp \
@ -163,7 +162,6 @@ EXPORTS = \
nsSVGRect.h \
nsSVGPoint.h \
nsSVGMatrix.h \
nsISVGEnum.h \
$(NULL)

View File

@ -1,63 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Rowley <tor@cs.brown.edu> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_ISVGENUM_H__
#define __NS_ISVGENUM_H__
#include "nsISupports.h"
////////////////////////////////////////////////////////////////////////
// nsISVGEnum: private interface for svg lengths
// {6bb710c5-a18c-45fc-a412-f042bae4da2d}
#define NS_ISVGENUM_IID \
{ 0x6bb710c5, 0xa18c, 0x45fc, { 0xa4, 0x12, 0xf0, 0x42, 0xba, 0xe4, 0xda, 0x2d } }
class nsISVGEnum : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGENUM_IID)
NS_IMETHOD GetIntegerValue(PRUint16 &value)=0;
NS_IMETHOD SetIntegerValue(PRUint16 value)=0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGEnum, NS_ISVGENUM_IID)
#endif // __NS_ISVGENUM_H__

View File

@ -1,209 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Rowley <tor@acm.org> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsSVGValue.h"
#include "nsWeakReference.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsISVGEnum.h"
#include "nsContentUtils.h"
////////////////////////////////////////////////////////////////////////
// nsSVGAnimatedEnumeration
class nsSVGAnimatedEnumeration : public nsIDOMSVGAnimatedEnumeration,
public nsSVGValue,
public nsISVGValueObserver
{
protected:
friend nsresult NS_NewSVGAnimatedEnumeration(nsIDOMSVGAnimatedEnumeration** result,
nsISVGEnum* aBaseVal);
nsSVGAnimatedEnumeration();
~nsSVGAnimatedEnumeration();
nsresult Init(nsISVGEnum* aBaseVal);
public:
// nsISupports interface:
NS_DECL_ISUPPORTS
// nsIDOMSVGAnimatedEnumeration interface:
NS_DECL_NSIDOMSVGANIMATEDENUMERATION
// remainder of nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
// nsISVGValueObserver
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
modificationType aModType);
// nsISupportsWeakReference
// implementation inherited from nsSupportsWeakReference
protected:
nsCOMPtr<nsISVGEnum> mBaseVal;
};
//----------------------------------------------------------------------
// Implementation
nsSVGAnimatedEnumeration::nsSVGAnimatedEnumeration()
{
}
nsSVGAnimatedEnumeration::~nsSVGAnimatedEnumeration()
{
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
if (val) val->RemoveObserver(this);
}
nsresult
nsSVGAnimatedEnumeration::Init(nsISVGEnum* aBaseVal)
{
mBaseVal = aBaseVal;
if (!mBaseVal) return NS_ERROR_FAILURE;
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
NS_ASSERTION(val, "baseval needs to implement nsISVGValue interface");
if (!val) return NS_ERROR_FAILURE;
val->AddObserver(this);
return NS_OK;
}
//----------------------------------------------------------------------
// nsISupports methods:
NS_IMPL_ADDREF(nsSVGAnimatedEnumeration)
NS_IMPL_RELEASE(nsSVGAnimatedEnumeration)
NS_INTERFACE_MAP_BEGIN(nsSVGAnimatedEnumeration)
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAnimatedEnumeration)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
NS_INTERFACE_MAP_END
//----------------------------------------------------------------------
// nsISVGValue methods:
NS_IMETHODIMP
nsSVGAnimatedEnumeration::SetValueString(const nsAString& aValue)
{
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
NS_ASSERTION(value, "svg animated enumeration base value has wrong interface!");
return value->SetValueString(aValue);
}
NS_IMETHODIMP
nsSVGAnimatedEnumeration::GetValueString(nsAString& aValue)
{
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
NS_ASSERTION(value, "svg animated enumeration base value has wrong interface!");
return value->GetValueString(aValue);
}
//----------------------------------------------------------------------
// nsIDOMSVGAnimatedEnumeration methods:
/* attribute unsigned short baseVal; */
NS_IMETHODIMP
nsSVGAnimatedEnumeration::GetBaseVal(PRUint16 *aBaseVal)
{
mBaseVal->GetIntegerValue(*aBaseVal);
return NS_OK;
}
NS_IMETHODIMP
nsSVGAnimatedEnumeration::SetBaseVal(PRUint16 aBaseVal)
{
return mBaseVal->SetIntegerValue(aBaseVal);
}
/* readonly attribute unsigned short animVal; */
NS_IMETHODIMP
nsSVGAnimatedEnumeration::GetAnimVal(PRUint16 *aAnimVal)
{
mBaseVal->GetIntegerValue(*aAnimVal);
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGValueObserver methods
NS_IMETHODIMP
nsSVGAnimatedEnumeration::WillModifySVGObservable(nsISVGValue* observable,
modificationType aModType)
{
WillModify(aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGAnimatedEnumeration::DidModifySVGObservable (nsISVGValue* observable,
modificationType aModType)
{
DidModify(aModType);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// Exported creation functions
nsresult
NS_NewSVGAnimatedEnumeration(nsIDOMSVGAnimatedEnumeration** aResult,
nsISVGEnum* aBaseVal)
{
*aResult = nsnull;
nsSVGAnimatedEnumeration* animatedEnum = new nsSVGAnimatedEnumeration();
if (!animatedEnum) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(animatedEnum);
nsresult rv = animatedEnum->Init(aBaseVal);
*aResult = (nsIDOMSVGAnimatedEnumeration*) animatedEnum;
return rv;
}

View File

@ -36,7 +36,14 @@
#include "nsSVGClipPathElement.h"
#include "nsGkAtoms.h"
#include "nsSVGEnum.h"
nsSVGElement::EnumInfo nsSVGClipPathElement::sEnumInfo[1] =
{
{ &nsGkAtoms::clipPathUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(ClipPath)
@ -51,6 +58,7 @@ NS_INTERFACE_MAP_BEGIN(nsSVGClipPathElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGClipPathElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGClipPathElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGClipPathElementBase)
@ -62,44 +70,18 @@ nsSVGClipPathElement::nsSVGClipPathElement(nsINodeInfo *aNodeInfo)
{
}
nsresult
nsSVGClipPathElement::Init()
{
nsresult rv = nsSVGClipPathElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// Define enumeration mappings
static struct nsSVGEnumMapping gUnitMap[] = {
{&nsGkAtoms::objectBoundingBox, nsIDOMSVGClipPathElement::SVG_CPUNITS_OBJECTBOUNDINGBOX},
{&nsGkAtoms::userSpaceOnUse, nsIDOMSVGClipPathElement::SVG_CPUNITS_USERSPACEONUSE},
{nsnull, 0}
};
// DOM property: clipPathUnits , #IMPLIED attrib: clipPathUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGClipPathElement::SVG_CPUNITS_USERSPACEONUSE,
gUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mClipPathUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::clipPathUnits, mClipPathUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
return NS_OK;
}
/* readonly attribute nsIDOMSVGAnimatedEnumeration clipPathUnits; */
NS_IMETHODIMP nsSVGClipPathElement::GetClipPathUnits(nsIDOMSVGAnimatedEnumeration * *aClipPathUnits)
{
*aClipPathUnits = mClipPathUnits;
NS_IF_ADDREF(*aClipPathUnits);
return NS_OK;
return mEnumAttributes[CLIPPATHUNITS].ToDOMAnimatedEnum(aClipPathUnits, this);
}
nsSVGElement::EnumAttributesInfo
nsSVGClipPathElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsIDOMNode methods

View File

@ -39,12 +39,14 @@
#include "nsSVGGraphicElement.h"
#include "nsIDOMSVGClipPathElement.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsSVGEnum.h"
typedef nsSVGGraphicElement nsSVGClipPathElementBase;
class nsSVGClipPathElement : public nsSVGClipPathElementBase,
public nsIDOMSVGClipPathElement
public nsIDOMSVGClipPathElement,
public nsIDOMSVGUnitTypes
{
friend class nsSVGClipPathFrame;
@ -52,7 +54,6 @@ protected:
friend nsresult NS_NewSVGClipPathElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo);
nsSVGClipPathElement(nsINodeInfo *aNodeInfo);
nsresult Init();
public:
// interfaces:
@ -70,8 +71,11 @@ public:
protected:
// nsIDOMSVGClipPathElement values
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mClipPathUnits;
enum { CLIPPATHUNITS };
nsSVGEnum mEnumAttributes[1];
static EnumInfo sEnumInfo[1];
virtual EnumAttributesInfo GetEnumInfo();
};
#endif

View File

@ -67,8 +67,16 @@
#include "nsSVGUtils.h"
#include "nsSVGLength2.h"
#include "nsSVGNumber2.h"
#include "nsSVGEnum.h"
#include "nsIDOMSVGUnitTypes.h"
#include <stdarg.h>
nsSVGEnumMapping nsSVGElement::sSVGUnitTypesMap[] = {
{&nsGkAtoms::userSpaceOnUse, nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE},
{&nsGkAtoms::objectBoundingBox, nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX},
{nsnull, 0}
};
nsSVGElement::nsSVGElement(nsINodeInfo *aNodeInfo)
: nsSVGElementBase(aNodeInfo), mSuppressNotification(PR_FALSE)
{
@ -96,6 +104,12 @@ nsSVGElement::Init()
numberInfo.mNumbers[i].Init(i, numberInfo.mNumberInfo[i].mDefaultValue);
}
EnumAttributesInfo enumInfo = GetEnumInfo();
for (i = 0; i < enumInfo.mEnumCount; i++) {
enumInfo.mEnums[i].Init(i, enumInfo.mEnumInfo[i].mDefaultValue);
}
return NS_OK;
}
@ -207,36 +221,44 @@ nsSVGElement::ParseAttribute(PRInt32 aNamespaceID,
}
if (aNamespaceID == kNameSpaceID_None) {
nsresult rv;
PRBool foundMatch = PR_FALSE;
// Check for nsSVGLength2 attribute
LengthAttributesInfo lengthInfo = GetLengthInfo();
PRUint32 i;
for (i = 0; i < lengthInfo.mLengthCount; i++) {
for (PRUint32 i = 0; i < lengthInfo.mLengthCount && !foundMatch; i++) {
if (aAttribute == *lengthInfo.mLengthInfo[i].mName) {
nsresult rv = lengthInfo.mLengths[i].SetBaseValueString(aValue, this,
PR_FALSE);
if (NS_FAILED(rv)) {
ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue);
return PR_FALSE;
}
aResult.SetTo(aValue);
return PR_TRUE;
rv = lengthInfo.mLengths[i].SetBaseValueString(aValue, this, PR_FALSE);
foundMatch = PR_TRUE;
}
}
// Check for nsSVGNumber2 attribute
NumberAttributesInfo numberInfo = GetNumberInfo();
for (i = 0; i < numberInfo.mNumberCount; i++) {
for (PRUint32 i = 0; i < numberInfo.mNumberCount && !foundMatch; i++) {
if (aAttribute == *numberInfo.mNumberInfo[i].mName) {
nsresult rv = numberInfo.mNumbers[i].SetBaseValueString(aValue, this,
PR_FALSE);
if (NS_FAILED(rv)) {
ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue);
return PR_FALSE;
}
aResult.SetTo(aValue);
return PR_TRUE;
rv = numberInfo.mNumbers[i].SetBaseValueString(aValue, this, PR_FALSE);
foundMatch = PR_TRUE;
}
}
// Check for nsSVGEnum attribute
EnumAttributesInfo enumInfo = GetEnumInfo();
for (PRUint32 i = 0; i < enumInfo.mEnumCount && !foundMatch; i++) {
if (aAttribute == *enumInfo.mEnumInfo[i].mName) {
rv = enumInfo.mEnums[i].SetBaseValueString(aValue, this, PR_FALSE);
foundMatch = PR_TRUE;
}
}
if (foundMatch) {
if (NS_FAILED(rv)) {
ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue);
return PR_FALSE;
}
aResult.SetTo(aValue);
return PR_TRUE;
}
}
return nsSVGElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
@ -284,6 +306,17 @@ nsSVGElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
break;
}
}
// Check if this is a number attribute going away
EnumAttributesInfo enumInfo = GetEnumInfo();
for (i = 0; i < enumInfo.mEnumCount; i++) {
if (aName == *enumInfo.mEnumInfo[i].mName) {
enumInfo.mEnums[i].Init(i, enumInfo.mEnumInfo[i].mDefaultValue);
DidChangeEnum(i, PR_FALSE);
break;
}
}
}
}
@ -865,6 +898,32 @@ nsSVGElement::GetAnimatedNumberValues(float *aFirst, ...)
va_end(args);
}
nsSVGElement::EnumAttributesInfo
nsSVGElement::GetEnumInfo()
{
return EnumAttributesInfo(nsnull, nsnull, 0);
}
void
nsSVGElement::DidChangeEnum(PRUint8 aAttrEnum, PRBool aDoSetAttr)
{
if (!aDoSetAttr)
return;
EnumAttributesInfo info = GetEnumInfo();
NS_ASSERTION(info.mEnumCount > 0,
"DidChangeNumber on element with no number attribs");
NS_ASSERTION(aAttrEnum < info.mEnumCount, "aAttrEnum out of range");
nsAutoString newStr;
info.mEnums[aAttrEnum].GetBaseValueString(newStr, this);
SetAttr(kNameSpaceID_None, *info.mEnumInfo[aAttrEnum].mName,
newStr, PR_TRUE);
}
nsresult
nsSVGElement::ReportAttributeParseFailure(nsIDocument* aDocument,
nsIAtom* aAttribute,

View File

@ -57,6 +57,8 @@
class nsSVGSVGElement;
class nsSVGLength2;
class nsSVGNumber2;
class nsSVGEnum;
struct nsSVGEnumMapping;
typedef nsStyledElement nsSVGElementBase;
@ -116,6 +118,7 @@ public:
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeNumber(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeEnum(PRUint8 aAttrEnum, PRBool aDoSetAttr);
void GetAnimatedLengthValues(float *aFirst, ...);
void GetAnimatedNumberValues(float *aFirst, ...);
@ -179,6 +182,26 @@ public:
{}
};
struct EnumInfo {
nsIAtom** mName;
nsSVGEnumMapping* mMapping;
PRUint16 mDefaultValue;
};
struct EnumAttributesInfo {
nsSVGEnum* mEnums;
EnumInfo* mEnumInfo;
PRUint32 mEnumCount;
EnumAttributesInfo(nsSVGEnum *aEnums,
EnumInfo *aEnumInfo,
PRUint32 aEnumCount) :
mEnums(aEnums), mEnumInfo(aEnumInfo), mEnumCount(aEnumCount)
{}
};
virtual EnumAttributesInfo GetEnumInfo();
protected:
virtual LengthAttributesInfo GetLengthInfo();
virtual NumberAttributesInfo GetNumberInfo();
@ -186,6 +209,9 @@ protected:
static nsresult ReportAttributeParseFailure(nsIDocument* aDocument,
nsIAtom* aAttribute,
const nsAString& aValue);
static nsSVGEnumMapping sSVGUnitTypesMap[];
nsCOMPtr<nsICSSStyleRule> mContentStyleRule;
nsAttrAndChildArray mMappedAttributes;

View File

@ -14,13 +14,11 @@
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2004
* The Initial Developer of the Original Code is IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Rowley <tor@cs.brown.edu> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -37,137 +35,41 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGEnum.h"
#include "nsSVGValue.h"
#include "nsISVGValueUtils.h"
#include "nsWeakReference.h"
#include "nsIAtom.h"
#include "nsSVGElement.h"
////////////////////////////////////////////////////////////////////////
// nsSVGEnum class
NS_IMPL_ADDREF(nsSVGEnum::DOMAnimatedEnum)
NS_IMPL_RELEASE(nsSVGEnum::DOMAnimatedEnum)
class nsSVGEnum : public nsISVGEnum,
public nsSVGValue
{
protected:
friend nsresult NS_NewSVGEnum(nsISVGEnum** result,
PRUint16 value,
nsSVGEnumMapping *mapping);
friend nsresult NS_NewSVGEnum(nsISVGEnum** result,
const nsAString &value,
nsSVGEnumMapping *mapping);
nsSVGEnum(PRUint16 value, nsSVGEnumMapping *mapping);
nsSVGEnum(nsSVGEnumMapping *mapping);
virtual ~nsSVGEnum();
public:
// nsISupports interface:
NS_DECL_ISUPPORTS
// nsISVGEnum interface:
NS_IMETHOD GetIntegerValue(PRUint16 &value);
NS_IMETHOD SetIntegerValue(PRUint16 value);
// nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
#ifdef DEBUG_scooter
void Print_mapping();
#endif
protected:
PRUint16 mValue;
nsSVGEnumMapping *mMapping;
};
//----------------------------------------------------------------------
// Implementation
#ifdef DEBUG_scooter
void nsSVGEnum::Print_mapping()
{
nsSVGEnumMapping *tmp = mMapping;
nsAutoString aStr;
printf("Print_mapping: mMapping = 0x%x\n", tmp);
while (tmp->key) {
(*tmp->key)->ToString(aStr);
printf ("Print_mapping: %s (%d)\n", NS_ConvertUTF16toUTF8(aStr).get(), tmp->val);
tmp++;
}
}
#endif
nsresult
NS_NewSVGEnum(nsISVGEnum** result,
PRUint16 value,
nsSVGEnumMapping *mapping)
{
NS_ASSERTION(mapping, "no mapping");
nsSVGEnum *pe = new nsSVGEnum(value, mapping);
if (!pe) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(pe);
*result = pe;
return NS_OK;
}
nsresult
NS_NewSVGEnum(nsISVGEnum** result,
const nsAString &value,
nsSVGEnumMapping *mapping)
{
NS_ASSERTION(mapping, "no mapping");
*result = nsnull;
nsSVGEnum *pe = new nsSVGEnum(0, mapping);
if (!pe) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(pe);
if (NS_FAILED(pe->SetValueString(value))) {
NS_RELEASE(pe);
return NS_ERROR_FAILURE;
}
*result = pe;
return NS_OK;
}
nsSVGEnum::nsSVGEnum(PRUint16 value,
nsSVGEnumMapping *mapping)
: mValue(value), mMapping(mapping)
{
}
nsSVGEnum::~nsSVGEnum()
{
}
//----------------------------------------------------------------------
// nsISupports methods:
NS_IMPL_ADDREF(nsSVGEnum)
NS_IMPL_RELEASE(nsSVGEnum)
NS_INTERFACE_MAP_BEGIN(nsSVGEnum)
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
NS_INTERFACE_MAP_ENTRY(nsISVGEnum)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
NS_INTERFACE_MAP_BEGIN(nsSVGEnum::DOMAnimatedEnum)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAnimatedEnumeration)
NS_INTERFACE_MAP_END
//----------------------------------------------------------------------
// nsISVGValue methods:
NS_IMETHODIMP
nsSVGEnum::SetValueString(const nsAString& aValue)
nsSVGEnumMapping *
nsSVGEnum::GetMapping(nsSVGElement *aSVGElement)
{
nsSVGElement::EnumAttributesInfo info = aSVGElement->GetEnumInfo();
NS_ASSERTION(info.mEnumCount > 0 && mAttrEnum < info.mEnumCount,
"mapping request for a non-attrib enum");
return info.mEnumInfo[mAttrEnum].mMapping;
}
nsresult
nsSVGEnum::SetBaseValueString(const nsAString& aValue,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr)
{
nsCOMPtr<nsIAtom> valAtom = do_GetAtom(aValue);
nsSVGEnumMapping *tmp = mMapping;
nsSVGEnumMapping *tmp = GetMapping(aSVGElement);
while (tmp->key) {
if (valAtom == *(tmp->key)) {
WillModify();
mValue = tmp->val;
DidModify();
while (tmp && tmp->mKey) {
if (valAtom == *(tmp->mKey)) {
mBaseVal = mAnimVal = tmp->mVal;
return NS_OK;
}
tmp++;
@ -178,39 +80,38 @@ nsSVGEnum::SetValueString(const nsAString& aValue)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSVGEnum::GetValueString(nsAString& aValue)
void
nsSVGEnum::GetBaseValueString(nsAString& aValue, nsSVGElement *aSVGElement)
{
nsSVGEnumMapping *tmp = mMapping;
nsSVGEnumMapping *tmp = GetMapping(aSVGElement);
while (tmp->key) {
if (mValue == tmp->val) {
(*tmp->key)->ToString(aValue);
return NS_OK;
while (tmp && tmp->mKey) {
if (mBaseVal == tmp->mVal) {
(*tmp->mKey)->ToString(aValue);
return;
}
tmp++;
}
NS_ERROR("unknown enumeration value");
return NS_ERROR_FAILURE;
}
//----------------------------------------------------------------------
// nsISVGEnum methods:
NS_IMETHODIMP
nsSVGEnum::GetIntegerValue(PRUint16& aValue)
void
nsSVGEnum::SetBaseValue(PRUint16 aValue,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr)
{
aValue = mValue;
mAnimVal = mBaseVal = static_cast<PRUint8>(aValue);
aSVGElement->DidChangeEnum(mAttrEnum, aDoSetAttr);
}
nsresult
nsSVGEnum::ToDOMAnimatedEnum(nsIDOMSVGAnimatedEnumeration **aResult,
nsSVGElement *aSVGElement)
{
*aResult = new DOMAnimatedEnum(this, aSVGElement);
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsSVGEnum::SetIntegerValue(PRUint16 aValue)
{
WillModify();
mValue = aValue;
DidModify();
return NS_OK;
}

View File

@ -14,17 +14,15 @@
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2004
* The Initial Developer of the Original Code is IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Rowley <tor@cs.brown.edu> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
@ -39,25 +37,67 @@
#ifndef __NS_SVGENUM_H__
#define __NS_SVGENUM_H__
#include "nsISVGEnum.h"
#include "nsAString.h"
#include "nsIAtom.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsSVGElement.h"
#include "nsDOMError.h"
typedef PRUint8 nsSVGEnumValue;
struct nsSVGEnumMapping {
nsIAtom **key;
PRUint16 val;
nsIAtom **mKey;
nsSVGEnumValue mVal;
};
nsresult
NS_NewSVGEnum(nsISVGEnum** result,
PRUint16 value,
struct nsSVGEnumMapping *mapping);
class nsSVGEnum
{
public:
void Init(PRUint8 aAttrEnum, PRUint16 aValue) {
mAnimVal = mBaseVal = static_cast<PRUint8>(aValue);
mAttrEnum = aAttrEnum;
}
nsresult
NS_NewSVGEnum(nsISVGEnum** result,
const nsAString &value,
struct nsSVGEnumMapping *mapping);
nsresult SetBaseValueString(const nsAString& aValue,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr);
void GetBaseValueString(nsAString& aValue,
nsSVGElement *aSVGElement);
#endif //__NS_SVGENUM_H__
void SetBaseValue(PRUint16 aValue,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr);
PRUint16 GetBaseValue()
{ return mBaseVal; }
PRUint16 GetAnimValue()
{ return mAnimVal; }
nsresult ToDOMAnimatedEnum(nsIDOMSVGAnimatedEnumeration **aResult,
nsSVGElement* aSVGElement);
private:
nsSVGEnumValue mAnimVal;
nsSVGEnumValue mBaseVal;
PRUint8 mAttrEnum; // element specified tracking for attribute
nsSVGEnumMapping *GetMapping(nsSVGElement *aSVGElement);
struct DOMAnimatedEnum : public nsIDOMSVGAnimatedEnumeration
{
NS_DECL_ISUPPORTS
DOMAnimatedEnum(nsSVGEnum* aVal, nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
nsSVGEnum *mVal; // kept alive because it belongs to content
nsRefPtr<nsSVGElement> mSVGElement;
NS_IMETHOD GetBaseVal(PRUint16* aResult)
{ *aResult = mVal->GetBaseValue(); return NS_OK; }
NS_IMETHOD SetBaseVal(PRUint16 aValue)
{ mVal->SetBaseValue(aValue, mSVGElement, PR_TRUE); return NS_OK; }
NS_IMETHOD GetAnimVal(PRUint16* aResult)
{ *aResult = mVal->GetAnimValue(); return NS_OK; }
};
};
#endif //__NS_SVGENUM2_H__

View File

@ -37,10 +37,8 @@
#include "nsGkAtoms.h"
#include "nsSVGLength.h"
#include "nsCOMPtr.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsSVGAnimatedInteger.h"
#include "nsSVGAnimatedString.h"
#include "nsSVGEnum.h"
#include "nsSVGFilterElement.h"
nsSVGElement::LengthInfo nsSVGFilterElement::sLengthInfo[4] =
@ -51,6 +49,18 @@ nsSVGElement::LengthInfo nsSVGFilterElement::sLengthInfo[4] =
{ &nsGkAtoms::height, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
};
nsSVGElement::EnumInfo nsSVGFilterElement::sEnumInfo[2] =
{
{ &nsGkAtoms::filterUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
},
{ &nsGkAtoms::primitiveUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Filter)
//----------------------------------------------------------------------
@ -82,39 +92,8 @@ nsSVGFilterElement::Init()
nsresult rv = nsSVGFilterElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// Define enumeration mappings
static struct nsSVGEnumMapping gUnitMap[] = {
{&nsGkAtoms::objectBoundingBox, nsIDOMSVGFilterElement::SVG_FUNITS_OBJECTBOUNDINGBOX},
{&nsGkAtoms::userSpaceOnUse, nsIDOMSVGFilterElement::SVG_FUNITS_USERSPACEONUSE},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: filterUnits , #IMPLIED attrib: filterUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGFilterElement::SVG_FUNITS_OBJECTBOUNDINGBOX, gUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mFilterUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::filterUnits, mFilterUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: primitiveUnits , #IMPLIED attrib: primitiveUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGFilterElement::SVG_FUNITS_USERSPACEONUSE, gUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mPrimitiveUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::primitiveUnits, mPrimitiveUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: filterResX , #IMPLIED attrib: filterRes
{
rv = NS_NewSVGAnimatedInteger(getter_AddRefs(mFilterResX), 0);
@ -178,17 +157,13 @@ NS_IMETHODIMP nsSVGFilterElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
/* readonly attribute nsIDOMSVGAnimatedEnumeration filterUnits; */
NS_IMETHODIMP nsSVGFilterElement::GetFilterUnits(nsIDOMSVGAnimatedEnumeration * *aUnits)
{
*aUnits = mFilterUnits;
NS_IF_ADDREF(*aUnits);
return NS_OK;
return mEnumAttributes[FILTERUNITS].ToDOMAnimatedEnum(aUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedEnumeration primitiveUnits; */
NS_IMETHODIMP nsSVGFilterElement::GetPrimitiveUnits(nsIDOMSVGAnimatedEnumeration * *aUnits)
{
*aUnits = mPrimitiveUnits;
NS_IF_ADDREF(*aUnits);
return NS_OK;
return mEnumAttributes[PRIMITIVEUNITS].ToDOMAnimatedEnum(aUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedEnumeration filterResY; */
@ -289,3 +264,10 @@ nsSVGFilterElement::GetLengthInfo()
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
NS_ARRAY_LENGTH(sLengthInfo));
}
nsSVGElement::EnumAttributesInfo
nsSVGFilterElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}

View File

@ -40,13 +40,16 @@
#include "nsSVGGraphicElement.h"
#include "nsIDOMSVGFilterElement.h"
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsSVGLength2.h"
#include "nsSVGEnum.h"
typedef nsSVGGraphicElement nsSVGFilterElementBase;
class nsSVGFilterElement : public nsSVGFilterElementBase,
public nsIDOMSVGFilterElement,
public nsIDOMSVGURIReference
public nsIDOMSVGURIReference,
public nsIDOMSVGUnitTypes
{
friend class nsSVGFilterFrame;
@ -83,13 +86,16 @@ public:
protected:
virtual LengthAttributesInfo GetLengthInfo();
virtual EnumAttributesInfo GetEnumInfo();
enum { X, Y, WIDTH, HEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mFilterUnits;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mPrimitiveUnits;
enum { FILTERUNITS, PRIMITIVEUNITS };
nsSVGEnum mEnumAttributes[2];
static EnumInfo sEnumInfo[2];
nsCOMPtr<nsIDOMSVGAnimatedInteger> mFilterResX;
nsCOMPtr<nsIDOMSVGAnimatedInteger> mFilterResY;
nsCOMPtr<nsIDOMSVGAnimatedString> mHref;

View File

@ -48,7 +48,6 @@
#include "nsWeakReference.h"
#include "nsIDOMSVGFilterElement.h"
#include "nsSVGEnum.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsSVGNumberList.h"
#include "nsSVGAnimatedNumberList.h"
#include "nsISVGValueUtils.h"
@ -931,9 +930,32 @@ public:
protected:
virtual EnumAttributesInfo GetEnumInfo();
enum { MODE };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sModeMap[];
static EnumInfo sEnumInfo[1];
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
nsCOMPtr<nsIDOMSVGAnimatedString> mIn2;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMode;
};
nsSVGEnumMapping nsSVGFEBlendElement::sModeMap[] = {
{&nsGkAtoms::normal, nsSVGFEBlendElement::SVG_MODE_NORMAL},
{&nsGkAtoms::multiply, nsSVGFEBlendElement::SVG_MODE_MULTIPLY},
{&nsGkAtoms::screen, nsSVGFEBlendElement::SVG_MODE_SCREEN},
{&nsGkAtoms::darken, nsSVGFEBlendElement::SVG_MODE_DARKEN},
{&nsGkAtoms::lighten, nsSVGFEBlendElement::SVG_MODE_LIGHTEN},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGFEBlendElement::sEnumInfo[1] =
{
{ &nsGkAtoms::mode,
sModeMap,
nsSVGFEBlendElement::SVG_MODE_NORMAL
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(FEBlend)
@ -968,28 +990,7 @@ nsSVGFEBlendElement::Init()
nsresult rv = nsSVGFEBlendElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
static struct nsSVGEnumMapping gModeTypes[] = {
{&nsGkAtoms::normal, nsSVGFEBlendElement::SVG_MODE_NORMAL},
{&nsGkAtoms::multiply, nsSVGFEBlendElement::SVG_MODE_MULTIPLY},
{&nsGkAtoms::screen, nsSVGFEBlendElement::SVG_MODE_SCREEN},
{&nsGkAtoms::darken, nsSVGFEBlendElement::SVG_MODE_DARKEN},
{&nsGkAtoms::lighten, nsSVGFEBlendElement::SVG_MODE_LIGHTEN},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: mode, #IMPLIED attrib: mode
{
nsCOMPtr<nsISVGEnum> modes;
rv = NS_NewSVGEnum(getter_AddRefs(modes),
nsSVGFEBlendElement::SVG_MODE_NORMAL,
gModeTypes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mMode), modes);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::mode, mMode);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: in1 , #IMPLIED attrib: in
{
@ -1038,9 +1039,7 @@ NS_IMETHODIMP nsSVGFEBlendElement::GetIn2(nsIDOMSVGAnimatedString * *aIn)
/* readonly attribute nsIDOMSVGAnimatedEnumeration mode; */
NS_IMETHODIMP nsSVGFEBlendElement::GetMode(nsIDOMSVGAnimatedEnumeration * *aMode)
{
*aMode = mMode;
NS_IF_ADDREF(*aMode);
return NS_OK;
return mEnumAttributes[MODE].ToDOMAnimatedEnum(aMode, this);
}
NS_IMETHODIMP
@ -1070,8 +1069,7 @@ nsSVGFEBlendElement::Filter(nsSVGFilterInstance *instance)
NS_ENSURE_SUCCESS(rv, rv);
rect = fr.GetFilterSubregion();
PRUint16 mode;
mMode->GetAnimVal(&mode);
PRUint16 mode = mEnumAttributes[MODE].GetAnimValue();
for (PRInt32 x = rect.x; x < rect.XMost(); x++) {
for (PRInt32 y = rect.y; y < rect.YMost(); y++) {
@ -1122,6 +1120,13 @@ nsSVGFEBlendElement::GetRequirements(PRUint32 *aRequirements)
return NS_OK;
}
nsSVGElement::EnumAttributesInfo
nsSVGFEBlendElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//---------------------Color Matrix------------------------
typedef nsSVGFE nsSVGFEColorMatrixElementBase;
@ -1158,13 +1163,33 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected:
//virtual NumberAttributesInfo GetNumberInfo();
virtual EnumAttributesInfo GetEnumInfo();
enum { TYPE };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sTypeMap[];
static EnumInfo sEnumInfo[1];
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mType;
nsCOMPtr<nsIDOMSVGAnimatedNumberList> mValues;
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
};
nsSVGEnumMapping nsSVGFEColorMatrixElement::sTypeMap[] = {
{&nsGkAtoms::matrix, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_MATRIX},
{&nsGkAtoms::saturate, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_SATURATE},
{&nsGkAtoms::hueRotate, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_HUE_ROTATE},
{&nsGkAtoms::luminanceToAlpha, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_LUMINANCE_TO_ALPHA},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGFEColorMatrixElement::sEnumInfo[1] =
{
{ &nsGkAtoms::type,
sTypeMap,
nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_MATRIX
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(FEColorMatrix)
//----------------------------------------------------------------------
@ -1197,27 +1222,7 @@ nsSVGFEColorMatrixElement::Init()
nsresult rv = nsSVGFEColorMatrixElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
static struct nsSVGEnumMapping gTypes[] = {
{&nsGkAtoms::matrix, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_MATRIX},
{&nsGkAtoms::saturate, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_SATURATE},
{&nsGkAtoms::hueRotate, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_HUE_ROTATE},
{&nsGkAtoms::luminanceToAlpha, nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_LUMINANCE_TO_ALPHA},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: type, #IMPLIED attrib: type
{
nsCOMPtr<nsISVGEnum> types;
rv = NS_NewSVGEnum(getter_AddRefs(types),
nsSVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_MATRIX,
gTypes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mType), types);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::type, mType);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: values, #IMPLIED attrib: values
{
@ -1262,9 +1267,7 @@ NS_IMETHODIMP nsSVGFEColorMatrixElement::GetIn1(nsIDOMSVGAnimatedString * *aIn)
/* readonly attribute nsIDOMSVGAnimatedEnumeration type; */
NS_IMETHODIMP nsSVGFEColorMatrixElement::GetType(nsIDOMSVGAnimatedEnumeration * *aType)
{
*aType = mType;
NS_IF_ADDREF(*aType);
return NS_OK;
return mEnumAttributes[TYPE].ToDOMAnimatedEnum(aType, this);
}
/* readonly attribute nsIDOMSVGAnimatedNumberList values; */
@ -1282,6 +1285,13 @@ nsSVGFEColorMatrixElement::GetRequirements(PRUint32 *aRequirements)
return NS_OK;
}
nsSVGElement::EnumAttributesInfo
nsSVGFEColorMatrixElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -1298,8 +1308,7 @@ nsSVGFEColorMatrixElement::Filter(nsSVGFilterInstance *instance)
rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv);
PRUint16 type;
mType->GetAnimVal(&type);
PRUint16 type = mEnumAttributes[TYPE].GetAnimValue();
nsCOMPtr<nsIDOMSVGNumberList> list;
mValues->GetAnimVal(getter_AddRefs(list));
@ -1482,14 +1491,19 @@ public:
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual EnumAttributesInfo GetEnumInfo();
enum { K1, K2, K3, K4 };
nsSVGNumber2 mNumberAttributes[4];
static NumberInfo sNumberInfo[4];
enum { OPERATOR };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sOperatorMap[];
static EnumInfo sEnumInfo[1];
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
nsCOMPtr<nsIDOMSVGAnimatedString> mIn2;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mOperator;
};
nsSVGElement::NumberInfo nsSVGFECompositeElement::sNumberInfo[4] =
@ -1500,6 +1514,24 @@ nsSVGElement::NumberInfo nsSVGFECompositeElement::sNumberInfo[4] =
{ &nsGkAtoms::k4, 0 }
};
nsSVGEnumMapping nsSVGFECompositeElement::sOperatorMap[] = {
{&nsGkAtoms::over, nsSVGFECompositeElement::SVG_OPERATOR_OVER},
{&nsGkAtoms::in, nsSVGFECompositeElement::SVG_OPERATOR_IN},
{&nsGkAtoms::out, nsSVGFECompositeElement::SVG_OPERATOR_OUT},
{&nsGkAtoms::atop, nsSVGFECompositeElement::SVG_OPERATOR_ATOP},
{&nsGkAtoms::xor_, nsSVGFECompositeElement::SVG_OPERATOR_XOR},
{&nsGkAtoms::arithmetic, nsSVGFECompositeElement::SVG_OPERATOR_ARITHMETIC},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGFECompositeElement::sEnumInfo[1] =
{
{ &nsGkAtoms::_operator,
sOperatorMap,
nsIDOMSVGFECompositeElement::SVG_OPERATOR_OVER
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(FEComposite)
//----------------------------------------------------------------------
@ -1532,30 +1564,8 @@ nsSVGFECompositeElement::Init()
nsresult rv = nsSVGFECompositeElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
static struct nsSVGEnumMapping gOperatorTypes[] = {
{&nsGkAtoms::over, nsSVGFECompositeElement::SVG_OPERATOR_OVER},
{&nsGkAtoms::in, nsSVGFECompositeElement::SVG_OPERATOR_IN},
{&nsGkAtoms::out, nsSVGFECompositeElement::SVG_OPERATOR_OUT},
{&nsGkAtoms::atop, nsSVGFECompositeElement::SVG_OPERATOR_ATOP},
{&nsGkAtoms::xor_, nsSVGFECompositeElement::SVG_OPERATOR_XOR},
{&nsGkAtoms::arithmetic, nsSVGFECompositeElement::SVG_OPERATOR_ARITHMETIC},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: operator, #IMPLIED attrib: operator
{
nsCOMPtr<nsISVGEnum> operators;
rv = NS_NewSVGEnum(getter_AddRefs(operators),
nsIDOMSVGFECompositeElement::SVG_OPERATOR_OVER,
gOperatorTypes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mOperator), operators);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::_operator, mOperator);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: in1 , #IMPLIED attrib: in
{
rv = NS_NewSVGAnimatedString(getter_AddRefs(mIn1));
@ -1603,9 +1613,7 @@ NS_IMETHODIMP nsSVGFECompositeElement::GetIn2(nsIDOMSVGAnimatedString * *aIn)
/* readonly attribute nsIDOMSVGAnimatedEnumeration operator; */
NS_IMETHODIMP nsSVGFECompositeElement::GetOperator(nsIDOMSVGAnimatedEnumeration * *aOperator)
{
*aOperator = mOperator;
NS_IF_ADDREF(*aOperator);
return NS_OK;
return mEnumAttributes[OPERATOR].ToDOMAnimatedEnum(aOperator, this);
}
/* readonly attribute nsIDOMSVGAnimatedNumber K1; */
@ -1658,8 +1666,7 @@ nsSVGFECompositeElement::Filter(nsSVGFilterInstance *instance)
getter_AddRefs(targetSurface));
NS_ENSURE_SUCCESS(rv, rv);
PRUint16 op;
mOperator->GetAnimVal(&op);
PRUint16 op = mEnumAttributes[OPERATOR].GetAnimValue();
// Cairo does not support arithmetic operator
if (op == nsSVGFECompositeElement::SVG_OPERATOR_ARITHMETIC) {
@ -1738,6 +1745,13 @@ nsSVGFECompositeElement::GetRequirements(PRUint32 *aRequirements)
return NS_OK;
}
nsSVGElement::EnumAttributesInfo
nsSVGFECompositeElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -1931,15 +1945,19 @@ public:
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual EnumAttributesInfo GetEnumInfo();
// nsIDOMSVGComponentTransferFunctionElement properties:
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mType;
nsCOMPtr<nsIDOMSVGAnimatedNumberList> mTableValues;
enum { SLOPE, INTERCEPT, AMPLITUDE, EXPONENT, OFFSET };
nsSVGNumber2 mNumberAttributes[5];
static NumberInfo sNumberInfo[5];
enum { TYPE };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sTypeMap[];
static EnumInfo sEnumInfo[1];
};
nsSVGElement::NumberInfo nsSVGComponentTransferFunctionElement::sNumberInfo[5] =
@ -1951,6 +1969,28 @@ nsSVGElement::NumberInfo nsSVGComponentTransferFunctionElement::sNumberInfo[5] =
{ &nsGkAtoms::offset, 0 }
};
nsSVGEnumMapping nsSVGComponentTransferFunctionElement::sTypeMap[] = {
{&nsGkAtoms::identity,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY},
{&nsGkAtoms::table,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_TABLE},
{&nsGkAtoms::discrete,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE},
{&nsGkAtoms::linear,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_LINEAR},
{&nsGkAtoms::gamma,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_GAMMA},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGComponentTransferFunctionElement::sEnumInfo[1] =
{
{ &nsGkAtoms::type,
sTypeMap,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY
}
};
//----------------------------------------------------------------------
// nsISupports methods
@ -1974,36 +2014,8 @@ nsSVGComponentTransferFunctionElement::Init()
nsresult rv = nsSVGComponentTransferFunctionElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// enumeration mappings
static struct nsSVGEnumMapping gComponentTransferTypes[] = {
{&nsGkAtoms::identity,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY},
{&nsGkAtoms::table,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_TABLE},
{&nsGkAtoms::discrete,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE},
{&nsGkAtoms::linear,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_LINEAR},
{&nsGkAtoms::gamma,
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_GAMMA},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: type, #IMPLIED attrib: type
{
nsCOMPtr<nsISVGEnum> types;
rv = NS_NewSVGEnum(getter_AddRefs(types),
nsIDOMSVGComponentTransferFunctionElement::SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY,
gComponentTransferTypes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mType), types);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::type, mType);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: tableValues, #IMPLIED attrib: tableValues
{
nsCOMPtr<nsIDOMSVGNumberList> values;
@ -2018,15 +2030,20 @@ nsSVGComponentTransferFunctionElement::Init()
return NS_OK;
}
nsSVGElement::EnumAttributesInfo
nsSVGComponentTransferFunctionElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsIDOMSVGComponentTransferFunctionElement methods
/* readonly attribute nsIDOMSVGAnimatedEnumeration type; */
NS_IMETHODIMP nsSVGComponentTransferFunctionElement::GetType(nsIDOMSVGAnimatedEnumeration * *aType)
{
*aType = mType;
NS_IF_ADDREF(*aType);
return NS_OK;
return mEnumAttributes[TYPE].ToDOMAnimatedEnum(aType, this);
}
/* readonly attribute nsIDOMSVGAnimatedNumberList tableValues; */
@ -2070,8 +2087,7 @@ NS_IMETHODIMP nsSVGComponentTransferFunctionElement::GetOffset(nsIDOMSVGAnimated
NS_IMETHODIMP
nsSVGComponentTransferFunctionElement::GenerateLookupTable(PRUint8 *aTable)
{
PRUint16 type;
mType->GetAnimVal(&type);
PRUint16 type = mEnumAttributes[TYPE].GetAnimValue();
float slope, intercept, amplitude, exponent, offset;
GetAnimatedNumberValues(&slope, &intercept, &amplitude,
@ -3080,14 +3096,19 @@ public:
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual EnumAttributesInfo GetEnumInfo();
enum { BASE_FREQ_X, BASE_FREQ_Y, SEED}; // floating point seed?!
nsSVGNumber2 mNumberAttributes[3];
static NumberInfo sNumberInfo[3];
enum { STITCHTILES, TYPE };
nsSVGEnum mEnumAttributes[2];
static nsSVGEnumMapping sStitchTilesMap[];
static nsSVGEnumMapping sTypeMap[];
static EnumInfo sEnumInfo[2];
nsCOMPtr<nsIDOMSVGAnimatedInteger> mNumOctaves;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mStitchTiles;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mType;
private:
@ -3158,6 +3179,34 @@ nsSVGElement::NumberInfo nsSVGFETurbulenceElement::sNumberInfo[3] =
{ &nsGkAtoms::seed, 0 }
};
nsSVGEnumMapping nsSVGFETurbulenceElement::sTypeMap[] = {
{&nsGkAtoms::fractalNoise,
nsIDOMSVGFETurbulenceElement::SVG_TURBULENCE_TYPE_FRACTALNOISE},
{&nsGkAtoms::turbulence,
nsIDOMSVGFETurbulenceElement::SVG_TURBULENCE_TYPE_TURBULENCE},
{nsnull, 0}
};
nsSVGEnumMapping nsSVGFETurbulenceElement::sStitchTilesMap[] = {
{&nsGkAtoms::stitch,
nsIDOMSVGFETurbulenceElement::SVG_STITCHTYPE_STITCH},
{&nsGkAtoms::noStitch,
nsIDOMSVGFETurbulenceElement::SVG_STITCHTYPE_NOSTITCH},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGFETurbulenceElement::sEnumInfo[2] =
{
{ &nsGkAtoms::type,
sTypeMap,
nsIDOMSVGFETurbulenceElement::SVG_TURBULENCE_TYPE_TURBULENCE
},
{ &nsGkAtoms::stitchTiles,
sStitchTilesMap,
nsIDOMSVGFETurbulenceElement::SVG_STITCHTYPE_NOSTITCH
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(FETurbulence)
//----------------------------------------------------------------------
@ -3190,51 +3239,8 @@ nsSVGFETurbulenceElement::Init()
nsresult rv = nsSVGFETurbulenceElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// enumeration mappings
static struct nsSVGEnumMapping gTurbulenceTypes[] = {
{&nsGkAtoms::fractalNoise,
nsIDOMSVGFETurbulenceElement::SVG_TURBULENCE_TYPE_FRACTALNOISE},
{&nsGkAtoms::turbulence,
nsIDOMSVGFETurbulenceElement::SVG_TURBULENCE_TYPE_TURBULENCE},
{nsnull, 0}
};
static struct nsSVGEnumMapping gStitchTypes[] = {
{&nsGkAtoms::stitch,
nsIDOMSVGFETurbulenceElement::SVG_STITCHTYPE_STITCH},
{&nsGkAtoms::noStitch,
nsIDOMSVGFETurbulenceElement::SVG_STITCHTYPE_NOSTITCH},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: stitchTiles, #IMPLIED attrib: stitchTiles
{
nsCOMPtr<nsISVGEnum> stitch;
rv = NS_NewSVGEnum(getter_AddRefs(stitch),
nsIDOMSVGFETurbulenceElement::SVG_STITCHTYPE_NOSTITCH,
gStitchTypes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mStitchTiles), stitch);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::stitchTiles, mStitchTiles);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: type, #IMPLIED attrib: type
{
nsCOMPtr<nsISVGEnum> types;
rv = NS_NewSVGEnum(getter_AddRefs(types),
nsIDOMSVGFETurbulenceElement::SVG_TURBULENCE_TYPE_TURBULENCE,
gTurbulenceTypes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mType), types);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::type, mType);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: numOctaves , #IMPLIED attrib: numOctaves
{
rv = NS_NewSVGAnimatedInteger(getter_AddRefs(mNumOctaves), 1);
@ -3246,6 +3252,13 @@ nsSVGFETurbulenceElement::Init()
return rv;
}
nsSVGElement::EnumAttributesInfo
nsSVGFETurbulenceElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsIDOMNode methods
@ -3283,17 +3296,13 @@ NS_IMETHODIMP nsSVGFETurbulenceElement::GetSeed(nsIDOMSVGAnimatedNumber * *aSeed
/* readonly attribute nsIDOMSVGAnimatedEnumeration stitchTiles; */
NS_IMETHODIMP nsSVGFETurbulenceElement::GetStitchTiles(nsIDOMSVGAnimatedEnumeration * *aStitch)
{
*aStitch = mStitchTiles;
NS_IF_ADDREF(*aStitch);
return NS_OK;
return mEnumAttributes[STITCHTILES].ToDOMAnimatedEnum(aStitch, this);
}
/* readonly attribute nsIDOMSVGAnimatedEnumeration type; */
NS_IMETHODIMP nsSVGFETurbulenceElement::GetType(nsIDOMSVGAnimatedEnumeration * *aType)
{
*aType = mType;
NS_IF_ADDREF(*aType);
return NS_OK;
return mEnumAttributes[TYPE].ToDOMAnimatedEnum(aType, this);
}
PRBool
@ -3338,12 +3347,11 @@ nsSVGFETurbulenceElement::Filter(nsSVGFilterInstance *instance)
float fX, fY, seed;
PRInt32 octaves;
PRUint16 type, stitch;
PRUint16 type = mEnumAttributes[TYPE].GetAnimValue();
PRUint16 stitch = mEnumAttributes[STITCHTILES].GetAnimValue();
GetAnimatedNumberValues(&fX, &fY, &seed, nsnull);
mNumOctaves->GetAnimVal(&octaves);
mStitchTiles->GetAnimVal(&stitch);
mType->GetAnimVal(&type);
Init((PRInt32)seed);
@ -3621,13 +3629,18 @@ public:
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual EnumAttributesInfo GetEnumInfo();
enum { RADIUS_X, RADIUS_Y };
nsSVGNumber2 mNumberAttributes[2];
static NumberInfo sNumberInfo[2];
enum { OPERATOR };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sOperatorMap[];
static EnumInfo sEnumInfo[1];
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mOperator;
};
nsSVGElement::NumberInfo nsSVGFEMorphologyElement::sNumberInfo[2] =
@ -3636,6 +3649,20 @@ nsSVGElement::NumberInfo nsSVGFEMorphologyElement::sNumberInfo[2] =
{ &nsGkAtoms::radius, 0 }
};
nsSVGEnumMapping nsSVGFEMorphologyElement::sOperatorMap[] = {
{&nsGkAtoms::erode, nsSVGFEMorphologyElement::SVG_OPERATOR_ERODE},
{&nsGkAtoms::dilate, nsSVGFEMorphologyElement::SVG_OPERATOR_DILATE},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGFEMorphologyElement::sEnumInfo[1] =
{
{ &nsGkAtoms::_operator,
sOperatorMap,
nsSVGFEMorphologyElement::SVG_OPERATOR_ERODE
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(FEMorphology)
//----------------------------------------------------------------------
@ -3668,25 +3695,7 @@ nsSVGFEMorphologyElement::Init()
nsresult rv = nsSVGFEMorphologyElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
static struct nsSVGEnumMapping gOperatorTypes[] = {
{&nsGkAtoms::erode, nsSVGFEMorphologyElement::SVG_OPERATOR_ERODE},
{&nsGkAtoms::dilate, nsSVGFEMorphologyElement::SVG_OPERATOR_DILATE},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: operator, #IMPLIED attrib: operator
{
nsCOMPtr<nsISVGEnum> operators;
rv = NS_NewSVGEnum(getter_AddRefs(operators),
nsSVGFEMorphologyElement::SVG_OPERATOR_ERODE,
gOperatorTypes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mOperator), operators);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::_operator, mOperator);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: in1 , #IMPLIED attrib: in
{
@ -3720,9 +3729,7 @@ NS_IMETHODIMP nsSVGFEMorphologyElement::GetIn1(nsIDOMSVGAnimatedString * *aIn)
/* readonly attribute nsIDOMSVGAnimatedEnumeration operator; */
NS_IMETHODIMP nsSVGFEMorphologyElement::GetOperator(nsIDOMSVGAnimatedEnumeration * *aOperator)
{
*aOperator = mOperator;
NS_IF_ADDREF(*aOperator);
return NS_OK;
return mEnumAttributes[OPERATOR].ToDOMAnimatedEnum(aOperator, this);
}
/* readonly attribute nsIDOMSVGAnimatedNumber radiusX; */
@ -3779,6 +3786,13 @@ nsSVGFEMorphologyElement::GetNumberInfo()
NS_ARRAY_LENGTH(sNumberInfo));
}
nsSVGElement::EnumAttributesInfo
nsSVGFEMorphologyElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
NS_IMETHODIMP
nsSVGFEMorphologyElement::Filter(nsSVGFilterInstance *instance)
{
@ -3810,8 +3824,7 @@ nsSVGFEMorphologyElement::Filter(nsSVGFilterInstance *instance)
PRInt32 stride = fr.GetDataStride();
PRUint32 xExt[4], yExt[4]; // X, Y indices of RGBA extrema
PRUint8 extrema[4]; // RGBA magnitude of extrema
PRUint16 op;
mOperator->GetAnimVal(&op);
PRUint16 op = mEnumAttributes[OPERATOR].GetAnimValue();
if (rx == 0 && ry == 0) {
fr.CopySourceImage();
@ -3918,17 +3931,22 @@ public:
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual EnumAttributesInfo GetEnumInfo();
enum { DIVISOR, BIAS, KERNEL_UNIT_LENGTH_X, KERNEL_UNIT_LENGTH_Y };
nsSVGNumber2 mNumberAttributes[4];
static NumberInfo sNumberInfo[4];
enum { EDGEMODE };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sEdgeModeMap[];
static EnumInfo sEnumInfo[1];
nsCOMPtr<nsIDOMSVGAnimatedInteger> mOrderX;
nsCOMPtr<nsIDOMSVGAnimatedInteger> mOrderY;
nsCOMPtr<nsIDOMSVGAnimatedInteger> mTargetX;
nsCOMPtr<nsIDOMSVGAnimatedInteger> mTargetY;
nsCOMPtr<nsIDOMSVGAnimatedNumberList> mKernelMatrix;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mEdgeMode;
nsCOMPtr<nsIDOMSVGAnimatedBoolean> mPreserveAlpha;
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
@ -3942,6 +3960,21 @@ nsSVGElement::NumberInfo nsSVGFEConvolveMatrixElement::sNumberInfo[4] =
{ &nsGkAtoms::kernelUnitLength, 0 }
};
nsSVGEnumMapping nsSVGFEConvolveMatrixElement::sEdgeModeMap[] = {
{&nsGkAtoms::duplicate, nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_DUPLICATE},
{&nsGkAtoms::wrap, nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_WRAP},
{&nsGkAtoms::none, nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_NONE},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGFEConvolveMatrixElement::sEnumInfo[1] =
{
{ &nsGkAtoms::edgeMode,
sEdgeModeMap,
nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_DUPLICATE
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(FEConvolveMatrix)
//----------------------------------------------------------------------
@ -3974,26 +4007,7 @@ nsSVGFEConvolveMatrixElement::Init()
nsresult rv = nsSVGFEConvolveMatrixElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
static struct nsSVGEnumMapping gEdgeModes[] = {
{&nsGkAtoms::duplicate, nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_DUPLICATE},
{&nsGkAtoms::wrap, nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_WRAP},
{&nsGkAtoms::none, nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_NONE},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: edgeMode, #IMPLIED attrib: edgeMode
{
nsCOMPtr<nsISVGEnum> edgeMode;
rv = NS_NewSVGEnum(getter_AddRefs(edgeMode),
nsSVGFEConvolveMatrixElement::SVG_EDGEMODE_DUPLICATE,
gEdgeModes);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mEdgeMode), edgeMode);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::edgeMode, mEdgeMode);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: kernelMarix, #IMPLIED attrib: kernelMatrix
{
@ -4100,9 +4114,7 @@ NS_IMETHODIMP nsSVGFEConvolveMatrixElement::GetTargetY(nsIDOMSVGAnimatedInteger
NS_IMETHODIMP nsSVGFEConvolveMatrixElement::GetEdgeMode(nsIDOMSVGAnimatedEnumeration * *aEdgeMode)
{
*aEdgeMode = mEdgeMode;
NS_IF_ADDREF(*aEdgeMode);
return NS_OK;
return mEnumAttributes[EDGEMODE].ToDOMAnimatedEnum(aEdgeMode, this);
}
NS_IMETHODIMP nsSVGFEConvolveMatrixElement::GetPreserveAlpha(nsIDOMSVGAnimatedBoolean * *aPreserveAlpha)
@ -4353,8 +4365,7 @@ nsSVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance *instance)
}
#endif
PRUint16 edgeMode;
mEdgeMode->GetAnimVal(&edgeMode);
PRUint16 edgeMode = mEnumAttributes[EDGEMODE].GetAnimValue();
float bias = 0;
if (HasAttr(kNameSpaceID_None, nsGkAtoms::bias)) {
@ -4395,6 +4406,13 @@ nsSVGFEConvolveMatrixElement::GetNumberInfo()
NS_ARRAY_LENGTH(sNumberInfo));
}
nsSVGElement::EnumAttributesInfo
nsSVGFEConvolveMatrixElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//---------------------DistantLight------------------------
typedef nsSVGElement nsSVGFEDistantLightElementBase;

View File

@ -38,8 +38,6 @@
#include "nsSVGTransformList.h"
#include "nsSVGAnimatedTransformList.h"
#include "nsSVGEnum.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGGradientElement.h"
@ -51,6 +49,25 @@
//--------------------- Gradients------------------------
nsSVGEnumMapping nsSVGGradientElement::sSpreadMethodMap[] = {
{&nsGkAtoms::pad, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD},
{&nsGkAtoms::reflect, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REFLECT},
{&nsGkAtoms::repeat, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REPEAT},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGGradientElement::sEnumInfo[2] =
{
{ &nsGkAtoms::gradientUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
},
{ &nsGkAtoms::spreadMethod,
sSpreadMethodMap,
nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD
}
};
//----------------------------------------------------------------------
// nsISupports methods
@ -59,6 +76,7 @@ NS_IMPL_RELEASE_INHERITED(nsSVGGradientElement,nsSVGGradientElementBase)
NS_INTERFACE_MAP_BEGIN(nsSVGGradientElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
NS_INTERFACE_MAP_END_INHERITING(nsSVGGradientElementBase)
//----------------------------------------------------------------------
@ -75,34 +93,8 @@ nsSVGGradientElement::Init()
nsresult rv = nsSVGGradientElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// Define enumeration mappings
static struct nsSVGEnumMapping gUnitMap[] = {
{&nsGkAtoms::objectBoundingBox, nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX},
{&nsGkAtoms::userSpaceOnUse, nsIDOMSVGGradientElement::SVG_GRUNITS_USERSPACEONUSE},
{nsnull, 0}
};
static struct nsSVGEnumMapping gSpreadMap[] = {
{&nsGkAtoms::pad, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD},
{&nsGkAtoms::reflect, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REFLECT},
{&nsGkAtoms::repeat, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REPEAT},
{nsnull, 0}
};
// Create mapped attributes
// DOM property: gradientUnits , #IMPLIED attrib: gradientUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX, gUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mGradientUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::gradientUnits, mGradientUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: gradientTransform , #IMPLIED attrib: gradientTransform
{
nsCOMPtr<nsIDOMSVGTransformList> transformList;
@ -115,18 +107,6 @@ nsSVGGradientElement::Init()
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: spreadMethod , #IMPLIED attrib: spreadMethod
{
nsCOMPtr<nsISVGEnum> spread;
rv = NS_NewSVGEnum(getter_AddRefs(spread),
nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD, gSpreadMap );
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mSpreadMethod), spread);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::spreadMethod, mSpreadMethod);
NS_ENSURE_SUCCESS(rv,rv);
}
// nsIDOMSVGURIReference properties
// DOM property: href , #IMPLIED attrib: xlink:href
@ -140,15 +120,20 @@ nsSVGGradientElement::Init()
return NS_OK;
}
nsSVGElement::EnumAttributesInfo
nsSVGGradientElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsIDOMSVGGradientElement methods
/* readonly attribute nsIDOMSVGAnimatedEnumeration gradientUnits; */
NS_IMETHODIMP nsSVGGradientElement::GetGradientUnits(nsIDOMSVGAnimatedEnumeration * *aGradientUnits)
{
*aGradientUnits = mGradientUnits;
NS_IF_ADDREF(*aGradientUnits);
return NS_OK;
return mEnumAttributes[GRADIENTUNITS].ToDOMAnimatedEnum(aGradientUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedTransformList gradientTransform; */
@ -162,9 +147,7 @@ NS_IMETHODIMP nsSVGGradientElement::GetGradientTransform(nsIDOMSVGAnimatedTransf
/* readonly attribute nsIDOMSVGAnimatedEnumeration spreadMethod; */
NS_IMETHODIMP nsSVGGradientElement::GetSpreadMethod(nsIDOMSVGAnimatedEnumeration * *aSpreadMethod)
{
*aSpreadMethod = mSpreadMethod;
NS_IF_ADDREF(*aSpreadMethod);
return NS_OK;
return mEnumAttributes[SPREADMETHOD].ToDOMAnimatedEnum(aSpreadMethod, this);
}
//----------------------------------------------------------------------

View File

@ -39,18 +39,20 @@
#ifndef __NS_SVGGRADIENTELEMENT_H__
#define __NS_SVGGRADIENTELEMENT_H__
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGGradientElement.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsSVGStylableElement.h"
#include "nsSVGLength2.h"
#include "nsSVGEnum.h"
//--------------------- Gradients------------------------
typedef nsSVGStylableElement nsSVGGradientElementBase;
class nsSVGGradientElement : public nsSVGGradientElementBase,
public nsIDOMSVGURIReference
public nsIDOMSVGURIReference,
public nsIDOMSVGUnitTypes
{
friend class nsSVGGradientFrame;
@ -72,11 +74,16 @@ public:
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
protected:
// nsIDOMSVGGradientElement values
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mGradientUnits;
nsCOMPtr<nsIDOMSVGAnimatedTransformList> mGradientTransform;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mSpreadMethod;
enum { GRADIENTUNITS, SPREADMETHOD };
nsSVGEnum mEnumAttributes[2];
static nsSVGEnumMapping sSpreadMethodMap[];
static EnumInfo sEnumInfo[2];
virtual EnumAttributesInfo GetEnumInfo();
// nsIDOMSVGURIReference properties
nsCOMPtr<nsIDOMSVGAnimatedString> mHref;

View File

@ -38,10 +38,8 @@
#include "nsSVGAnimatedAngle.h"
#include "nsSVGAnimatedRect.h"
#include "nsSVGLength.h"
#include "nsSVGEnum.h"
#include "nsSVGAngle.h"
#include "nsSVGRect.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsCOMPtr.h"
#include "nsISVGValueUtils.h"
#include "nsSVGAnimatedPreserveAspectRatio.h"
@ -59,6 +57,20 @@ nsSVGElement::LengthInfo nsSVGMarkerElement::sLengthInfo[4] =
{ &nsGkAtoms::markerHeight, 3, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, nsSVGUtils::Y },
};
nsSVGEnumMapping nsSVGMarkerElement::sUnitsMap[] = {
{&nsGkAtoms::objectBoundingBox, nsIDOMSVGMarkerElement::SVG_MARKERUNITS_STROKEWIDTH},
{&nsGkAtoms::userSpaceOnUse, nsIDOMSVGMarkerElement::SVG_MARKERUNITS_USERSPACEONUSE},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGMarkerElement::sEnumInfo[1] =
{
{ &nsGkAtoms::markerUnits,
sUnitsMap,
nsIDOMSVGMarkerElement::SVG_MARKERUNITS_STROKEWIDTH
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Marker)
//----------------------------------------------------------------------
@ -90,25 +102,10 @@ nsSVGMarkerElement::Init()
nsresult rv = nsSVGMarkerElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// enumeration mappings
static struct nsSVGEnumMapping gMarkerUnits[] = {
{&nsGkAtoms::strokeWidth, SVG_MARKERUNITS_STROKEWIDTH},
{&nsGkAtoms::userSpaceOnUse, SVG_MARKERUNITS_USERSPACEONUSE},
{nsnull, 0}
};
// Create mapped properties:
// non-attrib enum - pass in invalid enum (will never get used by nsSVGEnum)
mOrientType.Init(0xff, SVG_MARKER_ORIENT_AUTO);
// DOM property: markerUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units), SVG_MARKERUNITS_STROKEWIDTH, gMarkerUnits);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mMarkerUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::markerUnits, mMarkerUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
// Create mapped properties:
// DOM property: orient
{
@ -192,9 +189,7 @@ NS_IMETHODIMP nsSVGMarkerElement::GetRefY(nsIDOMSVGAnimatedLength * *aRefY)
/* readonly attribute nsIDOMSVGAnimatedEnumeration markerUnits; */
NS_IMETHODIMP nsSVGMarkerElement::GetMarkerUnits(nsIDOMSVGAnimatedEnumeration * *aMarkerUnits)
{
*aMarkerUnits = mMarkerUnits;
NS_IF_ADDREF(*aMarkerUnits);
return NS_OK;
return mEnumAttributes[MARKERUNITS].ToDOMAnimatedEnum(aMarkerUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedLength markerWidth; */
@ -212,32 +207,7 @@ NS_IMETHODIMP nsSVGMarkerElement::GetMarkerHeight(nsIDOMSVGAnimatedLength * *aMa
/* readonly attribute nsIDOMSVGAnimatedEnumeration orientType; */
NS_IMETHODIMP nsSVGMarkerElement::GetOrientType(nsIDOMSVGAnimatedEnumeration * *aOrientType)
{
static struct nsSVGEnumMapping gOrientType[] = {
{&nsGkAtoms::_auto, SVG_MARKER_ORIENT_AUTO},
{nsnull, 0}
};
nsresult rv;
nsCOMPtr<nsISVGEnum> orient;
rv = NS_NewSVGEnum(getter_AddRefs(orient), SVG_MARKER_ORIENT_ANGLE, gOrientType);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> orientType;
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(orientType), orient);
NS_ENSURE_SUCCESS(rv,rv);
nsIDOMSVGAngle *a;
mOrient->GetBaseVal(&a);
nsAutoString value;
a->GetValueAsString(value);
if (value.EqualsLiteral("auto")) {
orientType->SetBaseVal(SVG_MARKER_ORIENT_AUTO);
} else {
orientType->SetBaseVal(SVG_MARKER_ORIENT_ANGLE);
}
*aOrientType = orientType;
NS_IF_ADDREF(*aOrientType);
return NS_OK;
return mOrientType.ToDOMAnimatedEnum(aOrientType, this);
}
/* readonly attribute nsIDOMSVGAnimatedLength orientAngle; */
@ -306,18 +276,37 @@ nsSVGMarkerElement::IsAttributeMapped(const nsIAtom* name) const
//----------------------------------------------------------------------
// nsSVGElement methods
nsresult
nsSVGMarkerElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify)
{
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::orient) {
if (aValue->EqualsLiteral("auto")) {
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO, this, PR_FALSE);
} else {
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_ANGLE, this, PR_FALSE);
}
}
return nsSVGMarkerElementBase::AfterSetAttr(aNamespaceID, aName,
aValue, aNotify);
}
nsresult
nsSVGMarkerElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aNamespaceID == kNameSpaceID_None &&
aName == nsGkAtoms::viewBox && mCoordCtx) {
nsCOMPtr<nsIDOMSVGRect> vb;
mViewBox->GetAnimVal(getter_AddRefs(vb));
vb->SetX(0);
vb->SetY(0);
vb->SetWidth(mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx));
vb->SetHeight(mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
if (aNamespaceID == kNameSpaceID_None) {
if (aName == nsGkAtoms::viewBox && mCoordCtx) {
nsCOMPtr<nsIDOMSVGRect> vb;
mViewBox->GetAnimVal(getter_AddRefs(vb));
vb->SetX(0);
vb->SetY(0);
vb->SetWidth(mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx));
vb->SetHeight(mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
} else if (aName == nsGkAtoms::orient) {
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO, this, PR_FALSE);
}
}
return nsSVGMarkerElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
@ -363,6 +352,13 @@ nsSVGMarkerElement::GetLengthInfo()
NS_ARRAY_LENGTH(sLengthInfo));
}
nsSVGElement::EnumAttributesInfo
nsSVGMarkerElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// public helpers
@ -372,9 +368,8 @@ nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
nsIDOMSVGMatrix **_retval)
{
float scale = 1.0;
PRUint16 val;
mMarkerUnits->GetAnimVal(&val);
if (val == SVG_MARKERUNITS_STROKEWIDTH)
if (mEnumAttributes[MARKERUNITS].GetAnimValue() ==
SVG_MARKERUNITS_STROKEWIDTH)
scale = aStrokeWidth;
nsCOMPtr<nsIDOMSVGAngle> a;

View File

@ -41,6 +41,7 @@
#include "nsIDOMSVGMarkerElement.h"
#include "nsIDOMSVGFitToViewBox.h"
#include "nsSVGLength2.h"
#include "nsSVGEnum.h"
typedef nsSVGGraphicElement nsSVGMarkerElementBase;
@ -75,6 +76,8 @@ public:
// nsIContent interface
NS_IMETHODIMP_(PRBool) IsAttributeMapped(const nsIAtom* name) const;
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify);
@ -94,13 +97,21 @@ protected:
void SetParentCoordCtxProvider(nsSVGSVGElement *aContext);
virtual LengthAttributesInfo GetLengthInfo();
virtual EnumAttributesInfo GetEnumInfo();
enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
enum { MARKERUNITS };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sUnitsMap[];
static EnumInfo sEnumInfo[1];
// this needs to be handled seperately because its a derived enum
nsSVGEnum mOrientType;
nsSVGSVGElement *mCoordCtx;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMarkerUnits;
nsCOMPtr<nsIDOMSVGAnimatedAngle> mOrient;
nsCOMPtr<nsIDOMSVGAnimatedRect> mViewBox;

View File

@ -34,9 +34,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsSVGEnum.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsCOMPtr.h"
#include "nsGkAtoms.h"
#include "nsSVGMaskElement.h"
@ -51,6 +48,18 @@ nsSVGElement::LengthInfo nsSVGMaskElement::sLengthInfo[4] =
{ &nsGkAtoms::height, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
};
nsSVGElement::EnumInfo nsSVGMaskElement::sEnumInfo[2] =
{
{ &nsGkAtoms::maskUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
},
{ &nsGkAtoms::maskContentUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Mask)
//----------------------------------------------------------------------
@ -64,6 +73,7 @@ NS_INTERFACE_MAP_BEGIN(nsSVGMaskElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGMaskElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGMaskElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGMaskElementBase)
@ -75,48 +85,6 @@ nsSVGMaskElement::nsSVGMaskElement(nsINodeInfo* aNodeInfo)
{
}
nsresult
nsSVGMaskElement::Init()
{
nsresult rv = nsSVGMaskElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// Define enumeration mappings
static struct nsSVGEnumMapping pUnitMap[] = {
{&nsGkAtoms::objectBoundingBox, nsIDOMSVGMaskElement::SVG_MUNITS_OBJECTBOUNDINGBOX},
{&nsGkAtoms::userSpaceOnUse, nsIDOMSVGMaskElement::SVG_MUNITS_USERSPACEONUSE},
{nsnull, 0}
};
// Create mapped attributes
// DOM property: maskUnits , #IMPLIED attrib: maskUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGMaskElement::SVG_MUNITS_OBJECTBOUNDINGBOX, pUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mMaskUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::maskUnits, mMaskUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: maskContentUnits , #IMPLIED attrib: maskContentUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGMaskElement::SVG_MUNITS_USERSPACEONUSE, pUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mMaskContentUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::maskContentUnits, mMaskContentUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
return NS_OK;
}
//----------------------------------------------------------------------
// nsIDOMNode method
@ -128,17 +96,13 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMaskElement)
/* readonly attribute nsIDOMSVGAnimatedEnumeration maskUnits; */
NS_IMETHODIMP nsSVGMaskElement::GetMaskUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits)
{
*aMaskUnits = mMaskUnits;
NS_IF_ADDREF(*aMaskUnits);
return NS_OK;
return mEnumAttributes[MASKUNITS].ToDOMAnimatedEnum(aMaskUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedEnumeration maskContentUnits; */
NS_IMETHODIMP nsSVGMaskElement::GetMaskContentUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits)
{
*aMaskUnits = mMaskContentUnits;
NS_IF_ADDREF(*aMaskUnits);
return NS_OK;
return mEnumAttributes[MASKCONTENTUNITS].ToDOMAnimatedEnum(aMaskUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedLength x; */
@ -175,6 +139,13 @@ nsSVGMaskElement::GetLengthInfo()
NS_ARRAY_LENGTH(sLengthInfo));
}
nsSVGElement::EnumAttributesInfo
nsSVGMaskElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsIContent methods

View File

@ -39,14 +39,17 @@
#include "nsSVGStylableElement.h"
#include "nsIDOMSVGMaskElement.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsSVGLength2.h"
#include "nsSVGEnum.h"
//--------------------- Masks ------------------------
typedef nsSVGStylableElement nsSVGMaskElementBase;
class nsSVGMaskElement : public nsSVGMaskElementBase,
public nsIDOMSVGMaskElement
public nsIDOMSVGMaskElement,
public nsIDOMSVGUnitTypes
{
friend class nsSVGMaskFrame;
@ -54,7 +57,6 @@ protected:
friend nsresult NS_NewSVGMaskElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo);
nsSVGMaskElement(nsINodeInfo* aNodeInfo);
nsresult Init();
public:
// interfaces:
@ -74,14 +76,16 @@ public:
protected:
virtual LengthAttributesInfo GetLengthInfo();
virtual EnumAttributesInfo GetEnumInfo();
// nsIDOMSVGMaskElement values
enum { X, Y, WIDTH, HEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMaskUnits;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMaskContentUnits;
enum { MASKUNITS, MASKCONTENTUNITS };
nsSVGEnum mEnumAttributes[2];
static EnumInfo sEnumInfo[2];
};
#endif

View File

@ -38,8 +38,6 @@
#include "nsSVGTransformList.h"
#include "nsSVGAnimatedTransformList.h"
#include "nsSVGEnum.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsSVGAnimatedString.h"
#include "nsCOMPtr.h"
@ -62,6 +60,18 @@ nsSVGElement::LengthInfo nsSVGPatternElement::sLengthInfo[4] =
{ &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
};
nsSVGElement::EnumInfo nsSVGPatternElement::sEnumInfo[2] =
{
{ &nsGkAtoms::patternUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
},
{ &nsGkAtoms::patternContentUnits,
sSVGUnitTypesMap,
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Pattern)
//----------------------------------------------------------------------
@ -77,6 +87,7 @@ NS_INTERFACE_MAP_BEGIN(nsSVGPatternElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFitToViewBox)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPatternElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPatternElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGPatternElementBase)
@ -96,39 +107,8 @@ nsSVGPatternElement::Init()
nsresult rv = nsSVGPatternElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// Define enumeration mappings
static struct nsSVGEnumMapping pUnitMap[] = {
{&nsGkAtoms::objectBoundingBox, nsIDOMSVGPatternElement::SVG_PUNITS_OBJECTBOUNDINGBOX},
{&nsGkAtoms::userSpaceOnUse, nsIDOMSVGPatternElement::SVG_PUNITS_USERSPACEONUSE},
{nsnull, 0}
};
// Create mapped attributes
// DOM property: patternUnits , #IMPLIED attrib: patternUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGPatternElement::SVG_PUNITS_OBJECTBOUNDINGBOX, pUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mPatternUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::patternUnits, mPatternUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: patternContentUnits , #IMPLIED attrib: patternContentUnits
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units),
nsIDOMSVGPatternElement::SVG_PUNITS_USERSPACEONUSE, pUnitMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mPatternContentUnits), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::patternContentUnits, mPatternContentUnits);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: patternTransform , #IMPLIED attrib: patternTransform
{
nsCOMPtr<nsIDOMSVGTransformList> transformList;
@ -213,17 +193,13 @@ nsSVGPatternElement::GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio
/* readonly attribute nsIDOMSVGAnimatedEnumeration patternUnits; */
NS_IMETHODIMP nsSVGPatternElement::GetPatternUnits(nsIDOMSVGAnimatedEnumeration * *aPatternUnits)
{
*aPatternUnits = mPatternUnits;
NS_IF_ADDREF(*aPatternUnits);
return NS_OK;
return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(aPatternUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedEnumeration patternContentUnits; */
NS_IMETHODIMP nsSVGPatternElement::GetPatternContentUnits(nsIDOMSVGAnimatedEnumeration * *aPatternUnits)
{
*aPatternUnits = mPatternContentUnits;
NS_IF_ADDREF(*aPatternUnits);
return NS_OK;
return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(aPatternUnits, this);
}
/* readonly attribute nsIDOMSVGAnimatedTransformList patternTransform; */
@ -302,6 +278,13 @@ nsSVGPatternElement::GetLengthInfo()
NS_ARRAY_LENGTH(sLengthInfo));
}
nsSVGElement::EnumAttributesInfo
nsSVGPatternElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// nsIMutationObserver methods

View File

@ -43,8 +43,10 @@
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGFitToViewBox.h"
#include "nsIDOMSVGPatternElement.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsSVGLength2.h"
#include "nsStubMutationObserver.h"
#include "nsSVGEnum.h"
//--------------------- Patterns ------------------------
@ -54,6 +56,7 @@ class nsSVGPatternElement : public nsSVGPatternElementBase,
public nsIDOMSVGURIReference,
public nsIDOMSVGFitToViewBox,
public nsIDOMSVGPatternElement,
public nsIDOMSVGUnitTypes,
public nsStubMutationObserver
{
friend class nsSVGPatternFrame;
@ -98,14 +101,17 @@ protected:
void PushUpdate();
virtual LengthAttributesInfo GetLengthInfo();
virtual EnumAttributesInfo GetEnumInfo();
// nsIDOMSVGPatternElement values
enum { X, Y, WIDTH, HEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mPatternUnits;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mPatternContentUnits;
enum { PATTERNUNITS, PATTERNCONTENTUNITS };
nsSVGEnum mEnumAttributes[2];
static EnumInfo sEnumInfo[2];
nsCOMPtr<nsIDOMSVGAnimatedTransformList> mPatternTransform;
// nsIDOMSVGURIReference properties

View File

@ -59,7 +59,6 @@
#include "nsSVGPreserveAspectRatio.h"
#include "nsISVGValueUtils.h"
#include "nsDOMError.h"
#include "nsSVGEnum.h"
#include "nsISVGChildFrame.h"
#include "nsGUIEvent.h"
#include "nsSVGUtils.h"
@ -73,6 +72,20 @@ nsSVGElement::LengthInfo nsSVGSVGElement::sLengthInfo[4] =
{ &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
};
nsSVGEnumMapping nsSVGSVGElement::sZoomAndPanMap[] = {
{&nsGkAtoms::disable, nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE},
{&nsGkAtoms::magnify, nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGSVGElement::sEnumInfo[1] =
{
{ &nsGkAtoms::zoomAndPan,
sZoomAndPanMap,
nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(SVG)
//----------------------------------------------------------------------
@ -152,24 +165,6 @@ nsSVGSVGElement::Init()
mPreserveAspectRatio);
NS_ENSURE_SUCCESS(rv,rv);
}
// nsIDOMSVGZoomAndPan attribute ------:
// Define enumeration mappings
static struct nsSVGEnumMapping zoomMap[] = {
{&nsGkAtoms::disable, nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE},
{&nsGkAtoms::magnify, nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY},
{nsnull, 0}
};
// DOM property: zoomAndPan , #IMPLIED attrib: zoomAndPan
{
rv = NS_NewSVGEnum(getter_AddRefs(mZoomAndPan),
nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY, zoomMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::zoomAndPan, mZoomAndPan);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: currentScale
{
@ -959,15 +954,18 @@ nsSVGSVGElement::GetTransformToElement(nsIDOMSVGElement *element,
NS_IMETHODIMP
nsSVGSVGElement::GetZoomAndPan(PRUint16 *aZoomAndPan)
{
return mZoomAndPan->GetIntegerValue(*aZoomAndPan);
*aZoomAndPan = mEnumAttributes[ZOOMANDPAN].GetAnimValue();
return NS_OK;
}
NS_IMETHODIMP
nsSVGSVGElement::SetZoomAndPan(PRUint16 aZoomAndPan)
{
if (aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE ||
aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY)
return mZoomAndPan->SetIntegerValue(aZoomAndPan);
aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
mEnumAttributes[ZOOMANDPAN].SetBaseValue(aZoomAndPan, this, PR_TRUE);
return NS_OK;
}
return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
}
@ -983,14 +981,6 @@ nsSVGSVGElement::GetCurrentScaleNumber(nsIDOMSVGNumber **aResult)
return NS_OK;
}
NS_IMETHODIMP
nsSVGSVGElement::GetZoomAndPanEnum(nsISVGEnum **aResult)
{
*aResult = mZoomAndPan;
NS_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsSVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y)
{
@ -1445,3 +1435,18 @@ nsSVGSVGElement::GetLengthInfo()
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
NS_ARRAY_LENGTH(sLengthInfo));
}
void
nsSVGSVGElement::DidChangeEnum(PRUint8 aAttrEnum, PRBool aDoSetAttr)
{
nsSVGSVGElementBase::DidChangeEnum(aAttrEnum, aDoSetAttr);
InvalidateTransformNotifyFrame();
}
nsSVGElement::EnumAttributesInfo
nsSVGSVGElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}

View File

@ -47,8 +47,7 @@
#include "nsIDOMSVGZoomAndPan.h"
#include "nsIDOMSVGMatrix.h"
#include "nsSVGLength2.h"
class nsISVGEnum;
#include "nsSVGEnum.h"
#define QI_AND_CAST_TO_NSSVGSVGELEMENT(base) \
(nsCOMPtr<nsIDOMSVGSVGElement>(do_QueryInterface(base)) ? \
@ -91,7 +90,6 @@ public:
// helper methods for implementing SVGZoomEvent:
NS_IMETHOD GetCurrentScaleNumber(nsIDOMSVGNumber **aResult);
NS_IMETHOD GetZoomAndPanEnum(nsISVGEnum **aResult);
/**
* For use by zoom controls to allow currentScale, currentTranslate.x and
@ -137,6 +135,7 @@ public:
// nsSVGElement specializations:
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeEnum(PRUint8 aAttrEnum, PRBool aDoSetAttr);
// nsSVGSVGElement methods:
float GetLength(PRUint8 mCtxType);
@ -164,6 +163,13 @@ protected:
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
virtual EnumAttributesInfo GetEnumInfo();
enum { ZOOMANDPAN };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sZoomAndPanMap[];
static EnumInfo sEnumInfo[1];
nsSVGSVGElement *mCoordCtx;
nsCOMPtr<nsIDOMSVGAnimatedRect> mViewBox;
nsCOMPtr<nsIDOMSVGAnimatedPreserveAspectRatio> mPreserveAspectRatio;
@ -174,7 +180,6 @@ protected:
// zoom and pan
// IMPORTANT: only RecordCurrentScaleTranslate should change the "mPreviousX"
// members below - see the comment in RecordCurrentScaleTranslate
nsCOMPtr<nsISVGEnum> mZoomAndPan;
nsCOMPtr<nsIDOMSVGPoint> mCurrentTranslate;
nsCOMPtr<nsIDOMSVGNumber> mCurrentScale;
float mPreviousTranslate_x;

View File

@ -42,7 +42,6 @@
#include "nsISVGTextContentMetrics.h"
#include "nsIFrame.h"
#include "nsSVGAnimatedString.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsSVGEnum.h"
#include "nsDOMError.h"
#include "nsSVGLength2.h"
@ -81,6 +80,7 @@ public:
protected:
virtual LengthAttributesInfo GetLengthInfo();
virtual EnumAttributesInfo GetEnumInfo();
virtual PRBool IsEventName(nsIAtom* aName);
@ -90,8 +90,12 @@ protected:
nsSVGLength2 mLengthAttributes[1];
static LengthInfo sLengthInfo[1];
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMethod;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mSpacing;
enum { METHOD, SPACING };
nsSVGEnum mEnumAttributes[2];
static nsSVGEnumMapping sMethodMap[];
static nsSVGEnumMapping sSpacingMap[];
static EnumInfo sEnumInfo[2];
nsCOMPtr<nsIDOMSVGAnimatedString> mHref;
};
@ -100,6 +104,30 @@ nsSVGElement::LengthInfo nsSVGTextPathElement::sLengthInfo[1] =
{ &nsGkAtoms::startOffset, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, nsSVGUtils::X },
};
nsSVGEnumMapping nsSVGTextPathElement::sMethodMap[] = {
{&nsGkAtoms::align, nsIDOMSVGTextPathElement::TEXTPATH_METHODTYPE_ALIGN},
{&nsGkAtoms::stretch, nsIDOMSVGTextPathElement::TEXTPATH_METHODTYPE_STRETCH},
{nsnull, 0}
};
nsSVGEnumMapping nsSVGTextPathElement::sSpacingMap[] = {
{&nsGkAtoms::_auto, nsIDOMSVGTextPathElement::TEXTPATH_SPACINGTYPE_AUTO},
{&nsGkAtoms::exact, nsIDOMSVGTextPathElement::TEXTPATH_SPACINGTYPE_EXACT},
{nsnull, 0}
};
nsSVGElement::EnumInfo nsSVGTextPathElement::sEnumInfo[2] =
{
{ &nsGkAtoms::method,
sMethodMap,
nsIDOMSVGTextPathElement::TEXTPATH_METHODTYPE_ALIGN
},
{ &nsGkAtoms::spacing,
sSpacingMap,
nsIDOMSVGTextPathElement::TEXTPATH_SPACINGTYPE_EXACT
}
};
NS_IMPL_NS_NEW_SVG_ELEMENT(TextPath)
//----------------------------------------------------------------------
@ -132,45 +160,8 @@ nsSVGTextPathElement::Init()
nsresult rv = nsSVGTextPathElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// enumeration mappings
static struct nsSVGEnumMapping methodMap[] = {
{&nsGkAtoms::align, TEXTPATH_METHODTYPE_ALIGN},
{&nsGkAtoms::stretch, TEXTPATH_METHODTYPE_STRETCH},
{nsnull, 0}
};
static struct nsSVGEnumMapping spacingMap[] = {
{&nsGkAtoms::_auto, TEXTPATH_SPACINGTYPE_AUTO},
{&nsGkAtoms::exact, TEXTPATH_SPACINGTYPE_EXACT},
{nsnull, 0}
};
// Create mapped properties:
// DOM property: method, #IMPLIED attrib: method
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units), TEXTPATH_METHODTYPE_ALIGN,
methodMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mMethod), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::method, mMethod);
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: spacing, #IMPLIED attrib: spacing
{
nsCOMPtr<nsISVGEnum> units;
rv = NS_NewSVGEnum(getter_AddRefs(units), TEXTPATH_SPACINGTYPE_EXACT,
spacingMap);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mSpacing), units);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::spacing, mSpacing);
NS_ENSURE_SUCCESS(rv,rv);
}
// nsIDOMSVGURIReference properties
// DOM property: href , #REQUIRED attrib: xlink:href
@ -212,17 +203,13 @@ NS_IMETHODIMP nsSVGTextPathElement::GetStartOffset(nsIDOMSVGAnimatedLength * *aS
/* readonly attribute nsIDOMSVGAnimatedEnumeration method; */
NS_IMETHODIMP nsSVGTextPathElement::GetMethod(nsIDOMSVGAnimatedEnumeration * *aMethod)
{
*aMethod = mMethod;
NS_IF_ADDREF(*aMethod);
return NS_OK;
return mEnumAttributes[METHOD].ToDOMAnimatedEnum(aMethod, this);
}
/* readonly attribute nsIDOMSVGAnimatedEnumeration spacing; */
NS_IMETHODIMP nsSVGTextPathElement::GetSpacing(nsIDOMSVGAnimatedEnumeration * *aSpacing)
{
*aSpacing = mSpacing;
NS_IF_ADDREF(*aSpacing);
return NS_OK;
return mEnumAttributes[SPACING].ToDOMAnimatedEnum(aSpacing, this);
}
//----------------------------------------------------------------------
@ -381,6 +368,13 @@ nsSVGTextPathElement::GetLengthInfo()
NS_ARRAY_LENGTH(sLengthInfo));
}
nsSVGElement::EnumAttributesInfo
nsSVGTextPathElement::GetEnumInfo()
{
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
NS_ARRAY_LENGTH(sEnumInfo));
}
//----------------------------------------------------------------------
// implementation helpers:

View File

@ -120,6 +120,7 @@ XPIDLSRCS = \
nsIDOMSVGTransformable.idl \
nsIDOMSVGTSpanElement.idl \
nsIDOMSVGURIReference.idl \
nsIDOMSVGUnitTypes.idl \
nsIDOMSVGUseElement.idl \
nsIDOMSVGViewSpec.idl \
nsIDOMSVGZoomAndPan.idl \

View File

@ -65,11 +65,5 @@ interface nsIDOMSVGClipPathElement
nsIDOMSVGTransformable,
*/
{
// Extended to provide enumerations for clipPathUnits
// These constants are taken from SVGUnitTypes
const unsigned short SVG_CPUNITS_UNKNOWN = 0;
const unsigned short SVG_CPUNITS_OBJECTBOUNDINGBOX = 1;
const unsigned short SVG_CPUNITS_USERSPACEONUSE = 2;
readonly attribute nsIDOMSVGAnimatedEnumeration clipPathUnits;
};

View File

@ -58,11 +58,6 @@ interface nsIDOMSVGFilterElement
nsIDOMSVGStylable,
*/
{
// These constants are taken from SVGUnitTypes
const unsigned short SVG_FUNITS_UNKNOWN = 0;
const unsigned short SVG_FUNITS_OBJECTBOUNDINGBOX = 1;
const unsigned short SVG_FUNITS_USERSPACEONUSE = 2;
readonly attribute nsIDOMSVGAnimatedEnumeration filterUnits;
readonly attribute nsIDOMSVGAnimatedEnumeration primitiveUnits;
readonly attribute nsIDOMSVGAnimatedLength x;

View File

@ -69,12 +69,6 @@ interface nsIDOMSVGGradientElement
const unsigned short SVG_SPREADMETHOD_PAD = 1;
const unsigned short SVG_SPREADMETHOD_REFLECT = 2;
const unsigned short SVG_SPREADMETHOD_REPEAT = 3;
// Extended to provide enumerations for gradientUnits
// These constants are taken from SVGUnitTypes
const unsigned short SVG_GRUNITS_UNKNOWN = 0;
const unsigned short SVG_GRUNITS_OBJECTBOUNDINGBOX = 1;
const unsigned short SVG_GRUNITS_USERSPACEONUSE = 2;
readonly attribute nsIDOMSVGAnimatedEnumeration gradientUnits;
readonly attribute nsIDOMSVGAnimatedTransformList gradientTransform;

View File

@ -59,11 +59,6 @@ interface nsIDOMSVGMaskElement
*/
{
// These constants are taken from SVGUnitTypes
const unsigned short SVG_MUNITS_UNKNOWN = 0;
const unsigned short SVG_MUNITS_OBJECTBOUNDINGBOX = 1;
const unsigned short SVG_MUNITS_USERSPACEONUSE = 2;
readonly attribute nsIDOMSVGAnimatedEnumeration maskUnits;
readonly attribute nsIDOMSVGAnimatedEnumeration maskContentUnits;
readonly attribute nsIDOMSVGAnimatedLength x;

View File

@ -71,10 +71,6 @@ interface nsIDOMSVGPatternElement
SVGUnitTypes
*/
{
const unsigned short SVG_PUNITS_UNKNOWN = 0;
const unsigned short SVG_PUNITS_OBJECTBOUNDINGBOX = 1;
const unsigned short SVG_PUNITS_USERSPACEONUSE = 2;
readonly attribute nsIDOMSVGAnimatedEnumeration patternUnits;
readonly attribute nsIDOMSVGAnimatedEnumeration patternContentUnits;
readonly attribute nsIDOMSVGAnimatedTransformList patternTransform;

View File

@ -1,10 +1,10 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ----- BEGIN LICENSE BLOCK -----
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
@ -14,39 +14,41 @@
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2004
* The Initial Developer of the Original Code is IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Rowley <tor@acm.org> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
* ----- END LICENSE BLOCK ----- */
#include "nsSVGValue.h"
#ifndef __NS_SVGANIMATEDENUMERATION_H__
#define __NS_SVGANIMATEDENUMERATION_H__
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsISVGEnum.h"
nsresult NS_NewSVGAnimatedEnumeration(nsIDOMSVGAnimatedEnumeration** result,
nsISVGEnum* baseVal);
#endif //__NS_SVGANIMATEDENUMERATION_H__
#include "domstubs.idl"
/**
* The nsIDOMSVGUnitTypes interface is the interface to SVG unit types.
*
* For more information on this interface please see
* http://www.w3.org/TR/SVG11/types.html
*
*/
[scriptable, uuid(154b572f-3d0b-49c0-8b5d-8864d05bd3d1)]
interface nsIDOMSVGUnitTypes : nsISupports
{
// Unit Types
const unsigned short SVG_UNIT_TYPE_UNKNOWN = 0;
const unsigned short SVG_UNIT_TYPE_USERSPACEONUSE = 1;
const unsigned short SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2;
};

View File

@ -342,6 +342,7 @@ enum nsDOMClassInfoID {
eDOMClassInfo_SVGRect_id,
eDOMClassInfo_SVGTransform_id,
eDOMClassInfo_SVGTransformList_id,
eDOMClassInfo_SVGUnitTypes_id,
eDOMClassInfo_SVGZoomEvent_id,
#endif // MOZ_SVG

View File

@ -414,6 +414,7 @@
#include "nsIDOMSVGTSpanElement.h"
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGUseElement.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsIDOMSVGZoomAndPan.h"
#include "nsIDOMSVGZoomEvent.h"
#endif // MOZ_SVG
@ -1103,6 +1104,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGUnitTypes, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#endif // MOZ_SVG
@ -2618,6 +2621,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2785,6 +2789,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2804,6 +2809,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLinearGradientElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2822,6 +2828,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(SVGMaskElement, nsIDOMSVGMaskElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMaskElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2841,6 +2848,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2861,6 +2869,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRadialGradientElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -3151,6 +3160,10 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformList)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGUnitTypes, nsIDOMSVGUnitTypes)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGZoomEvent, nsIDOMSVGZoomEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES

View File

@ -38,7 +38,6 @@
#include "nsIDocument.h"
#include "nsIDOMSVGClipPathElement.h"
#include "nsSVGClipPathFrame.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsGkAtoms.h"
#include "nsSVGUtils.h"
#include "nsSVGClipPathElement.h"
@ -211,11 +210,11 @@ nsSVGClipPathFrame::GetCanvasTM()
canvasTM = mClipParentMatrix;
/* object bounding box? */
PRUint16 units;
clipPath->mClipPathUnits->GetAnimVal(&units);
PRUint16 units =
clipPath->mEnumAttributes[nsSVGClipPathElement::CLIPPATHUNITS].GetAnimValue();
if (mClipParent &&
units == nsIDOMSVGClipPathElement::SVG_CPUNITS_OBJECTBOUNDINGBOX) {
units == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
nsCOMPtr<nsIDOMSVGRect> rect;
nsresult rv = mClipParent->GetBBox(getter_AddRefs(rect));

View File

@ -42,7 +42,6 @@
#include "nsISVGFilter.h"
#include "nsGkAtoms.h"
#include "nsIDOMSVGAnimatedInteger.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsSVGUtils.h"
#include "nsSVGFilterElement.h"
#include "nsSVGFilterInstance.h"
@ -153,10 +152,10 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
tmpWidth = &filter->mLengthAttributes[nsSVGFilterElement::WIDTH];
tmpHeight = &filter->mLengthAttributes[nsSVGFilterElement::HEIGHT];
PRUint16 units;
filter->mFilterUnits->GetAnimVal(&units);
PRUint16 units =
filter->mEnumAttributes[nsSVGFilterElement::FILTERUNITS].GetAnimValue();
if (units == nsIDOMSVGFilterElement::SVG_FUNITS_OBJECTBOUNDINGBOX) {
if (units == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
if (!bbox)
return NS_OK;
@ -241,8 +240,9 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
aTarget->PaintSVG(&tmpState, nsnull);
PRUint16 primitiveUnits;
filter->mPrimitiveUnits->GetAnimVal(&primitiveUnits);
PRUint16 primitiveUnits =
filter->mEnumAttributes[nsSVGFilterElement::PRIMITIVEUNITS].GetAnimValue();
nsSVGFilterInstance instance(target, bbox,
x, y, width, height,
filterRes.width, filterRes.height,
@ -336,10 +336,8 @@ nsSVGFilterFrame::GetInvalidationRegion(nsIFrame *aTarget)
nsSVGFilterElement *filter = static_cast<nsSVGFilterElement*>(mContent);
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> units;
filter->GetFilterUnits(getter_AddRefs(units));
PRUint16 type;
units->GetAnimVal(&type);
PRUint16 type =
filter->mEnumAttributes[nsSVGFilterElement::FILTERUNITS].GetAnimValue();
float x, y, width, height;
nsCOMPtr<nsIDOMSVGRect> bbox;
@ -358,7 +356,7 @@ nsSVGFilterFrame::GetInvalidationRegion(nsIFrame *aTarget)
tmpWidth = &filter->mLengthAttributes[nsSVGFilterElement::WIDTH];
tmpHeight = &filter->mLengthAttributes[nsSVGFilterElement::HEIGHT];
if (type == nsIDOMSVGFilterElement::SVG_FUNITS_OBJECTBOUNDINGBOX) {
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
if (!bbox)
return nsRect();
@ -425,7 +423,7 @@ float
nsSVGFilterInstance::GetPrimitiveLength(nsSVGLength2 *aLength)
{
float value;
if (mPrimitiveUnits == nsIDOMSVGFilterElement::SVG_FUNITS_OBJECTBOUNDINGBOX)
if (mPrimitiveUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
value = nsSVGUtils::ObjectSpace(mTargetBBox, aLength);
else
value = nsSVGUtils::UserSpace(mTarget, aLength);
@ -459,8 +457,7 @@ nsSVGFilterInstance::GetFilterSubregion(
float x, y, width, height;
if (mPrimitiveUnits ==
nsIDOMSVGFilterElement::SVG_FUNITS_OBJECTBOUNDINGBOX) {
if (mPrimitiveUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
x = nsSVGUtils::ObjectSpace(mTargetBBox, tmpX);
y = nsSVGUtils::ObjectSpace(mTargetBBox, tmpY);
width = nsSVGUtils::ObjectSpace(mTargetBBox, tmpWidth);

View File

@ -244,7 +244,7 @@ nsSVGGradientFrame::GetGradientTransform(nsSVGGeometryFrame *aSource)
PRUint16 gradientUnits = GetGradientUnits();
nsIAtom *callerType = aSource->GetType();
if (gradientUnits == nsIDOMSVGGradientElement::SVG_GRUNITS_USERSPACEONUSE) {
if (gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
// If this gradient is applied to text, our caller
// will be the glyph, which is not a container, so we
// need to get the parent
@ -256,7 +256,7 @@ nsSVGGradientFrame::GetGradientTransform(nsSVGGeometryFrame *aSource)
NS_ASSERTION(mSourceContent, "Can't get content for gradient");
}
else {
NS_ASSERTION(gradientUnits == nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX,
NS_ASSERTION(gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX,
"Unknown gradientUnits type");
// objectBoundingBox is the default anyway
@ -312,9 +312,7 @@ nsSVGGradientFrame::GetSpreadMethod()
nsSVGGradientElement *gradElement = static_cast<nsSVGGradientElement*>
(gradient);
PRUint16 val;
gradElement->mSpreadMethod->GetAnimVal(&val);
return val;
return gradElement->mEnumAttributes[nsSVGGradientElement::SPREADMETHOD].GetAnimValue();
}
//----------------------------------------------------------------------
@ -534,9 +532,7 @@ nsSVGGradientFrame::GetGradientUnits()
nsSVGGradientElement *gradElement = static_cast<nsSVGGradientElement*>
(gradient);
PRUint16 units;
gradElement->mGradientUnits->GetAnimVal(&units);
return units;
return gradElement->mEnumAttributes[nsSVGGradientElement::GRADIENTUNITS].GetAnimValue();
}
// -------------------------------------------------------------------------
@ -582,16 +578,16 @@ nsSVGLinearGradientFrame::GradientLookupAttribute(nsIAtom *aAtomName,
static_cast<nsSVGLinearGradientElement*>(gradient);
// Object bounding box units are handled by setting the appropriate
// transform in GetGradientTransfrom, but we need to handle user
// transform in GetGradientTransform, but we need to handle user
// space units as part of the individual Get* routines. Fixes 323669.
PRUint16 gradientUnits = GetGradientUnits();
if (gradientUnits == nsIDOMSVGGradientElement::SVG_GRUNITS_USERSPACEONUSE) {
if (gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
return nsSVGUtils::UserSpace(mSourceContent,
&element->mLengthAttributes[aEnumName]);
}
NS_ASSERTION(gradientUnits == nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX,
NS_ASSERTION(gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX,
"Unknown gradientUnits type");
return element->mLengthAttributes[aEnumName].
@ -664,16 +660,16 @@ nsSVGRadialGradientFrame::GradientLookupAttribute(nsIAtom *aAtomName,
static_cast<nsSVGRadialGradientElement*>(gradient);
// Object bounding box units are handled by setting the appropriate
// transform in GetGradientTransfrom, but we need to handle user
// transform in GetGradientTransform, but we need to handle user
// space units as part of the individual Get* routines. Fixes 323669.
PRUint16 gradientUnits = GetGradientUnits();
if (gradientUnits == nsIDOMSVGGradientElement::SVG_GRUNITS_USERSPACEONUSE) {
if (gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
return nsSVGUtils::UserSpace(mSourceContent,
&element->mLengthAttributes[aEnumName]);
}
NS_ASSERTION(gradientUnits == nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX,
NS_ASSERTION(gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX,
"Unknown gradientUnits type");
return element->mLengthAttributes[aEnumName].

View File

@ -36,7 +36,6 @@
#include "nsIDocument.h"
#include "nsSVGMaskFrame.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsSVGContainerFrame.h"
#include "nsSVGMaskElement.h"
#include "nsIDOMSVGMatrix.h"
@ -117,10 +116,10 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
tmpWidth = &mask->mLengthAttributes[nsSVGMaskElement::WIDTH];
tmpHeight = &mask->mLengthAttributes[nsSVGMaskElement::HEIGHT];
PRUint16 units;
mask->mMaskUnits->GetAnimVal(&units);
PRUint16 units =
mask->mEnumAttributes[nsSVGMaskElement::MASKUNITS].GetAnimValue();
if (units == nsIDOMSVGMaskElement::SVG_MUNITS_OBJECTBOUNDINGBOX) {
if (units == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
aParent->SetMatrixPropagation(PR_FALSE);
aParent->NotifyCanvasTMChanged(PR_TRUE);
@ -257,11 +256,11 @@ nsSVGMaskFrame::GetCanvasTM()
/* object bounding box? */
nsSVGMaskElement *mask = static_cast<nsSVGMaskElement*>(mContent);
PRUint16 contentUnits;
mask->mMaskContentUnits->GetAnimVal(&contentUnits);
PRUint16 contentUnits =
mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS].GetAnimValue();
if (mMaskParent &&
contentUnits == nsIDOMSVGMaskElement::SVG_MUNITS_OBJECTBOUNDINGBOX) {
contentUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
nsCOMPtr<nsIDOMSVGRect> rect;
nsresult rv = mMaskParent->GetBBox(getter_AddRefs(rect));

View File

@ -160,7 +160,6 @@ nsSVGOuterSVGFrame::InitSVG()
// we only care about our content's zoom and pan values if it's the root element
if (doc->GetRootContent() == mContent) {
nsSVGSVGElement *SVGElement = static_cast<nsSVGSVGElement*>(mContent);
SVGElement->GetZoomAndPanEnum(getter_AddRefs(mZoomAndPan));
SVGElement->GetCurrentTranslate(getter_AddRefs(mCurrentTranslate));
SVGElement->GetCurrentScaleNumber(getter_AddRefs(mCurrentScale));
}
@ -568,24 +567,21 @@ nsSVGOuterSVGFrame::GetCanvasTM()
nsSVGSVGElement *svgElement = static_cast<nsSVGSVGElement*>(mContent);
svgElement->GetViewboxToViewportTransform(getter_AddRefs(mCanvasTM));
if (mZoomAndPan) {
// our content is the document element so we must premultiply the values
// of it's currentScale and currentTranslate properties
PRUint16 val;
mZoomAndPan->GetIntegerValue(val);
if (val == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
nsCOMPtr<nsIDOMSVGMatrix> zoomPanMatrix;
nsCOMPtr<nsIDOMSVGMatrix> temp;
float scale, x, y;
mCurrentScale->GetValue(&scale);
mCurrentTranslate->GetX(&x);
mCurrentTranslate->GetY(&y);
svgElement->CreateSVGMatrix(getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Translate(x, y, getter_AddRefs(temp));
temp->Scale(scale, getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Multiply(mCanvasTM, getter_AddRefs(temp));
temp.swap(mCanvasTM);
}
// our content is the document element so we must premultiply the values
// of its currentScale and currentTranslate properties
if (svgElement->mEnumAttributes[nsSVGSVGElement::ZOOMANDPAN].GetAnimValue()
== nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
nsCOMPtr<nsIDOMSVGMatrix> zoomPanMatrix;
nsCOMPtr<nsIDOMSVGMatrix> temp;
float scale, x, y;
mCurrentScale->GetValue(&scale);
mCurrentTranslate->GetX(&x);
mCurrentTranslate->GetY(&y);
svgElement->CreateSVGMatrix(getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Translate(x, y, getter_AddRefs(temp));
temp->Scale(scale, getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Multiply(mCanvasTM, getter_AddRefs(temp));
temp.swap(mCanvasTM);
}
}
nsIDOMSVGMatrix* retval = mCanvasTM.get();

View File

@ -41,7 +41,6 @@
#include "nsSVGContainerFrame.h"
#include "nsISVGSVGFrame.h"
#include "nsISVGEnum.h"
#include "nsIDOMSVGPoint.h"
#include "nsIDOMSVGNumber.h"
@ -134,7 +133,6 @@ protected:
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
// zoom and pan
nsCOMPtr<nsISVGEnum> mZoomAndPan;
nsCOMPtr<nsIDOMSVGPoint> mCurrentTranslate;
nsCOMPtr<nsIDOMSVGNumber> mCurrentScale;

View File

@ -37,7 +37,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsGkAtoms.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsIDOMSVGAnimatedRect.h"
#include "nsIDOMSVGAnimTransformList.h"
#include "nsSVGTransformList.h"
@ -388,7 +387,7 @@ nsSVGPatternFrame::GetPatternUnits()
// No, return the values
nsSVGPatternElement *patternElement = static_cast<nsSVGPatternElement*>
(mContent);
patternElement->mPatternUnits->GetAnimVal(&rv);
rv = patternElement->mEnumAttributes[nsSVGPatternElement::PATTERNUNITS].GetAnimValue();
} else {
// Yes, get it from the target
rv = mNextPattern->GetPatternUnits();
@ -407,7 +406,7 @@ nsSVGPatternFrame::GetPatternContentUnits()
// No, return the values
nsSVGPatternElement *patternElement = static_cast<nsSVGPatternElement*>
(mContent);
patternElement->mPatternContentUnits->GetAnimVal(&rv);
rv = patternElement->mEnumAttributes[nsSVGPatternElement::PATTERNCONTENTUNITS].GetAnimValue();
} else {
// Yes, get it from the target
rv = mNextPattern->GetPatternContentUnits();
@ -637,7 +636,7 @@ nsSVGPatternFrame::GetPatternRect(nsIDOMSVGRect **patternRect,
tmpHeight = GetHeight();
tmpWidth = GetWidth();
if (type == nsIDOMSVGPatternElement::SVG_PUNITS_OBJECTBOUNDINGBOX) {
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
x = nsSVGUtils::ObjectSpace(bbox, tmpX);
y = nsSVGUtils::ObjectSpace(bbox, tmpY);
width = nsSVGUtils::ObjectSpace(bbox, tmpWidth);
@ -668,7 +667,7 @@ nsSVGPatternFrame::ConstructCTM(nsIDOMSVGMatrix **aCTM,
// this must be handled in the CTM
PRUint16 type = GetPatternContentUnits();
if (type == nsIDOMSVGPatternElement::SVG_PUNITS_OBJECTBOUNDINGBOX) {
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
// Use the bounding box
float width, height;
callerBBox->GetWidth(&width);
@ -727,7 +726,7 @@ nsSVGPatternFrame::GetPatternMatrix(nsIDOMSVGRect *bbox,
bbox->GetY(&miny);
PRUint16 type = GetPatternContentUnits();
if (type == nsIDOMSVGPatternElement::SVG_PUNITS_OBJECTBOUNDINGBOX) {
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
float x, y;
callerBBox->GetX(&x);
callerBBox->GetY(&y);
@ -776,7 +775,7 @@ nsSVGPatternFrame::GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
callerSVGFrame->GetBBox(aBBox);
// Sanity check
PRUint16 type = GetPatternUnits();
if (type == nsIDOMSVGPatternElement::SVG_PUNITS_OBJECTBOUNDINGBOX) {
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
float width, height;
(*aBBox)->GetWidth(&width);
(*aBBox)->GetHeight(&height);