Bug 572689 - Allow overriding ID targets with mozSetImageElement for the BackgroundImageProperty which is used for -moz-element drawing. r=roc
authorMarkus Stange <mstange@themasta.com>
Fri, 13 Aug 2010 15:36:05 +0200
changeset 50429 8b129680a3bb80c88a90fc57aa9b1091d8f738f1
parent 50428 6876b5b6d83cceee7d8cbcc8270ebbfd92f4c957
child 50430 4a50f3c34d5ae09c27bdad9aeeebe29e4d61c043
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs572689
milestone2.0b4pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 572689 - Allow overriding ID targets with mozSetImageElement for the BackgroundImageProperty which is used for -moz-element drawing. r=roc
layout/svg/base/src/nsSVGEffects.cpp
layout/svg/base/src/nsSVGEffects.h
--- a/layout/svg/base/src/nsSVGEffects.cpp
+++ b/layout/svg/base/src/nsSVGEffects.cpp
@@ -69,26 +69,27 @@ NS_IMPL_ISUPPORTS1(nsSVGRenderingObserve
 #ifdef _MSC_VER
 // Disable "warning C4355: 'this' : used in base member initializer list".
 // We can ignore that warning because we know that mElement's constructor 
 // doesn't dereference the pointer passed to it.
 #pragma warning(push)
 #pragma warning(disable:4355)
 #endif
 nsSVGRenderingObserver::nsSVGRenderingObserver(nsIURI *aURI,
-                                               nsIFrame *aFrame)
+                                               nsIFrame *aFrame,
+                                               PRBool aReferenceImage)
   : mElement(this), mFrame(aFrame),
     mFramePresShell(aFrame->PresContext()->PresShell()),
     mInObserverList(PR_FALSE)
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
 {
   // Start watching the target element
-  mElement.Reset(aFrame->GetContent(), aURI);
+  mElement.Reset(aFrame->GetContent(), aURI, PR_TRUE, aReferenceImage);
   StartListening();
 }
 
 nsSVGRenderingObserver::~nsSVGRenderingObserver()
 {
   StopListening();
 }
 
@@ -314,45 +315,45 @@ nsSVGPaintingProperty::DoUpdate()
   if (mFrame->IsFrameOfType(nsIFrame::eSVG)) {
     nsSVGUtils::InvalidateCoveredRegion(mFrame);
   } else {
     InvalidateAllContinuations(mFrame);
   }
 }
 
 static nsSVGRenderingObserver *
-CreateFilterProperty(nsIURI *aURI, nsIFrame *aFrame)
-{ return new nsSVGFilterProperty(aURI, aFrame); }
+CreateFilterProperty(nsIURI *aURI, nsIFrame *aFrame, PRBool aReferenceImage)
+{ return new nsSVGFilterProperty(aURI, aFrame, aReferenceImage); }
 
 static nsSVGRenderingObserver *
-CreateMarkerProperty(nsIURI *aURI, nsIFrame *aFrame)
-{ return new nsSVGMarkerProperty(aURI, aFrame); }
+CreateMarkerProperty(nsIURI *aURI, nsIFrame *aFrame, PRBool aReferenceImage)
+{ return new nsSVGMarkerProperty(aURI, aFrame, aReferenceImage); }
 
 static nsSVGRenderingObserver *
-CreateTextPathProperty(nsIURI *aURI, nsIFrame *aFrame)
-{ return new nsSVGTextPathProperty(aURI, aFrame); }
+CreateTextPathProperty(nsIURI *aURI, nsIFrame *aFrame, PRBool aReferenceImage)
+{ return new nsSVGTextPathProperty(aURI, aFrame, aReferenceImage); }
 
 static nsSVGRenderingObserver *
-CreatePaintingProperty(nsIURI *aURI, nsIFrame *aFrame)
-{ return new nsSVGPaintingProperty(aURI, aFrame); }
+CreatePaintingProperty(nsIURI *aURI, nsIFrame *aFrame, PRBool aReferenceImage)
+{ return new nsSVGPaintingProperty(aURI, aFrame, aReferenceImage); }
 
 static nsSVGRenderingObserver *
 GetEffectProperty(nsIURI *aURI, nsIFrame *aFrame,
                   const FramePropertyDescriptor *aProperty,
-                  nsSVGRenderingObserver * (* aCreate)(nsIURI *, nsIFrame *))
+                  nsSVGRenderingObserver * (* aCreate)(nsIURI *, nsIFrame *, PRBool))
 {
   if (!aURI)
     return nsnull;
 
   FrameProperties props = aFrame->Properties();
   nsSVGRenderingObserver *prop =
     static_cast<nsSVGRenderingObserver*>(props.Get(aProperty));
   if (prop)
     return prop;
-  prop = aCreate(aURI, aFrame);
+  prop = aCreate(aURI, aFrame, PR_FALSE);
   if (!prop)
     return nsnull;
   NS_ADDREF(prop);
   props.Set(aProperty, static_cast<nsISupports*>(prop));
   return prop;
 }
 
 nsSVGMarkerProperty *
@@ -377,30 +378,31 @@ nsSVGEffects::GetPaintingProperty(nsIURI
 {
   return static_cast<nsSVGPaintingProperty*>(
           GetEffectProperty(aURI, aFrame, aProp, CreatePaintingProperty));
 }
 
 static nsSVGRenderingObserver *
 GetEffectPropertyForURI(nsIURI *aURI, nsIFrame *aFrame,
                         const FramePropertyDescriptor *aProperty,
-                        nsSVGRenderingObserver * (* aCreate)(nsIURI *, nsIFrame *))
+                        nsSVGRenderingObserver * (* aCreate)(nsIURI *, nsIFrame *, PRBool))
 {
   FrameProperties props = aFrame->Properties();
   nsSVGEffects::URIObserverHashtable *hashtable =
     static_cast<nsSVGEffects::URIObserverHashtable*>(props.Get(aProperty));
   if (!hashtable) {
     hashtable = new nsSVGEffects::URIObserverHashtable();
     hashtable->Init();
     props.Set(aProperty, hashtable);
   }
   nsSVGRenderingObserver* prop =
     static_cast<nsSVGRenderingObserver*>(hashtable->GetWeak(aURI));
   if (!prop) {
-    prop = aCreate(aURI, aFrame);
+    PRBool watchImage = aProperty == nsSVGEffects::BackgroundImageProperty();
+    prop = aCreate(aURI, aFrame, watchImage);
     hashtable->Put(aURI, prop);
   }
   return prop;
 }
 
 nsSVGPaintingProperty *
 nsSVGEffects::GetPaintingPropertyForURI(nsIURI *aURI, nsIFrame *aFrame,
                                         const FramePropertyDescriptor *aProp)
--- a/layout/svg/base/src/nsSVGEffects.h
+++ b/layout/svg/base/src/nsSVGEffects.h
@@ -58,17 +58,18 @@ class nsSVGMaskFrame;
  * 
  * When a frame references a supporting resource, we create a property
  * object derived from nsSVGRenderingObserver to manage the relationship. The
  * property object is attached to the referencing frame.
  */
 class nsSVGRenderingObserver : public nsStubMutationObserver {
 public:
   typedef mozilla::dom::Element Element;
-  nsSVGRenderingObserver(nsIURI* aURI, nsIFrame *aFrame);
+  nsSVGRenderingObserver(nsIURI* aURI, nsIFrame *aFrame,
+                         PRBool aReferenceImage);
   virtual ~nsSVGRenderingObserver();
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
@@ -121,18 +122,19 @@ protected:
   nsIPresShell *mFramePresShell;
   // Whether we're in our referenced element's observer list at this time.
   PRPackedBool mInObserverList;
 };
 
 class nsSVGFilterProperty :
   public nsSVGRenderingObserver, public nsISVGFilterProperty {
 public:
-  nsSVGFilterProperty(nsIURI *aURI, nsIFrame *aFilteredFrame)
-    : nsSVGRenderingObserver(aURI, aFilteredFrame) {}
+  nsSVGFilterProperty(nsIURI *aURI, nsIFrame *aFilteredFrame,
+                      PRBool aReferenceImage)
+    : nsSVGRenderingObserver(aURI, aFilteredFrame, aReferenceImage) {}
 
   /**
    * @return the filter frame, or null if there is no filter frame
    */
   nsSVGFilterFrame *GetFilterFrame();
 
   // nsISupports
   NS_DECL_ISUPPORTS
@@ -142,36 +144,36 @@ public:
 
 private:
   // nsSVGRenderingObserver
   virtual void DoUpdate();
 };
 
 class nsSVGMarkerProperty : public nsSVGRenderingObserver {
 public:
-  nsSVGMarkerProperty(nsIURI *aURI, nsIFrame *aFrame)
-    : nsSVGRenderingObserver(aURI, aFrame) {}
+  nsSVGMarkerProperty(nsIURI *aURI, nsIFrame *aFrame, PRBool aReferenceImage)
+    : nsSVGRenderingObserver(aURI, aFrame, aReferenceImage) {}
 
 protected:
   virtual void DoUpdate();
 };
 
 class nsSVGTextPathProperty : public nsSVGRenderingObserver {
 public:
-  nsSVGTextPathProperty(nsIURI *aURI, nsIFrame *aFrame)
-    : nsSVGRenderingObserver(aURI, aFrame) {}
+  nsSVGTextPathProperty(nsIURI *aURI, nsIFrame *aFrame, PRBool aReferenceImage)
+    : nsSVGRenderingObserver(aURI, aFrame, aReferenceImage) {}
 
 protected:
   virtual void DoUpdate();
 };
  
 class nsSVGPaintingProperty : public nsSVGRenderingObserver {
 public:
-  nsSVGPaintingProperty(nsIURI *aURI, nsIFrame *aFrame)
-    : nsSVGRenderingObserver(aURI, aFrame) {}
+  nsSVGPaintingProperty(nsIURI *aURI, nsIFrame *aFrame, PRBool aReferenceImage)
+    : nsSVGRenderingObserver(aURI, aFrame, aReferenceImage) {}
 
 protected:
   virtual void DoUpdate();
 };
 
 /**
  * A manager for one-shot nsSVGRenderingObserver tracking.
  * nsSVGRenderingObservers can be added or removed. They are not strongly