summaryrefslogtreecommitdiff
path: root/widget/gtk
diff options
context:
space:
mode:
authortrav90 <travawine@protonmail.ch>2018-04-06 09:10:47 -0500
committertrav90 <travawine@protonmail.ch>2018-04-06 09:10:47 -0500
commit08f07544062212ad6d89a68d921e0039d95a6954 (patch)
treeb1c5d275002b568ecf8a80a76eec19a2a506d2bb /widget/gtk
parentdfe72009d38d82f7cee61d458b8574fb9eddfb2e (diff)
downloaduxp-08f07544062212ad6d89a68d921e0039d95a6954.tar.gz
[GTK3] Consider textview root node background in addition to text node for -moz-field
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.
Diffstat (limited to 'widget/gtk')
-rw-r--r--widget/gtk/nsLookAndFeel.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp
index abc0ff0617..22d0099eff 100644
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -62,6 +62,22 @@ nsLookAndFeel::~nsLookAndFeel()
}
#if MOZ_WIDGET_GTK != 2
+// Modifies color |*aDest| as if a pattern of color |aSource| was painted with
+// CAIRO_OPERATOR_OVER to a surface with color |*aDest|.
+static void
+ApplyColorOver(const GdkRGBA& aSource, GdkRGBA* aDest) {
+ gdouble sourceCoef = aSource.alpha;
+ gdouble destCoef = aDest->alpha * (1.0 - sourceCoef);
+ gdouble resultAlpha = sourceCoef + destCoef;
+ if (resultAlpha != 0.0) { // don't divide by zero
+ destCoef /= resultAlpha;
+ sourceCoef /= resultAlpha;
+ aDest->red = sourceCoef * aSource.red + destCoef * aDest->red;
+ aDest->green = sourceCoef * aSource.green + destCoef * aDest->green;
+ aDest->blue = sourceCoef * aSource.blue + destCoef * aDest->blue;
+ }
+}
+
static void
GetLightAndDarkness(const GdkRGBA& aColor,
double* aLightness, double* aDarkness)
@@ -1291,9 +1307,19 @@ nsLookAndFeel::Init()
}
#else
// Text colors
+ GdkRGBA bgColor;
+ // If the text window background is translucent, then the background of
+ // the textview root node is visible.
+ style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW);
+ gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
+ &bgColor);
+ ReleaseStyleContext(style);
+
style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT);
- gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
- sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color);
+ gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
+ &color);
+ ApplyColorOver(color, &bgColor);
+ sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(bgColor);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMozFieldText = GDK_RGBA_TO_NS_RGBA(color);