From deb230db9381f2ab2b0534a2433d08180f3be77f Mon Sep 17 00:00:00 2001 From: "tor%cs.brown.edu" Date: Thu, 2 Mar 2006 20:22:19 +0000 Subject: [PATCH] Bug 301628 - first pass at removal of svg observer mechanism. r=scooter/jwatt, sr=roc git-svn-id: svn://10.0.0.236/trunk@191604 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/svg/content/src/nsSVGElement.cpp | 12 +- .../content/svg/content/src/nsSVGElement.h | 2 + .../layout/svg/base/src/nsSVGCircleFrame.cpp | 57 +++---- .../layout/svg/base/src/nsSVGDefsFrame.cpp | 75 +++------ mozilla/layout/svg/base/src/nsSVGDefsFrame.h | 21 +-- .../layout/svg/base/src/nsSVGEllipseFrame.cpp | 55 +++---- .../layout/svg/base/src/nsSVGFilterFrame.cpp | 8 +- .../svg/base/src/nsSVGForeignObjectFrame.cpp | 58 +++---- .../svg/base/src/nsSVGForeignObjectFrame.h | 6 +- mozilla/layout/svg/base/src/nsSVGGFrame.cpp | 11 +- mozilla/layout/svg/base/src/nsSVGGFrame.h | 11 +- .../layout/svg/base/src/nsSVGImageFrame.cpp | 62 +++----- .../svg/base/src/nsSVGInnerSVGFrame.cpp | 29 +--- .../layout/svg/base/src/nsSVGLineFrame.cpp | 58 +++---- .../layout/svg/base/src/nsSVGMarkerFrame.cpp | 75 ++++----- .../layout/svg/base/src/nsSVGMaskFrame.cpp | 17 -- .../svg/base/src/nsSVGOuterSVGFrame.cpp | 140 +---------------- .../layout/svg/base/src/nsSVGPathFrame.cpp | 36 ++--- .../svg/base/src/nsSVGPathGeometryFrame.cpp | 32 +--- .../svg/base/src/nsSVGPathGeometryFrame.h | 1 - .../layout/svg/base/src/nsSVGPatternFrame.cpp | 4 +- .../layout/svg/base/src/nsSVGPolygonFrame.cpp | 38 ++--- .../svg/base/src/nsSVGPolylineFrame.cpp | 39 ++--- .../layout/svg/base/src/nsSVGRectFrame.cpp | 65 +++----- .../layout/svg/base/src/nsSVGTSpanFrame.cpp | 130 ++-------------- mozilla/layout/svg/base/src/nsSVGTSpanFrame.h | 22 +-- .../layout/svg/base/src/nsSVGTextFrame.cpp | 146 ++++-------------- .../svg/base/src/nsSVGTextPathFrame.cpp | 69 +++++++-- mozilla/layout/svg/base/src/nsSVGUseFrame.cpp | 41 ++++- 29 files changed, 416 insertions(+), 904 deletions(-) diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index 2566d2487b4..bba15233278 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -68,7 +68,7 @@ #include "nsIEventListenerManager.h" nsSVGElement::nsSVGElement(nsINodeInfo *aNodeInfo) - : nsGenericElement(aNodeInfo) + : nsGenericElement(aNodeInfo), mSuppressNotification(PR_FALSE) { } @@ -186,6 +186,11 @@ nsSVGElement::ParseAttribute(PRInt32 aNamespaceID, } 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 @@ -207,6 +212,7 @@ nsSVGElement::ParseAttribute(PRInt32 aNamespaceID, else { aResult.SetTo(svg_value); } + mSuppressNotification = PR_FALSE; return PR_TRUE; } @@ -532,6 +538,10 @@ nsSVGElement::DidModifySVGObservable(nsISVGValue* aObservable, if (aModType == nsISVGValue::mod_context) return NS_OK; + // Return without setting DOM attribute + if (mSuppressNotification) + return NS_OK; + PRUint32 i, count = mMappedAttributes.AttrCount(); const nsAttrValue* attrValue = nsnull; for (i = 0; i < count; ++i) { diff --git a/mozilla/content/svg/content/src/nsSVGElement.h b/mozilla/content/svg/content/src/nsSVGElement.h index 2bc213e52cb..f7643683b81 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.h +++ b/mozilla/content/svg/content/src/nsSVGElement.h @@ -136,6 +136,8 @@ protected: nsCOMPtr mContentStyleRule; nsAttrAndChildArray mMappedAttributes; + + PRPackedBool mSuppressNotification; }; /** diff --git a/mozilla/layout/svg/base/src/nsSVGCircleFrame.cpp b/mozilla/layout/svg/base/src/nsSVGCircleFrame.cpp index 0786a491925..ab432914399 100644 --- a/mozilla/layout/svg/base/src/nsSVGCircleFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGCircleFrame.cpp @@ -43,9 +43,10 @@ #include "nsIDOMSVGCircleElement.h" #include "nsIDOMSVGElement.h" #include "nsIDOMSVGSVGElement.h" -//#include "nsASVGPathBuilder.h" #include "nsISVGRendererPathBuilder.h" #include "nsLayoutAtoms.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" class nsSVGCircleFrame : public nsSVGPathGeometryFrame { @@ -53,7 +54,6 @@ protected: friend nsIFrame* NS_NewSVGCircleFrame(nsIPresShell* aPresShell, nsIContent* aContent); - virtual ~nsSVGCircleFrame(); NS_IMETHOD InitSVG(); public: @@ -71,9 +71,10 @@ public: } #endif - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); @@ -101,17 +102,6 @@ NS_NewSVGCircleFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGCircleFrame; } -nsSVGCircleFrame::~nsSVGCircleFrame() -{ - nsCOMPtr value; - if (mCx && (value = do_QueryInterface(mCx))) - value->RemoveObserver(this); - if (mCy && (value = do_QueryInterface(mCy))) - value->RemoveObserver(this); - if (mR && (value = do_QueryInterface(mR))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGCircleFrame::InitSVG() { @@ -128,31 +118,22 @@ nsSVGCircleFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mCx)); NS_ASSERTION(mCx, "no cx"); if (!mCx) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mCx); - if (value) - value->AddObserver(this); } { nsCOMPtr length; circle->GetCy(getter_AddRefs(length)); length->GetAnimVal(getter_AddRefs(mCy)); - NS_ASSERTION(mCx, "no cy"); - if (!mCx) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mCy); - if (value) - value->AddObserver(this); + NS_ASSERTION(mCy, "no cy"); + if (!mCy) return NS_ERROR_FAILURE; } { nsCOMPtr length; circle->GetR(getter_AddRefs(length)); length->GetAnimVal(getter_AddRefs(mR)); - NS_ASSERTION(mCx, "no r"); - if (!mCx) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mR); - if (value) - value->AddObserver(this); + NS_ASSERTION(mR, "no r"); + if (!mR) return NS_ERROR_FAILURE; } return NS_OK; @@ -165,19 +146,23 @@ nsSVGCircleFrame::GetType() const } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsIFrame methods: NS_IMETHODIMP -nsSVGCircleFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGCircleFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && (mCx==l || mCy==l || mR==l)) { + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::cx || + aAttribute == nsGkAtoms::cy || + aAttribute == nsGkAtoms::r)) { UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); return NS_OK; } - // else - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } diff --git a/mozilla/layout/svg/base/src/nsSVGDefsFrame.cpp b/mozilla/layout/svg/base/src/nsSVGDefsFrame.cpp index e0a1cb50937..b733b1a325c 100644 --- a/mozilla/layout/svg/base/src/nsSVGDefsFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGDefsFrame.cpp @@ -47,6 +47,8 @@ #include "nsIDOMSVGTransformList.h" #include "nsSVGDefsFrame.h" #include "nsSVGUtils.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" //---------------------------------------------------------------------- // Implementation @@ -57,37 +59,11 @@ NS_NewSVGDefsFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGDefsFrame; } -nsSVGDefsFrame::nsSVGDefsFrame() -{ -} - -nsSVGDefsFrame::~nsSVGDefsFrame() -{ - nsCOMPtr transformable = do_QueryInterface(mContent); - if (!transformable) - return; - - nsCOMPtr transforms; - transformable->GetTransform(getter_AddRefs(transforms)); - nsCOMPtr value = do_QueryInterface(transforms); - NS_ASSERTION(value, "interface not found"); - if (value) - value->RemoveObserver(this); -} - +// Stub method specialized by subclasses. Not called by said +// specializations. NS_IMETHODIMP nsSVGDefsFrame::InitSVG() { - nsCOMPtr transformable = do_QueryInterface(mContent); - if (!transformable) - return NS_OK; - - nsCOMPtr transforms; - transformable->GetTransform(getter_AddRefs(transforms)); - nsCOMPtr value = do_QueryInterface(transforms); - NS_ASSERTION(value, "interface not found"); - if (value) - value->AddObserver(this); return NS_OK; } @@ -97,8 +73,6 @@ nsSVGDefsFrame::InitSVG() NS_INTERFACE_MAP_BEGIN(nsSVGDefsFrame) NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame) NS_INTERFACE_MAP_ENTRY(nsISVGContainerFrame) - NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) - NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver) NS_INTERFACE_MAP_END_INHERITING(nsSVGDefsFrameBase) @@ -195,34 +169,27 @@ nsSVGDefsFrame::IsFrameOfType(PRUint32 aFlags) const return !(aFlags & ~nsIFrame::eSVG); } -//---------------------------------------------------------------------- -// nsISVGValueObserver methods: - NS_IMETHODIMP -nsSVGDefsFrame::WillModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGDefsFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - return NS_OK; -} + if (aNameSpaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::transform) { + // make sure our cached transform matrix gets (lazily) updated + mCanvasTM = nsnull; - -NS_IMETHODIMP -nsSVGDefsFrame::DidModifySVGObservable (nsISVGValue* observable, - nsISVGValue::modificationType aModType) -{ - // make sure our cached transform matrix gets (lazily) updated - mCanvasTM = nsnull; + for (nsIFrame* kid = mFrames.FirstChild(); kid; + kid = kid->GetNextSibling()) { + nsISVGChildFrame* SVGFrame=nsnull; + kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); + if (SVGFrame) + SVGFrame->NotifyCanvasTMChanged(PR_FALSE); + } + } - for (nsIFrame* kid = mFrames.FirstChild(); kid; - kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame=nsnull; - kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); - if (SVGFrame) - SVGFrame->NotifyCanvasTMChanged(PR_FALSE); - } - return NS_OK; -} - + return NS_OK; + } //---------------------------------------------------------------------- // nsISVGChildFrame methods diff --git a/mozilla/layout/svg/base/src/nsSVGDefsFrame.h b/mozilla/layout/svg/base/src/nsSVGDefsFrame.h index 51f11340cf6..59fb7aa4ad6 100644 --- a/mozilla/layout/svg/base/src/nsSVGDefsFrame.h +++ b/mozilla/layout/svg/base/src/nsSVGDefsFrame.h @@ -42,23 +42,17 @@ #include "nsContainerFrame.h" #include "nsISVGChildFrame.h" #include "nsISVGContainerFrame.h" -#include "nsISVGValueObserver.h" -#include "nsWeakReference.h" #include "nsLayoutAtoms.h" typedef nsContainerFrame nsSVGDefsFrameBase; class nsSVGDefsFrame : public nsSVGDefsFrameBase, public nsISVGChildFrame, - public nsISVGContainerFrame, - public nsISVGValueObserver, - public nsSupportsWeakReference + public nsISVGContainerFrame { friend nsIFrame* NS_NewSVGDefsFrame(nsIPresShell* aPresShell, nsIContent* aContent); protected: - nsSVGDefsFrame(); - virtual ~nsSVGDefsFrame(); NS_IMETHOD InitSVG(); // nsISupports interface: @@ -81,6 +75,10 @@ public: nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow); + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); + /** * Get the "type" of the frame * @@ -96,15 +94,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(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectTwips, diff --git a/mozilla/layout/svg/base/src/nsSVGEllipseFrame.cpp b/mozilla/layout/svg/base/src/nsSVGEllipseFrame.cpp index 7194c903d46..d311a89dd0b 100644 --- a/mozilla/layout/svg/base/src/nsSVGEllipseFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGEllipseFrame.cpp @@ -46,14 +46,14 @@ #include "nsIDOMSVGSVGElement.h" #include "nsISVGRendererPathBuilder.h" #include "nsLayoutAtoms.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" class nsSVGEllipseFrame : public nsSVGPathGeometryFrame { friend nsIFrame* NS_NewSVGEllipseFrame(nsIPresShell* aPresShell, nsIContent* aContent); - virtual ~nsSVGEllipseFrame(); - NS_IMETHOD InitSVG(); /** @@ -70,9 +70,10 @@ class nsSVGEllipseFrame : public nsSVGPathGeometryFrame } #endif - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); @@ -100,19 +101,6 @@ NS_NewSVGEllipseFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGEllipseFrame; } -nsSVGEllipseFrame::~nsSVGEllipseFrame() -{ - nsCOMPtr value; - if (mCx && (value = do_QueryInterface(mCx))) - value->RemoveObserver(this); - if (mCy && (value = do_QueryInterface(mCy))) - value->RemoveObserver(this); - if (mRx && (value = do_QueryInterface(mRx))) - value->RemoveObserver(this); - if (mRy && (value = do_QueryInterface(mRy))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGEllipseFrame::InitSVG() { @@ -128,9 +116,6 @@ nsSVGEllipseFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mCx)); NS_ASSERTION(mCx, "no cx"); if (!mCx) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mCx); - if (value) - value->AddObserver(this); } { @@ -139,9 +124,6 @@ nsSVGEllipseFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mCy)); NS_ASSERTION(mCy, "no cy"); if (!mCy) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mCy); - if (value) - value->AddObserver(this); } { @@ -150,9 +132,6 @@ nsSVGEllipseFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mRx)); NS_ASSERTION(mRx, "no rx"); if (!mRx) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mRx); - if (value) - value->AddObserver(this); } { @@ -161,9 +140,6 @@ nsSVGEllipseFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mRy)); NS_ASSERTION(mRy, "no ry"); if (!mRy) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mRy); - if (value) - value->AddObserver(this); } return NS_OK; @@ -176,19 +152,24 @@ nsSVGEllipseFrame::GetType() const } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsIFrame methods: NS_IMETHODIMP -nsSVGEllipseFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGEllipseFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && (mCx==l || mCy==l || mRx==l || mRy==l)) { + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::cx || + aAttribute == nsGkAtoms::cy || + aAttribute == nsGkAtoms::rx || + aAttribute == nsGkAtoms::ry)) { UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); return NS_OK; } - // else - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/svg/base/src/nsSVGFilterFrame.cpp b/mozilla/layout/svg/base/src/nsSVGFilterFrame.cpp index d36b23786b2..ef9c5278223 100644 --- a/mozilla/layout/svg/base/src/nsSVGFilterFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGFilterFrame.cpp @@ -61,10 +61,14 @@ #include "nsSVGPoint.h" #include "nsIDOMSVGAnimatedInteger.h" #include "nsSVGUtils.h" +#include "nsISVGValueObserver.h" +#include "nsWeakReference.h" class nsSVGFilterFrame : public nsSVGDefsFrame, public nsSVGValue, - public nsISVGFilterFrame + public nsISVGFilterFrame, + public nsISVGValueObserver, + public nsSupportsWeakReference { protected: friend nsIFrame* @@ -121,6 +125,8 @@ 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(nsSupportsWeakReference) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue) NS_INTERFACE_MAP_END_INHERITING(nsSVGDefsFrame) diff --git a/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp b/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp index 4b66881170d..6a59982c346 100644 --- a/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp @@ -64,6 +64,8 @@ #include "nsSVGPoint.h" #include "nsSVGRect.h" #include "nsSVGMatrix.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" //---------------------------------------------------------------------- // Implementation @@ -91,24 +93,6 @@ nsSVGForeignObjectFrame::nsSVGForeignObjectFrame() nsSVGForeignObjectFrame::~nsSVGForeignObjectFrame() { -// nsCOMPtr transformable = do_QueryInterface(mContent); -// NS_ASSERTION(transformable, "wrong content element"); -// nsCOMPtr transforms; -// transformable->GetTransform(getter_AddRefs(transforms)); -// nsCOMPtr value = do_QueryInterface(transforms); -// NS_ASSERTION(value, "interface not found"); -// if (value) -// value->RemoveObserver(this); - nsCOMPtr value; - if (mX && (value = do_QueryInterface(mX))) - value->RemoveObserver(this); - if (mY && (value = do_QueryInterface(mY))) - value->RemoveObserver(this); - if (mWidth && (value = do_QueryInterface(mWidth))) - value->RemoveObserver(this); - if (mHeight && (value = do_QueryInterface(mHeight))) - value->RemoveObserver(this); - if (mFilter) { NS_REMOVE_SVGVALUE_OBSERVER(mFilter); } @@ -125,9 +109,6 @@ nsresult nsSVGForeignObjectFrame::Init() length->GetAnimVal(getter_AddRefs(mX)); NS_ASSERTION(mX, "no x"); if (!mX) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mX); - if (value) - value->AddObserver(this); } { @@ -136,9 +117,6 @@ nsresult nsSVGForeignObjectFrame::Init() length->GetAnimVal(getter_AddRefs(mY)); NS_ASSERTION(mY, "no y"); if (!mY) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mY); - if (value) - value->AddObserver(this); } { @@ -147,9 +125,6 @@ nsresult nsSVGForeignObjectFrame::Init() length->GetAnimVal(getter_AddRefs(mWidth)); NS_ASSERTION(mWidth, "no width"); if (!mWidth) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mWidth); - if (value) - value->AddObserver(this); } { @@ -158,21 +133,8 @@ nsresult nsSVGForeignObjectFrame::Init() length->GetAnimVal(getter_AddRefs(mHeight)); NS_ASSERTION(mHeight, "no height"); if (!mHeight) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mHeight); - if (value) - value->AddObserver(this); } -// XXX -// nsCOMPtr transformable = do_QueryInterface(mContent); -// NS_ASSERTION(transformable, "wrong content element"); -// nsCOMPtr transforms; -// transformable->GetTransform(getter_AddRefs(transforms)); -// nsCOMPtr value = do_QueryInterface(transforms); -// NS_ASSERTION(value, "interface not found"); -// if (value) -// value->AddObserver(this); - // XXX for some reason updating fails when done here. Why is this too early? // anyway - we use a less desirable mechanism now of updating in paint(). // Update(); @@ -294,6 +256,22 @@ nsSVGForeignObjectFrame::IsFrameOfType(PRUint32 aFlags) const return !(aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGForeignObject)); } +NS_IMETHODIMP +nsSVGForeignObjectFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) +{ + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::x || + aAttribute == nsGkAtoms::y || + aAttribute == nsGkAtoms::width || + aAttribute == nsGkAtoms::height || + aAttribute == nsGkAtoms::transform)) + Update(); + + return NS_OK; +} + //---------------------------------------------------------------------- // nsISVGValueObserver methods: diff --git a/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.h b/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.h index d0d0046e5be..6fe1ecece65 100644 --- a/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.h +++ b/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.h @@ -92,7 +92,11 @@ public: NS_IMETHOD RemoveFrame(nsIAtom* aListName, nsIFrame* aOldFrame); - + + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); + /** * Get the "type" of the frame * diff --git a/mozilla/layout/svg/base/src/nsSVGGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGFrame.cpp index 881aa330405..287b0c03a60 100644 --- a/mozilla/layout/svg/base/src/nsSVGGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGFrame.cpp @@ -52,6 +52,11 @@ #include "nsISVGValueUtils.h" #include "nsSVGMaskFrame.h" +NS_INTERFACE_MAP_BEGIN(nsSVGGFrame) + NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver) + NS_INTERFACE_MAP_ENTRY(nsSupportsWeakReference) +NS_INTERFACE_MAP_END_INHERITING(nsSVGDefsFrame) + //---------------------------------------------------------------------- // Implementation @@ -336,11 +341,9 @@ nsSVGGFrame::WillModifySVGObservable(nsISVGValue* observable, nsCOMPtr region; nsSVGUtils::FindFilterInvalidation(this, getter_AddRefs(region)); outerSVGFrame->InvalidateRegion(region, PR_TRUE); - - return NS_OK; } - return nsSVGGFrameBase::WillModifySVGObservable(observable, aModType); + return NS_OK; } NS_IMETHODIMP @@ -370,5 +373,5 @@ nsSVGGFrame::DidModifySVGObservable(nsISVGValue* observable, outerSVGFrame->InvalidateRegion(region, PR_TRUE); } - return nsSVGGFrameBase::DidModifySVGObservable(observable, aModType); + return NS_OK; } diff --git a/mozilla/layout/svg/base/src/nsSVGGFrame.h b/mozilla/layout/svg/base/src/nsSVGGFrame.h index e478730af5c..4de893e274c 100644 --- a/mozilla/layout/svg/base/src/nsSVGGFrame.h +++ b/mozilla/layout/svg/base/src/nsSVGGFrame.h @@ -40,12 +40,16 @@ #define NSSVGGFRAME_H #include "nsSVGDefsFrame.h" +#include "nsISVGValueObserver.h" +#include "nsWeakReference.h" typedef nsSVGDefsFrame nsSVGGFrameBase; class nsISVGFilterFrame; -class nsSVGGFrame : public nsSVGGFrameBase +class nsSVGGFrame : public nsSVGGFrameBase, + public nsISVGValueObserver, + public nsSupportsWeakReference { public: nsSVGGFrame() : mFilter(nsnull), mPropagateTransform(PR_TRUE) {} @@ -67,6 +71,11 @@ 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); diff --git a/mozilla/layout/svg/base/src/nsSVGImageFrame.cpp b/mozilla/layout/svg/base/src/nsSVGImageFrame.cpp index cbeea303f65..468bc3fef4c 100644 --- a/mozilla/layout/svg/base/src/nsSVGImageFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGImageFrame.cpp @@ -59,6 +59,8 @@ #include "nsSVGFilterFrame.h" #include "nsSVGUtils.h" #include "nsSVGMaskFrame.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" #define NS_GET_BIT(rowptr, x) (rowptr[(x)>>3] & (1<<(7-(x)&0x7))) @@ -91,9 +93,10 @@ protected: NS_IMETHOD InitSVG(); public: - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); @@ -157,18 +160,6 @@ NS_NewSVGImageFrame(nsIPresShell* aPresShell, nsIContent* aContent) nsSVGImageFrame::~nsSVGImageFrame() { - nsCOMPtr value; - if (mX && (value = do_QueryInterface(mX))) - value->RemoveObserver(this); - if (mY && (value = do_QueryInterface(mY))) - value->RemoveObserver(this); - if (mWidth && (value = do_QueryInterface(mWidth))) - value->RemoveObserver(this); - if (mHeight && (value = do_QueryInterface(mHeight))) - value->RemoveObserver(this); - if (mPreserveAspectRatio && (value = do_QueryInterface(mPreserveAspectRatio))) - value->RemoveObserver(this); - // set the frame to null so we don't send messages to a dead object. if (mListener) { nsCOMPtr imageLoader = do_QueryInterface(mContent); @@ -195,9 +186,6 @@ nsSVGImageFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mX)); NS_ASSERTION(mX, "no x"); if (!mX) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mX); - if (value) - value->AddObserver(this); } { @@ -206,9 +194,6 @@ nsSVGImageFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mY)); NS_ASSERTION(mY, "no y"); if (!mY) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mY); - if (value) - value->AddObserver(this); } { @@ -217,9 +202,6 @@ nsSVGImageFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mWidth)); NS_ASSERTION(mWidth, "no width"); if (!mWidth) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mWidth); - if (value) - value->AddObserver(this); } { @@ -228,9 +210,6 @@ nsSVGImageFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mHeight)); NS_ASSERTION(mHeight, "no height"); if (!mHeight) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mHeight); - if (value) - value->AddObserver(this); } { @@ -239,9 +218,6 @@ nsSVGImageFrame::InitSVG() ratio->GetAnimVal(getter_AddRefs(mPreserveAspectRatio)); NS_ASSERTION(mHeight, "no preserveAspectRatio"); if (!mPreserveAspectRatio) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mPreserveAspectRatio); - if (value) - value->AddObserver(this); } mSurface = nsnull; @@ -257,19 +233,25 @@ nsSVGImageFrame::InitSVG() } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsIFrame methods: NS_IMETHODIMP -nsSVGImageFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGImageFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && (mX==l || mY==l || mWidth==l || mHeight==l)) { - UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); - return NS_OK; - } - // else - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::x || + aAttribute == nsGkAtoms::y || + aAttribute == nsGkAtoms::width || + aAttribute == nsGkAtoms::height || + aAttribute == nsGkAtoms::preserveAspectRatio)) { + UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); + return NS_OK; + } + + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp index 32874529848..337c851784f 100644 --- a/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp @@ -60,6 +60,7 @@ #include "nsSVGClipPathFrame.h" #include "nsSVGMaskFrame.h" #include "nsISVGRendererSurface.h" +#include "nsGkAtoms.h" typedef nsContainerFrame nsSVGInnerSVGFrameBase; @@ -98,9 +99,10 @@ public: nsStyleContext* aContext, nsIFrame* aPrevInFlow); - NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); + // We don't define an AttributeChanged method since changes to the + // 'x', 'y', 'width' and 'height' attributes of our content object + // are handled in nsSVGSVGElement::DidModifySVGObservable + /** * Get the "type" of the frame * @@ -217,9 +219,6 @@ nsresult nsSVGInnerSVGFrame::Init() length->GetAnimVal(getter_AddRefs(mX)); NS_ASSERTION(mX, "no x"); if (!mX) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mX); - if (value) - value->AddObserver(this); // nsISVGValueObserver } { @@ -228,9 +227,6 @@ nsresult nsSVGInnerSVGFrame::Init() length->GetAnimVal(getter_AddRefs(mY)); NS_ASSERTION(mY, "no y"); if (!mY) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mY); - if (value) - value->AddObserver(this); } return NS_OK; @@ -329,21 +325,6 @@ nsSVGInnerSVGFrame::RemoveFrame(nsIAtom* aListName, return result ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP -nsSVGInnerSVGFrame::AttributeChanged(PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType) -{ -#ifdef DEBUG - nsAutoString str; - aAttribute->ToString(str); - printf("** nsSVGInnerSVGFrame::AttributeChanged(%s)\n", - NS_LossyConvertUTF16toASCII(str).get()); -#endif - - return NS_OK; -} - nsIAtom * nsSVGInnerSVGFrame::GetType() const { diff --git a/mozilla/layout/svg/base/src/nsSVGLineFrame.cpp b/mozilla/layout/svg/base/src/nsSVGLineFrame.cpp index be733da6247..71a908e47ef 100644 --- a/mozilla/layout/svg/base/src/nsSVGLineFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGLineFrame.cpp @@ -47,6 +47,8 @@ #include "nsISVGRendererPathBuilder.h" #include "nsISVGMarkable.h" #include "nsLayoutAtoms.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" class nsSVGLineFrame : public nsSVGPathGeometryFrame, public nsISVGMarkable @@ -55,7 +57,6 @@ protected: friend nsIFrame* NS_NewSVGLineFrame(nsIPresShell* aPresShell, nsIContent* aContent); - virtual ~nsSVGLineFrame(); NS_IMETHOD InitSVG(); /** @@ -73,9 +74,10 @@ protected: #endif public: - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); @@ -117,19 +119,6 @@ NS_NewSVGLineFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGLineFrame; } -nsSVGLineFrame::~nsSVGLineFrame() -{ - nsCOMPtr value; - if (mX1 && (value = do_QueryInterface(mX1))) - value->RemoveObserver(this); - if (mY1 && (value = do_QueryInterface(mY1))) - value->RemoveObserver(this); - if (mX2 && (value = do_QueryInterface(mX2))) - value->RemoveObserver(this); - if (mY2 && (value = do_QueryInterface(mY2))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGLineFrame::InitSVG() { @@ -145,9 +134,6 @@ nsSVGLineFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mX1)); NS_ASSERTION(mX1, "no x1"); if (!mX1) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mX1); - if (value) - value->AddObserver(this); } { @@ -156,9 +142,6 @@ nsSVGLineFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mY1)); NS_ASSERTION(mY1, "no y1"); if (!mY1) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mY1); - if (value) - value->AddObserver(this); } { @@ -167,9 +150,6 @@ nsSVGLineFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mX2)); NS_ASSERTION(mX2, "no x2"); if (!mX2) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mX2); - if (value) - value->AddObserver(this); } { @@ -178,34 +158,36 @@ nsSVGLineFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mY2)); NS_ASSERTION(mY2, "no y2"); if (!mY2) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mY2); - if (value) - value->AddObserver(this); } return NS_OK; } +//---------------------------------------------------------------------- +// nsIFrame methods: + nsIAtom * nsSVGLineFrame::GetType() const { return nsLayoutAtoms::svgLineFrame; } -//---------------------------------------------------------------------- -// nsISVGValueObserver methods: - NS_IMETHODIMP -nsSVGLineFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGLineFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && (mX1==l || mY1==l || mX2==l || mY2==l)) { + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::x1 || + aAttribute == nsGkAtoms::y1 || + aAttribute == nsGkAtoms::x2 || + aAttribute == nsGkAtoms::y2)) { UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); return NS_OK; } - // else - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/svg/base/src/nsSVGMarkerFrame.cpp b/mozilla/layout/svg/base/src/nsSVGMarkerFrame.cpp index 5d4486ccded..bcd100bc009 100644 --- a/mozilla/layout/svg/base/src/nsSVGMarkerFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGMarkerFrame.cpp @@ -57,6 +57,8 @@ #include "nsISVGRendererCanvas.h" #include "nsSVGUtils.h" #include "nsSVGMatrix.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" class nsSVGMarkerFrame : public nsSVGDefsFrame, public nsISVGMarkerFrame @@ -65,7 +67,6 @@ protected: friend nsIFrame* NS_NewSVGMarkerFrame(nsIPresShell* aPresShell, nsIContent* aContent); - virtual ~nsSVGMarkerFrame(); NS_IMETHOD InitSVG(); public: @@ -74,9 +75,10 @@ public: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } - // nsISVGValueObserver interface: - 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 @@ -163,30 +165,9 @@ NS_GetSVGMarkerFrame(nsISVGMarkerFrame **aResult, return NS_OK; } -nsSVGMarkerFrame::~nsSVGMarkerFrame() -{ - nsCOMPtr value; - if (mRefX && (value = do_QueryInterface(mRefX))) - value->RemoveObserver(this); - if (mRefY && (value = do_QueryInterface(mRefY))) - value->RemoveObserver(this); - if (mMarkerWidth && (value = do_QueryInterface(mMarkerWidth))) - value->RemoveObserver(this); - if (mMarkerHeight && (value = do_QueryInterface(mMarkerHeight))) - value->RemoveObserver(this); - if (mOrientAngle && (value = do_QueryInterface(mOrientAngle))) - value->RemoveObserver(this); - if (mViewBox && (value = do_QueryInterface(mViewBox))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGMarkerFrame::InitSVG() { - nsresult rv = nsSVGDefsFrame::InitSVG(); - if (NS_FAILED(rv)) - return rv; - nsCOMPtr marker = do_QueryInterface(mContent); NS_ASSERTION(marker, "wrong content element"); @@ -196,9 +177,6 @@ nsSVGMarkerFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mRefX)); NS_ASSERTION(mRefX, "no RefX"); if (!mRefX) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mRefX); - if (value) - value->AddObserver(this); } { @@ -207,9 +185,6 @@ nsSVGMarkerFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mRefY)); NS_ASSERTION(mRefY, "no RefY"); if (!mRefY) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mRefY); - if (value) - value->AddObserver(this); } { @@ -218,9 +193,6 @@ nsSVGMarkerFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mMarkerWidth)); NS_ASSERTION(mMarkerWidth, "no markerWidth"); if (!mMarkerWidth) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mMarkerWidth); - if (value) - value->AddObserver(this); } { @@ -229,9 +201,6 @@ nsSVGMarkerFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mMarkerHeight)); NS_ASSERTION(mMarkerHeight, "no markerHeight"); if (!mMarkerHeight) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mMarkerHeight); - if (value) - value->AddObserver(this); } { @@ -240,9 +209,6 @@ nsSVGMarkerFrame::InitSVG() angle->GetAnimVal(getter_AddRefs(mOrientAngle)); NS_ASSERTION(mOrientAngle, "no orientAngle"); if (!mOrientAngle) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mOrientAngle); - if (value) - value->AddObserver(this); } { @@ -252,11 +218,8 @@ nsSVGMarkerFrame::InitSVG() if (rect) { rect->GetAnimVal(getter_AddRefs(mViewBox)); - NS_ASSERTION(mRefY, "no viewBox"); - if (!mRefY) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mRefY); - if (value) - value->AddObserver(this); + NS_ASSERTION(mViewBox, "no viewBox"); + if (!mViewBox) return NS_ERROR_FAILURE; } } @@ -270,14 +233,28 @@ nsSVGMarkerFrame::InitSVG() } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsIFrame methods: NS_IMETHODIMP -nsSVGMarkerFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGMarkerFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - return nsSVGDefsFrame::DidModifySVGObservable(observable, aModType); + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::refX || + aAttribute == nsGkAtoms::refY || + aAttribute == nsGkAtoms::markerWidth || + aAttribute == nsGkAtoms::markerHeight || + aAttribute == nsGkAtoms::orient || + aAttribute == nsGkAtoms::viewBox)) { + // XXX: marker frame should be a nsSVGValue and call DidModify() here + return NS_OK; + } + + return nsSVGDefsFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } + //---------------------------------------------------------------------- // nsISVGContainerFrame methods: diff --git a/mozilla/layout/svg/base/src/nsSVGMaskFrame.cpp b/mozilla/layout/svg/base/src/nsSVGMaskFrame.cpp index 020cef0a09f..40b3ca20210 100644 --- a/mozilla/layout/svg/base/src/nsSVGMaskFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGMaskFrame.cpp @@ -55,7 +55,6 @@ class nsSVGMaskFrame : public nsSVGMaskFrameBase, friend nsIFrame* NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsIContent* aContent); - virtual ~nsSVGMaskFrame(); NS_IMETHOD InitSVG(); public: @@ -141,16 +140,6 @@ NS_GetSVGMaskFrame(nsISVGMaskFrame **aResult, return NS_OK; } -nsSVGMaskFrame::~nsSVGMaskFrame() -{ - NS_REMOVE_SVGVALUE_OBSERVER(mX); - NS_REMOVE_SVGVALUE_OBSERVER(mY); - NS_REMOVE_SVGVALUE_OBSERVER(mWidth); - NS_REMOVE_SVGVALUE_OBSERVER(mHeight); - NS_REMOVE_SVGVALUE_OBSERVER(mMaskUnits); - NS_REMOVE_SVGVALUE_OBSERVER(mMaskContentUnits); -} - NS_IMETHODIMP nsSVGMaskFrame::InitSVG() { @@ -169,7 +158,6 @@ nsSVGMaskFrame::InitSVG() length->GetBaseVal(getter_AddRefs(mX)); NS_ASSERTION(mX, "no X"); if (!mX) return NS_ERROR_FAILURE; - NS_ADD_SVGVALUE_OBSERVER(mX); } { @@ -178,7 +166,6 @@ nsSVGMaskFrame::InitSVG() length->GetBaseVal(getter_AddRefs(mY)); NS_ASSERTION(mY, "no Y"); if (!mY) return NS_ERROR_FAILURE; - NS_ADD_SVGVALUE_OBSERVER(mY); } { @@ -187,7 +174,6 @@ nsSVGMaskFrame::InitSVG() length->GetBaseVal(getter_AddRefs(mWidth)); NS_ASSERTION(mWidth, "no Width"); if (!mWidth) return NS_ERROR_FAILURE; - NS_ADD_SVGVALUE_OBSERVER(mWidth); } { @@ -196,14 +182,11 @@ nsSVGMaskFrame::InitSVG() length->GetBaseVal(getter_AddRefs(mHeight)); NS_ASSERTION(mHeight, "no Height"); if (!mHeight) return NS_ERROR_FAILURE; - NS_ADD_SVGVALUE_OBSERVER(mHeight); } mask->GetMaskUnits(getter_AddRefs(mMaskUnits)); - NS_ADD_SVGVALUE_OBSERVER(mMaskUnits); mask->GetMaskContentUnits(getter_AddRefs(mMaskContentUnits)); - NS_ADD_SVGVALUE_OBSERVER(mMaskContentUnits); return NS_OK; } diff --git a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index b8d3d687fda..9de971ec66e 100644 --- a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -49,9 +49,7 @@ #include "nsISVGRendererCanvas.h" #include "nsIView.h" #include "nsIViewManager.h" -#include "nsWeakReference.h" #include "nsISVGValue.h" -#include "nsISVGValueObserver.h" #include "nsHTMLParts.h" #include "nsReflowPath.h" #include "nsISVGRenderer.h" @@ -156,15 +154,12 @@ typedef nsContainerFrame nsSVGOuterSVGFrameBase; class nsSVGOuterSVGFrame : public nsSVGOuterSVGFrameBase, public nsISVGOuterSVGFrame, public nsISVGContainerFrame, - public nsISVGValueObserver, - public nsSupportsWeakReference, public nsSVGCoordCtxProvider { friend nsIFrame* NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent); protected: nsSVGOuterSVGFrame(); - virtual ~nsSVGOuterSVGFrame(); nsresult Init(); // nsISupports interface: @@ -198,9 +193,9 @@ public: NS_IMETHOD RemoveFrame(nsIAtom* aListName, nsIFrame* aOldFrame); - NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); + // We don't define an AttributeChanged method since changes to the + // 'x', 'y', 'width' and 'height' attributes of our content object + // are handled in nsSVGSVGElement::DidModifySVGObservable nsIFrame* GetFrameForPoint(const nsPoint& aPoint); @@ -227,15 +222,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 - // nsISVGOuterSVGFrame interface: NS_IMETHOD InvalidateRegion(nsISVGRendererRegion* region, PRBool bRedraw); NS_IMETHOD IsRedrawSuspended(PRBool* isSuspended); @@ -249,7 +235,7 @@ public: // nsISVGContainerFrame interface: already_AddRefed GetCanvasTM(); already_AddRefed GetCoordContextProvider(); - + protected: // implementation helpers: void InitiateReflow(); @@ -257,9 +243,6 @@ protected: float GetPxPerTwips(); float GetTwipsPerPx(); - void AddAsWidthHeightObserver(); - void RemoveAsWidthHeightObserver(); - void CalculateAvailableSpace(nsRect *maxRect, nsRect *preferredRect, nsPresContext* aPresContext, const nsHTMLReflowState& aReflowState); @@ -302,18 +285,6 @@ nsSVGOuterSVGFrame::nsSVGOuterSVGFrame() { } -nsSVGOuterSVGFrame::~nsSVGOuterSVGFrame() -{ -#ifdef DEBUG -// printf("~nsSVGOuterSVGFrame %p\n", this); -#endif - - if (mZoomAndPan) - NS_REMOVE_SVGVALUE_OBSERVER(mZoomAndPan); - - RemoveAsWidthHeightObserver(); -} - nsresult nsSVGOuterSVGFrame::Init() { nsresult rv; @@ -348,12 +319,10 @@ nsresult nsSVGOuterSVGFrame::Init() nsIDocument* doc = mContent->GetCurrentDoc(); if (doc && doc->GetRootContent() == mContent) { SVGElement->GetZoomAndPanEnum(getter_AddRefs(mZoomAndPan)); - NS_ADD_SVGVALUE_OBSERVER(mZoomAndPan); SVGElement->GetCurrentTranslate(getter_AddRefs(mCurrentTranslate)); SVGElement->GetCurrentScaleNumber(getter_AddRefs(mCurrentScale)); } - AddAsWidthHeightObserver(); SuspendRedraw(); AddStateBits(NS_STATE_IS_OUTER_SVG); @@ -368,8 +337,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGOuterSVGFrame) NS_INTERFACE_MAP_ENTRY(nsISVGContainerFrame) NS_INTERFACE_MAP_ENTRY(nsISVGOuterSVGFrame) NS_INTERFACE_MAP_ENTRY(nsISVGSVGFrame) - NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) - NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver) NS_INTERFACE_MAP_ENTRY(nsSVGCoordCtxProvider) NS_INTERFACE_MAP_END_INHERITING(nsSVGOuterSVGFrameBase) @@ -461,11 +428,6 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext, SuspendRedraw(); - // As soon as we set the coordinate context, the width/height - // attributes might emit change-notifications. We don't want those - // right now: - RemoveAsWidthHeightObserver(); - nsCOMPtr r; NS_NewSVGRect(getter_AddRefs(r), 0, 0, preferredWidth, preferredHeight); SetCoordCtxRect(r); @@ -538,8 +500,6 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext, aStatus = NS_FRAME_COMPLETE; NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); - AddAsWidthHeightObserver(); - UnsuspendRedraw(); return NS_OK; @@ -642,22 +602,6 @@ nsSVGOuterSVGFrame::RemoveFrame(nsIAtom* aListName, return result ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP -nsSVGOuterSVGFrame::AttributeChanged(PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType) -{ -#ifdef DEBUG -// { -// nsAutoString str; -// aAttribute->ToString(str); -// printf("** nsSVGOuterSVGFrame::AttributeChanged(%s)\n", -// NS_LossyConvertUTF16toASCII(str).get()); -// } -#endif - return NS_OK; -} - MOZ_DECL_CTOR_COUNTER(nsDisplaySVG) class nsDisplaySVG : public nsDisplayItem { public: @@ -839,30 +783,6 @@ nsSVGOuterSVGFrame::IsFrameOfType(PRUint32 aFlags) const return !(aFlags & ~nsIFrame::eSVG); } -//---------------------------------------------------------------------- -// nsISVGValueObserver methods: - -NS_IMETHODIMP -nsSVGOuterSVGFrame::WillModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) -{ - return NS_OK; -} - - -NS_IMETHODIMP -nsSVGOuterSVGFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) -{ - mNeedsReflow = PR_TRUE; - if (mRedrawSuspendCount==0) { - InitiateReflow(); - } - - return NS_OK; -} - - //---------------------------------------------------------------------- // nsISVGOuterSVGFrame methods: @@ -1076,58 +996,6 @@ void nsSVGOuterSVGFrame::InitiateReflow() } -void nsSVGOuterSVGFrame::AddAsWidthHeightObserver() -{ - nsCOMPtr svgElement = do_QueryInterface(mContent); - NS_ASSERTION(svgElement, "wrong content element"); - - { - nsCOMPtr animLength; - svgElement->GetWidth(getter_AddRefs(animLength)); - NS_ASSERTION(animLength, "could not get :width"); - nsCOMPtr length; - animLength->GetAnimVal(getter_AddRefs(length)); - NS_ASSERTION(length, "could not get :width:animval"); - NS_ADD_SVGVALUE_OBSERVER(length); - } - - { - nsCOMPtr animLength; - svgElement->GetHeight(getter_AddRefs(animLength)); - NS_ASSERTION(animLength, "could not get :height"); - nsCOMPtr length; - animLength->GetAnimVal(getter_AddRefs(length)); - NS_ASSERTION(length, "could not get :height:animval"); - NS_ADD_SVGVALUE_OBSERVER(length); - } -} - -void nsSVGOuterSVGFrame::RemoveAsWidthHeightObserver() -{ - nsCOMPtr svgElement = do_QueryInterface(mContent); - NS_ASSERTION(svgElement, "wrong content element"); - - { - nsCOMPtr animLength; - svgElement->GetWidth(getter_AddRefs(animLength)); - NS_ASSERTION(animLength, "could not get :width"); - nsCOMPtr length; - animLength->GetAnimVal(getter_AddRefs(length)); - NS_ASSERTION(length, "could not get :width:animval"); - NS_REMOVE_SVGVALUE_OBSERVER(length); - } - - { - nsCOMPtr animLength; - svgElement->GetHeight(getter_AddRefs(animLength)); - NS_ASSERTION(animLength, "could not get :height"); - nsCOMPtr length; - animLength->GetAnimVal(getter_AddRefs(length)); - NS_ASSERTION(length, "could not get :height:animval"); - NS_REMOVE_SVGVALUE_OBSERVER(length); - } -} - void nsSVGOuterSVGFrame::CalculateAvailableSpace(nsRect *maxRect, nsRect *preferredRect, diff --git a/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp b/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp index 7662a2c59b3..b490afb0d6c 100644 --- a/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp @@ -49,6 +49,8 @@ #include "nsLayoutAtoms.h" #include "nsISVGPathFlatten.h" #include "nsSVGUtils.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" class nsSVGPathFrame : public nsSVGPathGeometryFrame, public nsISVGMarkable, @@ -58,13 +60,13 @@ protected: friend nsIFrame* NS_NewSVGPathFrame(nsIPresShell* aPresShell, nsIContent* aContent); - ~nsSVGPathFrame(); NS_IMETHOD InitSVG(); public: - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); @@ -121,13 +123,6 @@ NS_NewSVGPathFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGPathFrame; } -nsSVGPathFrame::~nsSVGPathFrame() -{ - nsCOMPtr value; - if (mSegments && (value = do_QueryInterface(mSegments))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGPathFrame::InitSVG() { @@ -139,27 +134,26 @@ nsSVGPathFrame::InitSVG() anim_data->GetAnimatedPathSegList(getter_AddRefs(mSegments)); NS_ASSERTION(mSegments, "no pathseglist"); if (!mSegments) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mSegments); - if (value) - value->AddObserver(this); return NS_OK; } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsISVGFrame methods: NS_IMETHODIMP -nsSVGPathFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGPathFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && mSegments==l) { + if (aNameSpaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::d) { UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); return NS_OK; } - // else - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp b/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp index 925015f3723..7a5e0bdae52 100644 --- a/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp @@ -64,6 +64,7 @@ #include "nsSVGFilterFrame.h" #include "nsSVGMaskFrame.h" #include "nsISVGRendererSurface.h" +#include "nsINameSpaceManager.h" //////////////////////////////////////////////////////////////////////// // nsSVGPathGeometryFrame @@ -84,11 +85,6 @@ nsSVGPathGeometryFrame::~nsSVGPathGeometryFrame() // printf("~nsSVGPathGeometryFrame %p\n", this); #endif - nsCOMPtr transformable = do_QueryInterface(mContent); - NS_ASSERTION(transformable, "wrong content element"); - nsCOMPtr transforms; - transformable->GetTransform(getter_AddRefs(transforms)); - NS_REMOVE_SVGVALUE_OBSERVER(transforms); if (mFillGradient) { NS_REMOVE_SVGVALUE_OBSERVER(mFillGradient); } @@ -147,17 +143,9 @@ nsSVGPathGeometryFrame::AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) { - // we don't use this notification mechanism - -#ifdef DEBUG -// printf("** nsSVGPathGeometryFrame::AttributeChanged("); -// nsAutoString str; -// aAttribute->ToString(str); -// nsCAutoString cstr; -// cstr.AssignWithConversion(str); -// printf(cstr.get()); -// printf(")\n"); -#endif + if (aNameSpaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::transform) + UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM); return NS_OK; } @@ -616,10 +604,8 @@ nsSVGPathGeometryFrame::DidModifySVGObservable (nsISVGValue* observable, } UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT); } - } else { - // No, all of our other observables update the canvastm by default - UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM); } + return NS_OK; } @@ -1027,14 +1013,6 @@ nsSVGPathGeometryFrame::GetShapeRendering(PRUint16 *aShapeRendering) NS_IMETHODIMP nsSVGPathGeometryFrame::InitSVG() { - // all path geometry frames listen in on changes to their - // corresponding content element's transform attribute: - nsCOMPtr transformable = do_QueryInterface(mContent); - NS_ASSERTION(transformable, "wrong content element"); - nsCOMPtr transforms; - transformable->GetTransform(getter_AddRefs(transforms)); - NS_ADD_SVGVALUE_OBSERVER(transforms); - // construct a pathgeometry object: nsISVGOuterSVGFrame* outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(this); if (!outerSVGFrame) { diff --git a/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.h b/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.h index fe22c911b07..7c1b703e645 100644 --- a/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.h +++ b/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.h @@ -105,7 +105,6 @@ public: #endif protected: - // nsISVGValueObserver NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable, nsISVGValue::modificationType aModType); diff --git a/mozilla/layout/svg/base/src/nsSVGPatternFrame.cpp b/mozilla/layout/svg/base/src/nsSVGPatternFrame.cpp index 99b59d3c238..6b73a81da5b 100644 --- a/mozilla/layout/svg/base/src/nsSVGPatternFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGPatternFrame.cpp @@ -91,7 +91,9 @@ static void printRect(char *msg, nsIDOMSVGRect *aRect); class nsSVGPatternFrame : public nsSVGPatternFrameBase, public nsSVGValue, - public nsISVGPattern + public nsISVGPattern, + public nsISVGValueObserver, + public nsSupportsWeakReference { protected: friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell, diff --git a/mozilla/layout/svg/base/src/nsSVGPolygonFrame.cpp b/mozilla/layout/svg/base/src/nsSVGPolygonFrame.cpp index 93ec4eeba22..d77225c65ce 100644 --- a/mozilla/layout/svg/base/src/nsSVGPolygonFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGPolygonFrame.cpp @@ -45,6 +45,8 @@ #include "nsSVGMarkerFrame.h" #include "nsLayoutAtoms.h" #include "nsSVGUtils.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" class nsSVGPolygonFrame : public nsSVGPathGeometryFrame, public nsISVGMarkable @@ -53,14 +55,13 @@ protected: friend nsIFrame* NS_NewSVGPolygonFrame(nsIPresShell* aPresShell, nsIContent* aContent); - ~nsSVGPolygonFrame(); - NS_IMETHOD InitSVG(); public: - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); @@ -114,13 +115,6 @@ NS_NewSVGPolygonFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGPolygonFrame; } -nsSVGPolygonFrame::~nsSVGPolygonFrame() -{ - nsCOMPtr value; - if (mPoints && (value = do_QueryInterface(mPoints))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGPolygonFrame::InitSVG() { @@ -132,26 +126,26 @@ nsSVGPolygonFrame::InitSVG() anim_points->GetPoints(getter_AddRefs(mPoints)); NS_ASSERTION(mPoints, "no points"); if (!mPoints) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mPoints); - if (value) - value->AddObserver(this); + return NS_OK; } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsIFrame methods: NS_IMETHODIMP -nsSVGPolygonFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGPolygonFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && mPoints==l) { + if (aNameSpaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::points) { UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); return NS_OK; } - // else - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/svg/base/src/nsSVGPolylineFrame.cpp b/mozilla/layout/svg/base/src/nsSVGPolylineFrame.cpp index 062876e1291..488f5ada723 100644 --- a/mozilla/layout/svg/base/src/nsSVGPolylineFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGPolylineFrame.cpp @@ -45,6 +45,8 @@ #include "nsSVGMarkerFrame.h" #include "nsLayoutAtoms.h" #include "nsSVGUtils.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" class nsSVGPolylineFrame : public nsSVGPathGeometryFrame, public nsISVGMarkable @@ -53,7 +55,6 @@ protected: friend nsIFrame* NS_NewSVGPolylineFrame(nsIPresShell* aPresShell, nsIContent* aContent); - virtual ~nsSVGPolylineFrame(); NS_IMETHOD InitSVG(); public: @@ -64,6 +65,7 @@ public: */ virtual nsIAtom* GetType() const; + // nsIFrame interface: #ifdef DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const { @@ -71,15 +73,13 @@ public: } #endif - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); -// virtual void ConstructPath(nsASVGPathBuilder* pathBuilder); - nsCOMPtr mPoints; // nsISVGMarkable interface @@ -114,13 +114,6 @@ NS_NewSVGPolylineFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGPolylineFrame; } -nsSVGPolylineFrame::~nsSVGPolylineFrame() -{ - nsCOMPtr value; - if (mPoints && (value = do_QueryInterface(mPoints))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGPolylineFrame::InitSVG() { @@ -132,9 +125,7 @@ nsSVGPolylineFrame::InitSVG() anim_points->GetPoints(getter_AddRefs(mPoints)); NS_ASSERTION(mPoints, "no points"); if (!mPoints) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mPoints); - if (value) - value->AddObserver(this); + return NS_OK; } @@ -145,19 +136,21 @@ nsSVGPolylineFrame::GetType() const } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsIFrame methods: NS_IMETHODIMP -nsSVGPolylineFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGPolylineFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && mPoints==l) { + if (aNameSpaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::points) { UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); return NS_OK; } - // else - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/svg/base/src/nsSVGRectFrame.cpp b/mozilla/layout/svg/base/src/nsSVGRectFrame.cpp index 7b9aa14a988..1f9e39feb11 100644 --- a/mozilla/layout/svg/base/src/nsSVGRectFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGRectFrame.cpp @@ -54,17 +54,17 @@ protected: friend nsIFrame* NS_NewSVGRectFrame(nsIPresShell* aPresShell, nsIContent* aContent); - virtual ~nsSVGRectFrame(); NS_IMETHOD InitSVG(); public: - // nsISVGValueObserver interface: - NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); - // nsISVGPathGeometrySource interface: NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder); + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); + /** * Get the "type" of the frame * @@ -103,23 +103,6 @@ NS_NewSVGRectFrame(nsIPresShell* aPresShell, nsIContent* aContent) return new (aPresShell) nsSVGRectFrame; } -nsSVGRectFrame::~nsSVGRectFrame() -{ - nsCOMPtr value; - if (mX && (value = do_QueryInterface(mX))) - value->RemoveObserver(this); - if (mY && (value = do_QueryInterface(mY))) - value->RemoveObserver(this); - if (mWidth && (value = do_QueryInterface(mWidth))) - value->RemoveObserver(this); - if (mHeight && (value = do_QueryInterface(mHeight))) - value->RemoveObserver(this); - if (mRx && (value = do_QueryInterface(mRx))) - value->RemoveObserver(this); - if (mRy && (value = do_QueryInterface(mRy))) - value->RemoveObserver(this); -} - NS_IMETHODIMP nsSVGRectFrame::InitSVG() { @@ -136,9 +119,6 @@ nsSVGRectFrame::InitSVG() NS_ASSERTION(mX, "no x"); if (!mX) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mX); - if (value) - value->AddObserver(this); } { @@ -148,9 +128,6 @@ nsSVGRectFrame::InitSVG() NS_ASSERTION(mY, "no y"); if (!mY) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mY); - if (value) - value->AddObserver(this); } { @@ -160,10 +137,8 @@ nsSVGRectFrame::InitSVG() NS_ASSERTION(mWidth, "no width"); if (!mWidth) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mWidth); - if (value) - value->AddObserver(this); } + { nsCOMPtr length; Rect->GetHeight(getter_AddRefs(length)); @@ -171,9 +146,6 @@ nsSVGRectFrame::InitSVG() NS_ASSERTION(mHeight, "no height"); if (!mHeight) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mHeight); - if (value) - value->AddObserver(this); } { @@ -183,9 +155,6 @@ nsSVGRectFrame::InitSVG() NS_ASSERTION(mRx, "no rx"); if (!mRx) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mRx); - if (value) - value->AddObserver(this); } { @@ -195,28 +164,32 @@ nsSVGRectFrame::InitSVG() NS_ASSERTION(mRy, "no ry"); if (!mRy) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mRy); - if (value) - value->AddObserver(this); } return NS_OK; } //---------------------------------------------------------------------- -// nsISVGValueObserver methods: +// nsIFrame methods: NS_IMETHODIMP -nsSVGRectFrame::DidModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGRectFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { - nsCOMPtr l = do_QueryInterface(observable); - if (l && (mX==l || mY==l || mWidth==l || mHeight==l || mRx==l || mRy==l)) { + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::x || + aAttribute == nsGkAtoms::y || + aAttribute == nsGkAtoms::width || + aAttribute == nsGkAtoms::height || + aAttribute == nsGkAtoms::rx || + aAttribute == nsGkAtoms::ry)) { UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH); return NS_OK; } - return nsSVGPathGeometryFrame::DidModifySVGObservable(observable, aModType); + return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, + aAttribute, aModType); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp b/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp index 552d59d28f3..15b3f8a10cf 100644 --- a/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp @@ -71,88 +71,6 @@ nsSVGTSpanFrame::nsSVGTSpanFrame() { } -nsSVGTSpanFrame::~nsSVGTSpanFrame() -{ - nsCOMPtr element = do_QueryInterface(mContent); - - // clean up our listener refs: - if (element) { - nsCOMPtr animLengthList; - element->GetX(getter_AddRefs(animLengthList)); - if (animLengthList) { - nsCOMPtr lengthList; - animLengthList->GetAnimVal(getter_AddRefs(lengthList)); - if (lengthList) - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } - } - - if (element) { - nsCOMPtr animLengthList; - element->GetY(getter_AddRefs(animLengthList)); - if (animLengthList) { - nsCOMPtr lengthList; - animLengthList->GetAnimVal(getter_AddRefs(lengthList)); - if (lengthList) - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } - } - - { - nsCOMPtr lengthList = GetDx(); - if (lengthList) - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetDy(); - if (lengthList) - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } -} - -nsresult nsSVGTSpanFrame::InitSVG() -{ - nsCOMPtr element = do_QueryInterface(mContent); - - // set us up as a listener for various -properties: - { - nsCOMPtr animLengthList; - element->GetX(getter_AddRefs(animLengthList)); - if (animLengthList) { - nsCOMPtr lengthList; - animLengthList->GetAnimVal(getter_AddRefs(lengthList)); - if (lengthList) - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - } - - { - nsCOMPtr animLengthList; - element->GetY(getter_AddRefs(animLengthList)); - if (animLengthList) { - nsCOMPtr lengthList; - animLengthList->GetAnimVal(getter_AddRefs(lengthList)); - if (lengthList) - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - } - - { - nsCOMPtr lengthList = GetDx(); - if (lengthList) - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetDy(); - if (lengthList) - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - - return NS_OK; -} - nsIAtom * nsSVGTSpanFrame::GetType() const { @@ -173,29 +91,12 @@ NS_INTERFACE_MAP_BEGIN(nsSVGTSpanFrame) NS_INTERFACE_MAP_ENTRY(nsISVGGlyphFragmentNode) NS_INTERFACE_MAP_ENTRY(nsISVGContainerFrame) NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame) - NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) - NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver) NS_INTERFACE_MAP_ENTRY(nsISVGTextContentMetrics) NS_INTERFACE_MAP_END_INHERITING(nsSVGTSpanFrameBase) //---------------------------------------------------------------------- // nsIFrame methods -NS_IMETHODIMP -nsSVGTSpanFrame::Init(nsPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsStyleContext* aContext, - nsIFrame* aPrevInFlow) -{ - nsresult rv; - rv = nsSVGTSpanFrameBase::Init(aPresContext, aContent, aParent, - aContext, aPrevInFlow); - - InitSVG(); - - return rv; -} NS_IMETHODIMP nsSVGTSpanFrame::AppendFrames(nsIAtom* aListName, @@ -272,29 +173,24 @@ nsSVGTSpanFrame::RemoveFrame(nsIAtom* aListName, return result ? NS_OK : NS_ERROR_FAILURE; } -//---------------------------------------------------------------------- -// nsISVGValueObserver methods: - NS_IMETHODIMP -nsSVGTSpanFrame::WillModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType) +nsSVGTSpanFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) { + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::x || + aAttribute == nsGkAtoms::y || + aAttribute == nsGkAtoms::dx || + aAttribute == nsGkAtoms::dy)) { + nsISVGTextFrame* text_frame = GetTextFrame(); + if (text_frame) + text_frame->NotifyGlyphMetricsChange(this); + } + return NS_OK; } - -NS_IMETHODIMP -nsSVGTSpanFrame::DidModifySVGObservable (nsISVGValue* observable, - nsISVGValue::modificationType aModType) -{ - nsISVGTextFrame* text_frame = GetTextFrame(); - if (text_frame) - text_frame->NotifyGlyphMetricsChange(this); - - return NS_OK; -} - - //---------------------------------------------------------------------- // nsISVGTextContentMetrics NS_IMETHODIMP diff --git a/mozilla/layout/svg/base/src/nsSVGTSpanFrame.h b/mozilla/layout/svg/base/src/nsSVGTSpanFrame.h index e1f309a5c5b..6efdc15df03 100644 --- a/mozilla/layout/svg/base/src/nsSVGTSpanFrame.h +++ b/mozilla/layout/svg/base/src/nsSVGTSpanFrame.h @@ -44,9 +44,7 @@ #include "nsPresContext.h" #include "nsISVGTextContainerFrame.h" #include "nsISVGRendererCanvas.h" -#include "nsWeakReference.h" #include "nsISVGValue.h" -#include "nsISVGValueObserver.h" #include "nsIDOMSVGSVGElement.h" #include "nsIDOMSVGMatrix.h" #include "nsIDOMSVGLengthList.h" @@ -73,17 +71,13 @@ class nsSVGTSpanFrame : public nsSVGTSpanFrameBase, public nsISVGGlyphFragmentNode, public nsISVGChildFrame, public nsISVGContainerFrame, - public nsISVGValueObserver, - public nsISVGTextContentMetrics, - public nsSupportsWeakReference + public nsISVGTextContentMetrics { friend nsIFrame* NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame* parentFrame); protected: nsSVGTSpanFrame(); - virtual ~nsSVGTSpanFrame(); - virtual nsresult InitSVG(); // nsISupports interface: NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); @@ -100,11 +94,9 @@ public: nsIFrame* aFrameList); NS_IMETHOD RemoveFrame(nsIAtom* aListName, nsIFrame* aOldFrame); - NS_IMETHOD Init(nsPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsStyleContext* aContext, - nsIFrame* aPrevInFlow); + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); /** * Get the "type" of the frame @@ -121,12 +113,6 @@ public: } #endif - // nsISVGValueObserver - NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable, - nsISVGValue::modificationType aModType); - NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable, - nsISVGValue::modificationType aModType); - // nsISVGTextContentMetrics NS_IMETHOD GetNumberOfChars(PRInt32 *_retval); NS_IMETHOD GetComputedTextLength(float *_retval); diff --git a/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp b/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp index 8231b4bdcf4..8dc52efbc05 100644 --- a/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp @@ -72,6 +72,8 @@ #include "nsSVGMaskFrame.h" #include "nsSVGClipPathFrame.h" #include "nsISVGRendererSurface.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" typedef nsContainerFrame nsSVGTextFrameBase; @@ -88,7 +90,6 @@ class nsSVGTextFrame : public nsSVGTextFrameBase, protected: nsSVGTextFrame(); virtual ~nsSVGTextFrame(); - nsresult Init(); // nsISupports interface: NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); @@ -106,12 +107,6 @@ public: NS_IMETHOD RemoveFrame(nsIAtom* aListName, nsIFrame* aOldFrame); - NS_IMETHOD Init(nsPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsStyleContext* aContext, - nsIFrame* aPrevInFlow); - NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType); @@ -246,71 +241,11 @@ nsSVGTextFrame::nsSVGTextFrame() nsSVGTextFrame::~nsSVGTextFrame() { - // clean up our listener refs: - { - nsCOMPtr lengthList = GetX(); - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetY(); - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetDx(); - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetDy(); - NS_REMOVE_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr transformable = do_QueryInterface(mContent); - NS_ASSERTION(transformable, "wrong content element"); - nsCOMPtr transforms; - transformable->GetTransform(getter_AddRefs(transforms)); - NS_REMOVE_SVGVALUE_OBSERVER(transforms); - } - if (mFilter) { NS_REMOVE_SVGVALUE_OBSERVER(mFilter); } } -nsresult nsSVGTextFrame::Init() -{ - // set us up as a listener for various -properties: - { - nsCOMPtr lengthList = GetX(); - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetY(); - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetDx(); - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr lengthList = GetDy(); - NS_ADD_SVGVALUE_OBSERVER(lengthList); - } - - { - nsCOMPtr transforms = GetTransform(); - NS_ADD_SVGVALUE_OBSERVER(transforms); - } - - return NS_OK; -} - //---------------------------------------------------------------------- // nsISupports methods @@ -327,38 +262,40 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGTextFrameBase) //---------------------------------------------------------------------- // nsIFrame methods -NS_IMETHODIMP -nsSVGTextFrame::Init(nsPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsStyleContext* aContext, - nsIFrame* aPrevInFlow) -{ - nsresult rv; - rv = nsSVGTextFrameBase::Init(aPresContext, aContent, aParent, - aContext, aPrevInFlow); - - Init(); - - return rv; -} NS_IMETHODIMP nsSVGTextFrame::AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) { - // we don't use this notification mechanism - -#ifdef DEBUG - printf("** nsSVGTextFrame::AttributeChanged("); - nsAutoString str; - aAttribute->ToString(str); - printf(NS_ConvertUTF16toUTF8(str).get()); - printf(")\n"); -#endif - - return NS_OK; + if (aNameSpaceID != kNameSpaceID_None) + return NS_OK; + + if (aAttribute == nsGkAtoms::transform) { + // transform has changed + + // make sure our cached transform matrix gets (lazily) updated + mCanvasTM = nsnull; + + nsIFrame* kid = mFrames.FirstChild(); + while (kid) { + nsISVGChildFrame* SVGFrame=0; + kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); + if (SVGFrame) + SVGFrame->NotifyCanvasTMChanged(PR_FALSE); + kid = kid->GetNextSibling(); + } + } else if (aAttribute == nsGkAtoms::x || + aAttribute == nsGkAtoms::y || + aAttribute == nsGkAtoms::dx || + aAttribute == nsGkAtoms::dy) { + mPositioningDirty = PR_TRUE; + if (mMetricsState == unsuspended) { + UpdateGlyphPositioning(); + } + } + + return NS_OK; } NS_IMETHODIMP @@ -489,7 +426,6 @@ nsSVGTextFrame::DidModifySVGObservable (nsISVGValue* observable, { nsISVGFilterFrame *filter; CallQueryInterface(observable, &filter); - nsCOMPtr transforms = GetTransform(); if (filter) { if (aModType == nsISVGValue::mod_die) { @@ -509,28 +445,8 @@ nsSVGTextFrame::DidModifySVGObservable (nsISVGValue* observable, if (region) outerSVGFrame->InvalidateRegion(region, PR_TRUE); - } else if (SameCOMIdentity(observable, transforms)) { - // transform has changed + } - // make sure our cached transform matrix gets (lazily) updated - mCanvasTM = nsnull; - - nsIFrame* kid = mFrames.FirstChild(); - while (kid) { - nsISVGChildFrame* SVGFrame=0; - kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); - if (SVGFrame) - SVGFrame->NotifyCanvasTMChanged(PR_FALSE); - kid = kid->GetNextSibling(); - } - } - else { - // x, y have changed - mPositioningDirty = PR_TRUE; - if (mMetricsState == unsuspended) { - UpdateGlyphPositioning(); - } - } return NS_OK; } diff --git a/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp b/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp index 992eeba79f2..3f80c81839d 100644 --- a/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp @@ -50,14 +50,27 @@ #include "nsIDOMSVGURIReference.h" #include "nsIDOMDocument.h" #include "nsIDocument.h" +#include "nsISVGValueObserver.h" +#include "nsWeakReference.h" typedef nsSVGTSpanFrame nsSVGTextPathFrameBase; class nsSVGTextPathFrame : public nsSVGTextPathFrameBase, - public nsISVGPathFlatten + public nsISVGPathFlatten, + public nsISVGValueObserver, + public nsSupportsWeakReference { public: + // nsIFrame: + NS_IMETHOD Init(nsPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsStyleContext* aContext, + nsIFrame* aPrevInFlow); + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); /** * Get the "type" of the frame * @@ -73,6 +86,8 @@ public: #endif // nsISVGValueObserver interface: + NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable, + nsISVGValue::modificationType aModType); NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable, nsISVGValue::modificationType aModType); @@ -88,7 +103,6 @@ private: protected: virtual ~nsSVGTextPathFrame(); - virtual nsresult InitSVG(); NS_IMETHOD_(already_AddRefed) GetX(); NS_IMETHOD_(already_AddRefed) GetY(); @@ -106,6 +120,8 @@ private: NS_INTERFACE_MAP_BEGIN(nsSVGTextPathFrame) NS_INTERFACE_MAP_ENTRY(nsISVGPathFlatten) + NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver) + NS_INTERFACE_MAP_ENTRY(nsSupportsWeakReference) NS_INTERFACE_MAP_END_INHERITING(nsSVGTSpanFrame) @@ -136,14 +152,19 @@ NS_NewSVGTextPathFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsSVGTextPathFrame::~nsSVGTextPathFrame() { - NS_REMOVE_SVGVALUE_OBSERVER(mStartOffset); - NS_REMOVE_SVGVALUE_OBSERVER(mHref); NS_REMOVE_SVGVALUE_OBSERVER(mSegments); } -nsresult -nsSVGTextPathFrame::InitSVG() +NS_IMETHODIMP +nsSVGTextPathFrame::Init(nsPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsStyleContext* aContext, + nsIFrame* aPrevInFlow) { + nsSVGTextPathFrameBase::Init(aPresContext, aContent, aParent, + aContext, aPrevInFlow); + nsCOMPtr tpath = do_QueryInterface(mContent); { @@ -159,8 +180,6 @@ nsSVGTextPathFrame::InitSVG() nsCOMPtr length; mX->AppendItem(mStartOffset, getter_AddRefs(length)); } - - NS_ADD_SVGVALUE_OBSERVER(mStartOffset); } { @@ -169,7 +188,6 @@ nsSVGTextPathFrame::InitSVG() aRef->GetHref(getter_AddRefs(mHref)); if (!mHref) return NS_ERROR_FAILURE; - NS_ADD_SVGVALUE_OBSERVER(mHref); } return NS_OK; @@ -250,15 +268,42 @@ nsSVGTextPathFrame::GetFlattenedPath(nsSVGPathData **data, nsIFrame *parent) { //---------------------------------------------------------------------- // nsISVGValueObserver methods: +NS_IMETHODIMP +nsSVGTextPathFrame::WillModifySVGObservable(nsISVGValue* observable, + nsISVGValue::modificationType aModType) +{ + return NS_OK; +} + NS_IMETHODIMP nsSVGTextPathFrame::DidModifySVGObservable(nsISVGValue* observable, nsISVGValue::modificationType aModType) { - nsCOMPtr s = do_QueryInterface(observable); - if (s && mHref==s) { + nsISVGTextFrame* text_frame = GetTextFrame(); + if (text_frame) + text_frame->NotifyGlyphMetricsChange(this); + + return NS_OK; +} + +//---------------------------------------------------------------------- +// nsIFrame methods + +NS_IMETHODIMP +nsSVGTextPathFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) +{ + if (aNameSpaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::startOffset) { + nsISVGTextFrame* text_frame = GetTextFrame(); + if (text_frame) + text_frame->NotifyGlyphMetricsChange(this); + } else if (aNameSpaceID == kNameSpaceID_XLink && + aAttribute == nsGkAtoms::href) { NS_REMOVE_SVGVALUE_OBSERVER(mSegments); mSegments = nsnull; } - return nsSVGTextPathFrameBase::DidModifySVGObservable(observable, aModType); + return NS_OK; } diff --git a/mozilla/layout/svg/base/src/nsSVGUseFrame.cpp b/mozilla/layout/svg/base/src/nsSVGUseFrame.cpp index eef6b8919bc..3a0bdbafe71 100644 --- a/mozilla/layout/svg/base/src/nsSVGUseFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGUseFrame.cpp @@ -44,6 +44,8 @@ #include "nsIAnonymousContentCreator.h" #include "nsSVGMatrix.h" #include "nsLayoutAtoms.h" +#include "nsINameSpaceManager.h" +#include "nsGkAtoms.h" typedef nsSVGGFrame nsSVGUseFrameBase; @@ -64,6 +66,10 @@ private: NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } public: + // nsIFrame interface: + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // nsISVGContainerFrame interface: already_AddRefed GetCanvasTM(); @@ -126,9 +132,6 @@ nsSVGUseFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mX)); NS_ASSERTION(mX, "no x"); if (!mX) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mX); - if (value) - value->AddObserver(this); // nsISVGValueObserver } { @@ -137,9 +140,6 @@ nsSVGUseFrame::InitSVG() length->GetAnimVal(getter_AddRefs(mY)); NS_ASSERTION(mY, "no y"); if (!mY) return NS_ERROR_FAILURE; - nsCOMPtr value = do_QueryInterface(mY); - if (value) - value->AddObserver(this); } return NS_OK; @@ -158,6 +158,35 @@ NS_INTERFACE_MAP_BEGIN(nsSVGUseFrame) NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator) NS_INTERFACE_MAP_END_INHERITING(nsSVGUseFrameBase) +//---------------------------------------------------------------------- +// nsIFrame methods: + +NS_IMETHODIMP +nsSVGUseFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) +{ + if (aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::x || + aAttribute == nsGkAtoms::y)) { + // make sure our cached transform matrix gets (lazily) updated + mCanvasTM = nsnull; + + for (nsIFrame* kid = mFrames.FirstChild(); kid; + kid = kid->GetNextSibling()) { + nsISVGChildFrame* SVGFrame=nsnull; + kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); + if (SVGFrame) + SVGFrame->NotifyCanvasTMChanged(PR_FALSE); + } + return NS_OK; + } + + return nsSVGUseFrameBase::AttributeChanged(aNameSpaceID, + aAttribute, aModType); +} + + //---------------------------------------------------------------------- // nsISVGContainerFrame methods: