Bug 877605 - Port GTK2 to GTK3 - tab widget rendering. r=karlt
authorMartin Stransky <stransky@redhat.com>
Mon, 02 Dec 2013 11:53:09 -0500
changeset 173954 2c9fa83a8dc58a3993de611716eda8be409aafbd
parent 173953 048be1fe0b10811935ab32c7890592ef7259f62c
child 173955 13c1b3a2d135ff95fac2557f9bb5ac974784f2e3
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs877605
milestone28.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 877605 - Port GTK2 to GTK3 - tab widget rendering. r=karlt
widget/gtk/gtk3drawing.c
--- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c
@@ -2062,22 +2062,23 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
 {
     /* When the tab isn't selected, we just draw a notebook extension.
      * When it is selected, we overwrite the adjacent border of the tabpanel
      * touching the tab with a pierced border (called "the gap") to make the
      * tab appear physically attached to the tabpanel; see details below. */
 
     GtkStyleContext* style;
     GdkRectangle focusRect;
+    GdkRectangle backRect;
 
     ensure_tab_widget();
     gtk_widget_set_direction(gTabWidget, direction);
 
     style = gtk_widget_get_style_context(gTabWidget);    
-    focusRect = *rect;
+    backRect = focusRect = *rect;
 
     gtk_style_context_save(style);
 
     if ((flags & MOZ_GTK_TAB_SELECTED) == 0) {
         /* Only draw the tab */
         gtk_style_context_set_state(style, GTK_STATE_FLAG_NORMAL);
         gtk_render_extension(style, cr,
                              rect->x, rect->y, rect->width, rect->height,
@@ -2148,50 +2149,63 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
             /* Draw the tab on bottom */
             focusRect.y += gap_voffset;
             focusRect.height -= gap_voffset;
 
             gtk_render_extension(style, cr,
                                  rect->x, rect->y + gap_voffset, rect->width,
                                  rect->height - gap_voffset, GTK_POS_TOP);
 
+            gtk_style_context_remove_region(style, GTK_STYLE_REGION_TAB);
+
+            backRect.y += (gap_voffset - gap_height);
+            backRect.height = gap_height;
+
             /* Draw the gap; erase with background color before painting in
              * case theme does not */
-            gtk_render_background(style, cr,
-                                 rect->x,
-                                 rect->y + gap_voffset
-                                         - gap_height,
-                                 rect->width, gap_height);
+            gtk_render_background(style, cr, backRect.x, backRect.y,
+                                 backRect.width, backRect.height);
+            cairo_save(cr);
+            cairo_rectangle(cr, backRect.x, backRect.y, backRect.width, backRect.height);
+            cairo_clip(cr);
+
             gtk_render_frame_gap(style, cr,
                                  rect->x - gap_loffset,
                                  rect->y + gap_voffset - 3 * gap_height,
                                  rect->width + gap_loffset + gap_roffset,
                                  3 * gap_height, GTK_POS_BOTTOM,
                                  gap_loffset, gap_loffset + rect->width);
-                                 
+            cairo_restore(cr);
         } else {
             /* Draw the tab on top */
             focusRect.height -= gap_voffset;
             gtk_render_extension(style, cr,
                                  rect->x, rect->y, rect->width,
                                  rect->height - gap_voffset, GTK_POS_BOTTOM);
 
+            gtk_style_context_remove_region(style, GTK_STYLE_REGION_TAB);
+
+            backRect.y += (rect->height - gap_voffset);
+            backRect.height = gap_height;
+
             /* Draw the gap; erase with background color before painting in
              * case theme does not */
-            gtk_render_background(style, cr,
-                                  rect->x,
-                                  rect->y + rect->height
-                                          - gap_voffset,
-                                  rect->width, gap_height);
+            gtk_render_background(style, cr, backRect.x, backRect.y,
+                                  backRect.width, backRect.height);
+            cairo_save(cr);
+            cairo_rectangle(cr, backRect.x, backRect.y, backRect.width, backRect.height);
+            cairo_clip(cr);
+
             gtk_render_frame_gap(style, cr,
                                  rect->x - gap_loffset,
                                  rect->y + rect->height - gap_voffset,
                                  rect->width + gap_loffset + gap_roffset,
                                  3 * gap_height, GTK_POS_TOP,
                                  gap_loffset, gap_loffset + rect->width);
+            cairo_restore(cr);
         }
     }
 
     if (state->focused) {
       /* Paint the focus ring */
       GtkBorder border;
       gtk_style_context_get_border(style, GetStateFlagsFromGtkWidgetState(state), &border);