Changeset 286581 in webkit


Ignore:
Timestamp:
Dec 6, 2021 5:15:26 PM (8 months ago)
Author:
Chris Dumez
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:

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:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286577 r286581  
     12021-12-06  Chris Dumez  <cdumez@apple.com>
     2
     3        <input type="time">'s range should be reversible
     4        https://bugs.webkit.org/show_bug.cgi?id=233835
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline WPT tests that are now passing.
     9
     10        * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt:
     11        * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt:
     12
    1132021-12-06  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow-expected.txt

    r286316 r286581  
    1414PASS The value "23:59:59.999" overflows the maximum value "13:16".
    1515PASS The value "13:16" overflows the maximum value "12:00".
    16 PASS The value "23:59:59.999" overflows the maximum value "13:16" when disabled.
     16PASS The value "23:59:59.999" doesn't overflow the maximum value "13:16" when disabled.
     17PASS The value "13:17:59.999" overflows the maximum value "13:16" when disabled.
    1718PASS successfullyParsed is true
    1819
  • trunk/LayoutTests/fast/forms/time/time-validity-rangeoverflow.html

    r286316 r286581  
    6767
    6868// Disabled
    69 checkOverflow('23:59:59.999', '13:16', true);
     69checkNotOverflow('23:59:59.999', '13:16', true);
     70checkOverflow('13:17:59.999', '13:16', true);
    7071</script>
    7172<script src="../../../resources/js-test-post.js"></script>
  • trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt

    r286331 r286581  
    5656PASS [INPUT in TIME status] The time is max for reversed range
    5757PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
    58 FAIL [INPUT in TIME status] The time is min for reversed range assert_false: The validity.rangeOverflow should be false. expected false got true
    59 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
     58PASS [INPUT in TIME status] The time is min for reversed range
     59PASS [INPUT in TIME status] The time is inside the accepted range for reversed range
    6060PASS [INPUT in NUMBER status] The max attribute is not set
    6161PASS [INPUT in NUMBER status] Value is empty string
  • trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt

    r286331 r286581  
    5252PASS [INPUT in TIME status] The value is less than min(with millisecond in 3 digit)
    5353PASS [INPUT in TIME status] The time missing second part is valid
    54 FAIL [INPUT in TIME status] The time is max for reversed range assert_false: The validity.rangeUnderflow should be false. expected false got true
     54PASS [INPUT in TIME status] The time is max for reversed range
    5555PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
    5656PASS [INPUT in TIME status] The time is min for reversed range
  • trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt

    r286316 r286581  
    5656PASS [INPUT in TIME status] The time is max for reversed range
    5757PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
    58 FAIL [INPUT in TIME status] The time is min for reversed range assert_false: The validity.rangeOverflow should be false. expected false got true
    59 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
     58PASS [INPUT in TIME status] The time is min for reversed range
     59PASS [INPUT in TIME status] The time is inside the accepted range for reversed range
    6060PASS [INPUT in NUMBER status] The max attribute is not set
    6161PASS [INPUT in NUMBER status] Value is empty string
  • trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt

    r286316 r286581  
    5252PASS [INPUT in TIME status] The value is less than min(with millisecond in 3 digit)
    5353PASS [INPUT in TIME status] The time missing second part is valid
    54 FAIL [INPUT in TIME status] The time is max for reversed range assert_false: The validity.rangeUnderflow should be false. expected false got true
     54PASS [INPUT in TIME status] The time is max for reversed range
    5555PASS [INPUT in TIME status] The time is outside the accepted range for reversed range
    5656PASS [INPUT in TIME status] The time is min for reversed range
  • trunk/Source/WebCore/ChangeLog

    r286578 r286581  
     12021-12-06  Chris Dumez  <cdumez@apple.com>
     2
     3        <input type="time">'s range should be reversible
     4        https://bugs.webkit.org/show_bug.cgi?id=233835
     5
     6        Reviewed by Darin Adler.
     7
     8        <input type="time">'s range should be reversible when checking for overflow / underflow:
     9        - https://html.spec.whatwg.org/#has-a-periodic-domain
     10
     11        No new tests, rebaselined existing tests.
     12
     13        * html/InputType.cpp:
     14        (WebCore::InputType::rangeUnderflow const):
     15        (WebCore::InputType::rangeOverflow const):
     16        * html/StepRange.cpp:
     17        (WebCore::StepRange::StepRange):
     18        * html/StepRange.h:
     19        (WebCore::StepRange::isReversible const):
     20        * html/TimeInputType.cpp:
     21        (WebCore::TimeInputType::createStepRange const):
     22
    1232021-12-06  Said Abou-Hallawa  <said@apple.com>
    224
  • trunk/Source/WebCore/html/InputType.cpp

    r286560 r286581  
    270270        return false;
    271271
    272     return numericValue < createStepRange(AnyStepHandling::Reject).minimum();
     272    auto range = createStepRange(AnyStepHandling::Reject);
     273
     274    if (range.isReversible() && range.maximum() < range.minimum())
     275        return numericValue > range.maximum() && numericValue < range.minimum();
     276
     277    return numericValue < range.minimum();
    273278}
    274279
     
    282287        return false;
    283288
    284     return numericValue > createStepRange(AnyStepHandling::Reject).maximum();
     289    auto range = createStepRange(AnyStepHandling::Reject);
     290
     291    if (range.isReversible() && range.maximum() < range.minimum())
     292        return numericValue > range.maximum() && numericValue < range.minimum();
     293
     294    return numericValue > range.maximum();
    285295}
    286296
  • trunk/Source/WebCore/html/StepRange.cpp

    r264600 r286581  
    5151}
    5252
    53 StepRange::StepRange(const Decimal& stepBase, RangeLimitations rangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription)
     53StepRange::StepRange(const Decimal& stepBase, RangeLimitations rangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription, IsReversible isReversible)
    5454    : m_maximum(maximum)
    5555    , m_minimum(minimum)
     
    5959    , m_hasRangeLimitations(rangeLimitations == RangeLimitations::Valid)
    6060    , m_hasStep(step.isFinite())
     61    , m_isReversible(isReversible == IsReversible::Yes)
    6162{
    6263    ASSERT(m_maximum.isFinite());
  • trunk/Source/WebCore/html/StepRange.h

    r264656 r286581  
    6262    };
    6363
     64    enum class IsReversible : bool { No, Yes };
     65
    6466    StepRange();
    6567    StepRange(const StepRange&);
    66     StepRange(const Decimal& stepBase, RangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription&);
     68    StepRange(const Decimal& stepBase, RangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription&, IsReversible = IsReversible::No);
    6769    Decimal acceptableError() const;
    6870    Decimal alignValueForStep(const Decimal& currentValue, const Decimal& newValue) const;
     
    7779    int stepScaleFactor() const { return m_stepDescription.stepScaleFactor; }
    7880    bool stepMismatch(const Decimal&) const;
     81    bool isReversible() const { return m_isReversible; }
    7982
    8083    // Clamp the middle value according to the step
     
    110113    const bool m_hasRangeLimitations { false };
    111114    const bool m_hasStep { false };
     115    const bool m_isReversible { false };
    112116};
    113117
  • trunk/Source/WebCore/html/TimeInputType.cpp

    r283851 r286581  
    9191    const Decimal maximum = parseToNumber(element()->attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumTime()));
    9292    const Decimal step = StepRange::parseStep(anyStepHandling, timeStepDescription, element()->attributeWithoutSynchronization(stepAttr));
    93     return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, timeStepDescription);
     93    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, timeStepDescription, StepRange::IsReversible::Yes);
    9494}
    9595
Note: See TracChangeset for help on using the changeset viewer.