--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -3117,77 +3117,65 @@ GetActiveScrollbarMetrics(GtkOrientation
/*
* get_shadow_width() from gtkwindow.c is not public so we need
* to implement it.
*/
bool
GetCSDDecorationSize(GtkWindow *aGtkWindow, GtkBorder* aDecorationSize)
{
+ // Available on GTK 3.20+.
+ static auto sGtkRenderBackgroundGetClip =
+ (void (*)(GtkStyleContext*, gdouble, gdouble, gdouble, gdouble, GdkRectangle*))
+ dlsym(RTLD_DEFAULT, "gtk_render_background_get_clip");
+
+ if (!sGtkRenderBackgroundGetClip) {
+ *aDecorationSize = {0,0,0,0};
+ return false;
+ }
+
GtkStyleContext* context = gtk_widget_get_style_context(GTK_WIDGET(aGtkWindow));
bool solidDecorations = gtk_style_context_has_class(context, "solid-csd");
context = GetStyleContext(solidDecorations ?
MOZ_GTK_WINDOW_DECORATION_SOLID :
MOZ_GTK_WINDOW_DECORATION);
/* Always sum border + padding */
GtkBorder padding;
GtkStateFlags state = gtk_style_context_get_state(context);
gtk_style_context_get_border(context, state, aDecorationSize);
gtk_style_context_get_padding(context, state, &padding);
*aDecorationSize += padding;
- // Available on GTK 3.20+.
- static auto sGtkRenderBackgroundGetClip =
- (void (*)(GtkStyleContext*, gdouble, gdouble, gdouble, gdouble, GdkRectangle*))
- dlsym(RTLD_DEFAULT, "gtk_render_background_get_clip");
GtkBorder margin;
gtk_style_context_get_margin(context, state, &margin);
- GtkBorder extents = {0, 0, 0, 0};
- if (sGtkRenderBackgroundGetClip) {
- /* Get shadow extents but combine with style margin; use the bigger value.
- */
- GdkRectangle clip;
- sGtkRenderBackgroundGetClip(context, 0, 0, 0, 0, &clip);
-
- extents.top = -clip.y;
- extents.right = clip.width + clip.x;
- extents.bottom = clip.height + clip.y;
- extents.left = -clip.x;
-
- // Margin is used for resize grip size - it's not present on
- // popup windows.
- if (gtk_window_get_window_type(aGtkWindow) != GTK_WINDOW_POPUP) {
- extents.top = MAX(extents.top, margin.top);
- extents.right = MAX(extents.right, margin.right);
- extents.bottom = MAX(extents.bottom, margin.bottom);
- extents.left = MAX(extents.left, margin.left);
- }
- } else {
- /* If we can't get shadow extents use decoration-resize-handle instead
- * as a workaround. This is inspired by update_border_windows()
- * from gtkwindow.c although this is not 100% accurate as we emulate
- * the extents here.
- */
- gint handle;
- gtk_widget_style_get(GetWidget(MOZ_GTK_WINDOW),
- "decoration-resize-handle", &handle,
- NULL);
-
- extents.top = handle + margin.top;
- extents.right = handle + margin.right;
- extents.bottom = handle + margin.bottom;
- extents.left = handle + margin.left;
+ /* Get shadow extents but combine with style margin; use the bigger value.
+ */
+ GdkRectangle clip;
+ sGtkRenderBackgroundGetClip(context, 0, 0, 0, 0, &clip);
+
+ GtkBorder extents;
+ extents.top = -clip.y;
+ extents.right = clip.width + clip.x;
+ extents.bottom = clip.height + clip.y;
+ extents.left = -clip.x;
+
+ // Margin is used for resize grip size - it's not present on
+ // popup windows.
+ if (gtk_window_get_window_type(aGtkWindow) != GTK_WINDOW_POPUP) {
+ extents.top = MAX(extents.top, margin.top);
+ extents.right = MAX(extents.right, margin.right);
+ extents.bottom = MAX(extents.bottom, margin.bottom);
+ extents.left = MAX(extents.left, margin.left);
}
*aDecorationSize += extents;
-
- return (sGtkRenderBackgroundGetClip != nullptr);
+ return true;
}
/* cairo_t *cr argument has to be a system-cairo. */
gint
moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr,
GdkRectangle* rect,
GtkWidgetState* state, gint flags,
GtkTextDirection direction)