bug 1261277 use GtkTextView to get an appropriate color for resizers r?acomminos
MozReview-Commit-ID: IhcjE7Aax8g
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -36,19 +36,19 @@ static GtkWidget* gComboBoxArrowWidget;
static GtkWidget* gComboBoxSeparatorWidget;
static GtkWidget* gComboBoxEntryWidget;
static GtkWidget* gComboBoxEntryTextareaWidget;
static GtkWidget* gComboBoxEntryButtonWidget;
static GtkWidget* gComboBoxEntryArrowWidget;
static GtkWidget* gHandleBoxWidget;
static GtkWidget* gToolbarWidget;
static GtkWidget* gFrameWidget;
-static GtkWidget* gStatusbarWidget;
static GtkWidget* gProgressWidget;
static GtkWidget* gTabWidget;
+static GtkWidget* gTextViewWidget;
static GtkWidget* gTooltipWidget;
static GtkWidget* gMenuBarWidget;
static GtkWidget* gMenuBarItemWidget;
static GtkWidget* gMenuPopupWidget;
static GtkWidget* gMenuItemWidget;
static GtkWidget* gImageMenuItemWidget;
static GtkWidget* gCheckMenuItemWidget;
static GtkWidget* gTreeViewWidget;
@@ -533,33 +533,21 @@ ensure_progress_widget()
if (!gProgressWidget) {
gProgressWidget = gtk_progress_bar_new();
setup_widget_prototype(gProgressWidget);
}
return MOZ_GTK_SUCCESS;
}
static gint
-ensure_statusbar_widget()
-{
- if (!gStatusbarWidget) {
- gStatusbarWidget = gtk_statusbar_new();
- setup_widget_prototype(gStatusbarWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
ensure_frame_widget()
{
if (!gFrameWidget) {
- ensure_statusbar_widget();
gFrameWidget = gtk_frame_new(NULL);
- gtk_container_add(GTK_CONTAINER(gStatusbarWidget), gFrameWidget);
- gtk_widget_realize(gFrameWidget);
+ setup_widget_prototype(gFrameWidget);
}
return MOZ_GTK_SUCCESS;
}
static gint
ensure_menu_bar_widget()
{
if (!gMenuBarWidget) {
@@ -716,16 +704,27 @@ ensure_scrolled_window_widget()
{
if (!gScrolledWindowWidget) {
gScrolledWindowWidget = gtk_scrolled_window_new(NULL, NULL);
setup_widget_prototype(gScrolledWindowWidget);
}
return MOZ_GTK_SUCCESS;
}
+static void
+ensure_text_view_widget()
+{
+ if (gTextViewWidget)
+ return;
+
+ gTextViewWidget = gtk_text_view_new();
+ ensure_scrolled_window_widget();
+ gtk_container_add(GTK_CONTAINER(gScrolledWindowWidget), gTextViewWidget);
+}
+
gint
moz_gtk_init()
{
if (is_initialized)
return MOZ_GTK_SUCCESS;
is_initialized = TRUE;
have_arrow_scaling = (gtk_major_version > 2 ||
@@ -1955,21 +1954,26 @@ moz_gtk_tooltip_paint(cairo_t *cr, GdkRe
static gint
moz_gtk_resizer_paint(cairo_t *cr, GdkRectangle* rect,
GtkWidgetState* state,
GtkTextDirection direction)
{
GtkStyleContext* style;
- ensure_frame_widget();
- gtk_widget_set_direction(gStatusbarWidget, GTK_TEXT_DIR_LTR);
-
- style = gtk_widget_get_style_context(gStatusbarWidget);
+ // gtk_render_handle() draws a background, so use GtkTextView and its
+ // GTK_STYLE_CLASS_VIEW to match the background with textarea elements.
+ // The resizer is drawn with shaded variants of the background color, and
+ // so a transparent background would lead to a transparent resizer.
+ ensure_text_view_widget();
+ gtk_widget_set_direction(gTextViewWidget, GTK_TEXT_DIR_LTR);
+
+ style = gtk_widget_get_style_context(gTextViewWidget);
gtk_style_context_save(style);
+ gtk_style_context_add_class(style, GTK_STYLE_CLASS_VIEW);
gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP);
gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
// Workaround unico not respecting the text direction for resizers.
// See bug 1174248.
cairo_save(cr);
if (direction == GTK_TEXT_DIR_RTL) {
cairo_matrix_t mat;
@@ -3431,20 +3435,20 @@ moz_gtk_shutdown()
gComboBoxSeparatorWidget = NULL;
gComboBoxArrowWidget = NULL;
gComboBoxEntryWidget = NULL;
gComboBoxEntryButtonWidget = NULL;
gComboBoxEntryArrowWidget = NULL;
gComboBoxEntryTextareaWidget = NULL;
gHandleBoxWidget = NULL;
gToolbarWidget = NULL;
- gStatusbarWidget = NULL;
gFrameWidget = NULL;
gProgressWidget = NULL;
gTabWidget = NULL;
+ gTextViewWidget = nullptr;
gTooltipWidget = NULL;
gMenuBarWidget = NULL;
gMenuBarItemWidget = NULL;
gMenuPopupWidget = NULL;
gMenuItemWidget = NULL;
gImageMenuItemWidget = NULL;
gCheckMenuItemWidget = NULL;
gTreeViewWidget = NULL;