Title: [286581] trunk
Revision
286581
Author
[email protected]
Date
2021-12-06 17:15:26 -0800 (Mon, 06 Dec 2021)

Log Message

<input type="time">'s range should be reversible
https://bugs.webkit.org/show_bug.cgi?id=233835

Reviewed by Darin Adler.

Source/WebCore:

<input type="time">'s range should be reversible when checking for overflow / underflow:
- https://html.spec.whatwg.org/#has-a-periodic-domain

No new tests, rebaselined existing tests.

* html/InputType.cpp:
(WebCore::InputType::rangeUnderflow const):
(WebCore::InputType::rangeOverflow const):
* html/StepRange.cpp:
(WebCore::StepRange::StepRange):
* html/StepRange.h:
(WebCore::StepRange::isReversible const):
* html/TimeInputType.cpp:
(WebCore::TimeInputType::createStepRange const):

LayoutTests:

Rebaseline WPT tests that are now passing.

* platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt:
* platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286580 => 286581)


--- trunk/LayoutTests/ChangeLog	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/LayoutTests/ChangeLog	2021-12-07 01:15:26 UTC (rev 286581)
@@ -1,3 +1,15 @@
+2021-12-06  Chris Dumez  <[email protected]>
+
+        <input type="time">'s range should be reversible
+        https://bugs.webkit.org/show_bug.cgi?id=233835
+
+        Reviewed by Darin Adler.
+
+        Rebaseline WPT tests that are now passing.
+
+        * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt:
+        * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt:
+
 2021-12-06  Ryan Haddad  <[email protected]>
 
         [ iOS ] imported/w3c/web-platform-tests/content-security-policy/worker-src/service-* tests are consistently failing

Modified: trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow-expected.txt (286580 => 286581)


--- trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow-expected.txt	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow-expected.txt	2021-12-07 01:15:26 UTC (rev 286581)
@@ -13,7 +13,8 @@
 PASS The value "13:16" overflows the maximum value "13:15".
 PASS The value "23:59:59.999" overflows the maximum value "13:16".
 PASS The value "13:16" overflows the maximum value "12:00".
-PASS The value "23:59:59.999" overflows the maximum value "13:16" when disabled.
+PASS The value "23:59:59.999" doesn't overflow the maximum value "13:16" when disabled.
+PASS The value "13:17:59.999" overflows the maximum value "13:16" when disabled.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow.html (286580 => 286581)


--- trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow.html	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow.html	2021-12-07 01:15:26 UTC (rev 286581)
@@ -66,7 +66,8 @@
 checkOverflow('13:16', '12:00');
 
 // Disabled
-checkOverflow('23:59:59.999', '13:16', true);
+checkNotOverflow('23:59:59.999', '13:16', true);
+checkOverflow('13:17:59.999', '13:16', true);
 </script>
 <script src=""
 </body>

Modified: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt (286580 => 286581)


--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt	2021-12-07 01:15:26 UTC (rev 286581)
@@ -55,8 +55,8 @@
 PASS [INPUT in TIME status] The time missing second part is valid
 PASS [INPUT in TIME status] The time is max for reversed range
 PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
-FAIL [INPUT in TIME status] The time is min for reversed range assert_false: The validity.rangeOverflow should be false. expected false got true
-FAIL [INPUT in TIME status] The time is inside the accepted range for reversed range assert_false: The validity.rangeOverflow should be false. expected false got true
+PASS [INPUT in TIME status] The time is min for reversed range
+PASS [INPUT in TIME status] The time is inside the accepted range for reversed range
 PASS [INPUT in NUMBER status] The max attribute is not set
 PASS [INPUT in NUMBER status] Value is empty string
 PASS [INPUT in NUMBER status] The max is greater than value(integer)

Modified: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt (286580 => 286581)


--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt	2021-12-07 01:15:26 UTC (rev 286581)
@@ -51,7 +51,7 @@
 PASS [INPUT in TIME status] The value is less than min(with millisecond in 2 digit)
 PASS [INPUT in TIME status] The value is less than min(with millisecond in 3 digit)
 PASS [INPUT in TIME status] The time missing second part is valid
-FAIL [INPUT in TIME status] The time is max for reversed range assert_false: The validity.rangeUnderflow should be false. expected false got true
+PASS [INPUT in TIME status] The time is max for reversed range
 PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
 PASS [INPUT in TIME status] The time is min for reversed range
 PASS [INPUT in TIME status] The time is inside the accepted range for reversed range

Modified: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt (286580 => 286581)


--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt	2021-12-07 01:15:26 UTC (rev 286581)
@@ -55,8 +55,8 @@
 PASS [INPUT in TIME status] The time missing second part is valid
 PASS [INPUT in TIME status] The time is max for reversed range
 PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
-FAIL [INPUT in TIME status] The time is min for reversed range assert_false: The validity.rangeOverflow should be false. expected false got true
-FAIL [INPUT in TIME status] The time is inside the accepted range for reversed range assert_false: The validity.rangeOverflow should be false. expected false got true
+PASS [INPUT in TIME status] The time is min for reversed range
+PASS [INPUT in TIME status] The time is inside the accepted range for reversed range
 PASS [INPUT in NUMBER status] The max attribute is not set
 PASS [INPUT in NUMBER status] Value is empty string
 PASS [INPUT in NUMBER status] The max is greater than value(integer)

Modified: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt (286580 => 286581)


--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt	2021-12-07 01:15:26 UTC (rev 286581)
@@ -51,7 +51,7 @@
 PASS [INPUT in TIME status] The value is less than min(with millisecond in 2 digit)
 PASS [INPUT in TIME status] The value is less than min(with millisecond in 3 digit)
 PASS [INPUT in TIME status] The time missing second part is valid
-FAIL [INPUT in TIME status] The time is max for reversed range assert_false: The validity.rangeUnderflow should be false. expected false got true
+PASS [INPUT in TIME status] The time is max for reversed range
 PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
 PASS [INPUT in TIME status] The time is min for reversed range
 PASS [INPUT in TIME status] The time is inside the accepted range for reversed range

Modified: trunk/Source/WebCore/ChangeLog (286580 => 286581)


--- trunk/Source/WebCore/ChangeLog	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/Source/WebCore/ChangeLog	2021-12-07 01:15:26 UTC (rev 286581)
@@ -1,3 +1,25 @@
+2021-12-06  Chris Dumez  <[email protected]>
+
+        <input type="time">'s range should be reversible
+        https://bugs.webkit.org/show_bug.cgi?id=233835
+
+        Reviewed by Darin Adler.
+
+        <input type="time">'s range should be reversible when checking for overflow / underflow:
+        - https://html.spec.whatwg.org/#has-a-periodic-domain
+
+        No new tests, rebaselined existing tests.
+
+        * html/InputType.cpp:
+        (WebCore::InputType::rangeUnderflow const):
+        (WebCore::InputType::rangeOverflow const):
+        * html/StepRange.cpp:
+        (WebCore::StepRange::StepRange):
+        * html/StepRange.h:
+        (WebCore::StepRange::isReversible const):
+        * html/TimeInputType.cpp:
+        (WebCore::TimeInputType::createStepRange const):
+
 2021-12-06  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process] Make FilterEffect calculate the primitive subregion only when needed

Modified: trunk/Source/WebCore/html/InputType.cpp (286580 => 286581)


--- trunk/Source/WebCore/html/InputType.cpp	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/Source/WebCore/html/InputType.cpp	2021-12-07 01:15:26 UTC (rev 286581)
@@ -269,7 +269,12 @@
     if (!numericValue.isFinite())
         return false;
 
-    return numericValue < createStepRange(AnyStepHandling::Reject).minimum();
+    auto range = createStepRange(AnyStepHandling::Reject);
+
+    if (range.isReversible() && range.maximum() < range.minimum())
+        return numericValue > range.maximum() && numericValue < range.minimum();
+
+    return numericValue < range.minimum();
 }
 
 bool InputType::rangeOverflow(const String& value) const
@@ -281,7 +286,12 @@
     if (!numericValue.isFinite())
         return false;
 
-    return numericValue > createStepRange(AnyStepHandling::Reject).maximum();
+    auto range = createStepRange(AnyStepHandling::Reject);
+
+    if (range.isReversible() && range.maximum() < range.minimum())
+        return numericValue > range.maximum() && numericValue < range.minimum();
+
+    return numericValue > range.maximum();
 }
 
 bool InputType::isInvalid(const String& value) const

Modified: trunk/Source/WebCore/html/StepRange.cpp (286580 => 286581)


--- trunk/Source/WebCore/html/StepRange.cpp	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/Source/WebCore/html/StepRange.cpp	2021-12-07 01:15:26 UTC (rev 286581)
@@ -50,7 +50,7 @@
 {
 }
 
-StepRange::StepRange(const Decimal& stepBase, RangeLimitations rangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription)
+StepRange::StepRange(const Decimal& stepBase, RangeLimitations rangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription, IsReversible isReversible)
     : m_maximum(maximum)
     , m_minimum(minimum)
     , m_step(step.isFinite() ? step : 1)
@@ -58,6 +58,7 @@
     , m_stepDescription(stepDescription)
     , m_hasRangeLimitations(rangeLimitations == RangeLimitations::Valid)
     , m_hasStep(step.isFinite())
+    , m_isReversible(isReversible == IsReversible::Yes)
 {
     ASSERT(m_maximum.isFinite());
     ASSERT(m_minimum.isFinite());

Modified: trunk/Source/WebCore/html/StepRange.h (286580 => 286581)


--- trunk/Source/WebCore/html/StepRange.h	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/Source/WebCore/html/StepRange.h	2021-12-07 01:15:26 UTC (rev 286581)
@@ -61,9 +61,11 @@
         }
     };
 
+    enum class IsReversible : bool { No, Yes };
+
     StepRange();
     StepRange(const StepRange&);
-    StepRange(const Decimal& stepBase, RangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription&);
+    StepRange(const Decimal& stepBase, RangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription&, IsReversible = IsReversible::No);
     Decimal acceptableError() const;
     Decimal alignValueForStep(const Decimal& currentValue, const Decimal& newValue) const;
     Decimal clampValue(const Decimal& value) const;
@@ -76,6 +78,7 @@
     Decimal stepBase() const { return m_stepBase; }
     int stepScaleFactor() const { return m_stepDescription.stepScaleFactor; }
     bool stepMismatch(const Decimal&) const;
+    bool isReversible() const { return m_isReversible; }
 
     // Clamp the middle value according to the step
     Decimal defaultValue() const
@@ -109,6 +112,7 @@
     const StepDescription m_stepDescription;
     const bool m_hasRangeLimitations { false };
     const bool m_hasStep { false };
+    const bool m_isReversible { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/TimeInputType.cpp (286580 => 286581)


--- trunk/Source/WebCore/html/TimeInputType.cpp	2021-12-07 01:13:33 UTC (rev 286580)
+++ trunk/Source/WebCore/html/TimeInputType.cpp	2021-12-07 01:15:26 UTC (rev 286581)
@@ -90,7 +90,7 @@
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), Decimal::fromDouble(DateComponents::minimumTime()));
     const Decimal maximum = parseToNumber(element()->attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumTime()));
     const Decimal step = StepRange::parseStep(anyStepHandling, timeStepDescription, element()->attributeWithoutSynchronization(stepAttr));
-    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, timeStepDescription);
+    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, timeStepDescription, StepRange::IsReversible::Yes);
 }
 
 std::optional<DateComponents> TimeInputType::parseToDateComponents(StringView source) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to