Bug 1406268 - Use rect width/height instead of minimum width/height and clamp the rect on Linux. r?mats
MozReview-Commit-ID: B7KjnO9uaef
--- a/layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html
+++ b/layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html
@@ -6,17 +6,17 @@
<style>
input { outline:1px solid black; }
</style>
</head>
<body>
-<div style="overflow:hidden; width:160px;">
+<div style="overflow:hidden; width:120px;">
<div style="float:left; width:799px; border:1px solid blue;">
<input type="checkbox" checked style="width:400px; visibility:hidden;">
<input type="checkbox" checked style="width:400px; height:100px; visibility:hidden;">
</div>
</div>
<input type="checkbox" checked style="width:400px;"><br>
--- a/layout/reftests/forms/input/checkbox/gtk-theme-width-height.html
+++ b/layout/reftests/forms/input/checkbox/gtk-theme-width-height.html
@@ -6,17 +6,17 @@
<style>
input { outline:1px solid black; }
</style>
</head>
<body>
-<div style="overflow:hidden; width:160px;">
+<div style="overflow:hidden; width:120px;">
<div style="float:left; width:799px; border:1px solid blue;">
<input type="checkbox" checked style="width:400px; outline:none;">
<input type="checkbox" checked style="width:400px; height:100px; outline:none;">
</div>
</div>
<input type="checkbox" checked style="width:400px; height:1px;"><br>
<input type="checkbox" checked style="width:1px; height:100px;"><br>
--- a/layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html
+++ b/layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html
@@ -6,17 +6,17 @@
<style>
input { outline:1px solid black; }
</style>
</head>
<body>
-<div style="overflow:hidden; width:160px;">
+<div style="overflow:hidden; width:120px;">
<div style="float:left; width:799px; border:1px solid blue;">
<input type="radio" checked style="width:400px; visibility:hidden;">
<input type="radio" checked style="width:400px; height:100px; visibility:hidden;">
</div>
</div>
<input type="radio" checked style="width:400px;"><br>
--- a/layout/reftests/forms/input/radio/gtk-theme-width-height.html
+++ b/layout/reftests/forms/input/radio/gtk-theme-width-height.html
@@ -6,17 +6,17 @@
<style>
input { outline:1px solid black; }
</style>
</head>
<body>
-<div style="overflow:hidden; width:160px;">
+<div style="overflow:hidden; width:120px;">
<div style="float:left; width:799px; border:1px solid blue;">
<input type="radio" checked style="width:400px; outline:none;">
<input type="radio" checked style="width:400px; height:100px; outline:none;">
</div>
</div>
<input type="radio" checked style="width:400px; height:1px;"><br>
<input type="radio" checked style="width:1px; height:100px;"><br>
--- a/widget/gtk/gtk2drawing.c
+++ b/widget/gtk/gtk2drawing.c
@@ -1039,26 +1039,31 @@ moz_gtk_toggle_paint(GdkDrawable* drawab
if (isradio) {
moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
w = gRadiobuttonWidget;
} else {
moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
w = gCheckboxWidget;
}
- // XXX we should assert rect->height >= indicator_size too
- // after bug 369581 is fixed.
- MOZ_ASSERT(rect->width >= indicator_size,
- "GetMinimumWidgetSize was ignored");
-
- // Paint it center aligned in the rect.
- x = rect->x + (rect->width - indicator_size) / 2;
- y = rect->y + (rect->height - indicator_size) / 2;
- width = indicator_size;
- height = indicator_size;
+ // Clamp the rect and paint it center aligned in the rect.
+ x = rect->x;
+ y = rect->y;
+ width = rect->width;
+ height = rect->height;
+
+ if (rect->width < rect->height) {
+ y = rect->y + (rect->height - rect->width) / 2;
+ height = rect->width;
+ }
+
+ if (rect->height < rect->width) {
+ x = rect->x + (rect->width - rect->height) / 2;
+ width = rect->height;
+ }
focus_x = x - indicator_spacing;
focus_y = y - indicator_spacing;
focus_width = width + 2 * indicator_spacing;
focus_height = height + 2 * indicator_spacing;
style = w->style;
TSOffsetStyleGCs(style, x, y);
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -387,26 +387,31 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
gboolean isradio, GtkTextDirection direction)
{
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
gint x, y, width, height;
GtkStyleContext *style;
const ToggleGTKMetrics* metrics = GetToggleMetrics(isradio);
- // XXX we should assert rect->height >= indicator_size too
- // after bug 369581 is fixed.
- MOZ_ASSERT(rect->width >= metrics->minSizeWithBorder.width,
- "GetMinimumWidgetSize was ignored");
-
- // Paint it center aligned in the rect.
- width = metrics->minSizeWithBorder.width;
- height = metrics->minSizeWithBorder.height;
- x = rect->x + (rect->width - width) / 2;
- y = rect->y + (rect->height - height) / 2;
+ // Clamp the rect and paint it center aligned in the rect.
+ x = rect->x;
+ y = rect->y;
+ width = rect->width;
+ height = rect->height;
+
+ if (rect->width < rect->height) {
+ y = rect->y + (rect->height - rect->width) / 2;
+ height = rect->width;
+ }
+
+ if (rect->height < rect->width) {
+ x = rect->x + (rect->width - rect->height) / 2;
+ width = rect->height;
+ }
if (selected)
state_flags = static_cast<GtkStateFlags>(state_flags|checkbox_check_state);
if (inconsistent)
state_flags = static_cast<GtkStateFlags>(state_flags|GTK_STATE_FLAG_INCONSISTENT);
style = GetStyleContext(isradio ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON,