Bug 933260 - Honor the specified CSS width and height on <input type=checkbox/radio> also on Linux. r=karlt
authorMats Palmgren <matspal@gmail.com>
Sat, 02 Nov 2013 12:11:30 +0000
changeset 167816 08ad8ae130cbdbc9ac53c455dd79910110ae28cc
parent 167815 f461151bdf2902dc42b8476b5d0441c41032a8fa
child 167817 b47fb3e914569889784085721305f0814d705824
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs933260
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 933260 - Honor the specified CSS width and height on <input type=checkbox/radio> also on Linux. r=karlt
layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html
layout/reftests/forms/input/checkbox/gtk-theme-width-height.html
layout/reftests/forms/input/checkbox/reftest.list
layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html
layout/reftests/forms/input/radio/gtk-theme-width-height.html
layout/reftests/forms/input/radio/reftest.list
widget/gtk/gtk2drawing.c
widget/gtk/gtk3drawing.c
widget/gtk/nsNativeThemeGTK.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Testcase for bug 932506</title>
+  <style>
+
+input { outline:1px solid black; }
+
+</style>
+</head>
+<body>
+
+<div style="overflow:hidden; width:160px;">
+  <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>
+<input type="checkbox" checked style="height:100px;"><br>
+<input type="checkbox" checked style=""><br>
+
+<input type="checkbox" checked style="width:400px;"><br>
+<input type="checkbox" checked style="height:100px;"><br>
+<input type="checkbox" checked style=""><br>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/checkbox/gtk-theme-width-height.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Testcase for bug 932506</title>
+  <style>
+
+input { outline:1px solid black; }
+
+</style>
+</head>
+<body>
+
+<div style="overflow:hidden; width:160px;">
+  <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>
+<input type="checkbox" checked style="width:1px; height:1px;"><br>
+
+<input type="checkbox" checked style="width:400px; height:0;"><br>
+<input type="checkbox" checked style="width:0; height:100px;"><br>
+<input type="checkbox" checked style="width:0; height:0;"><br>
+
+</body>
+</html>
--- a/layout/reftests/forms/input/checkbox/reftest.list
+++ b/layout/reftests/forms/input/checkbox/reftest.list
@@ -6,8 +6,9 @@ skip-if(B2G) fails-if(Android) == radio-
 != checked-notref.html about:blank
 != checked-native.html about:blank
 != checked-native-notref.html about:blank
 != indeterminate-checked.html indeterminate-checked-notref.html
 != indeterminate-unchecked.html indeterminate-unchecked-notref.html
 != indeterminate-native-checked.html indeterminate-native-checked-notref.html
 != indeterminate-native-unchecked.html indeterminate-native-unchecked-notref.html
 == indeterminate-selector.html indeterminate-selector-ref.html
+skip-if(!gtk2Widget) == gtk-theme-width-height.html gtk-theme-width-height-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Testcase for bug 932506</title>
+  <style>
+
+input { outline:1px solid black; }
+
+</style>
+</head>
+<body>
+
+<div style="overflow:hidden; width:160px;">
+  <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>
+<input type="radio" checked style="height:100px;"><br>
+<input type="radio" checked style=""><br>
+
+<input type="radio" checked style="width:400px;"><br>
+<input type="radio" checked style="height:100px;"><br>
+<input type="radio" checked style=""><br>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/radio/gtk-theme-width-height.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Testcase for bug 932506</title>
+  <style>
+
+input { outline:1px solid black; }
+
+</style>
+</head>
+<body>
+
+<div style="overflow:hidden; width:160px;">
+  <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>
+<input type="radio" checked style="width:1px; height:1px;"><br>
+
+<input type="radio" checked style="width:400px; height:0;"><br>
+<input type="radio" checked style="width:0; height:100px;"><br>
+<input type="radio" checked style="width:0; height:0;"><br>
+
+</body>
+</html>
--- a/layout/reftests/forms/input/radio/reftest.list
+++ b/layout/reftests/forms/input/radio/reftest.list
@@ -1,7 +1,8 @@
 == label-dynamic.html label-dynamic-ref.html
 != checked.html checked-notref.html
 != checked-native.html checked-native-notref.html
 != checked.html about:blank
 != checked-notref.html about:blank
 != checked-native.html about:blank
 != checked-native-notref.html about:blank
+skip-if(!gtk2Widget) == gtk-theme-width-height.html gtk-theme-width-height-ref.html
--- a/widget/gtk/gtk2drawing.c
+++ b/widget/gtk/gtk2drawing.c
@@ -1041,23 +1041,23 @@ 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;
     }
 
-    NS_ASSERTION(rect->width == indicator_size,
+    // XXX we should assert rect->height >= indicator_size too
+    // after bug 369581 is fixed.
+    NS_ASSERTION(rect->width >= indicator_size,
                  "GetMinimumWidgetSize was ignored");
-    /*
-     * vertically center in the box, since XUL sometimes ignores our
-     * GetMinimumWidgetSize in the vertical dimension
-     */
-    x = rect->x;
+
+    // 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;
 
     focus_x = x - indicator_spacing;
     focus_y = y - indicator_spacing;
     focus_width = width + 2 * indicator_spacing;
     focus_height = height + 2 * indicator_spacing;
--- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c
@@ -953,23 +953,23 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
     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;
     }
 
-    NS_ASSERTION(rect->width == indicator_size,
+    // XXX we should assert rect->height >= indicator_size too
+    // after bug 369581 is fixed.
+    NS_ASSERTION(rect->width >= indicator_size,
                  "GetMinimumWidgetSize was ignored");
-    /*
-     * vertically center in the box, since XUL sometimes ignores our
-     * GetMinimumWidgetSize in the vertical dimension
-     */
-    x = rect->x;
+
+    // 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;
 
     focus_x = x - indicator_spacing;
     focus_y = y - indicator_spacing;
     focus_width = width + 2 * indicator_spacing;
     focus_height = height + 2 * indicator_spacing;
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1181,17 +1181,16 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
         moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
       } else {
         moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
       }
 
       // Include space for the indicator and the padding around it.
       aResult->width = indicator_size;
       aResult->height = indicator_size;
-      *aIsOverridable = false;
     }
     break;
   case NS_THEME_TOOLBAR_BUTTON_DROPDOWN:
   case NS_THEME_BUTTON_ARROW_UP:
   case NS_THEME_BUTTON_ARROW_DOWN:
   case NS_THEME_BUTTON_ARROW_NEXT:
   case NS_THEME_BUTTON_ARROW_PREVIOUS:
     {