Title: [289209] trunk
Revision
289209
Author
[email protected]
Date
2022-02-07 05:51:03 -0800 (Mon, 07 Feb 2022)

Log Message

[Forms] Use min as default value when min > max for input type="range"
https://bugs.webkit.org/show_bug.cgi?id=236223

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Update the sub test expectation that is now passing.
* web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt:

Source/WebCore:

As per spec https://html.spec.whatwg.org/multipage/input.html#concept-input-value-default-range,
in the case of "the maximum is less than the minimum, in which case the default value is the minimum".

* html/RangeInputType.cpp:
(WebCore::ensureMaximum):
(WebCore::RangeInputType::createStepRange const):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (289208 => 289209)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-07 13:49:21 UTC (rev 289208)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-07 13:51:03 UTC (rev 289209)
@@ -1,3 +1,13 @@
+2022-02-07  Ziran Sun  <[email protected]>
+
+        [Forms] Use min as default value when min > max for input type="range"
+        https://bugs.webkit.org/show_bug.cgi?id=236223
+
+        Reviewed by Darin Adler.
+
+        Update the sub test expectation that is now passing.
+        * web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt:
+
 2022-02-06  Sam Weinig  <[email protected]>
 
         Update serialization of rgb() functions with none components to latest spec

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt (289208 => 289209)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt	2022-02-07 13:49:21 UTC (rev 289208)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt	2022-02-07 13:51:03 UTC (rev 289209)
@@ -14,7 +14,7 @@
 PASS default value of max attribute in input type=range
 PASS default value when min and max attributes are given (= min plus half the difference between min and max)
 PASS default value with step control when both min and max attributes are given
-FAIL default value when both min and max attributes are given, while min > max assert_equals: expected "2" but got "51"
+PASS default value when both min and max attributes are given, while min > max
 PASS The default step scale factor is 1, unless min attribute has non-integer value
 PASS Step scale factor behavior when min attribute has integer value but max attribute is non-integer
 FAIL The default scale factor is 1 even if step attribute is explicitly set to non-integer value, unless min attribute has non-integer value assert_equals: expected "1" but got "0.5"

Modified: trunk/Source/WebCore/ChangeLog (289208 => 289209)


--- trunk/Source/WebCore/ChangeLog	2022-02-07 13:49:21 UTC (rev 289208)
+++ trunk/Source/WebCore/ChangeLog	2022-02-07 13:51:03 UTC (rev 289209)
@@ -1,3 +1,17 @@
+2022-02-07  Ziran Sun  <[email protected]>
+
+        [Forms] Use min as default value when min > max for input type="range"
+        https://bugs.webkit.org/show_bug.cgi?id=236223
+
+        Reviewed by Darin Adler.
+
+        As per spec https://html.spec.whatwg.org/multipage/input.html#concept-input-value-default-range,
+        in the case of "the maximum is less than the minimum, in which case the default value is the minimum".
+
+        * html/RangeInputType.cpp:
+        (WebCore::ensureMaximum):
+        (WebCore::RangeInputType::createStepRange const):
+
 2022-02-07  Joonghun Park  <[email protected]>
 
         Remove unused CSSCalcExpressionNodeParser::parseValueTerm from CSSCalcExpressionNodeParser.h.

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (289208 => 289209)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2022-02-07 13:49:21 UTC (rev 289208)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2022-02-07 13:51:03 UTC (rev 289209)
@@ -75,9 +75,9 @@
 static const int rangeStepScaleFactor = 1;
 static const StepRange::StepDescription rangeStepDescription { rangeDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor };
 
-static Decimal ensureMaximum(const Decimal& proposedValue, const Decimal& minimum, const Decimal& fallbackValue)
+static Decimal ensureMaximum(const Decimal& proposedValue, const Decimal& minimum)
 {
-    return proposedValue >= minimum ? proposedValue : std::max(minimum, fallbackValue);
+    return proposedValue >= minimum ? proposedValue : minimum;
 }
 
 RangeInputType::RangeInputType(HTMLInputElement& element)
@@ -118,7 +118,7 @@
 {
     ASSERT(element());
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), rangeDefaultMinimum);
-    const Decimal maximum = ensureMaximum(parseToNumber(element()->attributeWithoutSynchronization(maxAttr), rangeDefaultMaximum), minimum, rangeDefaultMaximum);
+    const Decimal maximum = ensureMaximum(parseToNumber(element()->attributeWithoutSynchronization(maxAttr), rangeDefaultMaximum), minimum);
 
     const AtomString& precisionValue = element()->attributeWithoutSynchronization(precisionAttr);
     if (!precisionValue.isNull()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to