bug 1320860 consider textview root node background in addition to text node for -moz-appearance:textfield-multiline r?stransky draft
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 30 Dec 2016 12:54:28 +1300
changeset 455184 533194c7b0ea0fcbf94a18be503d4aee49b92577
parent 455183 9ec8373f08373b8917799a7694768f1cd3321cb1
child 455185 14d5661aab62ad112762cf841d04d4ac9571a24c
push id40148
push userktomlinson@mozilla.com
push dateTue, 03 Jan 2017 00:13:34 +0000
reviewersstransky
bugs1320860, 1324262
milestone53.0a1
bug 1320860 consider textview root node background in addition to text node for -moz-appearance:textfield-multiline r?stransky This is necessary for GTK versions > 3.18 because windows no longer clear their backgrounds since https://git.gnome.org/browse/gtk+/commit/?id=580ea227a6bb19ad6c6d4766b3a36dbad24583f3 and Ambiance for 3.20 has a transparent background for the "text" window. See bug 1324262. MozReview-Commit-ID: 7HCCwfOv0LP
widget/gtk/gtk3drawing.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -865,44 +865,42 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect
         gtk_render_background(style, cr, x, y, width, height);
     }
     gtk_render_frame(style, cr, x, y, width, height);
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
-moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* rect,
+moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* aRect,
                         GtkWidgetState* state,
                         GtkTextDirection direction)
 {
     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
 
     GtkStyleContext* style_frame =
         ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction, state_flags);
-    gtk_render_frame(style_frame, cr, rect->x, rect->y, rect->width, rect->height);
+    gtk_render_frame(style_frame, cr,
+                     aRect->x, aRect->y, aRect->width, aRect->height);
 
-    GtkBorder border, padding;
-    gtk_style_context_get_border(style_frame, state_flags, &border);
-    gtk_style_context_get_padding(style_frame, state_flags, &padding);
+    GdkRectangle rect = *aRect;
+    InsetByBorderPadding(&rect, style_frame);
+
     ReleaseStyleContext(style_frame);
 
-    // There is a separate "text" window, which provides the background behind
-    // the text.
     GtkStyleContext* style =
-        ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags);
-
-    gint xthickness = border.left + padding.left;
-    gint ythickness = border.top + padding.top;
-
-    gtk_render_background(style, cr,
-                          rect->x + xthickness, rect->y + ythickness,
-                          rect->width - 2 * xthickness,
-                          rect->height - 2 * ythickness);
-
+        ClaimStyleContext(MOZ_GTK_TEXT_VIEW, direction, state_flags);
+    gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height);
+    ReleaseStyleContext(style);
+    // There is a separate "text" window, which usually provides the
+    // background behind the text.  However, this is transparent in Ambiance
+    // for GTK 3.20, in which case the MOZ_GTK_TEXT_VIEW background is
+    // visible.
+    style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags);
+    gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height);
     ReleaseStyleContext(style);
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint 
 moz_gtk_treeview_paint(cairo_t *cr, GdkRectangle* rect,
                        GtkWidgetState* state,