Bug 359516 - replace hand-wired observer scheme for filters with

nsIMutationObserver.  r=roc, sr=sicking


git-svn-id: svn://10.0.0.236/trunk@219519 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
tor%cs.brown.edu 2007-02-05 20:04:17 +00:00
parent b439fd4ad9
commit 5a65ba5365
15 changed files with 133 additions and 538 deletions

View File

@ -65,7 +65,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFilterElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterElement)
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFilterElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFilterElementBase)
@ -210,27 +209,6 @@ nsSVGFilterElement::SetFilterRes(PRUint32 filterResX, PRUint32 filterResY)
//----------------------------------------------------------------------
// nsIContent methods
nsresult
nsSVGFilterElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify)
{
WillModify();
nsresult rv = nsSVGFilterElementBase::InsertChildAt(aKid, aIndex, aNotify);
DidModify();
return rv;
}
nsresult
nsSVGFilterElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
{
WillModify();
nsresult rv = nsSVGFilterElementBase::RemoveChildAt(aIndex, aNotify);
DidModify();
return rv;
}
nsresult
nsSVGFilterElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,

View File

@ -39,14 +39,12 @@
#include "nsSVGGraphicElement.h"
#include "nsIDOMSVGFilterElement.h"
#include "nsSVGValue.h"
#include "nsSVGLength2.h"
typedef nsSVGGraphicElement nsSVGFilterElementBase;
class nsSVGFilterElement : public nsSVGFilterElementBase,
public nsIDOMSVGFilterElement,
public nsSVGValue
public nsIDOMSVGFilterElement
{
friend class nsSVGFilterFrame;
@ -72,9 +70,6 @@ public:
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFilterElementBase::)
// nsIContent
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify);

View File

@ -101,28 +101,6 @@ nsSVGFE::Init()
return NS_OK;
}
NS_IMETHODIMP
nsSVGFE::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsCOMPtr<nsIDOMSVGFilterElement> filter = do_QueryInterface(GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (filter && value)
value->BeginBatchUpdate();
return nsSVGFEBase::WillModifySVGObservable(observable, aModType);
}
NS_IMETHODIMP
nsSVGFE::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsCOMPtr<nsIDOMSVGFilterElement> filter = do_QueryInterface(GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (filter && value)
value->EndBatchUpdate();
return nsSVGFEBase::DidModifySVGObservable(observable, aModType);
}
PRBool
nsSVGFE::ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute,
nsSVGNumber2* aNum1, nsSVGNumber2* aNum2,
@ -222,30 +200,6 @@ NS_IMETHODIMP nsSVGFE::GetResult(nsIDOMSVGAnimatedString * *aResult)
//----------------------------------------------------------------------
// nsSVGElement methods
void
nsSVGFE::DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr)
{
nsSVGFEBase::DidChangeLength(aAttrEnum, aDoSetAttr);
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (value) {
value->BeginBatchUpdate();
value->EndBatchUpdate();
}
}
void
nsSVGFE::DidChangeNumber(PRUint8 aAttrEnum, PRBool aDoSetAttr)
{
nsSVGFEBase::DidChangeNumber(aAttrEnum, aDoSetAttr);
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (value) {
value->BeginBatchUpdate();
value->EndBatchUpdate();
}
}
nsSVGElement::LengthAttributesInfo
nsSVGFE::GetLengthInfo()
{
@ -1396,10 +1350,6 @@ public:
NS_FORWARD_NSIDOMELEMENT(nsSVGFEComponentTransferElementBase::)
// nsIContent
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected:
@ -1525,42 +1475,6 @@ nsSVGFEComponentTransferElement::GetRequirements(PRUint32 *aRequirements)
return NS_OK;
}
//----------------------------------------------------------------------
// nsIContent methods
nsresult
nsSVGFEComponentTransferElement::InsertChildAt(nsIContent* aKid,
PRUint32 aIndex,
PRBool aNotify)
{
nsCOMPtr<nsIDOMSVGFilterElement> filter = do_QueryInterface(GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (filter && value)
value->BeginBatchUpdate();
nsresult rv = nsSVGFEComponentTransferElementBase::InsertChildAt(aKid,
aIndex,
aNotify);
if (filter && value)
value->EndBatchUpdate();
return rv;
}
nsresult
nsSVGFEComponentTransferElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
{
nsCOMPtr<nsIDOMSVGFilterElement> filter = do_QueryInterface(GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (filter && value)
value->BeginBatchUpdate();
nsresult rv = nsSVGFEComponentTransferElementBase::RemoveChildAt(aIndex,
aNotify);
if (filter && value)
value->EndBatchUpdate();
return rv;
}
//--------------------------------------------
typedef nsSVGElement nsSVGComponentTransferFunctionElementBase;
@ -1573,12 +1487,6 @@ protected:
nsSVGComponentTransferFunctionElement(nsINodeInfo* aNodeInfo);
nsresult Init();
// nsISVGValueObserver interface:
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
public:
// interfaces:
@ -1673,38 +1581,6 @@ nsSVGComponentTransferFunctionElement::Init()
return NS_OK;
}
NS_IMETHODIMP
nsSVGComponentTransferFunctionElement::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsCOMPtr<nsIDOMSVGFEComponentTransferElement> element;
nsCOMPtr<nsIDOMSVGFilterElement> filter;
element = do_QueryInterface(GetParent());
if (GetParent())
filter = do_QueryInterface(GetParent()->GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(filter);
if (element && filter && value)
value->BeginBatchUpdate();
return nsSVGComponentTransferFunctionElementBase::WillModifySVGObservable(observable, aModType);
}
NS_IMETHODIMP
nsSVGComponentTransferFunctionElement::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsCOMPtr<nsIDOMSVGFEComponentTransferElement> element;
nsCOMPtr<nsIDOMSVGFilterElement> filter;
element = do_QueryInterface(GetParent());
if (GetParent())
filter = do_QueryInterface(GetParent()->GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(filter);
if (element && filter && value)
value->EndBatchUpdate();
return nsSVGComponentTransferFunctionElementBase::DidModifySVGObservable(observable, aModType);
}
//----------------------------------------------------------------------
// nsIDOMSVGComponentTransferFunctionElement methods
@ -2030,7 +1906,6 @@ protected:
friend nsresult NS_NewSVGFEMergeElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo);
nsSVGFEMergeElement(nsINodeInfo* aNodeInfo);
virtual ~nsSVGFEMergeElement();
public:
// interfaces:
@ -2052,9 +1927,6 @@ public:
NS_FORWARD_NSIDOMELEMENT(nsSVGFEMergeElementBase::)
// nsIContent
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
};
@ -2085,10 +1957,6 @@ nsSVGFEMergeElement::nsSVGFEMergeElement(nsINodeInfo *aNodeInfo)
{
}
nsSVGFEMergeElement::~nsSVGFEMergeElement()
{
}
//----------------------------------------------------------------------
// nsIDOMNode methods
@ -2152,38 +2020,6 @@ nsSVGFEMergeElement::GetRequirements(PRUint32 *aRequirements)
return NS_OK;
}
//----------------------------------------------------------------------
// nsIContent methods
nsresult
nsSVGFEMergeElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify)
{
nsCOMPtr<nsIDOMSVGFilterElement> filter = do_QueryInterface(GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (filter && value)
value->BeginBatchUpdate();
nsresult rv = nsSVGFEMergeElementBase::InsertChildAt(aKid, aIndex, aNotify);
if (filter && value)
value->EndBatchUpdate();
return rv;
}
nsresult
nsSVGFEMergeElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
{
nsCOMPtr<nsIDOMSVGFilterElement> filter = do_QueryInterface(GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(GetParent());
if (filter && value)
value->BeginBatchUpdate();
nsresult rv = nsSVGFEMergeElementBase::RemoveChildAt(aIndex, aNotify);
if (filter && value)
value->EndBatchUpdate();
return rv;
}
//---------------------Merge Node------------------------
typedef nsSVGStylableElement nsSVGFEMergeNodeElementBase;
@ -2197,12 +2033,6 @@ protected:
nsSVGFEMergeNodeElement(nsINodeInfo* aNodeInfo);
nsresult Init();
// nsISVGValueObserver interface:
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
@ -2266,38 +2096,6 @@ nsSVGFEMergeNodeElement::Init()
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEMergeNodeElement)
NS_IMETHODIMP
nsSVGFEMergeNodeElement::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsCOMPtr<nsIDOMSVGFEMergeElement> element;
nsCOMPtr<nsIDOMSVGFilterElement> filter;
element = do_QueryInterface(GetParent());
if (GetParent())
filter = do_QueryInterface(GetParent()->GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(filter);
if (element && filter && value)
value->BeginBatchUpdate();
return nsSVGFEMergeNodeElementBase::WillModifySVGObservable(observable, aModType);
}
NS_IMETHODIMP
nsSVGFEMergeNodeElement::DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsCOMPtr<nsIDOMSVGFEMergeElement> element;
nsCOMPtr<nsIDOMSVGFilterElement> filter;
element = do_QueryInterface(GetParent());
if (GetParent())
filter = do_QueryInterface(GetParent()->GetParent());
nsCOMPtr<nsISVGValue> value = do_QueryInterface(filter);
if (element && filter && value)
value->EndBatchUpdate();
return nsSVGFEMergeNodeElementBase::DidModifySVGObservable(observable, aModType);
}
//----------------------------------------------------------------------
// nsIDOMSVGFEMergeNodeElement methods
@ -3514,7 +3312,6 @@ protected:
friend nsresult NS_NewSVGFEUnimplementedMOZElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo);
nsSVGFEUnimplementedMOZElement(nsINodeInfo* aNodeInfo);
virtual ~nsSVGFEUnimplementedMOZElement();
public:
// interfaces:
@ -3564,10 +3361,6 @@ nsSVGFEUnimplementedMOZElement::nsSVGFEUnimplementedMOZElement(nsINodeInfo *aNod
{
}
nsSVGFEUnimplementedMOZElement::~nsSVGFEUnimplementedMOZElement()
{
}
//----------------------------------------------------------------------
// nsIDOMNode methods

View File

@ -51,11 +51,6 @@ protected:
nsSVGFE(nsINodeInfo *aNodeInfo);
nsresult Init();
// nsISVGValueObserver interface:
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
PRBool ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute,
nsSVGNumber2* aNum1, nsSVGNumber2* aNum2,
NumberInfo* aInfo1, NumberInfo* aInfo2,
@ -69,12 +64,9 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES
// nsSVGElement specializations:
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeNumber(PRUint8 aAttrEnum, PRBool aDoSetAttr);
protected:
// nsSVGElement specializations:
virtual LengthAttributesInfo GetLengthInfo();
// nsIDOMSVGFitlerPrimitiveStandardAttributes values

View File

@ -54,16 +54,12 @@
typedef nsSVGContainerFrame nsSVGFilterFrameBase;
class nsSVGFilterFrame : public nsSVGFilterFrameBase,
public nsSVGValue,
public nsISVGFilterFrame,
public nsISVGValueObserver,
public nsSupportsWeakReference
public nsISVGFilterFrame
{
protected:
friend nsIFrame*
NS_NewSVGFilterFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
virtual ~nsSVGFilterFrame();
NS_IMETHOD InitSVG();
public:
@ -83,17 +79,6 @@ public:
NS_IMETHOD SetValueString(const nsAString &aValue) { return NS_OK; }
NS_IMETHOD GetValueString(nsAString& aValue) { return NS_ERROR_NOT_IMPLEMENTED; }
// nsISVGValueObserver interface:
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
// nsIFrame interface:
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
/**
* Get the "type" of the frame
*
@ -114,11 +99,7 @@ private:
};
NS_INTERFACE_MAP_BEGIN(nsSVGFilterFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
NS_INTERFACE_MAP_ENTRY(nsISVGFilterFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFilterFrameBase)
nsIFrame*
@ -158,58 +139,6 @@ NS_GetSVGFilterFrame(nsISVGFilterFrame **aResult,
return NS_OK;
}
nsSVGFilterFrame::~nsSVGFilterFrame()
{
WillModify();
// Notify the world that we're dying
DidModify(mod_die);
NS_REMOVE_SVGVALUE_OBSERVER(mFilterUnits);
NS_REMOVE_SVGVALUE_OBSERVER(mPrimitiveUnits);
NS_REMOVE_SVGVALUE_OBSERVER(mFilterResX);
NS_REMOVE_SVGVALUE_OBSERVER(mFilterResY);
NS_REMOVE_SVGVALUE_OBSERVER(mContent);
}
//----------------------------------------------------------------------
// nsISVGValueObserver methods:
NS_IMETHODIMP
nsSVGFilterFrame::WillModifySVGObservable(nsISVGValue* observable,
modificationType aModType)
{
WillModify(aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGFilterFrame::DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
// Something we depend on was modified -- pass it on!
DidModify(aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGFilterFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
if (aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::x ||
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height)) {
WillModify();
DidModify();
return NS_OK;
}
return nsSVGFilterFrameBase::AttributeChanged(aNameSpaceID,
aAttribute, aModType);
}
NS_IMETHODIMP
nsSVGFilterFrame::InitSVG()
{
@ -221,18 +150,9 @@ nsSVGFilterFrame::InitSVG()
NS_ASSERTION(filter, "wrong content element");
filter->GetFilterUnits(getter_AddRefs(mFilterUnits));
NS_ADD_SVGVALUE_OBSERVER(mFilterUnits);
filter->GetPrimitiveUnits(getter_AddRefs(mPrimitiveUnits));
NS_ADD_SVGVALUE_OBSERVER(mPrimitiveUnits);
filter->GetFilterResX(getter_AddRefs(mFilterResX));
NS_ADD_SVGVALUE_OBSERVER(mFilterResX);
filter->GetFilterResY(getter_AddRefs(mFilterResY));
NS_ADD_SVGVALUE_OBSERVER(mFilterResY);
NS_ADD_SVGVALUE_OBSERVER(mContent);
return NS_OK;
}

View File

@ -90,8 +90,6 @@ nsSVGForeignObjectFrame::nsSVGForeignObjectFrame(nsStyleContext* aContext)
NS_INTERFACE_MAP_BEGIN(nsSVGForeignObjectFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_END_INHERITING(nsSVGForeignObjectFrameBase)
//----------------------------------------------------------------------
@ -194,30 +192,6 @@ nsSVGForeignObjectFrame::Reflow(nsPresContext* aPresContext,
}
//----------------------------------------------------------------------
// nsISVGValueObserver methods:
NS_IMETHODIMP
nsSVGForeignObjectFrame::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::WillModifyEffects(this, observable, aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGForeignObjectFrame::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::DidModifyEffects(this, observable, aModType);
UpdateGraphic();
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGChildFrame methods

View File

@ -41,8 +41,6 @@
#include "nsBlockFrame.h"
#include "nsISVGChildFrame.h"
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
#include "nsIDOMSVGMatrix.h"
#include "nsIDOMSVGLength.h"
#include "nsRegion.h"
@ -52,9 +50,7 @@ typedef nsContainerFrame nsSVGForeignObjectFrameBase;
class nsISVGFilterFrame;
class nsSVGForeignObjectFrame : public nsSVGForeignObjectFrameBase,
public nsISVGChildFrame,
public nsISVGValueObserver,
public nsSupportsWeakReference
public nsISVGChildFrame
{
friend nsIFrame*
NS_NewSVGForeignObjectFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
@ -104,15 +100,6 @@ public:
}
#endif
// nsISVGValueObserver
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
// nsISupportsWeakReference
// implementation inherited from nsSupportsWeakReference
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);

View File

@ -46,11 +46,6 @@
#include "nsISVGValueUtils.h"
#include "nsSVGGraphicElement.h"
NS_INTERFACE_MAP_BEGIN(nsSVGGFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END_INHERITING(nsSVGDisplayContainerFrame)
//----------------------------------------------------------------------
// Implementation
@ -138,22 +133,6 @@ nsSVGGFrame::GetCanvasTM()
return retval;
}
NS_IMETHODIMP
nsSVGGFrame::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::WillModifyEffects(this, observable, aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGGFrame::DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::DidModifyEffects(this, observable, aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGGFrame::DidSetStyleContext()
{

View File

@ -40,16 +40,12 @@
#define NSSVGGFRAME_H
#include "nsSVGContainerFrame.h"
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
typedef nsSVGDisplayContainerFrame nsSVGGFrameBase;
class nsISVGFilterFrame;
class nsSVGGFrame : public nsSVGGFrameBase,
public nsISVGValueObserver,
public nsSupportsWeakReference
class nsSVGGFrame : public nsSVGGFrameBase
{
public:
nsSVGGFrame(nsStyleContext* aContext) :
@ -70,11 +66,6 @@ public:
#endif
protected:
// nsISupports interface:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
friend nsIFrame*
NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
@ -92,12 +83,6 @@ protected:
// nsSVGContainerFrame methods:
virtual already_AddRefed<nsIDOMSVGMatrix> GetCanvasTM();
// nsISVGValueObserver
NS_IMETHOD WillModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsCOMPtr<nsIDOMSVGMatrix> mOverrideCTM;

View File

@ -375,7 +375,6 @@ NS_IMETHODIMP
nsSVGInnerSVGFrame::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::WillModifyEffects(this, observable, aModType);
return NS_OK;
}
@ -383,15 +382,7 @@ NS_IMETHODIMP
nsSVGInnerSVGFrame::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsISVGFilterFrame *filter;
CallQueryInterface(observable, &filter);
nsSVGUtils::DidModifyEffects(this, observable, aModType);
if (!filter) {
NotifyViewportChange();
}
NotifyViewportChange();
return NS_OK;
}

View File

@ -501,8 +501,6 @@ NS_IMETHODIMP
nsSVGPathGeometryFrame::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::WillModifyEffects(this, observable, aModType);
return NS_OK;
}
@ -511,8 +509,6 @@ NS_IMETHODIMP
nsSVGPathGeometryFrame::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::DidModifyEffects(this, observable, aModType);
nsSVGPathGeometryFrameBase::DidModifySVGObservable(observable, aModType);
nsIFrame *frame = nsnull;
@ -520,9 +516,7 @@ nsSVGPathGeometryFrame::DidModifySVGObservable (nsISVGValue* observable,
if (!frame)
return NS_OK;
if (frame->GetType() == nsGkAtoms::svgFilterFrame) {
UpdateGraphic();
} else if (frame->GetType() == nsGkAtoms::svgMarkerFrame) {
if (frame->GetType() == nsGkAtoms::svgMarkerFrame) {
if (aModType == nsISVGValue::mod_die)
RemoveMarkerObserver(NS_STATIC_CAST(nsSVGMarkerProperty *,
GetProperty(nsGkAtoms::marker)),

View File

@ -81,15 +81,6 @@ nsSVGTextFrame::nsSVGTextFrame(nsStyleContext* aContext)
{
}
//----------------------------------------------------------------------
// nsISupports methods
NS_INTERFACE_MAP_BEGIN(nsSVGTextFrame)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_END_INHERITING(nsSVGTextFrameBase)
//----------------------------------------------------------------------
// nsIFrame methods
@ -139,28 +130,6 @@ nsSVGTextFrame::GetType() const
return nsGkAtoms::svgTextFrame;
}
//----------------------------------------------------------------------
// nsISVGValueObserver methods:
NS_IMETHODIMP
nsSVGTextFrame::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::WillModifyEffects(this, observable, aModType);
return NS_OK;
}
NS_IMETHODIMP
nsSVGTextFrame::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsSVGUtils::DidModifyEffects(this, observable, aModType);
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGTextContentMetrics
NS_IMETHODIMP

View File

@ -40,26 +40,16 @@
#define NS_SVGTEXTFRAME_H
#include "nsSVGTextContainerFrame.h"
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
typedef nsSVGTextContainerFrame nsSVGTextFrameBase;
class nsSVGTextFrame : public nsSVGTextFrameBase,
public nsISVGValueObserver,
public nsSupportsWeakReference
class nsSVGTextFrame : public nsSVGTextFrameBase
{
friend nsIFrame*
NS_NewSVGTextFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
protected:
nsSVGTextFrame(nsStyleContext* aContext);
// nsISupports interface:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
public:
// nsIFrame:
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
@ -82,15 +72,6 @@ public:
}
#endif
// nsISVGValueObserver
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
// nsISupportsWeakReference
// implementation inherited from nsSupportsWeakReference
// nsISVGChildFrame interface:
NS_IMETHOD SetMatrixPropagation(PRBool aPropagate);
NS_IMETHOD SetOverrideCTM(nsIDOMSVGMatrix *aCTM);

View File

@ -80,12 +80,123 @@
#include "gfxRect.h"
#include "gfxImageSurface.h"
#include "gfxMatrix.h"
#include "nsStubMutationObserver.h"
struct nsSVGFilterProperty {
nsRect mFilterRect;
class nsSVGFilterProperty : public nsStubMutationObserver {
public:
nsSVGFilterProperty(nsISVGFilterFrame *aFilter, nsIFrame *aFrame);
nsRect GetRect() { return mFilterRect; }
nsISVGFilterFrame *GetFilterFrame() { return mFilter; }
void RemoveMutationObserver();
// nsISupports
NS_DECL_ISUPPORTS
// nsIMutationObserver
virtual void AttributeChanged(nsIDocument* aDocument, nsIContent* aContent,
PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRInt32 aModType);
virtual void ContentAppended(nsIDocument* aDocument, nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer,
nsIContent* aChild, PRInt32 aIndexInContainer);
virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer,
nsIContent* aChild, PRInt32 aIndexInContainer);
virtual void NodeWillBeDestroyed(const nsINode *aNode);
private:
void DoUpdate();
nsWeakPtr mObservedFilter;
nsISVGFilterFrame *mFilter;
nsIFrame *mFrame; // frame being filtered
nsRect mFilterRect;
};
NS_IMPL_ISUPPORTS1(nsSVGFilterProperty, nsIMutationObserver)
nsSVGFilterProperty::nsSVGFilterProperty(nsISVGFilterFrame *aFilter,
nsIFrame *aFrame)
: mFilter(aFilter), mFrame(aFrame)
{
mFilterRect = mFilter->GetInvalidationRegion(mFrame);
nsIFrame *filter = nsnull;
CallQueryInterface(mFilter, &filter);
nsCOMPtr<nsIContent> filterContent = filter->GetContent();
mObservedFilter = do_GetWeakReference(filterContent);
filterContent->AddMutationObserver(this);
}
void
nsSVGFilterProperty::RemoveMutationObserver()
{
nsCOMPtr<nsIContent> filter = do_QueryReferent(mObservedFilter);
if (filter)
filter->RemoveMutationObserver(this);
}
void
nsSVGFilterProperty::DoUpdate()
{
nsSVGOuterSVGFrame *outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(mFrame);
if (outerSVGFrame) {
outerSVGFrame->InvalidateRect(mFilterRect);
mFilterRect = mFilter->GetInvalidationRegion(mFrame);
outerSVGFrame->InvalidateRect(mFilterRect);
}
}
void
nsSVGFilterProperty::AttributeChanged(nsIDocument *aDocument,
nsIContent *aContent,
PRInt32 aNameSpaceID,
nsIAtom *aAttribute,
PRInt32 aModType)
{
DoUpdate();
}
void
nsSVGFilterProperty::ContentAppended(nsIDocument *aDocument,
nsIContent *aContainer,
PRInt32 aNewIndexInContainer)
{
DoUpdate();
}
void
nsSVGFilterProperty::ContentInserted(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
PRInt32 aIndexInContainer)
{
DoUpdate();
}
void
nsSVGFilterProperty::ContentRemoved(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
PRInt32 aIndexInContainer)
{
DoUpdate();
}
void
nsSVGFilterProperty::NodeWillBeDestroyed(const nsINode *aNode)
{
nsSVGOuterSVGFrame *outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(mFrame);
if (outerSVGFrame)
outerSVGFrame->InvalidateRect(mFilterRect);
mFrame->RemoveStateBits(NS_STATE_SVG_FILTERED);
mFrame->DeleteProperty(nsGkAtoms::filter);
}
cairo_surface_t *nsSVGUtils::mCairoComputationalSurface = nsnull;
gfxASurface *nsSVGUtils::mThebesComputationalSurface = nsnull;
@ -415,7 +526,7 @@ nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame)
nsSVGFilterProperty *property;
property = NS_STATIC_CAST(nsSVGFilterProperty *,
aFrame->GetProperty(nsGkAtoms::filter));
rect = property->mFilterRect;
rect = property->GetRect();
}
aFrame = aFrame->GetParent();
}
@ -648,27 +759,6 @@ nsSVGUtils::RemoveObserver(nsISupports *aObserver, nsISupports *aTarget)
// ************************************************************
// Effect helper functions
static void
FilterPropertyDtor(void *aObject, nsIAtom *aPropertyName,
void *aPropertyValue, void *aData)
{
nsSVGFilterProperty *property = NS_STATIC_CAST(nsSVGFilterProperty *,
aPropertyValue);
nsSVGUtils::RemoveObserver(NS_STATIC_CAST(nsIFrame *, aObject),
property->mFilter);
delete property;
}
static void
InvalidateFilterRegion(nsIFrame *aFrame)
{
nsSVGOuterSVGFrame *outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(aFrame);
if (outerSVGFrame) {
nsRect rect = nsSVGUtils::FindFilterInvalidation(aFrame);
outerSVGFrame->InvalidateRect(rect);
}
}
static void
AddEffectProperties(nsIFrame *aFrame)
{
@ -678,15 +768,15 @@ AddEffectProperties(nsIFrame *aFrame)
nsISVGFilterFrame *filter;
NS_GetSVGFilterFrame(&filter, style->mFilter, aFrame->GetContent());
if (filter) {
nsSVGUtils::AddObserver(aFrame, filter);
nsSVGFilterProperty *property = new nsSVGFilterProperty;
nsSVGFilterProperty *property = new nsSVGFilterProperty(filter, aFrame);
if (!property) {
NS_ERROR("Could not create filter property");
return;
}
property->mFilter = filter;
property->mFilterRect = filter->GetInvalidationRegion(aFrame);
aFrame->SetProperty(nsGkAtoms::filter, property, FilterPropertyDtor);
NS_ADDREF(property); // addref to allow QI - FilterPropertyDtor releases
aFrame->SetProperty(nsGkAtoms::filter,
NS_STATIC_CAST(nsISupports*, property),
nsPropertyTable::SupportsDtorFunc);
aFrame->AddStateBits(NS_STATE_SVG_FILTERED);
}
}
@ -846,7 +936,7 @@ nsSVGUtils::PaintChildWithEffects(nsSVGRenderState *aContext,
nsSVGFilterProperty *property;
property = NS_STATIC_CAST(nsSVGFilterProperty *,
aFrame->GetProperty(nsGkAtoms::filter));
property->mFilter->FilterPaint(aContext, svgChildFrame);
property->GetFilterFrame()->FilterPaint(aContext, svgChildFrame);
} else {
svgChildFrame->PaintSVG(aContext, aDirtyRect);
}
@ -901,6 +991,11 @@ nsSVGUtils::StyleEffects(nsIFrame *aFrame)
}
if (state & NS_STATE_SVG_FILTERED) {
nsSVGFilterProperty *property;
property = NS_STATIC_CAST(nsSVGFilterProperty *,
aFrame->GetProperty(nsGkAtoms::filter));
if (property)
property->RemoveMutationObserver();
aFrame->DeleteProperty(nsGkAtoms::filter);
}
@ -913,34 +1008,6 @@ nsSVGUtils::StyleEffects(nsIFrame *aFrame)
NS_STATE_SVG_MASKED);
}
void
nsSVGUtils::WillModifyEffects(nsIFrame *aFrame, nsISVGValue *observable,
nsISVGValue::modificationType aModType)
{
nsISVGFilterFrame *filter;
CallQueryInterface(observable, &filter);
if (filter)
InvalidateFilterRegion(aFrame);
}
void
nsSVGUtils::DidModifyEffects(nsIFrame *aFrame, nsISVGValue *observable,
nsISVGValue::modificationType aModType)
{
nsISVGFilterFrame *filter;
CallQueryInterface(observable, &filter);
if (filter) {
InvalidateFilterRegion(aFrame);
if (aModType == nsISVGValue::mod_die) {
aFrame->DeleteProperty(nsGkAtoms::filter);
aFrame->RemoveStateBits(NS_STATE_SVG_FILTERED);
}
}
}
PRBool
nsSVGUtils::HitTestClip(nsIFrame *aFrame, float x, float y)
{

View File

@ -252,16 +252,6 @@ public:
static void
StyleEffects(nsIFrame *aFrame);
/* Modification events for effects (filter/clip/mask/opacity) - call
* when observers on effects get called to make sure properties stay
* in sync. */
static void
WillModifyEffects(nsIFrame *aFrame, nsISVGValue *observable,
nsISVGValue::modificationType aModType);
static void
DidModifyEffects(nsIFrame *aFrame, nsISVGValue *observable,
nsISVGValue::modificationType aModType);
/* Hit testing - check if point hits the clipPath of indicated
* frame. Returns true of no clipPath set. */