Convert DateComponents parsing code to use Optional based return values rather than...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 Jun 2020 19:58:25 +0000 (19:58 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 Jun 2020 19:58:25 +0000 (19:58 +0000)
commit2b0ee7b423eb24ebf52f2d830e7447c8fe63631f
tree4105bc039993196e96060b751bcee2b08beeb4a8
parentea37a48b7ed245a151daf09dd3fef591a04ddd44
Convert DateComponents parsing code to use Optional based return values rather than out-parameters
https://bugs.webkit.org/show_bug.cgi?id=213440

Reviewed by Darin Adler.

Rework DateComponents and Date/Time related InputTypes to use Optional based programming
for parsing results. Also take the opportunity to remove unicode upconversion from
DateComponent parsing and instead separate UChar and LChar variants via templates.

* html/BaseDateAndTimeInputType.cpp:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
* html/DateInputType.h:
* html/DateTimeInputType.cpp:
* html/DateTimeInputType.h:
* html/DateTimeLocalInputType.cpp:
* html/DateTimeLocalInputType.h:
* html/HTMLInputElement.cpp:
* html/HTMLInputElement.h:
* html/InputType.cpp:
* html/InputType.h:
* html/MonthInputType.cpp:
* html/MonthInputType.h:
* html/TimeInputType.cpp:
* html/TimeInputType.h:
* html/WeekInputType.cpp:
* html/WeekInputType.h:
    - Removes parseToDateComponentsInternal. No need it and parseToDateComponents.
    - Makes parseToDateComponents pure virtual. The old code had a default implementations
      down in InputType, but it had no callers.
    - Remove iOS vs. non-iOS difference for dateType(). It is now available on InputType
      on all platforms.
    - Make setMillisecondToDateComponents and parseToDateComponents return an Optional.

* platform/DateComponents.cpp:
* platform/DateComponents.h:
    - Replace member function based interfaces for parsing/setting explicit time offsets
      with new factory functions that return Optional<DateComponents>.
    - These factories are implemented using the existing member functions, which are
      now private.
    - Make max/min constants constexpr.
    - Make parse* member functions templates to allow factory parse functions to
      call them without upconverting.
    - Replace header guard with #pragma once.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263331 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/BaseDateAndTimeInputType.cpp
Source/WebCore/html/BaseDateAndTimeInputType.h
Source/WebCore/html/DateInputType.cpp
Source/WebCore/html/DateInputType.h
Source/WebCore/html/DateTimeInputType.cpp
Source/WebCore/html/DateTimeInputType.h
Source/WebCore/html/DateTimeLocalInputType.cpp
Source/WebCore/html/DateTimeLocalInputType.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/MonthInputType.cpp
Source/WebCore/html/MonthInputType.h
Source/WebCore/html/TimeInputType.cpp
Source/WebCore/html/TimeInputType.h
Source/WebCore/html/WeekInputType.cpp
Source/WebCore/html/WeekInputType.h
Source/WebCore/platform/DateComponents.cpp
Source/WebCore/platform/DateComponents.h