Bug 690486 - Kill nsISVGValue, nsSVGValue, nsISVGValueObserver, nsISVGValueUtils and nsSVGStringProxyValue. r=longsonr.

This commit is contained in:
Jonathan Watt 2011-09-30 10:25:34 +01:00
Родитель b58e09e78f
Коммит 387f4610a3
25 изменённых файлов: 10 добавлений и 985 удалений

Просмотреть файл

@ -51,7 +51,6 @@
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "prprf.h" #include "prprf.h"
#include "nsISVGValue.h"
namespace css = mozilla::css; namespace css = mozilla::css;
@ -83,12 +82,6 @@ nsAttrValue::nsAttrValue(css::StyleRule* aValue, const nsAString* aSerialized)
SetTo(aValue, aSerialized); SetTo(aValue, aSerialized);
} }
nsAttrValue::nsAttrValue(nsISVGValue* aValue)
: mBits(0)
{
SetTo(aValue);
}
nsAttrValue::nsAttrValue(const nsIntMargin& aValue) nsAttrValue::nsAttrValue(const nsIntMargin& aValue)
: mBits(0) : mBits(0)
{ {
@ -250,11 +243,6 @@ nsAttrValue::SetTo(const nsAttrValue& aOther)
} }
break; break;
} }
case eSVGValue:
{
NS_ADDREF(cont->mSVGValue = otherCont->mSVGValue);
break;
}
case eDoubleValue: case eDoubleValue:
{ {
cont->mDoubleValue = otherCont->mDoubleValue; cont->mDoubleValue = otherCont->mDoubleValue;
@ -316,16 +304,6 @@ nsAttrValue::SetTo(css::StyleRule* aValue, const nsAString* aSerialized)
} }
} }
void
nsAttrValue::SetTo(nsISVGValue* aValue)
{
if (EnsureEmptyMiscContainer()) {
MiscContainer* cont = GetMiscContainer();
NS_ADDREF(cont->mSVGValue = aValue);
cont->mType = eSVGValue;
}
}
void void
nsAttrValue::SetTo(const nsIntMargin& aValue) nsAttrValue::SetTo(const nsIntMargin& aValue)
{ {
@ -427,11 +405,6 @@ nsAttrValue::ToString(nsAString& aResult) const
break; break;
} }
case eSVGValue:
{
GetMiscContainer()->mSVGValue->GetValueString(aResult);
break;
}
case eDoubleValue: case eDoubleValue:
{ {
aResult.Truncate(); aResult.Truncate();
@ -590,10 +563,6 @@ nsAttrValue::HashValue() const
} }
return retval; return retval;
} }
case eSVGValue:
{
return NS_PTR_TO_INT32(cont->mSVGValue);
}
case eDoubleValue: case eDoubleValue:
{ {
// XXX this is crappy, but oh well // XXX this is crappy, but oh well
@ -687,10 +656,6 @@ nsAttrValue::Equals(const nsAttrValue& aOther) const
needsStringComparison = PR_TRUE; needsStringComparison = PR_TRUE;
break; break;
} }
case eSVGValue:
{
return thisCont->mSVGValue == otherCont->mSVGValue;
}
case eDoubleValue: case eDoubleValue:
{ {
return thisCont->mDoubleValue == otherCont->mDoubleValue; return thisCont->mDoubleValue == otherCont->mDoubleValue;
@ -1307,11 +1272,6 @@ nsAttrValue::EnsureEmptyMiscContainer()
delete cont->mAtomArray; delete cont->mAtomArray;
break; break;
} }
case eSVGValue:
{
NS_RELEASE(cont->mSVGValue);
break;
}
case eIntMarginValue: case eIntMarginValue:
{ {
delete cont->mIntMargin; delete cont->mIntMargin;
@ -1497,14 +1457,11 @@ nsAttrValue::SizeOf() const
size += str ? str->StorageSize() : 0; size += str ? str->StorageSize() : 0;
} }
// TODO: mCSSStyleRule and mSVGValue might be owned by another object // TODO: mCSSStyleRule might be owned by another object
// which would make us count them twice, bug 677493. // which would make us count them twice, bug 677493.
if (Type() == eCSSStyleRule && container->mCSSStyleRule) { if (Type() == eCSSStyleRule && container->mCSSStyleRule) {
// TODO: Add SizeOf() to StyleRule, bug 677503. // TODO: Add SizeOf() to StyleRule, bug 677503.
size += sizeof(*container->mCSSStyleRule); size += sizeof(*container->mCSSStyleRule);
} else if (Type() == eSVGValue && container->mSVGValue) {
// TODO: Add SizeOf() to nsSVGValue, bug 677504.
size += sizeof(*container->mSVGValue);
} else if (Type() == eAtomArray && container->mAtomArray) { } else if (Type() == eAtomArray && container->mAtomArray) {
size += sizeof(container->mAtomArray) + sizeof(nsTArrayHeader); size += sizeof(container->mAtomArray) + sizeof(nsTArrayHeader);
size += container->mAtomArray->Capacity() * sizeof(nsCOMPtr<nsIAtom>); size += container->mAtomArray->Capacity() * sizeof(nsCOMPtr<nsIAtom>);

Просмотреть файл

@ -55,7 +55,6 @@
typedef PRUptrdiff PtrBits; typedef PRUptrdiff PtrBits;
class nsAString; class nsAString;
class nsIAtom; class nsIAtom;
class nsISVGValue;
class nsIDocument; class nsIDocument;
template<class E, class A> class nsTArray; template<class E, class A> class nsTArray;
struct nsTArrayDefaultAllocator; struct nsTArrayDefaultAllocator;
@ -104,7 +103,6 @@ public:
nsAttrValue(const nsAttrValue& aOther); nsAttrValue(const nsAttrValue& aOther);
explicit nsAttrValue(const nsAString& aValue); explicit nsAttrValue(const nsAString& aValue);
nsAttrValue(mozilla::css::StyleRule* aValue, const nsAString* aSerialized); nsAttrValue(mozilla::css::StyleRule* aValue, const nsAString* aSerialized);
explicit nsAttrValue(nsISVGValue* aValue);
explicit nsAttrValue(const nsIntMargin& aValue); explicit nsAttrValue(const nsIntMargin& aValue);
~nsAttrValue(); ~nsAttrValue();
@ -122,11 +120,10 @@ public:
ePercent = 0x0F, // 1111 ePercent = 0x0F, // 1111
// Values below here won't matter, they'll be always stored in the 'misc' // Values below here won't matter, they'll be always stored in the 'misc'
// struct. // struct.
eCSSStyleRule = 0x10, eCSSStyleRule = 0x10
eAtomArray = 0x11 ,eAtomArray = 0x11
,eSVGValue = 0x12 ,eDoubleValue = 0x12
,eDoubleValue = 0x13 ,eIntMarginValue = 0x13
,eIntMarginValue = 0x14
}; };
ValueType Type() const; ValueType Type() const;
@ -137,7 +134,6 @@ public:
void SetTo(const nsAString& aValue); void SetTo(const nsAString& aValue);
void SetTo(PRInt16 aInt); void SetTo(PRInt16 aInt);
void SetTo(mozilla::css::StyleRule* aValue, const nsAString* aSerialized); void SetTo(mozilla::css::StyleRule* aValue, const nsAString* aSerialized);
void SetTo(nsISVGValue* aValue);
void SetTo(const nsIntMargin& aValue); void SetTo(const nsIntMargin& aValue);
void SwapValueWith(nsAttrValue& aOther); void SwapValueWith(nsAttrValue& aOther);
@ -155,7 +151,6 @@ public:
inline float GetPercentValue() const; inline float GetPercentValue() const;
inline AtomArray* GetAtomArrayValue() const; inline AtomArray* GetAtomArrayValue() const;
inline mozilla::css::StyleRule* GetCSSStyleRuleValue() const; inline mozilla::css::StyleRule* GetCSSStyleRuleValue() const;
inline nsISVGValue* GetSVGValue() const;
inline double GetDoubleValue() const; inline double GetDoubleValue() const;
bool GetIntMarginValue(nsIntMargin& aMargin) const; bool GetIntMarginValue(nsIntMargin& aMargin) const;
@ -329,7 +324,7 @@ private:
{ {
ValueType mType; ValueType mType;
// mStringBits points to either nsIAtom* or nsStringBuffer* and is used when // mStringBits points to either nsIAtom* or nsStringBuffer* and is used when
// mType isn't mCSSStyleRule or eSVGValue. // mType isn't mCSSStyleRule.
// Note eStringBase and eAtomBase is used also to handle the type of // Note eStringBase and eAtomBase is used also to handle the type of
// mStringBits. // mStringBits.
PtrBits mStringBits; PtrBits mStringBits;
@ -340,7 +335,6 @@ private:
PRInt32 mPercent; PRInt32 mPercent;
mozilla::css::StyleRule* mCSSStyleRule; mozilla::css::StyleRule* mCSSStyleRule;
AtomArray* mAtomArray; AtomArray* mAtomArray;
nsISVGValue* mSVGValue;
double mDoubleValue; double mDoubleValue;
nsIntMargin* mIntMargin; nsIntMargin* mIntMargin;
}; };
@ -446,13 +440,6 @@ nsAttrValue::GetCSSStyleRuleValue() const
return GetMiscContainer()->mCSSStyleRule; return GetMiscContainer()->mCSSStyleRule;
} }
inline nsISVGValue*
nsAttrValue::GetSVGValue() const
{
NS_PRECONDITION(Type() == eSVGValue, "wrong type");
return GetMiscContainer()->mSVGValue;
}
inline double inline double
nsAttrValue::GetDoubleValue() const nsAttrValue::GetDoubleValue() const
{ {

Просмотреть файл

@ -105,7 +105,6 @@ CPPSRCS = \
nsSVGPolylineElement.cpp \ nsSVGPolylineElement.cpp \
nsSVGScriptElement.cpp \ nsSVGScriptElement.cpp \
nsSVGString.cpp \ nsSVGString.cpp \
nsSVGStringProxyValue.cpp \
nsSVGStylableElement.cpp \ nsSVGStylableElement.cpp \
nsSVGRect.cpp \ nsSVGRect.cpp \
nsSVGRectElement.cpp \ nsSVGRectElement.cpp \
@ -121,7 +120,6 @@ CPPSRCS = \
nsSVGTextPositioningElement.cpp \ nsSVGTextPositioningElement.cpp \
nsSVGTitleElement.cpp \ nsSVGTitleElement.cpp \
nsSVGUseElement.cpp \ nsSVGUseElement.cpp \
nsSVGValue.cpp \
nsSVGViewBox.cpp \ nsSVGViewBox.cpp \
SVGAnimatedLengthList.cpp \ SVGAnimatedLengthList.cpp \
SVGAnimatedNumberList.cpp \ SVGAnimatedNumberList.cpp \
@ -169,9 +167,6 @@ include $(topsrcdir)/config/config.mk
FORCE_STATIC_LIB = 1 FORCE_STATIC_LIB = 1
EXPORTS = \ EXPORTS = \
nsISVGValue.h \
nsISVGValueObserver.h \
nsISVGValueUtils.h \
nsSVGFeatures.h \ nsSVGFeatures.h \
nsSVGRect.h \ nsSVGRect.h \
$(NULL) $(NULL)

Просмотреть файл

@ -38,7 +38,6 @@
#include "SVGAnimatedLengthList.h" #include "SVGAnimatedLengthList.h"
#include "SVGLength.h" #include "SVGLength.h"
#include "nsSVGElement.h" #include "nsSVGElement.h"
#include "nsISVGValueUtils.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsString.h" #include "nsString.h"

Просмотреть файл

@ -37,7 +37,6 @@
#include "SVGNumberList.h" #include "SVGNumberList.h"
#include "SVGAnimatedNumberList.h" #include "SVGAnimatedNumberList.h"
#include "nsSVGElement.h" #include "nsSVGElement.h"
#include "nsISVGValueUtils.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsString.h" #include "nsString.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"

Просмотреть файл

@ -38,7 +38,6 @@
#include "SVGAnimatedPathSegList.h" #include "SVGAnimatedPathSegList.h"
#include "SVGPathSegUtils.h" #include "SVGPathSegUtils.h"
#include "nsSVGElement.h" #include "nsSVGElement.h"
#include "nsISVGValueUtils.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsString.h" #include "nsString.h"

Просмотреть файл

@ -37,7 +37,6 @@
#include "SVGPointList.h" #include "SVGPointList.h"
#include "SVGAnimatedPointList.h" #include "SVGAnimatedPointList.h"
#include "nsSVGElement.h" #include "nsSVGElement.h"
#include "nsISVGValueUtils.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsString.h" #include "nsString.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"

Просмотреть файл

@ -1,95 +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
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (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_ISVGVALUE_H__
#define __NS_ISVGVALUE_H__
#include "nsISupports.h"
#include "nsString.h"
class nsISVGValueObserver;
////////////////////////////////////////////////////////////////////////
// nsISVGValue: private interface for svg values
/* This interface is implemented by all value-types (e.g. coords,
pointlists, matrices) that can be parsed from/to strings. This is
used for element-properties that are also XML attributes. E.g. the
'polyline'-element has a 'points'-attribute and a property
'animatedPoints' in the DOM.
XXX Observers
*/
// {d8299a5e-af9a-4bad-9845-fb1b6e2eed19}
#define NS_ISVGVALUE_IID \
{ 0xd8299a5e, 0xaf9a, 0x4bad, { 0x98, 0x45, 0xfb, 0x1b, 0x6e, 0x2e, 0xed, 0x19 } }
class nsISVGValue : public nsISupports
{
public:
enum modificationType {
mod_other = 0,
mod_context,
mod_die
};
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGVALUE_IID)
NS_IMETHOD SetValueString(const nsAString& aValue)=0;
NS_IMETHOD GetValueString(nsAString& aValue)=0;
NS_IMETHOD AddObserver(nsISVGValueObserver* observer)=0;
NS_IMETHOD RemoveObserver(nsISVGValueObserver* observer)=0;
NS_IMETHOD BeginBatchUpdate()=0;
NS_IMETHOD EndBatchUpdate()=0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGValue, NS_ISVGVALUE_IID)
nsresult
NS_CreateSVGGenericStringValue(const nsAString& aValue, nsISVGValue** aResult);
nsresult
NS_CreateSVGStringProxyValue(nsISVGValue* proxiedValue, nsISVGValue** aResult);
#endif // __NS_ISVGVALUE_H__

Просмотреть файл

@ -1,68 +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
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (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_ISVGVALUEOBSERVER_H__
#define __NS_ISVGVALUEOBSERVER_H__
#include "nsWeakReference.h"
#include "nsISVGValue.h"
////////////////////////////////////////////////////////////////////////
// nsISVGValueObserver
// {485029a4-2449-45c1-9814-08f38132ca4c}
#define NS_ISVGVALUEOBSERVER_IID \
{ 0x485029a4, 0x2449, 0x45c1, \
{ 0x98, 0x14, 0x08, 0xf3, 0x81, 0x32, 0xca, 0x4c } }
class nsISVGValueObserver : public nsSupportsWeakReference
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGVALUEOBSERVER_IID)
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType)=0;
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType)=0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGValueObserver, NS_ISVGVALUEOBSERVER_IID)
#endif // __NS_ISVGVALUEOBSERVER_H__

Просмотреть файл

@ -1,74 +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
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (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_ISVGVALUEUTILS_H__
#define __NS_ISVGVALUEUTILS_H__
// NS_ADD_SVGVALUE_OBSERVER() :
// add *this* as an observer to 'value'
#define NS_ADD_SVGVALUE_OBSERVER(value) \
PR_BEGIN_MACRO \
{ \
nsCOMPtr<nsISVGValue> v = do_QueryInterface(value); \
NS_ASSERTION(v, "can't find nsISVGValue interface on " #value ); \
if (v) \
v->AddObserver(this); \
} \
PR_END_MACRO
// NS_REMOVE_SVGVALUE_OBSERVER() :
// remove *this* as an observer to 'value'
#define NS_REMOVE_SVGVALUE_OBSERVER(value) \
PR_BEGIN_MACRO \
{ \
nsCOMPtr<nsISVGValue> v = do_QueryInterface(value); \
NS_ASSERTION(v, "can't find nsISVGValue interface on " #value ); \
if (v) \
v->RemoveObserver(this); \
} \
PR_END_MACRO
#endif // __NS_ISVGVALUEUTILS_H__

Просмотреть файл

@ -106,7 +106,7 @@ nsSVGEnumMapping nsSVGElement::sSVGUnitTypesMap[] = {
}; };
nsSVGElement::nsSVGElement(already_AddRefed<nsINodeInfo> aNodeInfo) nsSVGElement::nsSVGElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGElementBase(aNodeInfo), mSuppressNotification(PR_FALSE) : nsSVGElementBase(aNodeInfo)
{ {
} }
@ -205,14 +205,6 @@ nsSVGElement::Init()
return NS_OK; return NS_OK;
} }
nsSVGElement::~nsSVGElement()
{
PRUint32 i, count = mMappedAttributes.AttrCount();
for (i = 0; i < count; ++i) {
mMappedAttributes.AttrAt(i)->GetSVGValue()->RemoveObserver(this);
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsISupports methods // nsISupports methods
@ -220,8 +212,6 @@ NS_IMPL_ADDREF_INHERITED(nsSVGElement, nsSVGElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGElement, nsSVGElementBase) NS_IMPL_RELEASE_INHERITED(nsSVGElement, nsSVGElementBase)
NS_INTERFACE_MAP_BEGIN(nsSVGElement) NS_INTERFACE_MAP_BEGIN(nsSVGElement)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
// provided by nsGenericElement: // provided by nsGenericElement:
// NS_INTERFACE_MAP_ENTRY(nsIContent) // NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_END_INHERITING(nsSVGElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGElementBase)
@ -308,52 +298,6 @@ nsSVGElement::ParseAttribute(PRInt32 aNamespaceID,
const nsAString& aValue, const nsAString& aValue,
nsAttrValue& aResult) nsAttrValue& aResult)
{ {
// Parse value
nsCOMPtr<nsISVGValue> svg_value;
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aAttribute, aNamespaceID);
if (val) {
// Found the attr in the list.
if (val->Type() == nsAttrValue::eSVGValue) {
svg_value = val->GetSVGValue();
}
}
else {
// Could be a mapped attribute.
svg_value = GetMappedAttribute(aNamespaceID, aAttribute);
}
if (svg_value) {
// We want to prevent DidModifySVGObservable from running if we
// come in this route, otherwise AttributeChanged() gets called
// twice (once through DidMOdifySVGObservable, once through SetAttr).
mSuppressNotification = PR_TRUE;
if (NS_FAILED(svg_value->SetValueString(aValue))) {
// The value was rejected. This happens e.g. in a XUL template
// when trying to set a value like "?x" on a value object that
// expects a length.
// To accommodate this "erroneous" value, we'll insert a proxy
// object between ourselves and the actual value object:
ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue);
nsCOMPtr<nsISVGValue> proxy;
nsresult rv =
NS_CreateSVGStringProxyValue(svg_value, getter_AddRefs(proxy));
// Failure means we'll store this attr as a string, not an SVGValue, but
// that's the best we can do short of throwing outright.
NS_ENSURE_SUCCESS(rv, PR_FALSE);
svg_value->RemoveObserver(this);
proxy->SetValueString(aValue);
proxy->AddObserver(this);
aResult.SetTo(proxy);
}
else {
aResult.SetTo(svg_value);
}
mSuppressNotification = PR_FALSE;
return PR_TRUE;
}
nsresult rv = NS_OK; nsresult rv = NS_OK;
bool foundMatch = false; bool foundMatch = false;
if (aNamespaceID == kNameSpaceID_None) { if (aNamespaceID == kNameSpaceID_None) {
@ -1069,90 +1013,6 @@ nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
return NS_OK; return NS_OK;
} }
//----------------------------------------------------------------------
// nsISVGValueObserver methods:
nsSVGElement::ObservableModificationData
nsSVGElement::GetModificationDataForObservable(nsISVGValue* aObservable,
nsISVGValue::modificationType aModType)
{
// Return without setting DOM attributes as markup attributes if the
// attribute's element is being inserted into an SVG document fragment,
// which provides a context which percentage lengths are relative to.
// Bug 274886
if (aModType == nsISVGValue::mod_context)
return ObservableModificationData(nsnull, 0);
// Return without setting DOM attribute
if (mSuppressNotification)
return ObservableModificationData(nsnull, 0);
PRUint32 i, count = mMappedAttributes.AttrCount();
const nsAttrValue* attrValue = nsnull;
for (i = 0; i < count; ++i) {
attrValue = mMappedAttributes.AttrAt(i);
if (attrValue->GetSVGValue() == aObservable) {
break;
}
}
if (i == count) {
NS_NOTREACHED("unknown nsISVGValue");
return ObservableModificationData(nsnull, 1);
}
const nsAttrName* attrName = mMappedAttributes.AttrNameAt(i);
bool modification = !!mAttrsAndChildren.GetAttr(attrName->LocalName(),
attrName->NamespaceID());
PRUint8 modType = modification ?
static_cast<PRUint8>(nsIDOMMutationEvent::MODIFICATION) :
static_cast<PRUint8>(nsIDOMMutationEvent::ADDITION);
return ObservableModificationData(attrName, modType);
}
NS_IMETHODIMP
nsSVGElement::WillModifySVGObservable(nsISVGValue* aObservable,
nsISVGValue::modificationType aModType)
{
ObservableModificationData data =
GetModificationDataForObservable(aObservable, aModType);
const nsAttrName* attrName = data.name;
if (!attrName) {
return data.modType ? NS_ERROR_UNEXPECTED : NS_OK;
}
nsNodeUtils::AttributeWillChange(this, attrName->NamespaceID(),
attrName->LocalName(), data.modType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGElement::DidModifySVGObservable(nsISVGValue* aObservable,
nsISVGValue::modificationType aModType)
{
ObservableModificationData data =
GetModificationDataForObservable(aObservable, aModType);
const nsAttrName* attrName = data.name;
if (!attrName) {
return data.modType ? NS_ERROR_UNEXPECTED : NS_OK;
}
bool hasListeners =
nsContentUtils::HasMutationListeners(this,
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
this);
nsAttrValue newValue(aObservable);
return SetAttrAndNotify(attrName->NamespaceID(), attrName->LocalName(),
attrName->GetPrefix(), EmptyString(), newValue,
data.modType, hasListeners, PR_TRUE, nsnull);
}
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Helper class: MappedAttrParser, for parsing values of mapped attributes // Helper class: MappedAttrParser, for parsing values of mapped attributes
@ -1367,43 +1227,6 @@ nsSVGElement::GetAnimatedContentStyleRule()
} }
#endif // MOZ_SMIL #endif // MOZ_SMIL
nsISVGValue*
nsSVGElement::GetMappedAttribute(PRInt32 aNamespaceID, nsIAtom* aName)
{
const nsAttrValue* attrVal = mMappedAttributes.GetAttr(aName, aNamespaceID);
if (!attrVal)
return nsnull;
return attrVal->GetSVGValue();
}
nsresult
nsSVGElement::AddMappedSVGValue(nsIAtom* aName, nsISupports* aValue,
PRInt32 aNamespaceID)
{
nsresult rv;
nsCOMPtr<nsISVGValue> svg_value = do_QueryInterface(aValue);
svg_value->AddObserver(this);
nsAttrValue attrVal(svg_value);
if (aNamespaceID == kNameSpaceID_None) {
rv = mMappedAttributes.SetAndTakeAttr(aName, attrVal);
NS_ENSURE_SUCCESS(rv, rv);
}
else {
nsCOMPtr<nsINodeInfo> ni;
ni = mNodeInfo->NodeInfoManager()->GetNodeInfo(aName, nsnull,
aNamespaceID,
nsIDOMNode::ATTRIBUTE_NODE);
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
rv = mMappedAttributes.SetAndTakeAttr(ni, attrVal);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
/* static */ /* static */
nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr) nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr)
{ {

Просмотреть файл

@ -49,9 +49,7 @@
#include "nsIDOMSVGElement.h" #include "nsIDOMSVGElement.h"
#include "nsGenericElement.h" #include "nsGenericElement.h"
#include "nsStyledElement.h" #include "nsStyledElement.h"
#include "nsISVGValue.h" #include "mozilla/css/StyleRule.h"
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
#ifdef MOZ_SMIL #ifdef MOZ_SMIL
#include "nsISMILAttr.h" #include "nsISMILAttr.h"
@ -85,13 +83,12 @@ class SVGAnimatedTransformList;
typedef nsStyledElementNotElementCSSInlineStyle nsSVGElementBase; typedef nsStyledElementNotElementCSSInlineStyle nsSVGElementBase;
class nsSVGElement : public nsSVGElementBase, // nsIContent class nsSVGElement : public nsSVGElementBase // nsIContent
public nsISVGValueObserver // :nsISupportsWeakReference
{ {
protected: protected:
nsSVGElement(already_AddRefed<nsINodeInfo> aNodeInfo); nsSVGElement(already_AddRefed<nsINodeInfo> aNodeInfo);
nsresult Init(); nsresult Init();
virtual ~nsSVGElement(); virtual ~nsSVGElement(){}
public: public:
typedef mozilla::SVGNumberList SVGNumberList; typedef mozilla::SVGNumberList SVGNumberList;
@ -144,15 +141,6 @@ public:
NS_IMETHOD GetOwnerSVGElement(nsIDOMSVGSVGElement** aOwnerSVGElement); NS_IMETHOD GetOwnerSVGElement(nsIDOMSVGSVGElement** aOwnerSVGElement);
NS_IMETHOD GetViewportElement(nsIDOMSVGElement** aViewportElement); NS_IMETHOD GetViewportElement(nsIDOMSVGElement** aViewportElement);
// nsISVGValueObserver
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
// nsISupportsWeakReference
// implementation inherited from nsSupportsWeakReference
// Gets the element that establishes the rectangular viewport against which // Gets the element that establishes the rectangular viewport against which
// we should resolve percentage lengths (our "coordinate context"). Returns // we should resolve percentage lengths (our "coordinate context"). Returns
// nsnull for outer <svg> or SVG without an <svg> parent (invalid SVG). // nsnull for outer <svg> or SVG without an <svg> parent (invalid SVG).
@ -276,10 +264,6 @@ protected:
mozilla::css::StyleRule* GetAnimatedContentStyleRule(); mozilla::css::StyleRule* GetAnimatedContentStyleRule();
#endif // MOZ_SMIL #endif // MOZ_SMIL
nsISVGValue* GetMappedAttribute(PRInt32 aNamespaceID, nsIAtom* aName);
nsresult AddMappedSVGValue(nsIAtom* aName, nsISupports* aValue,
PRInt32 aNamespaceID = kNameSpaceID_None);
static nsIAtom* GetEventNameForAttr(nsIAtom* aAttr); static nsIAtom* GetEventNameForAttr(nsIAtom* aAttr);
struct LengthInfo { struct LengthInfo {
@ -535,24 +519,7 @@ protected:
static nsSVGEnumMapping sSVGUnitTypesMap[]; static nsSVGEnumMapping sSVGUnitTypesMap[];
private: private:
struct ObservableModificationData {
// Only to be used if |name| is non-null. Otherwise, modType will
// be 0 to indicate NS_OK should be returned and 1 to indicate
// NS_ERROR_UNEXPECTED should be returned.
ObservableModificationData(const nsAttrName* aName, PRUint32 aModType):
name(aName), modType(aModType)
{}
const nsAttrName* name;
PRUint8 modType;
};
ObservableModificationData
GetModificationDataForObservable(nsISVGValue* aObservable,
nsISVGValue::modificationType aModType);
nsRefPtr<mozilla::css::StyleRule> mContentStyleRule; nsRefPtr<mozilla::css::StyleRule> mContentStyleRule;
nsAttrAndChildArray mMappedAttributes;
bool mSuppressNotification;
}; };
/** /**

Просмотреть файл

@ -44,15 +44,11 @@
#include "nsIDOMSVGFilters.h" #include "nsIDOMSVGFilters.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsSVGFilterInstance.h" #include "nsSVGFilterInstance.h"
#include "nsSVGValue.h"
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
#include "nsIDOMSVGFilterElement.h" #include "nsIDOMSVGFilterElement.h"
#include "nsSVGEnum.h" #include "nsSVGEnum.h"
#include "SVGNumberList.h" #include "SVGNumberList.h"
#include "SVGAnimatedNumberList.h" #include "SVGAnimatedNumberList.h"
#include "DOMSVGAnimatedNumberList.h" #include "DOMSVGAnimatedNumberList.h"
#include "nsISVGValueUtils.h"
#include "nsSVGFilters.h" #include "nsSVGFilters.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"

Просмотреть файл

@ -36,7 +36,6 @@
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsISVGValueUtils.h"
#include "SVGAnimatedPreserveAspectRatio.h" #include "SVGAnimatedPreserveAspectRatio.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"

Просмотреть файл

@ -44,7 +44,6 @@
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsSVGPathDataParser.h" #include "nsSVGPathDataParser.h"
#include "nsSVGPathElement.h" #include "nsSVGPathElement.h"
#include "nsISVGValueUtils.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"
#include "DOMSVGPoint.h" #include "DOMSVGPoint.h"
#include "gfxContext.h" #include "gfxContext.h"

Просмотреть файл

@ -39,11 +39,8 @@
#include "nsSVGRect.h" #include "nsSVGRect.h"
#include "prdtoa.h" #include "prdtoa.h"
#include "nsSVGValue.h"
#include "nsISVGValueUtils.h"
#include "nsTextFormatter.h" #include "nsTextFormatter.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "nsWeakReference.h"
#include "nsIDOMSVGLength.h" #include "nsIDOMSVGLength.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsDOMError.h" #include "nsDOMError.h"

Просмотреть файл

@ -41,7 +41,6 @@
#define __NS_SVGRECT_H__ #define __NS_SVGRECT_H__
#include "nsIDOMSVGRect.h" #include "nsIDOMSVGRect.h"
#include "nsSVGValue.h"
#include "gfxRect.h" #include "gfxRect.h"
nsresult nsresult

Просмотреть файл

@ -53,7 +53,6 @@
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsISVGSVGFrame.h" //XXX #include "nsISVGSVGFrame.h" //XXX
#include "nsSVGRect.h" #include "nsSVGRect.h"
#include "nsISVGValueUtils.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsISVGChildFrame.h" #include "nsISVGChildFrame.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"

Просмотреть файл

@ -1,200 +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
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex@croczilla.com> (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"
////////////////////////////////////////////////////////////////////////
// nsSVGStringProxyValue implementation
//
// This class is intended to sit between a client and an nsISVGValue object.
// It is used to allow mapped SVG attributes (which store their value in parsed
// form) to assume any string value. This is needed for SVG to work properly with
// XUL templates, where we have XML like this: <svg:circle r="?r"/>.
//
// When nsSVGStringProxyValue::SetValueString() will attempt to call its
// proxied object's SetValueString method. If that call fails, nsSVGStringProxyValue
// will cache the string and return it for subsequent invocations of GetValueString().
// If the call succeeds, however, invocations of GetValueString() will call the
// proxied objects's GetValueString() method.
// If the proxied object's data is changed internally, invocations of GetValueString()
// will also return the proxied object's GetValueString().
class nsSVGStringProxyValue : public nsSVGValue,
public nsISVGValueObserver
{
protected:
friend nsresult
NS_CreateSVGStringProxyValue(nsISVGValue* proxiedValue, nsISVGValue** aResult);
nsSVGStringProxyValue();
virtual ~nsSVGStringProxyValue();
bool Init(nsISVGValue* proxiedValue);
public:
NS_DECL_ISUPPORTS
// 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:
nsString mCachedValue;
nsCOMPtr<nsISVGValue> mProxiedValue;
bool mUseCachedValue;
};
//----------------------------------------------------------------------
nsresult
NS_CreateSVGStringProxyValue(nsISVGValue* proxiedValue,
nsISVGValue** aResult)
{
*aResult = nsnull;
nsSVGStringProxyValue *sp = new nsSVGStringProxyValue();
if(!sp) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(sp);
if (!sp->Init(proxiedValue)) {
NS_RELEASE(sp);
return NS_ERROR_FAILURE;
}
*aResult = sp;
return NS_OK;
}
nsSVGStringProxyValue::nsSVGStringProxyValue()
{
#ifdef DEBUG
printf("nsSVGStringProxyValue CTOR\n");
#endif
}
nsSVGStringProxyValue::~nsSVGStringProxyValue()
{
mProxiedValue->RemoveObserver(this);
#ifdef DEBUG
printf("nsSVGStringProxyValue DTOR\n");
#endif
}
bool nsSVGStringProxyValue::Init(nsISVGValue* proxiedValue)
{
mProxiedValue = proxiedValue;
mProxiedValue->AddObserver(this);
return PR_TRUE;
}
//----------------------------------------------------------------------
// nsISupports methods:
NS_IMPL_ADDREF(nsSVGStringProxyValue)
NS_IMPL_RELEASE(nsSVGStringProxyValue)
NS_INTERFACE_MAP_BEGIN(nsSVGStringProxyValue)
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
NS_INTERFACE_MAP_END
//----------------------------------------------------------------------
// nsISVGValue methods:
NS_IMETHODIMP
nsSVGStringProxyValue::SetValueString(const nsAString& aValue)
{
#ifdef DEBUG
printf("nsSVGStringProxyValue(%p)::SetValueString(%s)\n",
static_cast<void*>(this), NS_ConvertUTF16toUTF8(aValue).get());
#endif
if (NS_FAILED(mProxiedValue->SetValueString(aValue))) {
#ifdef DEBUG
printf(" -> call failed, now using cached value\n");
#endif
mUseCachedValue = PR_TRUE; // mUseCachedValue will be reset in DidModifySVGObservable,
// should the inner object ever change state internally
mCachedValue = aValue;
}
return NS_OK;
}
NS_IMETHODIMP
nsSVGStringProxyValue::GetValueString(nsAString& aValue)
{
if (!mUseCachedValue)
return mProxiedValue->GetValueString(aValue);
aValue = mCachedValue;
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGValueObserver methods
NS_IMETHODIMP
nsSVGStringProxyValue::WillModifySVGObservable(nsISVGValue* observable,
modificationType aModType)
{
WillModify(aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGStringProxyValue::DidModifySVGObservable (nsISVGValue* observable,
modificationType aModType)
{
// Our internal proxied object has set its state internally.
// Make sure its new value takes priority over our cached string:
mUseCachedValue = PR_FALSE;
DidModify(aModType);
return NS_OK;
}

Просмотреть файл

@ -1,132 +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
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (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"
nsSVGValue::nsSVGValue()
: mModifyNestCount(0)
{
}
nsSVGValue::~nsSVGValue()
{
ReleaseObservers();
}
void
nsSVGValue::ReleaseObservers()
{
mObservers.Clear();
}
void
nsSVGValue::NotifyObservers(SVGObserverNotifyFunction f,
modificationType aModType)
{
PRInt32 count = mObservers.Length();
// Since notification might cause the listeners to remove themselves
// from the observer list (mod_die), walk backwards through the list
// to catch everyone.
for (PRInt32 i = count - 1; i >= 0; i--) {
nsIWeakReference* wr = mObservers.ElementAt(i);
nsCOMPtr<nsISVGValueObserver> observer = do_QueryReferent(wr);
if (observer)
(static_cast<nsISVGValueObserver*>(observer)->*f)(this, aModType);
}
}
void
nsSVGValue::WillModify(modificationType aModType)
{
if (++mModifyNestCount == 1)
NotifyObservers(&nsISVGValueObserver::WillModifySVGObservable, aModType);
}
void
nsSVGValue::DidModify(modificationType aModType)
{
NS_ASSERTION(mModifyNestCount>0, "unbalanced Will/DidModify calls");
if (--mModifyNestCount == 0) {
OnDidModify();
NotifyObservers(&nsISVGValueObserver::DidModifySVGObservable, aModType);
}
}
NS_IMETHODIMP
nsSVGValue::AddObserver(nsISVGValueObserver* observer)
{
nsWeakPtr wr = do_GetWeakReference(observer);
if (!wr) return NS_ERROR_FAILURE;
// Prevent duplicate observers - needed because geometry can attempt
// to add itself as an observer of a paint server for both the
// stroke and fill. Safe, as on a style change we remove both, as
// the change notification isn't fine grained, and re-add as
// appropriate.
if (!mObservers.Contains(wr)) {
mObservers.AppendElement(wr);
}
return NS_OK;
}
NS_IMETHODIMP
nsSVGValue::RemoveObserver(nsISVGValueObserver* observer)
{
nsWeakPtr wr = do_GetWeakReference(observer);
if (!wr) return NS_ERROR_FAILURE;
return mObservers.RemoveElement(wr) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSVGValue::BeginBatchUpdate()
{
WillModify();
return NS_OK;
}
NS_IMETHODIMP
nsSVGValue::EndBatchUpdate()
{
DidModify();
return NS_OK;
}

Просмотреть файл

@ -1,114 +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
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (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_SVGVALUE_H__
#define __NS_SVGVALUE_H__
#include "nscore.h"
#include "nsISVGValue.h"
#include "nsAutoPtr.h"
#include "nsTArray.h"
#include "nsISVGValueObserver.h"
#include "nsIWeakReference.h"
#include "nsCOMPtr.h"
class nsSVGValue : public nsISVGValue
{
protected:
nsSVGValue();
virtual ~nsSVGValue();
// to be called by subclass whenever value is being modified.
// nested calls will be ignored, so calls need to be balanced
void WillModify(modificationType aModType = mod_other);
void DidModify(modificationType aModType = mod_other);
friend class nsSVGValueAutoNotifier;
public:
// Partial Implementation of nsISVGValue interface:
NS_IMETHOD AddObserver(nsISVGValueObserver* observer);
NS_IMETHOD RemoveObserver(nsISVGValueObserver* observer);
NS_IMETHOD BeginBatchUpdate();
NS_IMETHOD EndBatchUpdate();
typedef
NS_STDCALL_FUNCPROTO(nsresult,
SVGObserverNotifyFunction,
nsISVGValueObserver, DidModifySVGObservable,
(nsISVGValue*, nsISVGValue::modificationType));
protected:
// implementation helpers
void ReleaseObservers();
void NotifyObservers(SVGObserverNotifyFunction f,
modificationType aModType);
PRInt32 GetModifyNestCount() { return mModifyNestCount; }
private:
virtual void OnDidModify(){} // hook that will be called before observers are notified
nsAutoTArray<nsWeakPtr, 1> mObservers;
PRInt32 mModifyNestCount;
};
// Class that will automatically call WillModify and DidModify in its ctor
// and dtor respectively (for functions that have multiple exit points).
class NS_STACK_CLASS nsSVGValueAutoNotifier
{
public:
nsSVGValueAutoNotifier(nsSVGValue* aVal,
nsISVGValue::modificationType aModType =
nsISVGValue::mod_other)
: mVal(aVal)
, mModType(aModType)
{
mVal->WillModify(mModType);
}
~nsSVGValueAutoNotifier()
{
mVal->DidModify(mModType);
}
private:
nsRefPtr<nsSVGValue> mVal;
nsISVGValue::modificationType mModType;
};
#endif //__NS_SVGVALUE_H__

Просмотреть файл

@ -40,7 +40,6 @@
#define __NS_SVGGRADIENTFRAME_H__ #define __NS_SVGGRADIENTFRAME_H__
#include "nsSVGPaintServerFrame.h" #include "nsSVGPaintServerFrame.h"
#include "nsWeakReference.h"
#include "nsSVGElement.h" #include "nsSVGElement.h"
#include "gfxPattern.h" #include "gfxPattern.h"

Просмотреть файл

@ -88,9 +88,6 @@ public:
// nsSVGContainerFrame methods: // nsSVGContainerFrame methods:
virtual gfxMatrix GetCanvasTM(); virtual gfxMatrix GetCanvasTM();
// nsISupportsWeakReference
// implementation inherited from nsSupportsWeakReference
// nsISVGSVGFrame interface: // nsISVGSVGFrame interface:
NS_IMETHOD SuspendRedraw(); NS_IMETHOD SuspendRedraw();
NS_IMETHOD UnsuspendRedraw(); NS_IMETHOD UnsuspendRedraw();

Просмотреть файл

@ -41,7 +41,6 @@
#include "nsFrame.h" #include "nsFrame.h"
#include "nsISVGChildFrame.h" #include "nsISVGChildFrame.h"
#include "nsWeakReference.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsSVGGeometryFrame.h" #include "nsSVGGeometryFrame.h"
#include "gfxRect.h" #include "gfxRect.h"

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsIDOMSVGTextElement.h" #include "nsIDOMSVGTextElement.h"
#include "nsSVGTextFrame.h" #include "nsSVGTextFrame.h"
#include "nsWeakReference.h"
#include "SVGLengthList.h" #include "SVGLengthList.h"
#include "nsIDOMSVGLength.h" #include "nsIDOMSVGLength.h"
#include "nsIDOMSVGAnimatedNumber.h" #include "nsIDOMSVGAnimatedNumber.h"