Title: [219813] releases/WebKitGTK/webkit-2.16/Source/WebCore
Revision
219813
Author
[email protected]
Date
2017-07-24 04:07:13 -0700 (Mon, 24 Jul 2017)

Log Message

Merge r219332, r219447 - [GTK] Spin buttons on input type number appear over the value itself for small widths
https://bugs.webkit.org/show_bug.cgi?id=173572

Reviewed by Carlos Garcia Campos.

Source/WebCore:

When drawing the spin buttons, override the width of the input
element to increment it with the width of the spin button.
This ensures that we don't end up covering the input values with
the spin buttons.

Do this also for user controlled styles, because most web authors
won't test how their site renders on WebKitGTK+, and they will
assume spin buttons in the order of 13 pixels wide (that is what
most browsers use), but the GTK+ spin button is much wider (66 pixels).

* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle):
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::adjustTextFieldStyle): Call the theme's adjustTextFieldStyle() also for user controlled styles.
(WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):

REGRESSION(r219332): [GTK] 9 new failures on fast/forms spinbutton related tests
https://bugs.webkit.org/show_bug.cgi?id=174395

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Before r219332 the height of the spin button widget was
calculated as the maximum value between the individual button
( the [+] or [-] ) width (33 pixels) and height (16 pixels).
And r219332 caused the height of the widget to be calculated as
the height of the button (16 pixels), which was incorrect as
each button should be first expanded vertically to fit the
preferred size of the widget.

Fix this by making the calculations about the spin button widget
on a new function spinButtonSize() that takes this into account,
and use this values both for adjusting the style of the input
field and the spin button widget itself.

* rendering/RenderThemeGtk.cpp:
(WebCore::spinButtonSize):
(WebCore::RenderThemeGtk::adjustTextFieldStyle):
(WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (219812 => 219813)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-07-24 10:57:33 UTC (rev 219812)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-07-24 11:07:13 UTC (rev 219813)
@@ -1,3 +1,55 @@
+2017-07-12  Carlos Alberto Lopez Perez  <[email protected]>
+
+        REGRESSION(r219332): [GTK] 9 new failures on fast/forms spinbutton related tests
+        https://bugs.webkit.org/show_bug.cgi?id=174395
+
+        Reviewed by Carlos Garcia Campos.
+
+        Covered by existing tests.
+
+        Before r219332 the height of the spin button widget was
+        calculated as the maximum value between the individual button
+        ( the [+] or [-] ) width (33 pixels) and height (16 pixels).
+        And r219332 caused the height of the widget to be calculated as
+        the height of the button (16 pixels), which was incorrect as
+        each button should be first expanded vertically to fit the
+        preferred size of the widget.
+
+        Fix this by making the calculations about the spin button widget
+        on a new function spinButtonSize() that takes this into account,
+        and use this values both for adjusting the style of the input
+        field and the spin button widget itself.
+
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::spinButtonSize):
+        (WebCore::RenderThemeGtk::adjustTextFieldStyle):
+        (WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
+
+2017-07-11  Carlos Alberto Lopez Perez  <[email protected]>
+
+        [GTK] Spin buttons on input type number appear over the value itself for small widths
+        https://bugs.webkit.org/show_bug.cgi?id=173572
+
+        Reviewed by Carlos Garcia Campos.
+
+        When drawing the spin buttons, override the width of the input
+        element to increment it with the width of the spin button.
+        This ensures that we don't end up covering the input values with
+        the spin buttons.
+
+        Do this also for user controlled styles, because most web authors
+        won't test how their site renders on WebKitGTK+, and they will
+        assume spin buttons in the order of 13 pixels wide (that is what
+        most browsers use), but the GTK+ spin button is much wider (66 pixels).
+
+        Test: platform/gtk/fast/forms/number/number-size-spinbutton-nocover.html
+
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::adjustStyle):
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::adjustTextFieldStyle): Call the theme's adjustTextFieldStyle() also for user controlled styles.
+        (WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
+
 2017-05-12  Jiewen Tan  <[email protected]>
 
         Elements should be inserted into a template element as its content's last child

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderTheme.cpp (219812 => 219813)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderTheme.cpp	2017-07-24 10:57:33 UTC (rev 219812)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderTheme.cpp	2017-07-24 11:07:13 UTC (rev 219813)
@@ -91,11 +91,18 @@
         style.setDisplay(BLOCK);
 
     if (UAHasAppearance && isControlStyled(style, border, background, backgroundColor)) {
-        if (part == MenulistPart) {
+        switch (part) {
+        case MenulistPart:
             style.setAppearance(MenulistButtonPart);
             part = MenulistButtonPart;
-        } else
+            break;
+        case TextFieldPart:
+            adjustTextFieldStyle(styleResolver, style, element);
+            FALLTHROUGH;
+        default:
             style.setAppearance(NoControlPart);
+            break;
+        }
     }
 
     if (!style.hasAppearance())

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderThemeGtk.cpp (219812 => 219813)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderThemeGtk.cpp	2017-07-24 10:57:33 UTC (rev 219812)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderThemeGtk.cpp	2017-07-24 11:07:13 UTC (rev 219813)
@@ -931,12 +931,9 @@
 }
 
 #if GTK_CHECK_VERSION(3, 20, 0)
-void RenderThemeGtk::adjustTextFieldStyle(StyleResolver&, RenderStyle& style, const Element* element) const
+
+static IntSize spinButtonSize()
 {
-    if (!is<HTMLInputElement>(element) || !shouldHaveSpinButton(downcast<HTMLInputElement>(*element)))
-        return;
-
-    // Spinbuttons need a minimum height to be rendered correctly.
     auto& spinButtonWidget = static_cast<RenderThemeSpinButton&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::SpinButton));
     spinButtonWidget.spinButton().setState(GTK_STATE_FLAG_NORMAL);
     spinButtonWidget.entry().setState(GTK_STATE_FLAG_NORMAL);
@@ -947,10 +944,27 @@
     preferredSize = preferredSize.expandedTo(spinButtonWidget.entry().preferredSize());
     IntSize upPreferredSize = preferredSize.expandedTo(spinButtonWidget.up().preferredSize());
     IntSize downPreferredSize = preferredSize.expandedTo(spinButtonWidget.down().preferredSize());
-    int height = std::max(upPreferredSize.height(), downPreferredSize.height());
-    style.setMinHeight(Length(height, Fixed));
+
+    return IntSize(upPreferredSize.width() + downPreferredSize.width(), std::max(upPreferredSize.height(), downPreferredSize.height()));
 }
 
+
+void RenderThemeGtk::adjustTextFieldStyle(StyleResolver&, RenderStyle& style, const Element* element) const
+{
+    if (!is<HTMLInputElement>(element) || !shouldHaveSpinButton(downcast<HTMLInputElement>(*element)))
+        return;
+
+    style.setMinHeight(Length(spinButtonSize().height(), Fixed));
+
+    // The default theme for the GTK+ port uses very wide spin buttons (66px) compared to what other
+    // browsers use (~13 px). And unfortunately, most of the web developers won't test how their site
+    // renders on WebKitGTK+. To ensure that spin buttons don't end up covering the values of the input
+    // field, we override the width of the input element and always increment it with the width needed
+    // for the spinbutton (when drawing the spinbutton).
+    int minimumWidth = style.width().intValue() + spinButtonSize().width();
+    style.setMinWidth(Length(minimumWidth, Fixed));
+}
+
 bool RenderThemeGtk::paintTextField(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
 {
     if (is<HTMLInputElement>(renderObject.node()) && shouldHaveSpinButton(downcast<HTMLInputElement>(*renderObject.node()))) {
@@ -1512,17 +1526,8 @@
 
 void RenderThemeGtk::adjustInnerSpinButtonStyle(StyleResolver&, RenderStyle& style, const Element*) const
 {
-    auto& spinButtonWidget = static_cast<RenderThemeSpinButton&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::SpinButton));
-    spinButtonWidget.spinButton().setState(GTK_STATE_FLAG_NORMAL);
-    spinButtonWidget.entry().setState(GTK_STATE_FLAG_NORMAL);
-    spinButtonWidget.up().setState(GTK_STATE_FLAG_NORMAL);
-    spinButtonWidget.down().setState(GTK_STATE_FLAG_NORMAL);
-
-    IntSize upPreferredSize = spinButtonWidget.up().preferredSize();
-    IntSize downPreferredSize = spinButtonWidget.down().preferredSize();
-    int buttonSize = std::max(std::max(upPreferredSize.width(), downPreferredSize.width()), std::max(upPreferredSize.height(), downPreferredSize.height()));
-    style.setWidth(Length(buttonSize * 2, Fixed));
-    style.setHeight(Length(buttonSize, Fixed));
+    style.setWidth(Length(spinButtonSize().width(), Fixed));
+    style.setHeight(Length(spinButtonSize().height(), Fixed));
 }
 
 bool RenderThemeGtk::paintInnerSpinButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to