[macOS] Date inputs should contain editable components
https://bugs.webkit.org/show_bug.cgi?id=215155
Reviewed by Devin Rousso.
Source/WebCore:
Currently, users are unable to edit the values in date and time input types.
To match system date controls, users should be able to select and edit
individual components of the input. For example, <input type="date"> should
contain an editable year, month, and day control.
Note that this functionality was present in WebKit, up until it was removed
in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
removed as it was only used by Chromium port. However, much of the removed
logic remains useful and is resurfaced in this patch. Modifications were made
to update the code to follow current WebKit practices.
DateTimeEditElement is a wrapper element that contains individual fields.
The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
are further specialized into DateTimeNumericFieldElement (for integral
values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
and P.M). DateTimeEditElement builds the control using the visitor pattern
and existing parsing logic contained in DateTimeFormat.
In order to reduce the patch size, this patch only sets up the rendering
and layout of multiple fields for <input type="date">. Upcoming patches will
add rendering for other date/time input types and introduce editability.
Test: fast/forms/date/date-pseudo-elements.html
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/html.css:
(input::-webkit-datetime-edit):
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input::-webkit-datetime-edit-text):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat):
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
(WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat const):
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat const):
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat const):
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::setupLayoutParameters const):
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat const):
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp: Added.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::build):
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::visitLiteral):
(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::fieldsWrapperElement const):
(WebCore::DateTimeEditElement::addField):
(WebCore::DateTimeEditElement::create):
(WebCore::DateTimeEditElement::layout):
(WebCore::DateTimeEditElement::localeIdentifier const):
(WebCore::DateTimeEditElement::resetFields):
(WebCore::DateTimeEditElement::setValueAsDate):
(WebCore::DateTimeEditElement::setEmptyValue):
(WebCore::DateTimeEditElement::value const):
* html/shadow/DateTimeEditElement.h: Added.
* html/shadow/DateTimeFieldElement.cpp: Added.
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
(WebCore::DateTimeFieldElement::initialize):
(WebCore::DateTimeFieldElement::localeForOwner const):
(WebCore::DateTimeFieldElement::localeIdentifier const):
(WebCore::DateTimeFieldElement::updateVisibleValue):
(WebCore::DateTimeFieldElement::supportsFocus const):
* html/shadow/DateTimeFieldElement.h: Added.
* html/shadow/DateTimeFieldElements.cpp: Added.
(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeDayFieldElement::setValueAsDate):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeMonthFieldElement::setValueAsDate):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):
(WebCore::DateTimeYearFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h: Added.
* html/shadow/DateTimeNumericFieldElement.cpp: Added.
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::formatValue const):
(WebCore::DateTimeNumericFieldElement::hasValue const):
(WebCore::DateTimeNumericFieldElement::initialize):
(WebCore::DateTimeNumericFieldElement::setEmptyValue):
(WebCore::DateTimeNumericFieldElement::setValueAsInteger):
(WebCore::DateTimeNumericFieldElement::value const):
(WebCore::DateTimeNumericFieldElement::valueAsInteger const):
(WebCore::DateTimeNumericFieldElement::visibleValue const):
* html/shadow/DateTimeNumericFieldElement.h: Added.
* html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
(WebCore::makeVisibleEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::hasValue const):
(WebCore::DateTimeSymbolicFieldElement::initialize):
(WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
(WebCore::DateTimeSymbolicFieldElement::value const):
(WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
(WebCore::DateTimeSymbolicFieldElement::visibleValue const):
* html/shadow/DateTimeSymbolicFieldElement.h: Added.
(WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
LayoutTests:
Added a test to verify styling of pseudo elements within date inputs.
Rebaselined existing tests to match new appearance.
* fast/forms/date/date-pseudo-elements-expected.txt: Added.
* fast/forms/date/date-pseudo-elements.html: Added.
* platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
* platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
Canonical link: https://commits.webkit.org/228787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 14:25:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Google Inc. All rights reserved.
|
|
|
|
* Copyright (C) 2020 Apple Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
|
|
|
|
|
|
|
|
#include "DateTimeNumericFieldElement.h"
|
|
|
|
#include "DateTimeSymbolicFieldElement.h"
|
|
|
|
|
|
|
|
namespace WebCore {
|
|
|
|
|
|
|
|
class DateTimeDayFieldElement final : public DateTimeNumericFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeDayFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeDayFieldElement> create(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeDayFieldElement(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Date inputs should contain editable components
https://bugs.webkit.org/show_bug.cgi?id=215155
Reviewed by Devin Rousso.
Source/WebCore:
Currently, users are unable to edit the values in date and time input types.
To match system date controls, users should be able to select and edit
individual components of the input. For example, <input type="date"> should
contain an editable year, month, and day control.
Note that this functionality was present in WebKit, up until it was removed
in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
removed as it was only used by Chromium port. However, much of the removed
logic remains useful and is resurfaced in this patch. Modifications were made
to update the code to follow current WebKit practices.
DateTimeEditElement is a wrapper element that contains individual fields.
The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
are further specialized into DateTimeNumericFieldElement (for integral
values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
and P.M). DateTimeEditElement builds the control using the visitor pattern
and existing parsing logic contained in DateTimeFormat.
In order to reduce the patch size, this patch only sets up the rendering
and layout of multiple fields for <input type="date">. Upcoming patches will
add rendering for other date/time input types and introduce editability.
Test: fast/forms/date/date-pseudo-elements.html
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/html.css:
(input::-webkit-datetime-edit):
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input::-webkit-datetime-edit-text):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat):
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
(WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat const):
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat const):
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat const):
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::setupLayoutParameters const):
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat const):
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp: Added.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::build):
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::visitLiteral):
(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::fieldsWrapperElement const):
(WebCore::DateTimeEditElement::addField):
(WebCore::DateTimeEditElement::create):
(WebCore::DateTimeEditElement::layout):
(WebCore::DateTimeEditElement::localeIdentifier const):
(WebCore::DateTimeEditElement::resetFields):
(WebCore::DateTimeEditElement::setValueAsDate):
(WebCore::DateTimeEditElement::setEmptyValue):
(WebCore::DateTimeEditElement::value const):
* html/shadow/DateTimeEditElement.h: Added.
* html/shadow/DateTimeFieldElement.cpp: Added.
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
(WebCore::DateTimeFieldElement::initialize):
(WebCore::DateTimeFieldElement::localeForOwner const):
(WebCore::DateTimeFieldElement::localeIdentifier const):
(WebCore::DateTimeFieldElement::updateVisibleValue):
(WebCore::DateTimeFieldElement::supportsFocus const):
* html/shadow/DateTimeFieldElement.h: Added.
* html/shadow/DateTimeFieldElements.cpp: Added.
(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeDayFieldElement::setValueAsDate):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeMonthFieldElement::setValueAsDate):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):
(WebCore::DateTimeYearFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h: Added.
* html/shadow/DateTimeNumericFieldElement.cpp: Added.
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::formatValue const):
(WebCore::DateTimeNumericFieldElement::hasValue const):
(WebCore::DateTimeNumericFieldElement::initialize):
(WebCore::DateTimeNumericFieldElement::setEmptyValue):
(WebCore::DateTimeNumericFieldElement::setValueAsInteger):
(WebCore::DateTimeNumericFieldElement::value const):
(WebCore::DateTimeNumericFieldElement::valueAsInteger const):
(WebCore::DateTimeNumericFieldElement::visibleValue const):
* html/shadow/DateTimeNumericFieldElement.h: Added.
* html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
(WebCore::makeVisibleEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::hasValue const):
(WebCore::DateTimeSymbolicFieldElement::initialize):
(WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
(WebCore::DateTimeSymbolicFieldElement::value const):
(WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
(WebCore::DateTimeSymbolicFieldElement::visibleValue const):
* html/shadow/DateTimeSymbolicFieldElement.h: Added.
(WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
LayoutTests:
Added a test to verify styling of pseudo elements within date inputs.
Rebaselined existing tests to match new appearance.
* fast/forms/date/date-pseudo-elements-expected.txt: Added.
* fast/forms/date/date-pseudo-elements.html: Added.
* platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
* platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
Canonical link: https://commits.webkit.org/228787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 14:25:37 +00:00
|
|
|
};
|
|
|
|
|
[macOS] Add editability to input type=time
https://bugs.webkit.org/show_bug.cgi?id=216188
Reviewed by Devin Rousso.
Source/WebCore:
This patch adds editability to input type=time by leveraging existing
logic to add editable components to date/time inputs.
DateTime{Hour|Minute|Second|Millisecond|Meridiem}FieldElements were
created to represent the new editable fields. By default, only the
hour and minute fields are displayed. However, the millisecond
and second fields may be added depending on the initial value of
the element, or the value of the step attribute.
Tests: fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
fast/forms/time/time-editable-components/time-editable-components-mouse-events.html
fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html
* css/html.css:
Update stylesheet to handle hour, minute, second, millisecond and meridiem fields.
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input[disabled]::-webkit-datetime-edit-year-field,):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::attributeChanged):
The step attribute can determine whether the second and/or millisecond
fields are displayed. Consequently, we should update the fields in
m_dateTimeEditElement when the step attribute is changed.
* html/BaseChooserOnlyDateAndTimeInputType.h:
setupLayoutParameters() now takes an additional DateComponents argument.
This argument is needed to determine whether the second and/or
millisecond field is displayed.
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeFieldsState.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::formatDateTimeFieldsState const):
(WebCore::TimeInputType::setupLayoutParameters const):
The millisecond field is displayed if the date has a non-zero value for
milliseconds, or if the step attribute has sub-second precision. The
second field is displayed if the millisecond field is displayed, if the
date has a non-zero value for seconds, or if the step attribute has
sub-minute precision.
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Updated to add new field types to the element.
* html/shadow/DateTimeEditElement.h:
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeHourFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHourFieldElement::setValueAsDate):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMeridiemFieldElement::setValueAsDate):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMillisecondFieldElement::setValueAsDate):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMinuteFieldElement::setValueAsDate):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeSecondFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h:
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum const):
* html/shadow/DateTimeNumericFieldElement.h:
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::handleKeyboardEvent): Implement editing using the same typeahead behavior as <select> elements.
(WebCore::DateTimeSymbolicFieldElement::indexOfSelectedOption const):
(WebCore::DateTimeSymbolicFieldElement::optionCount const):
(WebCore::DateTimeSymbolicFieldElement::optionAtIndex const):
* html/shadow/DateTimeSymbolicFieldElement.h:
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::localizedDecimalSeparator):
Added method to ensure the correct decimal separator is displayed
depending on the user's locale. This separator is used when
the millisecond field is present.
* platform/text/PlatformLocale.h:
LayoutTests:
* TestExpectations:
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Rebaselined for new appearance.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt: Rebaselined for new appearance.
Canonical link: https://commits.webkit.org/229143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-09 14:48:26 +00:00
|
|
|
class DateTimeHourFieldElement final : public DateTimeNumericFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeHourFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeHourFieldElement> create(Document&, FieldOwner&, int minimum, int maximum);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeHourFieldElement(Document&, FieldOwner&, int minimum, int maximum);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Add editability to input type=time
https://bugs.webkit.org/show_bug.cgi?id=216188
Reviewed by Devin Rousso.
Source/WebCore:
This patch adds editability to input type=time by leveraging existing
logic to add editable components to date/time inputs.
DateTime{Hour|Minute|Second|Millisecond|Meridiem}FieldElements were
created to represent the new editable fields. By default, only the
hour and minute fields are displayed. However, the millisecond
and second fields may be added depending on the initial value of
the element, or the value of the step attribute.
Tests: fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
fast/forms/time/time-editable-components/time-editable-components-mouse-events.html
fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html
* css/html.css:
Update stylesheet to handle hour, minute, second, millisecond and meridiem fields.
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input[disabled]::-webkit-datetime-edit-year-field,):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::attributeChanged):
The step attribute can determine whether the second and/or millisecond
fields are displayed. Consequently, we should update the fields in
m_dateTimeEditElement when the step attribute is changed.
* html/BaseChooserOnlyDateAndTimeInputType.h:
setupLayoutParameters() now takes an additional DateComponents argument.
This argument is needed to determine whether the second and/or
millisecond field is displayed.
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeFieldsState.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::formatDateTimeFieldsState const):
(WebCore::TimeInputType::setupLayoutParameters const):
The millisecond field is displayed if the date has a non-zero value for
milliseconds, or if the step attribute has sub-second precision. The
second field is displayed if the millisecond field is displayed, if the
date has a non-zero value for seconds, or if the step attribute has
sub-minute precision.
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Updated to add new field types to the element.
* html/shadow/DateTimeEditElement.h:
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeHourFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHourFieldElement::setValueAsDate):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMeridiemFieldElement::setValueAsDate):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMillisecondFieldElement::setValueAsDate):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMinuteFieldElement::setValueAsDate):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeSecondFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h:
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum const):
* html/shadow/DateTimeNumericFieldElement.h:
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::handleKeyboardEvent): Implement editing using the same typeahead behavior as <select> elements.
(WebCore::DateTimeSymbolicFieldElement::indexOfSelectedOption const):
(WebCore::DateTimeSymbolicFieldElement::optionCount const):
(WebCore::DateTimeSymbolicFieldElement::optionAtIndex const):
* html/shadow/DateTimeSymbolicFieldElement.h:
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::localizedDecimalSeparator):
Added method to ensure the correct decimal separator is displayed
depending on the user's locale. This separator is used when
the millisecond field is present.
* platform/text/PlatformLocale.h:
LayoutTests:
* TestExpectations:
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Rebaselined for new appearance.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt: Rebaselined for new appearance.
Canonical link: https://commits.webkit.org/229143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-09 14:48:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DateTimeMeridiemFieldElement final : public DateTimeSymbolicFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeMeridiemFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeMeridiemFieldElement> create(Document&, FieldOwner&, const Vector<String>&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeMeridiemFieldElement(Document&, FieldOwner&, const Vector<String>&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Add editability to input type=time
https://bugs.webkit.org/show_bug.cgi?id=216188
Reviewed by Devin Rousso.
Source/WebCore:
This patch adds editability to input type=time by leveraging existing
logic to add editable components to date/time inputs.
DateTime{Hour|Minute|Second|Millisecond|Meridiem}FieldElements were
created to represent the new editable fields. By default, only the
hour and minute fields are displayed. However, the millisecond
and second fields may be added depending on the initial value of
the element, or the value of the step attribute.
Tests: fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
fast/forms/time/time-editable-components/time-editable-components-mouse-events.html
fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html
* css/html.css:
Update stylesheet to handle hour, minute, second, millisecond and meridiem fields.
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input[disabled]::-webkit-datetime-edit-year-field,):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::attributeChanged):
The step attribute can determine whether the second and/or millisecond
fields are displayed. Consequently, we should update the fields in
m_dateTimeEditElement when the step attribute is changed.
* html/BaseChooserOnlyDateAndTimeInputType.h:
setupLayoutParameters() now takes an additional DateComponents argument.
This argument is needed to determine whether the second and/or
millisecond field is displayed.
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeFieldsState.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::formatDateTimeFieldsState const):
(WebCore::TimeInputType::setupLayoutParameters const):
The millisecond field is displayed if the date has a non-zero value for
milliseconds, or if the step attribute has sub-second precision. The
second field is displayed if the millisecond field is displayed, if the
date has a non-zero value for seconds, or if the step attribute has
sub-minute precision.
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Updated to add new field types to the element.
* html/shadow/DateTimeEditElement.h:
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeHourFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHourFieldElement::setValueAsDate):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMeridiemFieldElement::setValueAsDate):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMillisecondFieldElement::setValueAsDate):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMinuteFieldElement::setValueAsDate):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeSecondFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h:
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum const):
* html/shadow/DateTimeNumericFieldElement.h:
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::handleKeyboardEvent): Implement editing using the same typeahead behavior as <select> elements.
(WebCore::DateTimeSymbolicFieldElement::indexOfSelectedOption const):
(WebCore::DateTimeSymbolicFieldElement::optionCount const):
(WebCore::DateTimeSymbolicFieldElement::optionAtIndex const):
* html/shadow/DateTimeSymbolicFieldElement.h:
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::localizedDecimalSeparator):
Added method to ensure the correct decimal separator is displayed
depending on the user's locale. This separator is used when
the millisecond field is present.
* platform/text/PlatformLocale.h:
LayoutTests:
* TestExpectations:
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Rebaselined for new appearance.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt: Rebaselined for new appearance.
Canonical link: https://commits.webkit.org/229143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-09 14:48:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DateTimeMillisecondFieldElement final : public DateTimeNumericFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeMillisecondFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeMillisecondFieldElement> create(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeMillisecondFieldElement(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Add editability to input type=time
https://bugs.webkit.org/show_bug.cgi?id=216188
Reviewed by Devin Rousso.
Source/WebCore:
This patch adds editability to input type=time by leveraging existing
logic to add editable components to date/time inputs.
DateTime{Hour|Minute|Second|Millisecond|Meridiem}FieldElements were
created to represent the new editable fields. By default, only the
hour and minute fields are displayed. However, the millisecond
and second fields may be added depending on the initial value of
the element, or the value of the step attribute.
Tests: fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
fast/forms/time/time-editable-components/time-editable-components-mouse-events.html
fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html
* css/html.css:
Update stylesheet to handle hour, minute, second, millisecond and meridiem fields.
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input[disabled]::-webkit-datetime-edit-year-field,):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::attributeChanged):
The step attribute can determine whether the second and/or millisecond
fields are displayed. Consequently, we should update the fields in
m_dateTimeEditElement when the step attribute is changed.
* html/BaseChooserOnlyDateAndTimeInputType.h:
setupLayoutParameters() now takes an additional DateComponents argument.
This argument is needed to determine whether the second and/or
millisecond field is displayed.
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeFieldsState.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::formatDateTimeFieldsState const):
(WebCore::TimeInputType::setupLayoutParameters const):
The millisecond field is displayed if the date has a non-zero value for
milliseconds, or if the step attribute has sub-second precision. The
second field is displayed if the millisecond field is displayed, if the
date has a non-zero value for seconds, or if the step attribute has
sub-minute precision.
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Updated to add new field types to the element.
* html/shadow/DateTimeEditElement.h:
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeHourFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHourFieldElement::setValueAsDate):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMeridiemFieldElement::setValueAsDate):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMillisecondFieldElement::setValueAsDate):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMinuteFieldElement::setValueAsDate):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeSecondFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h:
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum const):
* html/shadow/DateTimeNumericFieldElement.h:
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::handleKeyboardEvent): Implement editing using the same typeahead behavior as <select> elements.
(WebCore::DateTimeSymbolicFieldElement::indexOfSelectedOption const):
(WebCore::DateTimeSymbolicFieldElement::optionCount const):
(WebCore::DateTimeSymbolicFieldElement::optionAtIndex const):
* html/shadow/DateTimeSymbolicFieldElement.h:
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::localizedDecimalSeparator):
Added method to ensure the correct decimal separator is displayed
depending on the user's locale. This separator is used when
the millisecond field is present.
* platform/text/PlatformLocale.h:
LayoutTests:
* TestExpectations:
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Rebaselined for new appearance.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt: Rebaselined for new appearance.
Canonical link: https://commits.webkit.org/229143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-09 14:48:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DateTimeMinuteFieldElement final : public DateTimeNumericFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeMinuteFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeMinuteFieldElement> create(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeMinuteFieldElement(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Add editability to input type=time
https://bugs.webkit.org/show_bug.cgi?id=216188
Reviewed by Devin Rousso.
Source/WebCore:
This patch adds editability to input type=time by leveraging existing
logic to add editable components to date/time inputs.
DateTime{Hour|Minute|Second|Millisecond|Meridiem}FieldElements were
created to represent the new editable fields. By default, only the
hour and minute fields are displayed. However, the millisecond
and second fields may be added depending on the initial value of
the element, or the value of the step attribute.
Tests: fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
fast/forms/time/time-editable-components/time-editable-components-mouse-events.html
fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html
* css/html.css:
Update stylesheet to handle hour, minute, second, millisecond and meridiem fields.
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input[disabled]::-webkit-datetime-edit-year-field,):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::attributeChanged):
The step attribute can determine whether the second and/or millisecond
fields are displayed. Consequently, we should update the fields in
m_dateTimeEditElement when the step attribute is changed.
* html/BaseChooserOnlyDateAndTimeInputType.h:
setupLayoutParameters() now takes an additional DateComponents argument.
This argument is needed to determine whether the second and/or
millisecond field is displayed.
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeFieldsState.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::formatDateTimeFieldsState const):
(WebCore::TimeInputType::setupLayoutParameters const):
The millisecond field is displayed if the date has a non-zero value for
milliseconds, or if the step attribute has sub-second precision. The
second field is displayed if the millisecond field is displayed, if the
date has a non-zero value for seconds, or if the step attribute has
sub-minute precision.
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Updated to add new field types to the element.
* html/shadow/DateTimeEditElement.h:
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeHourFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHourFieldElement::setValueAsDate):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMeridiemFieldElement::setValueAsDate):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMillisecondFieldElement::setValueAsDate):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMinuteFieldElement::setValueAsDate):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeSecondFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h:
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum const):
* html/shadow/DateTimeNumericFieldElement.h:
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::handleKeyboardEvent): Implement editing using the same typeahead behavior as <select> elements.
(WebCore::DateTimeSymbolicFieldElement::indexOfSelectedOption const):
(WebCore::DateTimeSymbolicFieldElement::optionCount const):
(WebCore::DateTimeSymbolicFieldElement::optionAtIndex const):
* html/shadow/DateTimeSymbolicFieldElement.h:
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::localizedDecimalSeparator):
Added method to ensure the correct decimal separator is displayed
depending on the user's locale. This separator is used when
the millisecond field is present.
* platform/text/PlatformLocale.h:
LayoutTests:
* TestExpectations:
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Rebaselined for new appearance.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt: Rebaselined for new appearance.
Canonical link: https://commits.webkit.org/229143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-09 14:48:26 +00:00
|
|
|
};
|
|
|
|
|
[macOS] Date inputs should contain editable components
https://bugs.webkit.org/show_bug.cgi?id=215155
Reviewed by Devin Rousso.
Source/WebCore:
Currently, users are unable to edit the values in date and time input types.
To match system date controls, users should be able to select and edit
individual components of the input. For example, <input type="date"> should
contain an editable year, month, and day control.
Note that this functionality was present in WebKit, up until it was removed
in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
removed as it was only used by Chromium port. However, much of the removed
logic remains useful and is resurfaced in this patch. Modifications were made
to update the code to follow current WebKit practices.
DateTimeEditElement is a wrapper element that contains individual fields.
The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
are further specialized into DateTimeNumericFieldElement (for integral
values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
and P.M). DateTimeEditElement builds the control using the visitor pattern
and existing parsing logic contained in DateTimeFormat.
In order to reduce the patch size, this patch only sets up the rendering
and layout of multiple fields for <input type="date">. Upcoming patches will
add rendering for other date/time input types and introduce editability.
Test: fast/forms/date/date-pseudo-elements.html
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/html.css:
(input::-webkit-datetime-edit):
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input::-webkit-datetime-edit-text):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat):
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
(WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat const):
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat const):
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat const):
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::setupLayoutParameters const):
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat const):
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp: Added.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::build):
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::visitLiteral):
(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::fieldsWrapperElement const):
(WebCore::DateTimeEditElement::addField):
(WebCore::DateTimeEditElement::create):
(WebCore::DateTimeEditElement::layout):
(WebCore::DateTimeEditElement::localeIdentifier const):
(WebCore::DateTimeEditElement::resetFields):
(WebCore::DateTimeEditElement::setValueAsDate):
(WebCore::DateTimeEditElement::setEmptyValue):
(WebCore::DateTimeEditElement::value const):
* html/shadow/DateTimeEditElement.h: Added.
* html/shadow/DateTimeFieldElement.cpp: Added.
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
(WebCore::DateTimeFieldElement::initialize):
(WebCore::DateTimeFieldElement::localeForOwner const):
(WebCore::DateTimeFieldElement::localeIdentifier const):
(WebCore::DateTimeFieldElement::updateVisibleValue):
(WebCore::DateTimeFieldElement::supportsFocus const):
* html/shadow/DateTimeFieldElement.h: Added.
* html/shadow/DateTimeFieldElements.cpp: Added.
(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeDayFieldElement::setValueAsDate):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeMonthFieldElement::setValueAsDate):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):
(WebCore::DateTimeYearFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h: Added.
* html/shadow/DateTimeNumericFieldElement.cpp: Added.
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::formatValue const):
(WebCore::DateTimeNumericFieldElement::hasValue const):
(WebCore::DateTimeNumericFieldElement::initialize):
(WebCore::DateTimeNumericFieldElement::setEmptyValue):
(WebCore::DateTimeNumericFieldElement::setValueAsInteger):
(WebCore::DateTimeNumericFieldElement::value const):
(WebCore::DateTimeNumericFieldElement::valueAsInteger const):
(WebCore::DateTimeNumericFieldElement::visibleValue const):
* html/shadow/DateTimeNumericFieldElement.h: Added.
* html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
(WebCore::makeVisibleEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::hasValue const):
(WebCore::DateTimeSymbolicFieldElement::initialize):
(WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
(WebCore::DateTimeSymbolicFieldElement::value const):
(WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
(WebCore::DateTimeSymbolicFieldElement::visibleValue const):
* html/shadow/DateTimeSymbolicFieldElement.h: Added.
(WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
LayoutTests:
Added a test to verify styling of pseudo elements within date inputs.
Rebaselined existing tests to match new appearance.
* fast/forms/date/date-pseudo-elements-expected.txt: Added.
* fast/forms/date/date-pseudo-elements.html: Added.
* platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
* platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
Canonical link: https://commits.webkit.org/228787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 14:25:37 +00:00
|
|
|
class DateTimeMonthFieldElement final : public DateTimeNumericFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeMonthFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeMonthFieldElement> create(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeMonthFieldElement(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Date inputs should contain editable components
https://bugs.webkit.org/show_bug.cgi?id=215155
Reviewed by Devin Rousso.
Source/WebCore:
Currently, users are unable to edit the values in date and time input types.
To match system date controls, users should be able to select and edit
individual components of the input. For example, <input type="date"> should
contain an editable year, month, and day control.
Note that this functionality was present in WebKit, up until it was removed
in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
removed as it was only used by Chromium port. However, much of the removed
logic remains useful and is resurfaced in this patch. Modifications were made
to update the code to follow current WebKit practices.
DateTimeEditElement is a wrapper element that contains individual fields.
The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
are further specialized into DateTimeNumericFieldElement (for integral
values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
and P.M). DateTimeEditElement builds the control using the visitor pattern
and existing parsing logic contained in DateTimeFormat.
In order to reduce the patch size, this patch only sets up the rendering
and layout of multiple fields for <input type="date">. Upcoming patches will
add rendering for other date/time input types and introduce editability.
Test: fast/forms/date/date-pseudo-elements.html
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/html.css:
(input::-webkit-datetime-edit):
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input::-webkit-datetime-edit-text):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat):
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
(WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat const):
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat const):
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat const):
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::setupLayoutParameters const):
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat const):
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp: Added.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::build):
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::visitLiteral):
(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::fieldsWrapperElement const):
(WebCore::DateTimeEditElement::addField):
(WebCore::DateTimeEditElement::create):
(WebCore::DateTimeEditElement::layout):
(WebCore::DateTimeEditElement::localeIdentifier const):
(WebCore::DateTimeEditElement::resetFields):
(WebCore::DateTimeEditElement::setValueAsDate):
(WebCore::DateTimeEditElement::setEmptyValue):
(WebCore::DateTimeEditElement::value const):
* html/shadow/DateTimeEditElement.h: Added.
* html/shadow/DateTimeFieldElement.cpp: Added.
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
(WebCore::DateTimeFieldElement::initialize):
(WebCore::DateTimeFieldElement::localeForOwner const):
(WebCore::DateTimeFieldElement::localeIdentifier const):
(WebCore::DateTimeFieldElement::updateVisibleValue):
(WebCore::DateTimeFieldElement::supportsFocus const):
* html/shadow/DateTimeFieldElement.h: Added.
* html/shadow/DateTimeFieldElements.cpp: Added.
(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeDayFieldElement::setValueAsDate):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeMonthFieldElement::setValueAsDate):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):
(WebCore::DateTimeYearFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h: Added.
* html/shadow/DateTimeNumericFieldElement.cpp: Added.
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::formatValue const):
(WebCore::DateTimeNumericFieldElement::hasValue const):
(WebCore::DateTimeNumericFieldElement::initialize):
(WebCore::DateTimeNumericFieldElement::setEmptyValue):
(WebCore::DateTimeNumericFieldElement::setValueAsInteger):
(WebCore::DateTimeNumericFieldElement::value const):
(WebCore::DateTimeNumericFieldElement::valueAsInteger const):
(WebCore::DateTimeNumericFieldElement::visibleValue const):
* html/shadow/DateTimeNumericFieldElement.h: Added.
* html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
(WebCore::makeVisibleEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::hasValue const):
(WebCore::DateTimeSymbolicFieldElement::initialize):
(WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
(WebCore::DateTimeSymbolicFieldElement::value const):
(WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
(WebCore::DateTimeSymbolicFieldElement::visibleValue const):
* html/shadow/DateTimeSymbolicFieldElement.h: Added.
(WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
LayoutTests:
Added a test to verify styling of pseudo elements within date inputs.
Rebaselined existing tests to match new appearance.
* fast/forms/date/date-pseudo-elements-expected.txt: Added.
* fast/forms/date/date-pseudo-elements.html: Added.
* platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
* platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
Canonical link: https://commits.webkit.org/228787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 14:25:37 +00:00
|
|
|
};
|
|
|
|
|
[macOS] Add editability to input type=time
https://bugs.webkit.org/show_bug.cgi?id=216188
Reviewed by Devin Rousso.
Source/WebCore:
This patch adds editability to input type=time by leveraging existing
logic to add editable components to date/time inputs.
DateTime{Hour|Minute|Second|Millisecond|Meridiem}FieldElements were
created to represent the new editable fields. By default, only the
hour and minute fields are displayed. However, the millisecond
and second fields may be added depending on the initial value of
the element, or the value of the step attribute.
Tests: fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
fast/forms/time/time-editable-components/time-editable-components-mouse-events.html
fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html
* css/html.css:
Update stylesheet to handle hour, minute, second, millisecond and meridiem fields.
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input[disabled]::-webkit-datetime-edit-year-field,):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::attributeChanged):
The step attribute can determine whether the second and/or millisecond
fields are displayed. Consequently, we should update the fields in
m_dateTimeEditElement when the step attribute is changed.
* html/BaseChooserOnlyDateAndTimeInputType.h:
setupLayoutParameters() now takes an additional DateComponents argument.
This argument is needed to determine whether the second and/or
millisecond field is displayed.
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeFieldsState.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::formatDateTimeFieldsState const):
(WebCore::TimeInputType::setupLayoutParameters const):
The millisecond field is displayed if the date has a non-zero value for
milliseconds, or if the step attribute has sub-second precision. The
second field is displayed if the millisecond field is displayed, if the
date has a non-zero value for seconds, or if the step attribute has
sub-minute precision.
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Updated to add new field types to the element.
* html/shadow/DateTimeEditElement.h:
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeHourFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHourFieldElement::setValueAsDate):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMeridiemFieldElement::setValueAsDate):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMillisecondFieldElement::setValueAsDate):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMinuteFieldElement::setValueAsDate):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeSecondFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h:
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum const):
* html/shadow/DateTimeNumericFieldElement.h:
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::handleKeyboardEvent): Implement editing using the same typeahead behavior as <select> elements.
(WebCore::DateTimeSymbolicFieldElement::indexOfSelectedOption const):
(WebCore::DateTimeSymbolicFieldElement::optionCount const):
(WebCore::DateTimeSymbolicFieldElement::optionAtIndex const):
* html/shadow/DateTimeSymbolicFieldElement.h:
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::localizedDecimalSeparator):
Added method to ensure the correct decimal separator is displayed
depending on the user's locale. This separator is used when
the millisecond field is present.
* platform/text/PlatformLocale.h:
LayoutTests:
* TestExpectations:
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Rebaselined for new appearance.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt: Rebaselined for new appearance.
Canonical link: https://commits.webkit.org/229143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-09 14:48:26 +00:00
|
|
|
class DateTimeSecondFieldElement final : public DateTimeNumericFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeSecondFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeSecondFieldElement> create(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeSecondFieldElement(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Add editability to input type=time
https://bugs.webkit.org/show_bug.cgi?id=216188
Reviewed by Devin Rousso.
Source/WebCore:
This patch adds editability to input type=time by leveraging existing
logic to add editable components to date/time inputs.
DateTime{Hour|Minute|Second|Millisecond|Meridiem}FieldElements were
created to represent the new editable fields. By default, only the
hour and minute fields are displayed. However, the millisecond
and second fields may be added depending on the initial value of
the element, or the value of the step attribute.
Tests: fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
fast/forms/time/time-editable-components/time-editable-components-mouse-events.html
fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html
* css/html.css:
Update stylesheet to handle hour, minute, second, millisecond and meridiem fields.
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input[disabled]::-webkit-datetime-edit-year-field,):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::attributeChanged):
The step attribute can determine whether the second and/or millisecond
fields are displayed. Consequently, we should update the fields in
m_dateTimeEditElement when the step attribute is changed.
* html/BaseChooserOnlyDateAndTimeInputType.h:
setupLayoutParameters() now takes an additional DateComponents argument.
This argument is needed to determine whether the second and/or
millisecond field is displayed.
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeFieldsState.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::formatDateTimeFieldsState const):
(WebCore::TimeInputType::setupLayoutParameters const):
The millisecond field is displayed if the date has a non-zero value for
milliseconds, or if the step attribute has sub-second precision. The
second field is displayed if the millisecond field is displayed, if the
date has a non-zero value for seconds, or if the step attribute has
sub-minute precision.
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Updated to add new field types to the element.
* html/shadow/DateTimeEditElement.h:
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeHourFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHourFieldElement::setValueAsDate):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMeridiemFieldElement::setValueAsDate):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMillisecondFieldElement::setValueAsDate):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeMinuteFieldElement::setValueAsDate):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSecondFieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeSecondFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h:
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum const):
* html/shadow/DateTimeNumericFieldElement.h:
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::handleKeyboardEvent): Implement editing using the same typeahead behavior as <select> elements.
(WebCore::DateTimeSymbolicFieldElement::indexOfSelectedOption const):
(WebCore::DateTimeSymbolicFieldElement::optionCount const):
(WebCore::DateTimeSymbolicFieldElement::optionAtIndex const):
* html/shadow/DateTimeSymbolicFieldElement.h:
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::localizedDecimalSeparator):
Added method to ensure the correct decimal separator is displayed
depending on the user's locale. This separator is used when
the millisecond field is present.
* platform/text/PlatformLocale.h:
LayoutTests:
* TestExpectations:
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-mouse-events.html: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field-expected.txt: Added.
* fast/forms/time/time-editable-components/time-editable-components-second-and-millisecond-field.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Rebaselined for new appearance.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt: Rebaselined for new appearance.
Canonical link: https://commits.webkit.org/229143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-09 14:48:26 +00:00
|
|
|
};
|
|
|
|
|
[macOS] Date inputs should contain editable components
https://bugs.webkit.org/show_bug.cgi?id=215155
Reviewed by Devin Rousso.
Source/WebCore:
Currently, users are unable to edit the values in date and time input types.
To match system date controls, users should be able to select and edit
individual components of the input. For example, <input type="date"> should
contain an editable year, month, and day control.
Note that this functionality was present in WebKit, up until it was removed
in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
removed as it was only used by Chromium port. However, much of the removed
logic remains useful and is resurfaced in this patch. Modifications were made
to update the code to follow current WebKit practices.
DateTimeEditElement is a wrapper element that contains individual fields.
The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
are further specialized into DateTimeNumericFieldElement (for integral
values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
and P.M). DateTimeEditElement builds the control using the visitor pattern
and existing parsing logic contained in DateTimeFormat.
In order to reduce the patch size, this patch only sets up the rendering
and layout of multiple fields for <input type="date">. Upcoming patches will
add rendering for other date/time input types and introduce editability.
Test: fast/forms/date/date-pseudo-elements.html
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/html.css:
(input::-webkit-datetime-edit):
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input::-webkit-datetime-edit-text):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat):
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
(WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat const):
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat const):
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat const):
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::setupLayoutParameters const):
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat const):
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp: Added.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::build):
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::visitLiteral):
(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::fieldsWrapperElement const):
(WebCore::DateTimeEditElement::addField):
(WebCore::DateTimeEditElement::create):
(WebCore::DateTimeEditElement::layout):
(WebCore::DateTimeEditElement::localeIdentifier const):
(WebCore::DateTimeEditElement::resetFields):
(WebCore::DateTimeEditElement::setValueAsDate):
(WebCore::DateTimeEditElement::setEmptyValue):
(WebCore::DateTimeEditElement::value const):
* html/shadow/DateTimeEditElement.h: Added.
* html/shadow/DateTimeFieldElement.cpp: Added.
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
(WebCore::DateTimeFieldElement::initialize):
(WebCore::DateTimeFieldElement::localeForOwner const):
(WebCore::DateTimeFieldElement::localeIdentifier const):
(WebCore::DateTimeFieldElement::updateVisibleValue):
(WebCore::DateTimeFieldElement::supportsFocus const):
* html/shadow/DateTimeFieldElement.h: Added.
* html/shadow/DateTimeFieldElements.cpp: Added.
(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeDayFieldElement::setValueAsDate):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeMonthFieldElement::setValueAsDate):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):
(WebCore::DateTimeYearFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h: Added.
* html/shadow/DateTimeNumericFieldElement.cpp: Added.
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::formatValue const):
(WebCore::DateTimeNumericFieldElement::hasValue const):
(WebCore::DateTimeNumericFieldElement::initialize):
(WebCore::DateTimeNumericFieldElement::setEmptyValue):
(WebCore::DateTimeNumericFieldElement::setValueAsInteger):
(WebCore::DateTimeNumericFieldElement::value const):
(WebCore::DateTimeNumericFieldElement::valueAsInteger const):
(WebCore::DateTimeNumericFieldElement::visibleValue const):
* html/shadow/DateTimeNumericFieldElement.h: Added.
* html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
(WebCore::makeVisibleEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::hasValue const):
(WebCore::DateTimeSymbolicFieldElement::initialize):
(WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
(WebCore::DateTimeSymbolicFieldElement::value const):
(WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
(WebCore::DateTimeSymbolicFieldElement::visibleValue const):
* html/shadow/DateTimeSymbolicFieldElement.h: Added.
(WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
LayoutTests:
Added a test to verify styling of pseudo elements within date inputs.
Rebaselined existing tests to match new appearance.
* fast/forms/date/date-pseudo-elements-expected.txt: Added.
* fast/forms/date/date-pseudo-elements.html: Added.
* platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
* platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
Canonical link: https://commits.webkit.org/228787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 14:25:37 +00:00
|
|
|
class DateTimeSymbolicMonthFieldElement final : public DateTimeSymbolicFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeSymbolicMonthFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeSymbolicMonthFieldElement> create(Document&, FieldOwner&, const Vector<String>&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeSymbolicMonthFieldElement(Document&, FieldOwner&, const Vector<String>&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Date inputs should contain editable components
https://bugs.webkit.org/show_bug.cgi?id=215155
Reviewed by Devin Rousso.
Source/WebCore:
Currently, users are unable to edit the values in date and time input types.
To match system date controls, users should be able to select and edit
individual components of the input. For example, <input type="date"> should
contain an editable year, month, and day control.
Note that this functionality was present in WebKit, up until it was removed
in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
removed as it was only used by Chromium port. However, much of the removed
logic remains useful and is resurfaced in this patch. Modifications were made
to update the code to follow current WebKit practices.
DateTimeEditElement is a wrapper element that contains individual fields.
The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
are further specialized into DateTimeNumericFieldElement (for integral
values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
and P.M). DateTimeEditElement builds the control using the visitor pattern
and existing parsing logic contained in DateTimeFormat.
In order to reduce the patch size, this patch only sets up the rendering
and layout of multiple fields for <input type="date">. Upcoming patches will
add rendering for other date/time input types and introduce editability.
Test: fast/forms/date/date-pseudo-elements.html
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/html.css:
(input::-webkit-datetime-edit):
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input::-webkit-datetime-edit-text):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat):
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
(WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat const):
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat const):
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat const):
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::setupLayoutParameters const):
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat const):
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp: Added.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::build):
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::visitLiteral):
(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::fieldsWrapperElement const):
(WebCore::DateTimeEditElement::addField):
(WebCore::DateTimeEditElement::create):
(WebCore::DateTimeEditElement::layout):
(WebCore::DateTimeEditElement::localeIdentifier const):
(WebCore::DateTimeEditElement::resetFields):
(WebCore::DateTimeEditElement::setValueAsDate):
(WebCore::DateTimeEditElement::setEmptyValue):
(WebCore::DateTimeEditElement::value const):
* html/shadow/DateTimeEditElement.h: Added.
* html/shadow/DateTimeFieldElement.cpp: Added.
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
(WebCore::DateTimeFieldElement::initialize):
(WebCore::DateTimeFieldElement::localeForOwner const):
(WebCore::DateTimeFieldElement::localeIdentifier const):
(WebCore::DateTimeFieldElement::updateVisibleValue):
(WebCore::DateTimeFieldElement::supportsFocus const):
* html/shadow/DateTimeFieldElement.h: Added.
* html/shadow/DateTimeFieldElements.cpp: Added.
(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeDayFieldElement::setValueAsDate):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeMonthFieldElement::setValueAsDate):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):
(WebCore::DateTimeYearFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h: Added.
* html/shadow/DateTimeNumericFieldElement.cpp: Added.
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::formatValue const):
(WebCore::DateTimeNumericFieldElement::hasValue const):
(WebCore::DateTimeNumericFieldElement::initialize):
(WebCore::DateTimeNumericFieldElement::setEmptyValue):
(WebCore::DateTimeNumericFieldElement::setValueAsInteger):
(WebCore::DateTimeNumericFieldElement::value const):
(WebCore::DateTimeNumericFieldElement::valueAsInteger const):
(WebCore::DateTimeNumericFieldElement::visibleValue const):
* html/shadow/DateTimeNumericFieldElement.h: Added.
* html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
(WebCore::makeVisibleEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::hasValue const):
(WebCore::DateTimeSymbolicFieldElement::initialize):
(WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
(WebCore::DateTimeSymbolicFieldElement::value const):
(WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
(WebCore::DateTimeSymbolicFieldElement::visibleValue const):
* html/shadow/DateTimeSymbolicFieldElement.h: Added.
(WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
LayoutTests:
Added a test to verify styling of pseudo elements within date inputs.
Rebaselined existing tests to match new appearance.
* fast/forms/date/date-pseudo-elements-expected.txt: Added.
* fast/forms/date/date-pseudo-elements.html: Added.
* platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
* platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
Canonical link: https://commits.webkit.org/228787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 14:25:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DateTimeYearFieldElement final : public DateTimeNumericFieldElement {
|
|
|
|
WTF_MAKE_ISO_ALLOCATED(DateTimeYearFieldElement);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Ref<DateTimeYearFieldElement> create(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DateTimeYearFieldElement(Document&, FieldOwner&);
|
|
|
|
|
|
|
|
// DateTimeFieldElement functions:
|
2020-09-10 14:39:13 +00:00
|
|
|
void setValueAsDate(const DateComponents&) final;
|
|
|
|
void populateDateTimeFieldsState(DateTimeFieldsState&) final;
|
[macOS] Date inputs should contain editable components
https://bugs.webkit.org/show_bug.cgi?id=215155
Reviewed by Devin Rousso.
Source/WebCore:
Currently, users are unable to edit the values in date and time input types.
To match system date controls, users should be able to select and edit
individual components of the input. For example, <input type="date"> should
contain an editable year, month, and day control.
Note that this functionality was present in WebKit, up until it was removed
in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
removed as it was only used by Chromium port. However, much of the removed
logic remains useful and is resurfaced in this patch. Modifications were made
to update the code to follow current WebKit practices.
DateTimeEditElement is a wrapper element that contains individual fields.
The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
are further specialized into DateTimeNumericFieldElement (for integral
values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
and P.M). DateTimeEditElement builds the control using the visitor pattern
and existing parsing logic contained in DateTimeFormat.
In order to reduce the patch size, this patch only sets up the rendering
and layout of multiple fields for <input type="date">. Upcoming patches will
add rendering for other date/time input types and introduce editability.
Test: fast/forms/date/date-pseudo-elements.html
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/html.css:
(input::-webkit-datetime-edit):
(input::-webkit-datetime-edit-fields-wrapper):
(input::-webkit-datetime-edit-year-field,):
(input::-webkit-datetime-edit-year-field:focus,):
(input::-webkit-datetime-edit-text):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat):
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
(WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
(WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseDateAndTimeInputType.h:
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat const):
(WebCore::DateInputType::setupLayoutParameters const):
* html/DateInputType.h:
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat const):
(WebCore::DateTimeLocalInputType::setupLayoutParameters const):
* html/DateTimeLocalInputType.h:
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat const):
(WebCore::MonthInputType::setupLayoutParameters const):
* html/MonthInputType.h:
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat const):
(WebCore::TimeInputType::setupLayoutParameters const):
* html/TimeInputType.h:
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat const):
(WebCore::WeekInputType::setupLayoutParameters const):
* html/WeekInputType.h:
* html/shadow/DateTimeEditElement.cpp: Added.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::build):
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::visitLiteral):
(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::fieldsWrapperElement const):
(WebCore::DateTimeEditElement::addField):
(WebCore::DateTimeEditElement::create):
(WebCore::DateTimeEditElement::layout):
(WebCore::DateTimeEditElement::localeIdentifier const):
(WebCore::DateTimeEditElement::resetFields):
(WebCore::DateTimeEditElement::setValueAsDate):
(WebCore::DateTimeEditElement::setEmptyValue):
(WebCore::DateTimeEditElement::value const):
* html/shadow/DateTimeEditElement.h: Added.
* html/shadow/DateTimeFieldElement.cpp: Added.
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
(WebCore::DateTimeFieldElement::initialize):
(WebCore::DateTimeFieldElement::localeForOwner const):
(WebCore::DateTimeFieldElement::localeIdentifier const):
(WebCore::DateTimeFieldElement::updateVisibleValue):
(WebCore::DateTimeFieldElement::supportsFocus const):
* html/shadow/DateTimeFieldElement.h: Added.
* html/shadow/DateTimeFieldElements.cpp: Added.
(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeDayFieldElement::setValueAsDate):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeMonthFieldElement::setValueAsDate):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):
(WebCore::DateTimeYearFieldElement::setValueAsDate):
* html/shadow/DateTimeFieldElements.h: Added.
* html/shadow/DateTimeNumericFieldElement.cpp: Added.
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::formatValue const):
(WebCore::DateTimeNumericFieldElement::hasValue const):
(WebCore::DateTimeNumericFieldElement::initialize):
(WebCore::DateTimeNumericFieldElement::setEmptyValue):
(WebCore::DateTimeNumericFieldElement::setValueAsInteger):
(WebCore::DateTimeNumericFieldElement::value const):
(WebCore::DateTimeNumericFieldElement::valueAsInteger const):
(WebCore::DateTimeNumericFieldElement::visibleValue const):
* html/shadow/DateTimeNumericFieldElement.h: Added.
* html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
(WebCore::makeVisibleEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
(WebCore::DateTimeSymbolicFieldElement::hasValue const):
(WebCore::DateTimeSymbolicFieldElement::initialize):
(WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
(WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
(WebCore::DateTimeSymbolicFieldElement::value const):
(WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
(WebCore::DateTimeSymbolicFieldElement::visibleValue const):
* html/shadow/DateTimeSymbolicFieldElement.h: Added.
(WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
LayoutTests:
Added a test to verify styling of pseudo elements within date inputs.
Rebaselined existing tests to match new appearance.
* fast/forms/date/date-pseudo-elements-expected.txt: Added.
* fast/forms/date/date-pseudo-elements.html: Added.
* platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
* platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
* platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
Canonical link: https://commits.webkit.org/228787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 14:25:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WebCore
|
|
|
|
|
|
|
|
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
|