Bug 901955 - Get 'opacity' property changes on SVG working again. r=roc, a=bajaj
authorJonathan Watt <jwatt@jwatt.org>
Wed, 14 Aug 2013 10:51:00 +0100
changeset 148393 3dbd75529f997c473f0a6cd73d729d98c52bf21c
parent 148386 cadb54f63c80a80378717085a1966bf6b84dfb09
child 148394 f650a848cd6cf110d36671fe2410ab91efe1d261
push id2780
push userjwatt@jwatt.org
push dateTue, 20 Aug 2013 08:30:37 +0000
treeherdermozilla-beta@3dbd75529f99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, bajaj
bugs901955
milestone24.0
Bug 901955 - Get 'opacity' property changes on SVG working again. r=roc, a=bajaj
layout/reftests/svg/dynamic-opacity-property-01.svg
layout/reftests/svg/reftest.list
layout/svg/nsSVGPathGeometryFrame.cpp
layout/svg/nsSVGPathGeometryFrame.h
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/dynamic-opacity-property-01.svg
@@ -0,0 +1,25 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg" class="reftest-wait">
+
+  <title>Test repainting for opacity property changes</title>
+
+  <script>
+
+function doTest() {
+  document.getElementById("r").style.opacity = 1;
+  document.documentElement.removeAttribute("class");
+}
+
+document.addEventListener("MozReftestInvalidate", doTest, false);
+setTimeout(doTest, 4000); // fallback for running outside reftest
+
+  </script>
+
+  <rect width="100%" height="100%" fill="lime"/>
+  <rect width="100" height="100" fill="red"/>
+  <rect id="r" width="100" height="100" fill="lime" style="opacity:0.5"/>
+
+</svg>
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -84,16 +84,17 @@ skip-if(B2G) == dynamic-gradient-content
 skip-if(B2G) == dynamic-gradient-contents-02.svg pass.svg
 skip-if(B2G) == dynamic-inner-svg-01.svg pass.svg
 == dynamic-link-style-01.svg pass.svg
 skip-if(B2G) == dynamic-marker-01.svg pass.svg
 skip-if(B2G) == dynamic-marker-02.svg dynamic-marker-02-ref.svg
 skip-if(B2G) == dynamic-marker-03.svg pass.svg
 == dynamic-mask-01.svg pass.svg
 skip-if(B2G) == dynamic-mask-contents-01.svg pass.svg
+== dynamic-opacity-property-01.svg pass.svg
 skip-if(B2G) == dynamic-pattern-01.svg pass.svg
 skip-if(B2G) == dynamic-pattern-02.svg pass.svg
 skip-if(B2G) == dynamic-pattern-contents-01.svg pass.svg
 skip-if(B2G) == dynamic-pattern-contents-02.svg pass.svg
 == dynamic-rect-01.svg dynamic-rect-01-ref.svg
 == dynamic-rect-02.svg dynamic-rect-02-ref.svg
 == dynamic-rect-03.svg dynamic-rect-03-ref.svg
 == dynamic-rect-04.xhtml pass.svg
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -115,16 +115,33 @@ nsSVGPathGeometryFrame::AttributeChanged
       (static_cast<nsSVGPathGeometryElement*>
                   (mContent)->AttributeDefinesGeometry(aAttribute))) {
     nsSVGEffects::InvalidateRenderingObservers(this);
     nsSVGUtils::ScheduleReflowSVG(this);
   }
   return NS_OK;
 }
 
+/* virtual */ void
+nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
+{
+  nsSVGPathGeometryFrameBase::DidSetStyleContext(aOldStyleContext);
+
+  if (aOldStyleContext) {
+    float oldOpacity = aOldStyleContext->PeekStyleDisplay()->mOpacity;
+    float newOpacity = StyleDisplay()->mOpacity;
+    if (newOpacity != oldOpacity &&
+        nsSVGUtils::CanOptimizeOpacity(this)) {
+      // nsIFrame::BuildDisplayListForStackingContext() is not going to create an
+      // nsDisplayOpacity display list item, so DLBI won't invalidate for us.
+      InvalidateFrame();
+    }
+  }
+}
+
 nsIAtom *
 nsSVGPathGeometryFrame::GetType() const
 {
   return nsGkAtoms::svgPathGeometryFrame;
 }
 
 bool
 nsSVGPathGeometryFrame::IsSVGTransformed(gfxMatrix *aOwnTransform,
--- a/layout/svg/nsSVGPathGeometryFrame.h
+++ b/layout/svg/nsSVGPathGeometryFrame.h
@@ -51,16 +51,18 @@ public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS
 
   // nsIFrame interface:
   NS_IMETHOD  AttributeChanged(int32_t         aNameSpaceID,
                                nsIAtom*        aAttribute,
                                int32_t         aModType) MOZ_OVERRIDE;
 
+  virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
+
   /**
    * Get the "type" of the frame
    *
    * @see nsGkAtoms::svgPathGeometryFrame
    */
   virtual nsIAtom* GetType() const MOZ_OVERRIDE;
 
   virtual bool IsSVGTransformed(gfxMatrix *aOwnTransforms = nullptr,