Bug 613659 - Add a Restore() method to Restore the current gfxContext if any. r=roc
authorMats Palmgren <matspal@gmail.com>
Mon, 05 May 2014 17:55:55 +0000
changeset 181577 06da59d29a48
parent 181576 48070863848c
child 181578 75cafc47ff36
push id26724
push userkwierso@gmail.com
push dateTue, 06 May 2014 03:51:22 +0000
treeherdermozilla-central@6d991528460d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs613659
milestone32.0a1
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 613659 - Add a Restore() method to Restore the current gfxContext if any. r=roc
gfx/thebes/gfxContext.h
layout/base/nsCSSRendering.cpp
layout/reftests/backgrounds/background-multiple-with-border-radius-ref.html
layout/reftests/backgrounds/background-multiple-with-border-radius.html
layout/reftests/backgrounds/reftest.list
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -815,35 +815,40 @@ class gfxContextAutoSaveRestore
 public:
   gfxContextAutoSaveRestore() : mContext(nullptr) {}
 
   gfxContextAutoSaveRestore(gfxContext *aContext) : mContext(aContext) {
     mContext->Save();
   }
 
   ~gfxContextAutoSaveRestore() {
-    if (mContext) {
-      mContext->Restore();
-    }
+    Restore();
   }
 
   void SetContext(gfxContext *aContext) {
     NS_ASSERTION(!mContext, "Not going to call Restore() on some context!!!");
     mContext = aContext;
     mContext->Save();    
   }
 
   void EnsureSaved(gfxContext *aContext) {
     MOZ_ASSERT(!mContext || mContext == aContext, "wrong context");
     if (!mContext) {
         mContext = aContext;
         mContext->Save();
     }
   }
 
+  void Restore() {
+    if (mContext) {
+      mContext->Restore();
+      mContext = nullptr;
+    }
+  }
+
 private:
   gfxContext *mContext;
 };
 
 /**
  * Sentry helper class for functions with multiple return points that need to
  * back up the current path of a context and have it automatically restored
  * before they return. This class assumes that the transformation matrix will
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -2721,17 +2721,17 @@ nsCSSRendering::PaintBackgroundWithSC(ns
             NS_STYLE_BG_CLIP_MOZ_ALMOST_PADDING : NS_STYLE_BG_CLIP_PADDING;
         }
         if (currentBackgroundClip != newBackgroundClip || !clipSet) {
           currentBackgroundClip = newBackgroundClip;
           // If clipSet is false that means this is the bottom layer and we
           // already called GetBackgroundClip above and it stored its results
           // in clipState.
           if (clipSet) {
-            autoSR = gfxContextAutoSaveRestore(); // reset the previous one
+            autoSR.Restore(); // reset the previous one
             GetBackgroundClip(ctx, currentBackgroundClip, layer.mAttachment, aForFrame,
                               clipBorderArea, aDirtyRect, haveRoundedCorners,
                               bgRadii, appUnitsPerPixel, &clipState);
           }
           SetupBackgroundClip(clipState, ctx, haveRoundedCorners,
                               appUnitsPerPixel, &autoSR);
           clipSet = true;
           if (!clipBorderArea.IsEqualEdges(aBorderArea)) {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/background-multiple-with-border-radius-ref.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>Test multiple backgrounds with border-radius</title>
+  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=998792">
+  <meta charset="utf-8">
+<style>
+
+.b2 {
+  background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD%2FgAIDAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAoUlEQVR42u3bwQ0AIAgEwcOmtXttgScmsxWQCTyp3EysJo61IliwYMGCBUuwYMGCBQuWYMGCBQsWLMGCBQsWLFiCBQsWLFiwBAsWLFiwYAkWLFiwYMESLFiwYMGCpXaVka%2BsO8dmOUNYggULFixYsAQLFixYsGAJFixYsGDBEixYsGDBgiVYsGDBggVLsGDBggULlmDBggULFizBggUL1t89N%2FYEtBGStpoAAAAASUVORK5CYII%3D);
+}
+
+.b {
+  background: yellow;
+}
+
+div.b {
+  width: 100px;
+  height: 100px;
+  padding: 30px;
+}
+
+div.border {
+  width: 160px;
+  height: 160px;
+  border: 10px dashed blue;
+  border-radius: 10px;
+}
+
+div.b2 {
+  width: 100px;
+  height: 100px;
+}
+
+</style>
+</head>
+<body>
+
+<div class="border"><div class="b"><div class="b2"></div></div></div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/background-multiple-with-border-radius.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>Test multiple backgrounds with border-radius</title>
+  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=998792">
+  <link rel="help" href="http://dev.w3.org/csswg/css-backgrounds/#the-border-radius">
+  <link rel="match" href="background-multiple-with-border-radius-ref.html">
+  <meta charset="utf-8">
+<style>
+
+.b {
+  background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD%2FgAIDAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAoUlEQVR42u3bwQ0AIAgEwcOmtXttgScmsxWQCTyp3EysJo61IliwYMGCBUuwYMGCBQuWYMGCBQsWLMGCBQsWLFiCBQsWLFiwBAsWLFiwYAkWLFiwYMESLFiwYMGCpXaVka%2BsO8dmOUNYggULFixYsAQLFixYsGAJFixYsGDBEixYsGDBgiVYsGDBggVLsGDBggULlmDBggULFizBggUL1t89N%2FYEtBGStpoAAAAASUVORK5CYII%3D) content-box, yellow padding-box;
+}
+
+div {
+  width: 100px;
+  height: 100px;
+  padding: 30px;
+  border: 10px dashed blue;
+  border-radius: 10px;
+}
+
+</style>
+</head>
+<body>
+
+<div class="b"></div>
+
+</body>
+</html>
--- a/layout/reftests/backgrounds/reftest.list
+++ b/layout/reftests/backgrounds/reftest.list
@@ -153,8 +153,10 @@ fails-if(Android&&AndroidVersion==15) ==
 fails-if(Android&&AndroidVersion==15) fuzzy-if(!Android||(Android&&AndroidVersion!=15),50,500) == attachment-local-clipping-color-6.html attachment-local-clipping-color-6-ref.html #Bug 959165
 
 == attachment-local-clipping-image-1.html attachment-local-clipping-image-1-ref.html
 == attachment-local-clipping-image-2.html attachment-local-clipping-image-1-ref.html  # Same ref as the previous test.
 == attachment-local-clipping-image-3.html attachment-local-clipping-image-3-ref.html
 fails-if(Android&&AndroidVersion==15) == attachment-local-clipping-image-4.html attachment-local-clipping-image-4-ref.html #Bug 959165
 fails-if(Android&&AndroidVersion==15) == attachment-local-clipping-image-5.html attachment-local-clipping-image-4-ref.html  # Same ref as the previous test. #Bug 959165
 fails-if(Android&&AndroidVersion==15) fuzzy-if(!Android||(Android&&AndroidVersion!=15),80,500) == attachment-local-clipping-image-6.html attachment-local-clipping-image-6-ref.html #Bug 959165
+
+== background-multiple-with-border-radius.html background-multiple-with-border-radius-ref.html