bug 1319650 draw tab gap with tabpanel style context r=stransky draft
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 29 Nov 2016 18:50:20 +1300
changeset 572873 4def9d426372d319575ad6a1b55f5723a20d9ac7
parent 572872 a4056c61ef3a309859743b9cc03367dfd58c93fc
child 627144 92d0053c0efcd028a98f0738b666aee9b3a0349f
push id57209
push userktomlinson@mozilla.com
push dateThu, 04 May 2017 20:55:30 +0000
reviewersstransky
bugs1319650
milestone55.0a1
bug 1319650 draw tab gap with tabpanel style context r=stransky This is more consistent with moz_gtk_tabpanels_paint() and avoids modifying the tab style context. MozReview-Commit-ID: HpKSVrpvO9b
widget/gtk/gtk3drawing.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -1570,18 +1570,18 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
              *           :    ^       bmargin          :  ^
              *           :    | (-negative margin,     :  |
              *  bottom   :    v  passed in flags)      :  |       gap_height
              *    of  -> :.............................:  |    (the size of the
              * the tab   .       part of the gap       .  |  tabpanel top border)
              *           .      outside of the tab     .  v
              * ----------------------------------------------
              *
-             * To draw the gap, we use gtk_paint_box_gap(), see comment in
-             * moz_gtk_tabpanels_paint(). This box_gap is made 3 * gap_height tall,
+             * To draw the gap, we use gtk_render_frame_gap(), see comment in
+             * moz_gtk_tabpanels_paint(). This gap is made 3 * gap_height tall,
              * which should suffice to ensure that the only visible border is the
              * pierced one.  If the tab is in the middle, we make the box_gap begin
              * a bit to the left of the tab and end a bit to the right, adjusting
              * the gap position so it still is under the tab, because we want the
              * rendering of a gap in the middle of a tabpanel.  This is the role of
              * the gints gap_{l,r}_offset. On the contrary, if the tab is the
              * first, we align the start border of the box_gap with the start
              * border of the tab (left if LTR, right if RTL), by setting the
@@ -1600,67 +1600,66 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
             gap_loffset = gap_roffset = 20; /* should be enough */
             if (flags & MOZ_GTK_TAB_FIRST) {
                 if (direction == GTK_TEXT_DIR_RTL)
                     gap_roffset = initial_gap;
                 else
                     gap_loffset = initial_gap;
             }
 
+            GtkStyleContext* panelStyle =
+                ClaimStyleContext(MOZ_GTK_TABPANELS, direction);
+
             if (isBottomTab) {
                 /* Draw the tab on bottom */
                 focusRect.y += gap_voffset;
                 focusRect.height -= gap_voffset;
 
                 gtk_render_extension(style, cr,
                                      tabRect.x, tabRect.y + gap_voffset, tabRect.width,
                                      tabRect.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, backRect.x, backRect.y,
+                gtk_render_background(panelStyle, 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,
+                gtk_render_frame_gap(panelStyle, cr,
                                      tabRect.x - gap_loffset,
                                      tabRect.y + gap_voffset - 3 * gap_height,
                                      tabRect.width + gap_loffset + gap_roffset,
                                      3 * gap_height, GTK_POS_BOTTOM,
                                      gap_loffset, gap_loffset + tabRect.width);
                 cairo_restore(cr);
             } else {
                 /* Draw the tab on top */
                 focusRect.height -= gap_voffset;
                 gtk_render_extension(style, cr,
                                      tabRect.x, tabRect.y, tabRect.width,
                                      tabRect.height - gap_voffset, GTK_POS_BOTTOM);
 
-                gtk_style_context_remove_region(style, GTK_STYLE_REGION_TAB);
-
                 backRect.y += (tabRect.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, backRect.x, backRect.y,
+                gtk_render_background(panelStyle, 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,
+                gtk_render_frame_gap(panelStyle, cr,
                                      tabRect.x - gap_loffset,
                                      tabRect.y + tabRect.height - gap_voffset,
                                      tabRect.width + gap_loffset + gap_roffset,
                                      3 * gap_height, GTK_POS_TOP,
                                      gap_loffset, gap_loffset + tabRect.width);
                 cairo_restore(cr);
             }
         }