]> Pileus Git - ~andy/gtk/commitdiff
themingengine: shrink the background size to the padding-box
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 15 Jun 2011 05:07:11 +0000 (01:07 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 15 Jun 2011 15:03:56 +0000 (11:03 -0400)
This fixes a regression introduced by this commit [1] that causes
background to draw beyond the padding-box, which breaks rounded corners,
(in addition to not being compliant with what CSS does by default).

[1] http://git.gnome.org/browse/gtk+/commit/?id=c56700ca3029a9ab1362009bff35f2a70e432c02

https://bugzilla.gnome.org/show_bug.cgi?id=652618

gtk/gtkthemingengine.c

index 89b710998466c1457a7f62bb95ff9b32619cf9b4..66adad6fe22e3f4a1a82f0277af69affb5ff9d28 100644 (file)
@@ -1388,6 +1388,7 @@ render_background_internal (GtkThemingEngine *engine,
   gdouble progress;
   GtkRoundedBox border_box;
   GtkShadow *box_shadow;
+  GtkBorder border;
 
   flags = gtk_theming_engine_get_state (engine);
 
@@ -1584,8 +1585,21 @@ render_background_internal (GtkThemingEngine *engine,
         cairo_pattern_destroy (other_pattern);
     }
 
+  gtk_theming_engine_get_border (engine, flags, &border);
+
+  /* In the CSS box model, by default the background positioning area is
+   * the padding-box, i.e. all the border-box minus the borders themselves,
+   * which determines also its default size, see
+   * http://dev.w3.org/csswg/css3-background/#background-origin
+   *
+   * In the future we might want to support different origins or clips, but
+   * right now we just shrink to the default.
+   */
   _gtk_rounded_box_init_rect (&border_box, 0, 0, width, height);
   _gtk_rounded_box_apply_border_radius (&border_box, engine, flags, junction);
+  _gtk_rounded_box_shrink (&border_box,
+                           border.top, border.right,
+                           border.bottom, border.left);
   _gtk_rounded_box_path (&border_box, cr);
 
   if (pattern)
@@ -1604,11 +1618,6 @@ render_background_internal (GtkThemingEngine *engine,
 
   if (box_shadow != NULL)
     {
-      GtkBorder border;
-      gtk_theming_engine_get_border (engine, flags, &border);
-      _gtk_rounded_box_shrink (&border_box,
-                               border.top, border.right,
-                               border.bottom, border.left);
       _gtk_box_shadow_render (box_shadow, cr, &border_box);
       _gtk_shadow_unref (box_shadow);
     }