[gtk+] themingengine: shrink the background size to the padding-box



commit af77ba78bb94c1298012b5d7b69941853e9c5e08
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jun 15 01:07:11 2011 -0400

    themingengine: shrink the background size to the padding-box
    
    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 |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 89b7109..66adad6 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -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);
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]