| Differences between
and this patch
- a/Source/WebCore/ChangeLog +137 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2020-08-07  Aditya Keerthi  <akeerthi@apple.com>
2
3
        [macOS] Date inputs should contain editable components
4
        https://bugs.webkit.org/show_bug.cgi?id=215155
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Currently, users are unable to edit the values in date and time input types.
9
        To match system date controls, users should be able to select and edit
10
        individual components of the input. For example, <input type="date"> should
11
        contain an editable year, month, and day control.
12
13
        Note that this functionality was present in WebKit, up until it was removed
14
        in r150876. Previously known as "INPUT_MULTIPLE_FIELDS_UI", the feature was
15
        removed as it was only used by Chromium port. However, much of the removed
16
        logic remains useful and is resurfaced in this patch. Modifications were made
17
        to update the code to follow current WebKit practices.
18
19
        DateTimeEditElement is a wrapper element that contains individual fields.
20
        The fields are all DateTimeFieldElements. Note that DateTimeFieldElements
21
        are further specialized into DateTimeNumericFieldElement (for integral
22
        values) and DateTimeSymbolicFieldElement (for symbolic values such as A.M
23
        and P.M). DateTimeEditElement builds the control using the visitor pattern
24
        and existing parsing logic contained in DateTimeFormat.
25
26
        In order to reduce the patch size, this patch only sets up the rendering
27
        and layout of multiple fields for <input type="date">. Upcoming patches will
28
        add rendering for other date/time input types and introduce editability.
29
30
        Test: fast/forms/date/date-pseudo-elements.html
31
32
        * Sources.txt:
33
        * WebCore.xcodeproj/project.pbxproj:
34
        * css/html.css:
35
        (input::-webkit-datetime-edit):
36
        (input::-webkit-datetime-edit-fields-wrapper):
37
        (input::-webkit-datetime-edit-year-field,):
38
        (input::-webkit-datetime-edit-year-field:focus,):
39
        (input::-webkit-datetime-edit-text):
40
        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
41
        (WebCore::DateTimeFormatValidator::DateTimeFormatValidator):
42
        (WebCore::DateTimeFormatValidator::visitField):
43
        (WebCore::DateTimeFormatValidator::validateFormat):
44
        (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
45
        (WebCore::BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree):
46
        (WebCore::BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue):
47
        (WebCore::BaseChooserOnlyDateAndTimeInputType::valueForEditControl const):
48
        (WebCore::BaseChooserOnlyDateAndTimeInputType::localeIdentifier const):
49
        * html/BaseChooserOnlyDateAndTimeInputType.h:
50
        * html/BaseDateAndTimeInputType.h:
51
        * html/DateInputType.cpp:
52
        (WebCore::DateInputType::isValidFormat const):
53
        (WebCore::DateInputType::setupLayoutParameters const):
54
        * html/DateInputType.h:
55
        * html/DateTimeLocalInputType.cpp:
56
        (WebCore::DateTimeLocalInputType::isValidFormat const):
57
        (WebCore::DateTimeLocalInputType::setupLayoutParameters const):
58
        * html/DateTimeLocalInputType.h:
59
        * html/MonthInputType.cpp:
60
        (WebCore::MonthInputType::isValidFormat const):
61
        (WebCore::MonthInputType::setupLayoutParameters const):
62
        * html/MonthInputType.h:
63
        * html/TimeInputType.cpp:
64
        (WebCore::TimeInputType::isValidFormat const):
65
        (WebCore::TimeInputType::setupLayoutParameters const):
66
        * html/TimeInputType.h:
67
        * html/WeekInputType.cpp:
68
        (WebCore::WeekInputType::isValidFormat const):
69
        (WebCore::WeekInputType::setupLayoutParameters const):
70
        * html/WeekInputType.h:
71
        * html/shadow/DateTimeEditElement.cpp: Added.
72
        (WebCore::DateTimeEditBuilder::DateTimeEditBuilder):
73
        (WebCore::DateTimeEditBuilder::build):
74
        (WebCore::DateTimeEditBuilder::visitField):
75
        (WebCore::DateTimeEditBuilder::visitLiteral):
76
        (WebCore::DateTimeEditElement::EditControlOwner::~EditControlOwner):
77
        (WebCore::DateTimeEditElement::DateTimeEditElement):
78
        (WebCore::DateTimeEditElement::~DateTimeEditElement):
79
        (WebCore::DateTimeEditElement::fieldsWrapperElement const):
80
        (WebCore::DateTimeEditElement::addField):
81
        (WebCore::DateTimeEditElement::create):
82
        (WebCore::DateTimeEditElement::layout):
83
        (WebCore::DateTimeEditElement::localeIdentifier const):
84
        (WebCore::DateTimeEditElement::resetFields):
85
        (WebCore::DateTimeEditElement::setValueAsDate):
86
        (WebCore::DateTimeEditElement::setEmptyValue):
87
        (WebCore::DateTimeEditElement::value const):
88
        * html/shadow/DateTimeEditElement.h: Added.
89
        * html/shadow/DateTimeFieldElement.cpp: Added.
90
        (WebCore::DateTimeFieldElement::FieldOwner::~FieldOwner):
91
        (WebCore::DateTimeFieldElement::DateTimeFieldElement):
92
        (WebCore::DateTimeFieldElement::initialize):
93
        (WebCore::DateTimeFieldElement::localeForOwner const):
94
        (WebCore::DateTimeFieldElement::localeIdentifier const):
95
        (WebCore::DateTimeFieldElement::updateVisibleValue):
96
        (WebCore::DateTimeFieldElement::supportsFocus const):
97
        * html/shadow/DateTimeFieldElement.h: Added.
98
        * html/shadow/DateTimeFieldElements.cpp: Added.
99
        (WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
100
        (WebCore::DateTimeDayFieldElement::create):
101
        (WebCore::DateTimeDayFieldElement::setValueAsDate):
102
        (WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
103
        (WebCore::DateTimeMonthFieldElement::create):
104
        (WebCore::DateTimeMonthFieldElement::setValueAsDate):
105
        (WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
106
        (WebCore::DateTimeSymbolicMonthFieldElement::create):
107
        (WebCore::DateTimeSymbolicMonthFieldElement::setValueAsDate):
108
        (WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
109
        (WebCore::DateTimeYearFieldElement::create):
110
        (WebCore::DateTimeYearFieldElement::setValueAsDate):
111
        * html/shadow/DateTimeFieldElements.h: Added.
112
        * html/shadow/DateTimeNumericFieldElement.cpp: Added.
113
        (WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement):
114
        (WebCore::DateTimeNumericFieldElement::formatValue const):
115
        (WebCore::DateTimeNumericFieldElement::hasValue const):
116
        (WebCore::DateTimeNumericFieldElement::initialize):
117
        (WebCore::DateTimeNumericFieldElement::setEmptyValue):
118
        (WebCore::DateTimeNumericFieldElement::setValueAsInteger):
119
        (WebCore::DateTimeNumericFieldElement::value const):
120
        (WebCore::DateTimeNumericFieldElement::valueAsInteger const):
121
        (WebCore::DateTimeNumericFieldElement::visibleValue const):
122
        * html/shadow/DateTimeNumericFieldElement.h: Added.
123
        * html/shadow/DateTimeSymbolicFieldElement.cpp: Added.
124
        (WebCore::makeVisibleEmptyValue):
125
        (WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement):
126
        (WebCore::DateTimeSymbolicFieldElement::hasValue const):
127
        (WebCore::DateTimeSymbolicFieldElement::initialize):
128
        (WebCore::DateTimeSymbolicFieldElement::setEmptyValue):
129
        (WebCore::DateTimeSymbolicFieldElement::setValueAsInteger):
130
        (WebCore::DateTimeSymbolicFieldElement::value const):
131
        (WebCore::DateTimeSymbolicFieldElement::valueAsInteger const):
132
        (WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue const):
133
        (WebCore::DateTimeSymbolicFieldElement::visibleValue const):
134
        * html/shadow/DateTimeSymbolicFieldElement.h: Added.
135
        (WebCore::DateTimeSymbolicFieldElement::symbolsSize const):
136
        * page/Settings.yaml:
137
1
2020-08-04  Devin Rousso  <drousso@apple.com>
138
2020-08-04  Devin Rousso  <drousso@apple.com>
2
139
3
        "DoubleDown Casino" respin button stops working with trackpad
140
        "DoubleDown Casino" respin button stops working with trackpad
- a/Source/WebKit/ChangeLog +13 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2020-08-07  Aditya Keerthi  <akeerthi@apple.com>
2
3
        [macOS] Date inputs should contain editable components
4
        https://bugs.webkit.org/show_bug.cgi?id=215155
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Added DateTimeInputsEditableComponentsEnabled as a runtime setting. This
9
        setting is enabled by default on macOS.
10
11
        * Shared/WebPreferences.yaml:
12
        * Shared/WebPreferencesDefaultValues.h:
13
1
2020-08-04  Brent Fulgham  <bfulgham@apple.com>
14
2020-08-04  Brent Fulgham  <bfulgham@apple.com>
2
15
3
        Unreviewed build fix after r265263
16
        Unreviewed build fix after r265263
- a/Source/WebCore/Sources.txt +5 lines
Lines 1310-1315 html/parser/XSSAuditorDelegate.cpp a/Source/WebCore/Sources.txt_sec1
1310
html/shadow/AutoFillButtonElement.cpp
1310
html/shadow/AutoFillButtonElement.cpp
1311
html/shadow/DataListButtonElement.cpp
1311
html/shadow/DataListButtonElement.cpp
1312
html/shadow/DetailsMarkerControl.cpp
1312
html/shadow/DetailsMarkerControl.cpp
1313
html/shadow/DateTimeEditElement.cpp
1314
html/shadow/DateTimeFieldElement.cpp
1315
html/shadow/DateTimeFieldElements.cpp
1316
html/shadow/DateTimeNumericFieldElement.cpp
1317
html/shadow/DateTimeSymbolicFieldElement.cpp
1313
html/shadow/MediaControlTextTrackContainerElement.cpp
1318
html/shadow/MediaControlTextTrackContainerElement.cpp
1314
html/shadow/ProgressShadowElement.cpp
1319
html/shadow/ProgressShadowElement.cpp
1315
html/shadow/SliderThumbElement.cpp
1320
html/shadow/SliderThumbElement.cpp
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +30 lines
Lines 5071-5076 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
5071
		E58B45BA20AD07DD00991025 /* DataListButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E58B45B820AD07DD00991025 /* DataListButtonElement.h */; };
5071
		E58B45BA20AD07DD00991025 /* DataListButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E58B45B820AD07DD00991025 /* DataListButtonElement.h */; };
5072
		E59DD4B821098287003C8B47 /* ListButtonArrow.png in Resources */ = {isa = PBXBuildFile; fileRef = E59DD4B721098285003C8B47 /* ListButtonArrow.png */; };
5072
		E59DD4B821098287003C8B47 /* ListButtonArrow.png in Resources */ = {isa = PBXBuildFile; fileRef = E59DD4B721098285003C8B47 /* ListButtonArrow.png */; };
5073
		E5BA7D63151437CA00FE1E3F /* LengthFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
5073
		E5BA7D63151437CA00FE1E3F /* LengthFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
5074
		E5F06AE724D4847B00BBC4F8 /* DateTimeFieldElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E5F06AE524D4847B00BBC4F8 /* DateTimeFieldElement.h */; };
5075
		E5F06AEB24D49BF700BBC4F8 /* DateTimeNumericFieldElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E5F06AE924D49BF700BBC4F8 /* DateTimeNumericFieldElement.h */; };
5076
		E5F06AEF24D4A63700BBC4F8 /* DateTimeSymbolicFieldElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E5F06AED24D4A63700BBC4F8 /* DateTimeSymbolicFieldElement.h */; };
5077
		E5F06AF324D4AAE400BBC4F8 /* DateTimeFieldElements.h in Headers */ = {isa = PBXBuildFile; fileRef = E5F06AF124D4AAE400BBC4F8 /* DateTimeFieldElements.h */; };
5078
		E5F06AF724D4BB5600BBC4F8 /* DateTimeEditElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E5F06AF524D4BB5600BBC4F8 /* DateTimeEditElement.h */; };
5074
		E71467B324ABAEF200FB2F50 /* AudioNodeOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E71467B124ABAEF100FB2F50 /* AudioNodeOptions.h */; };
5079
		E71467B324ABAEF200FB2F50 /* AudioNodeOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E71467B124ABAEF100FB2F50 /* AudioNodeOptions.h */; };
5075
		E71467B624ABAF1D00FB2F50 /* PannerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E71467B524ABAF1D00FB2F50 /* PannerOptions.h */; };
5080
		E71467B624ABAF1D00FB2F50 /* PannerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E71467B524ABAF1D00FB2F50 /* PannerOptions.h */; };
5076
		E755E89224C7434B009F7C23 /* PeriodicWaveConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = E755E88F24C7434B009F7C23 /* PeriodicWaveConstraints.h */; };
5081
		E755E89224C7434B009F7C23 /* PeriodicWaveConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = E755E88F24C7434B009F7C23 /* PeriodicWaveConstraints.h */; };
Lines 15885-15890 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
15885
		E58B45B820AD07DD00991025 /* DataListButtonElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListButtonElement.h; sourceTree = "<group>"; };
15890
		E58B45B820AD07DD00991025 /* DataListButtonElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListButtonElement.h; sourceTree = "<group>"; };
15886
		E59DD4B721098285003C8B47 /* ListButtonArrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ListButtonArrow.png; sourceTree = "<group>"; };
15891
		E59DD4B721098285003C8B47 /* ListButtonArrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ListButtonArrow.png; sourceTree = "<group>"; };
15887
		E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthFunctions.h; sourceTree = "<group>"; };
15892
		E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthFunctions.h; sourceTree = "<group>"; };
15893
		E5F06AE524D4847B00BBC4F8 /* DateTimeFieldElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DateTimeFieldElement.h; sourceTree = "<group>"; };
15894
		E5F06AE624D4847B00BBC4F8 /* DateTimeFieldElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DateTimeFieldElement.cpp; sourceTree = "<group>"; };
15895
		E5F06AE924D49BF700BBC4F8 /* DateTimeNumericFieldElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DateTimeNumericFieldElement.h; sourceTree = "<group>"; };
15896
		E5F06AEA24D49BF700BBC4F8 /* DateTimeNumericFieldElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DateTimeNumericFieldElement.cpp; sourceTree = "<group>"; };
15897
		E5F06AED24D4A63700BBC4F8 /* DateTimeSymbolicFieldElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DateTimeSymbolicFieldElement.h; sourceTree = "<group>"; };
15898
		E5F06AEE24D4A63700BBC4F8 /* DateTimeSymbolicFieldElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DateTimeSymbolicFieldElement.cpp; sourceTree = "<group>"; };
15899
		E5F06AF124D4AAE400BBC4F8 /* DateTimeFieldElements.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DateTimeFieldElements.h; sourceTree = "<group>"; };
15900
		E5F06AF224D4AAE400BBC4F8 /* DateTimeFieldElements.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DateTimeFieldElements.cpp; sourceTree = "<group>"; };
15901
		E5F06AF524D4BB5600BBC4F8 /* DateTimeEditElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DateTimeEditElement.h; sourceTree = "<group>"; };
15902
		E5F06AF624D4BB5600BBC4F8 /* DateTimeEditElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DateTimeEditElement.cpp; sourceTree = "<group>"; };
15888
		E71467B124ABAEF100FB2F50 /* AudioNodeOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioNodeOptions.h; sourceTree = "<group>"; };
15903
		E71467B124ABAEF100FB2F50 /* AudioNodeOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioNodeOptions.h; sourceTree = "<group>"; };
15889
		E71467B424ABAF0B00FB2F50 /* AudioNodeOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AudioNodeOptions.idl; sourceTree = "<group>"; };
15904
		E71467B424ABAF0B00FB2F50 /* AudioNodeOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AudioNodeOptions.idl; sourceTree = "<group>"; };
15890
		E71467B524ABAF1D00FB2F50 /* PannerOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PannerOptions.h; sourceTree = "<group>"; };
15905
		E71467B524ABAF1D00FB2F50 /* PannerOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PannerOptions.h; sourceTree = "<group>"; };
Lines 18622-18627 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
18622
				7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */,
18637
				7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */,
18623
				7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */,
18638
				7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */,
18624
				E58B45B820AD07DD00991025 /* DataListButtonElement.h */,
18639
				E58B45B820AD07DD00991025 /* DataListButtonElement.h */,
18640
				E5F06AF624D4BB5600BBC4F8 /* DateTimeEditElement.cpp */,
18641
				E5F06AF524D4BB5600BBC4F8 /* DateTimeEditElement.h */,
18642
				E5F06AE624D4847B00BBC4F8 /* DateTimeFieldElement.cpp */,
18643
				E5F06AE524D4847B00BBC4F8 /* DateTimeFieldElement.h */,
18644
				E5F06AF224D4AAE400BBC4F8 /* DateTimeFieldElements.cpp */,
18645
				E5F06AF124D4AAE400BBC4F8 /* DateTimeFieldElements.h */,
18646
				E5F06AEA24D49BF700BBC4F8 /* DateTimeNumericFieldElement.cpp */,
18647
				E5F06AE924D49BF700BBC4F8 /* DateTimeNumericFieldElement.h */,
18648
				E5F06AEE24D4A63700BBC4F8 /* DateTimeSymbolicFieldElement.cpp */,
18649
				E5F06AED24D4A63700BBC4F8 /* DateTimeSymbolicFieldElement.h */,
18625
				A7C9ABF61357A3BF00F5503F /* DetailsMarkerControl.cpp */,
18650
				A7C9ABF61357A3BF00F5503F /* DetailsMarkerControl.cpp */,
18626
				A7C9ABF71357A3BF00F5503F /* DetailsMarkerControl.h */,
18651
				A7C9ABF71357A3BF00F5503F /* DetailsMarkerControl.h */,
18627
				510192D318B6B9B7007FC7A1 /* ImageControlsRootElement.cpp */,
18652
				510192D318B6B9B7007FC7A1 /* ImageControlsRootElement.cpp */,
Lines 30651-30658 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
30651
				F55B3DB61251F12D003EF269 /* DateInputType.h in Headers */,
30676
				F55B3DB61251F12D003EF269 /* DateInputType.h in Headers */,
30652
				37C738F31EDBDE8A003F2B0B /* DateTimeChooser.h in Headers */,
30677
				37C738F31EDBDE8A003F2B0B /* DateTimeChooser.h in Headers */,
30653
				37C738F41EDBDE8D003F2B0B /* DateTimeChooserClient.h in Headers */,
30678
				37C738F41EDBDE8D003F2B0B /* DateTimeChooserClient.h in Headers */,
30679
				E5F06AF724D4BB5600BBC4F8 /* DateTimeEditElement.h in Headers */,
30680
				E5F06AE724D4847B00BBC4F8 /* DateTimeFieldElement.h in Headers */,
30681
				E5F06AF324D4AAE400BBC4F8 /* DateTimeFieldElements.h in Headers */,
30654
				453EB637159C570400001BB7 /* DateTimeFormat.h in Headers */,
30682
				453EB637159C570400001BB7 /* DateTimeFormat.h in Headers */,
30655
				F55B3DBA1251F12D003EF269 /* DateTimeLocalInputType.h in Headers */,
30683
				F55B3DBA1251F12D003EF269 /* DateTimeLocalInputType.h in Headers */,
30684
				E5F06AEB24D49BF700BBC4F8 /* DateTimeNumericFieldElement.h in Headers */,
30685
				E5F06AEF24D4A63700BBC4F8 /* DateTimeSymbolicFieldElement.h in Headers */,
30656
				0F6A12BE1A00923700C6DE72 /* DebugPageOverlays.h in Headers */,
30686
				0F6A12BE1A00923700C6DE72 /* DebugPageOverlays.h in Headers */,
30657
				45FEA5D0156DDE8C00654101 /* Decimal.h in Headers */,
30687
				45FEA5D0156DDE8C00654101 /* Decimal.h in Headers */,
30658
				715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */,
30688
				715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */,
- a/Source/WebCore/css/html.css +33 lines
Lines 484-489 input::-webkit-date-and-time-value { a/Source/WebCore/css/html.css_sec1
484
#endif
484
#endif
485
}
485
}
486
486
487
input::-webkit-datetime-edit {
488
    display: inline-block;
489
    overflow: hidden;
490
}
491
492
input::-webkit-datetime-edit-fields-wrapper {
493
    display: inline-block;
494
}
495
496
input::-webkit-datetime-edit-year-field,
497
input::-webkit-datetime-edit-month-field,
498
input::-webkit-datetime-edit-day-field {
499
    display: inline;
500
    padding: 1px;
501
}
502
503
input::-webkit-datetime-edit-year-field:focus,
504
input::-webkit-datetime-edit-month-field:focus,
505
input::-webkit-datetime-edit-day-field:focus {
506
#if defined(WTF_PLATFORM_COCOA) && WTF_PLATFORM_COCOA
507
    background-color: -apple-system-control-accent;
508
    color: white;
509
#else
510
    background-color: highlight;
511
    color: highlighttext;
512
#endif
513
    outline: none;
514
}
515
516
input::-webkit-datetime-edit-text {
517
    display: inline;
518
}
519
487
input::-webkit-inner-spin-button {
520
input::-webkit-inner-spin-button {
488
    -webkit-appearance: inner-spin-button;
521
    -webkit-appearance: inner-spin-button;
489
    display: block;
522
    display: block;
- a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp -12 / +110 lines
Lines 29-44 a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp_sec1
29
29
30
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
30
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
31
31
32
#include "DateTimeFormat.h"
32
#include "HTMLDivElement.h"
33
#include "HTMLDivElement.h"
33
#include "HTMLInputElement.h"
34
#include "HTMLInputElement.h"
34
#include "Page.h"
35
#include "Page.h"
36
#include "PlatformLocale.h"
35
#include "RenderElement.h"
37
#include "RenderElement.h"
38
#include "Settings.h"
36
#include "ShadowRoot.h"
39
#include "ShadowRoot.h"
40
#include "Text.h"
37
#include "UserGestureIndicator.h"
41
#include "UserGestureIndicator.h"
38
#include <wtf/NeverDestroyed.h>
42
#include <wtf/NeverDestroyed.h>
39
43
40
namespace WebCore {
44
namespace WebCore {
41
45
46
class DateTimeFormatValidator : public DateTimeFormat::TokenHandler {
47
public:
48
    DateTimeFormatValidator() { }
49
50
    void visitField(DateTimeFormat::FieldType, int) final;
51
    void visitLiteral(const String&) final { }
52
53
    bool validateFormat(const String& format, const BaseChooserOnlyDateAndTimeInputType&);
54
55
private:
56
    OptionSet<DateTimeFormatValidationResults> m_results;
57
};
58
59
void DateTimeFormatValidator::visitField(DateTimeFormat::FieldType fieldType, int)
60
{
61
    switch (fieldType) {
62
    case DateTimeFormat::FieldTypeYear:
63
        m_results.add(DateTimeFormatValidationResults::HasYear);
64
        break;
65
    case DateTimeFormat::FieldTypeMonth:
66
    case DateTimeFormat::FieldTypeMonthStandAlone:
67
        m_results.add(DateTimeFormatValidationResults::HasMonth);
68
        break;
69
    case DateTimeFormat::FieldTypeWeekOfYear:
70
        m_results.add(DateTimeFormatValidationResults::HasWeek);
71
        break;
72
    case DateTimeFormat::FieldTypeDayOfMonth:
73
        m_results.add(DateTimeFormatValidationResults::HasDay);
74
        break;
75
    case DateTimeFormat::FieldTypePeriod:
76
        m_results.add(DateTimeFormatValidationResults::HasAMPM);
77
        break;
78
    case DateTimeFormat::FieldTypeHour11:
79
    case DateTimeFormat::FieldTypeHour12:
80
        m_results.add(DateTimeFormatValidationResults::HasHour);
81
        break;
82
    case DateTimeFormat::FieldTypeHour23:
83
    case DateTimeFormat::FieldTypeHour24:
84
        m_results.add(DateTimeFormatValidationResults::HasHour);
85
        m_results.add(DateTimeFormatValidationResults::HasAMPM);
86
        break;
87
    case DateTimeFormat::FieldTypeMinute:
88
        m_results.add(DateTimeFormatValidationResults::HasWeek);
89
        break;
90
    case DateTimeFormat::FieldTypeSecond:
91
        m_results.add(DateTimeFormatValidationResults::HasSecond);
92
        break;
93
    default:
94
        break;
95
    }
96
}
97
98
bool DateTimeFormatValidator::validateFormat(const String& format, const BaseChooserOnlyDateAndTimeInputType& inputType)
99
{
100
    if (!DateTimeFormat::parse(format, *this))
101
        return false;
102
    return inputType.isValidFormat(m_results);
103
}
104
42
BaseChooserOnlyDateAndTimeInputType::~BaseChooserOnlyDateAndTimeInputType()
105
BaseChooserOnlyDateAndTimeInputType::~BaseChooserOnlyDateAndTimeInputType()
43
{
106
{
44
    closeDateTimeChooser();
107
    closeDateTimeChooser();
Lines 61-87 void BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent(Event&) a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp_sec2
61
124
62
void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree()
125
void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree()
63
{
126
{
64
    static MainThreadNeverDestroyed<const AtomString> valueContainerPseudo("-webkit-date-and-time-value", AtomString::ConstructFromLiteral);
65
66
    ASSERT(element());
127
    ASSERT(element());
67
    auto valueContainer = HTMLDivElement::create(element()->document());
128
    if (element()->document().page() && element()->document().page()->settings().dateTimeInputsEditableComponentsEnabled()) {
68
    valueContainer->setPseudo(valueContainerPseudo);
129
        m_dateTimeEditElement = DateTimeEditElement::create(element()->document(), *this);
69
    element()->userAgentShadowRoot()->appendChild(valueContainer);
130
        element()->userAgentShadowRoot()->appendChild(*m_dateTimeEditElement);
131
    } else {
132
        static MainThreadNeverDestroyed<const AtomString> valueContainerPseudo("-webkit-date-and-time-value", AtomString::ConstructFromLiteral);
133
        auto valueContainer = HTMLDivElement::create(element()->document());
134
        valueContainer->setPseudo(valueContainerPseudo);
135
        element()->userAgentShadowRoot()->appendChild(valueContainer);
136
    }
70
    updateInnerTextValue();
137
    updateInnerTextValue();
71
}
138
}
72
139
140
void BaseChooserOnlyDateAndTimeInputType::destroyShadowSubtree()
141
{
142
    m_dateTimeEditElement = nullptr;
143
}
144
73
void BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue()
145
void BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue()
74
{
146
{
75
    ASSERT(element());
147
    ASSERT(element());
76
    RefPtr<Node> node = element()->userAgentShadowRoot()->firstChild();
148
    if (!m_dateTimeEditElement) {
77
    if (!is<HTMLElement>(node))
149
        RefPtr<Node> node = element()->userAgentShadowRoot()->firstChild();
150
        if (!is<HTMLElement>(node))
151
            return;
152
        String displayValue = visibleValue();
153
        if (displayValue.isEmpty()) {
154
            // Need to put something to keep text baseline.
155
            displayValue = " "_s;
156
        }
157
        downcast<HTMLElement>(*node).setInnerText(displayValue);
78
        return;
158
        return;
79
    String displayValue = visibleValue();
80
    if (displayValue.isEmpty()) {
81
        // Need to put something to keep text baseline.
82
        displayValue = " "_s;
83
    }
159
    }
84
    downcast<HTMLElement>(*node).setInnerText(displayValue);
160
161
    DateTimeEditElement::LayoutParameters layoutParameters(element()->locale());
162
    setupLayoutParameters(layoutParameters);
163
164
    if (!DateTimeFormatValidator().validateFormat(layoutParameters.dateTimeFormat, *this))
165
        layoutParameters.dateTimeFormat = layoutParameters.fallbackDateTimeFormat;
166
167
    auto date = parseToDateComponents(element()->value());
168
    if (!date)
169
        m_dateTimeEditElement->setEmptyValue(layoutParameters);
170
    else
171
        m_dateTimeEditElement->setValueAsDate(layoutParameters, *date);
85
}
172
}
86
173
87
void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
174
void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
Lines 154-159 void BaseChooserOnlyDateAndTimeInputType::attributeChanged(const QualifiedName& a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp_sec3
154
    BaseDateAndTimeInputType::attributeChanged(name);
241
    BaseDateAndTimeInputType::attributeChanged(name);
155
}
242
}
156
243
244
String BaseChooserOnlyDateAndTimeInputType::valueForEditControl() const
245
{
246
    ASSERT(element());
247
    return element()->value();
248
}
249
250
AtomString BaseChooserOnlyDateAndTimeInputType::localeIdentifier() const
251
{
252
    return element()->computeInheritedLanguage();
253
}
254
157
}
255
}
158
256
159
#endif
257
#endif
- a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h -1 / +25 lines
Lines 32-51 a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h_sec1
32
#include "BaseDateAndTimeInputType.h"
32
#include "BaseDateAndTimeInputType.h"
33
#include "DateTimeChooser.h"
33
#include "DateTimeChooser.h"
34
#include "DateTimeChooserClient.h"
34
#include "DateTimeChooserClient.h"
35
#include "DateTimeEditElement.h"
36
#include <wtf/OptionSet.h>
35
37
36
namespace WebCore {
38
namespace WebCore {
37
39
38
class BaseChooserOnlyDateAndTimeInputType : public BaseDateAndTimeInputType, private DateTimeChooserClient {
40
enum class DateTimeFormatValidationResults : uint8_t {
41
    HasYear = 1 << 0,
42
    HasMonth = 1 << 1,
43
    HasWeek = 1 << 2,
44
    HasDay = 1 << 3,
45
    HasAMPM = 1 << 4,
46
    HasHour = 1 << 5,
47
    HasMinute = 1 << 6,
48
    HasSecond = 1 << 7,
49
};
50
51
class BaseChooserOnlyDateAndTimeInputType : public BaseDateAndTimeInputType, private DateTimeChooserClient, private DateTimeEditElement::EditControlOwner {
52
public:
53
    virtual bool isValidFormat(OptionSet<DateTimeFormatValidationResults>) const = 0;
54
39
protected:
55
protected:
40
    explicit BaseChooserOnlyDateAndTimeInputType(HTMLInputElement& element) : BaseDateAndTimeInputType(element) { }
56
    explicit BaseChooserOnlyDateAndTimeInputType(HTMLInputElement& element) : BaseDateAndTimeInputType(element) { }
41
    ~BaseChooserOnlyDateAndTimeInputType();
57
    ~BaseChooserOnlyDateAndTimeInputType();
42
58
59
    virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const = 0;
60
43
private:
61
private:
44
    void updateInnerTextValue() override;
62
    void updateInnerTextValue() override;
45
    void closeDateTimeChooser();
63
    void closeDateTimeChooser();
46
64
65
    // DateTimeEditElement::EditControlOwner functions:
66
    String valueForEditControl() const final;
67
    AtomString localeIdentifier() const final;
68
47
    // InputType functions:
69
    // InputType functions:
48
    void createShadowSubtree() override;
70
    void createShadowSubtree() override;
71
    void destroyShadowSubtree() override;
49
    void detach() override;
72
    void detach() override;
50
    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override;
73
    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override;
51
    void handleDOMActivateEvent(Event&) override;
74
    void handleDOMActivateEvent(Event&) override;
Lines 61-66 private: a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h_sec2
61
    void didEndChooser() final;
84
    void didEndChooser() final;
62
85
63
    RefPtr<DateTimeChooser> m_dateTimeChooser;
86
    RefPtr<DateTimeChooser> m_dateTimeChooser;
87
    RefPtr<DateTimeEditElement> m_dateTimeEditElement;
64
};
88
};
65
89
66
} // namespace WebCore
90
} // namespace WebCore
- a/Source/WebCore/html/BaseDateAndTimeInputType.h -1 / +2 lines
Lines 53-60 protected: a/Source/WebCore/html/BaseDateAndTimeInputType.h_sec1
53
    bool isKeyboardFocusable(KeyboardEvent*) const override;
53
    bool isKeyboardFocusable(KeyboardEvent*) const override;
54
#endif
54
#endif
55
55
56
private:
57
    virtual Optional<DateComponents> parseToDateComponents(const StringView&) const = 0;
56
    virtual Optional<DateComponents> parseToDateComponents(const StringView&) const = 0;
57
58
private:
58
    virtual Optional<DateComponents> setMillisecondToDateComponents(double) const = 0;
59
    virtual Optional<DateComponents> setMillisecondToDateComponents(double) const = 0;
59
60
60
    double valueAsDate() const override;
61
    double valueAsDate() const override;
- a/Source/WebCore/html/DateInputType.cpp +14 lines
Lines 35-40 a/Source/WebCore/html/DateInputType.cpp_sec1
35
#include "HTMLInputElement.h"
35
#include "HTMLInputElement.h"
36
#include "HTMLNames.h"
36
#include "HTMLNames.h"
37
#include "InputTypeNames.h"
37
#include "InputTypeNames.h"
38
#include "PlatformLocale.h"
38
#include "StepRange.h"
39
#include "StepRange.h"
39
40
40
namespace WebCore {
41
namespace WebCore {
Lines 86-90 bool DateInputType::isDateField() const a/Source/WebCore/html/DateInputType.cpp_sec2
86
    return true;
87
    return true;
87
}
88
}
88
89
90
bool DateInputType::isValidFormat(OptionSet<DateTimeFormatValidationResults> results) const
91
{
92
    return results.contains(DateTimeFormatValidationResults::HasYear)
93
        && results.contains(DateTimeFormatValidationResults::HasMonth)
94
        && results.contains(DateTimeFormatValidationResults::HasDay);
95
}
96
97
void DateInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters) const
98
{
99
    layoutParameters.dateTimeFormat = layoutParameters.locale.dateFormat();
100
    layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd"_s;
101
}
102
89
} // namespace WebCore
103
} // namespace WebCore
90
#endif
104
#endif
- a/Source/WebCore/html/DateInputType.h +3 lines
Lines 47-52 private: a/Source/WebCore/html/DateInputType.h_sec1
47
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
47
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
48
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
48
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
49
    bool isDateField() const override;
49
    bool isDateField() const override;
50
51
    bool isValidFormat(OptionSet<DateTimeFormatValidationResults>) const override;
52
    void setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const override;
50
};
53
};
51
54
52
} // namespace WebCore
55
} // namespace WebCore
- a/Source/WebCore/html/DateTimeLocalInputType.cpp +13 lines
Lines 95-100 bool DateTimeLocalInputType::isDateTimeLocalField() const a/Source/WebCore/html/DateTimeLocalInputType.cpp_sec1
95
    return true;
95
    return true;
96
}
96
}
97
97
98
bool DateTimeLocalInputType::isValidFormat(OptionSet<DateTimeFormatValidationResults> results) const
99
{
100
    return results.contains(DateTimeFormatValidationResults::HasYear)
101
        && results.contains(DateTimeFormatValidationResults::HasMonth)
102
        && results.contains(DateTimeFormatValidationResults::HasDay)
103
        && results.contains(DateTimeFormatValidationResults::HasHour)
104
        && results.contains(DateTimeFormatValidationResults::HasMinute);
105
}
106
107
void DateTimeLocalInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const
108
{
109
}
110
98
} // namespace WebCore
111
} // namespace WebCore
99
112
100
#endif
113
#endif
- a/Source/WebCore/html/DateTimeLocalInputType.h +3 lines
Lines 49-54 private: a/Source/WebCore/html/DateTimeLocalInputType.h_sec1
49
    Optional<DateComponents> parseToDateComponents(const StringView&) const final;
49
    Optional<DateComponents> parseToDateComponents(const StringView&) const final;
50
    Optional<DateComponents> setMillisecondToDateComponents(double) const final;
50
    Optional<DateComponents> setMillisecondToDateComponents(double) const final;
51
    bool isDateTimeLocalField() const final;
51
    bool isDateTimeLocalField() const final;
52
53
    bool isValidFormat(OptionSet<DateTimeFormatValidationResults>) const override;
54
    void setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const override;
52
};
55
};
53
56
54
} // namespace WebCore
57
} // namespace WebCore
- a/Source/WebCore/html/MonthInputType.cpp +10 lines
Lines 129-134 bool MonthInputType::isMonthField() const a/Source/WebCore/html/MonthInputType.cpp_sec1
129
    return true;
129
    return true;
130
}
130
}
131
131
132
bool MonthInputType::isValidFormat(OptionSet<DateTimeFormatValidationResults> results) const
133
{
134
    return results.contains(DateTimeFormatValidationResults::HasYear)
135
        && results.contains(DateTimeFormatValidationResults::HasMonth);
136
}
137
138
void MonthInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const
139
{
140
}
141
132
} // namespace WebCore
142
} // namespace WebCore
133
143
134
#endif
144
#endif
- a/Source/WebCore/html/MonthInputType.h +3 lines
Lines 51-56 private: a/Source/WebCore/html/MonthInputType.h_sec1
51
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
51
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
52
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
52
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
53
    bool isMonthField() const override;
53
    bool isMonthField() const override;
54
55
    bool isValidFormat(OptionSet<DateTimeFormatValidationResults>) const override;
56
    void setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const override;
54
};
57
};
55
58
56
} // namespace WebCore
59
} // namespace WebCore
- a/Source/WebCore/html/TimeInputType.cpp +11 lines
Lines 36-41 a/Source/WebCore/html/TimeInputType.cpp_sec1
36
#include "HTMLInputElement.h"
36
#include "HTMLInputElement.h"
37
#include "HTMLNames.h"
37
#include "HTMLNames.h"
38
#include "InputTypeNames.h"
38
#include "InputTypeNames.h"
39
#include "PlatformLocale.h"
39
#include "StepRange.h"
40
#include "StepRange.h"
40
#include <wtf/DateMath.h>
41
#include <wtf/DateMath.h>
41
#include <wtf/MathExtras.h>
42
#include <wtf/MathExtras.h>
Lines 104-109 bool TimeInputType::isTimeField() const a/Source/WebCore/html/TimeInputType.cpp_sec2
104
    return true;
105
    return true;
105
}
106
}
106
107
108
bool TimeInputType::isValidFormat(OptionSet<DateTimeFormatValidationResults> results) const
109
{
110
    return results.contains(DateTimeFormatValidationResults::HasHour)
111
        && results.contains(DateTimeFormatValidationResults::HasMinute);
112
}
113
114
void TimeInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const
115
{
116
}
117
107
} // namespace WebCore
118
} // namespace WebCore
108
119
109
#endif
120
#endif
- a/Source/WebCore/html/TimeInputType.h +3 lines
Lines 48-53 private: a/Source/WebCore/html/TimeInputType.h_sec1
48
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
48
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
49
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
49
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
50
    bool isTimeField() const override;
50
    bool isTimeField() const override;
51
52
    bool isValidFormat(OptionSet<DateTimeFormatValidationResults>) const override;
53
    void setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const override;
51
};
54
};
52
55
53
} // namespace WebCore
56
} // namespace WebCore
- a/Source/WebCore/html/WeekInputType.cpp +10 lines
Lines 82-87 bool WeekInputType::isWeekField() const a/Source/WebCore/html/WeekInputType.cpp_sec1
82
    return true;
82
    return true;
83
}
83
}
84
84
85
bool WeekInputType::isValidFormat(OptionSet<DateTimeFormatValidationResults> results) const
86
{
87
    return results.contains(DateTimeFormatValidationResults::HasYear)
88
        && results.contains(DateTimeFormatValidationResults::HasWeek);
89
}
90
91
void WeekInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const
92
{
93
}
94
85
} // namespace WebCore
95
} // namespace WebCore
86
96
87
#endif
97
#endif
- a/Source/WebCore/html/WeekInputType.h +3 lines
Lines 47-52 private: a/Source/WebCore/html/WeekInputType.h_sec1
47
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
47
    Optional<DateComponents> parseToDateComponents(const StringView&) const override;
48
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
48
    Optional<DateComponents> setMillisecondToDateComponents(double) const override;
49
    bool isWeekField() const override;
49
    bool isWeekField() const override;
50
51
    bool isValidFormat(OptionSet<DateTimeFormatValidationResults>) const override;
52
    void setupLayoutParameters(DateTimeEditElement::LayoutParameters&) const override;
50
};
53
};
51
54
52
} // namespace WebCore
55
} // namespace WebCore
- a/Source/WebCore/html/shadow/DateTimeEditElement.cpp +228 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeEditElement.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "DateTimeEditElement.h"
29
30
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
31
32
#include "DateComponents.h"
33
#include "DateTimeFieldElements.h"
34
#include "DateTimeFormat.h"
35
#include "DateTimeSymbolicFieldElement.h"
36
#include "HTMLNames.h"
37
#include "PlatformLocale.h"
38
#include "Text.h"
39
#include <wtf/IsoMallocInlines.h>
40
#include <wtf/text/StringBuilder.h>
41
42
namespace WebCore {
43
44
using namespace HTMLNames;
45
46
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeEditElement);
47
48
class DateTimeEditBuilder : private DateTimeFormat::TokenHandler {
49
    WTF_MAKE_NONCOPYABLE(DateTimeEditBuilder);
50
51
public:
52
    DateTimeEditBuilder(DateTimeEditElement&, const DateTimeEditElement::LayoutParameters&);
53
54
    bool build(const String&);
55
56
private:
57
    // DateTimeFormat::TokenHandler functions:
58
    void visitField(DateTimeFormat::FieldType, int) final;
59
    void visitLiteral(const String&) final;
60
61
    DateTimeEditElement& m_editElement;
62
    const DateTimeEditElement::LayoutParameters& m_parameters;
63
};
64
65
DateTimeEditBuilder::DateTimeEditBuilder(DateTimeEditElement& element, const DateTimeEditElement::LayoutParameters& layoutParameters)
66
    : m_editElement(element)
67
    , m_parameters(layoutParameters)
68
{
69
}
70
71
bool DateTimeEditBuilder::build(const String& formatString)
72
{
73
    m_editElement.resetFields();
74
    return DateTimeFormat::parse(formatString, *this);
75
}
76
77
void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int count)
78
{
79
    constexpr int countForAbbreviatedMonth = 3;
80
    constexpr int countForFullMonth = 4;
81
    constexpr int countForNarrowMonth = 5;
82
    Document& document = m_editElement.document();
83
84
    switch (fieldType) {
85
    case DateTimeFormat::FieldTypeDayOfMonth: {
86
        m_editElement.addField(DateTimeDayFieldElement::create(document, m_editElement));
87
        return;
88
    }
89
90
    case DateTimeFormat::FieldTypeMonth:
91
    case DateTimeFormat::FieldTypeMonthStandAlone: {
92
        switch (count) {
93
        case countForNarrowMonth:
94
        case countForAbbreviatedMonth: {
95
            auto field = DateTimeSymbolicMonthFieldElement::create(document, m_editElement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.shortMonthLabels() : m_parameters.locale.shortStandAloneMonthLabels());
96
            m_editElement.addField(field);
97
            break;
98
        }
99
        case countForFullMonth: {
100
            auto field = DateTimeSymbolicMonthFieldElement::create(document, m_editElement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.monthLabels() : m_parameters.locale.standAloneMonthLabels());
101
            m_editElement.addField(field);
102
            break;
103
        }
104
        default: {
105
            m_editElement.addField(DateTimeMonthFieldElement::create(document, m_editElement));
106
            break;
107
        }
108
        }
109
        return;
110
    }
111
112
    case DateTimeFormat::FieldTypeYear: {
113
        m_editElement.addField(DateTimeYearFieldElement::create(document, m_editElement));
114
        return;
115
    }
116
117
    default:
118
        return;
119
    }
120
}
121
122
void DateTimeEditBuilder::visitLiteral(const String& text)
123
{
124
    ASSERT(text.length());
125
    static MainThreadNeverDestroyed<const AtomString> textPseudoId("-webkit-datetime-edit-text", AtomString::ConstructFromLiteral);
126
    auto element = HTMLDivElement::create(m_editElement.document());
127
    element->setPseudo(textPseudoId);
128
    element->appendChild(Text::create(m_editElement.document(), text));
129
    m_editElement.fieldsWrapperElement()->appendChild(element);
130
}
131
132
DateTimeEditElement::EditControlOwner::~EditControlOwner()
133
{
134
}
135
136
DateTimeEditElement::DateTimeEditElement(Document& document, EditControlOwner& editControlOwner)
137
    : HTMLDivElement(divTag, document)
138
    , m_editControlOwner(&editControlOwner)
139
{
140
    static MainThreadNeverDestroyed<const AtomString> dateTimeEditPseudoId("-webkit-datetime-edit", AtomString::ConstructFromLiteral);
141
    setPseudo(dateTimeEditPseudoId);
142
}
143
144
DateTimeEditElement::~DateTimeEditElement()
145
{
146
}
147
148
inline Element* DateTimeEditElement::fieldsWrapperElement() const
149
{
150
    ASSERT(firstChild());
151
    return downcast<Element>(firstChild());
152
}
153
154
void DateTimeEditElement::addField(Ref<DateTimeFieldElement> field)
155
{
156
    if (m_fields.size() == m_fields.capacity())
157
        return;
158
    m_fields.append(field);
159
    fieldsWrapperElement()->appendChild(field);
160
}
161
162
Ref<DateTimeEditElement> DateTimeEditElement::create(Document& document, EditControlOwner& editControlOwner)
163
{
164
    return adoptRef(*new DateTimeEditElement(document, editControlOwner));
165
}
166
167
void DateTimeEditElement::layout(const LayoutParameters& layoutParameters)
168
{
169
    static MainThreadNeverDestroyed<const AtomString> fieldsWrapperPseudoId("-webkit-datetime-edit-fields-wrapper", AtomString::ConstructFromLiteral);
170
171
    if (!firstChild()) {
172
        auto element = HTMLDivElement::create(document());
173
        element->setPseudo(fieldsWrapperPseudoId);
174
        appendChild(element);
175
    }
176
177
    Element* fieldsWrapper = fieldsWrapperElement();
178
179
    DateTimeEditBuilder builder(*this, layoutParameters);
180
    Node* lastChildToBeRemoved = fieldsWrapper->lastChild();
181
    if (!builder.build(layoutParameters.dateTimeFormat) || m_fields.isEmpty()) {
182
        lastChildToBeRemoved = fieldsWrapper->lastChild();
183
        builder.build(layoutParameters.fallbackDateTimeFormat);
184
    }
185
186
    if (lastChildToBeRemoved) {
187
        for (Node* childNode = fieldsWrapper->firstChild(); childNode; childNode = fieldsWrapper->firstChild()) {
188
            fieldsWrapper->removeChild(*childNode);
189
            if (childNode == lastChildToBeRemoved)
190
                break;
191
        }
192
    }
193
}
194
195
AtomString DateTimeEditElement::localeIdentifier() const
196
{
197
    return m_editControlOwner ? m_editControlOwner->localeIdentifier() : nullAtom();
198
}
199
200
void DateTimeEditElement::resetFields()
201
{
202
    m_fields.shrink(0);
203
}
204
205
void DateTimeEditElement::setValueAsDate(const LayoutParameters& layoutParameters, const DateComponents& date)
206
{
207
    layout(layoutParameters);
208
    for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex)
209
        m_fields[fieldIndex]->setValueAsDate(date);
210
}
211
212
void DateTimeEditElement::setEmptyValue(const LayoutParameters& layoutParameters)
213
{
214
    layout(layoutParameters);
215
    for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex)
216
        m_fields[fieldIndex]->setEmptyValue();
217
}
218
219
String DateTimeEditElement::value() const
220
{
221
    if (!m_editControlOwner)
222
        return emptyString();
223
    return m_editControlOwner->valueForEditControl();
224
}
225
226
} // namespace WebCore
227
228
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeEditElement.h +96 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeEditElement.h_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#pragma once
28
29
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
30
31
#include "DateComponents.h"
32
#include "DateTimeFieldElement.h"
33
34
namespace WebCore {
35
36
class Locale;
37
38
class DateTimeEditElement final : public HTMLDivElement, public DateTimeFieldElement::FieldOwner {
39
    WTF_MAKE_ISO_ALLOCATED(DateTimeEditElement);
40
public:
41
    class EditControlOwner {
42
    public:
43
        virtual ~EditControlOwner();
44
        virtual String valueForEditControl() const = 0;
45
        virtual AtomString localeIdentifier() const = 0;
46
    };
47
48
    struct LayoutParameters {
49
        String dateTimeFormat;
50
        String fallbackDateTimeFormat;
51
        Locale& locale;
52
53
        LayoutParameters(Locale& locale)
54
            : locale(locale)
55
        {
56
        }
57
    };
58
59
    static Ref<DateTimeEditElement> create(Document&, EditControlOwner&);
60
61
    virtual ~DateTimeEditElement();
62
    void addField(Ref<DateTimeFieldElement>);
63
    Element* fieldsWrapperElement() const;
64
    void resetFields();
65
    void setEmptyValue(const LayoutParameters&);
66
    void setValueAsDate(const LayoutParameters&, const DateComponents&);
67
    String value() const;
68
69
private:
70
    static const size_t invalidFieldIndex = static_cast<size_t>(-1);
71
72
    // Datetime can be represented by at most 8 fields:
73
    // 1. year
74
    // 2. month
75
    // 3. day-of-month
76
    // 4. hour
77
    // 5. minute
78
    // 6. second
79
    // 7. millisecond
80
    // 8. AM/PM
81
    static const int maximumNumberOfFields = 8;
82
83
    DateTimeEditElement(Document&, EditControlOwner&);
84
85
    void layout(const LayoutParameters&);
86
87
    // DateTimeFieldElement::FieldOwner functions:
88
    AtomString localeIdentifier() const final;
89
90
    Vector<Ref<DateTimeFieldElement>, maximumNumberOfFields> m_fields;
91
    EditControlOwner* m_editControlOwner;
92
};
93
94
} // namespace WebCore
95
96
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeFieldElement.cpp +90 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeFieldElement.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "DateTimeFieldElement.h"
29
30
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
31
32
#include "DateComponents.h"
33
#include "HTMLNames.h"
34
#include "LocalizedStrings.h"
35
#include "PlatformLocale.h"
36
#include "Text.h"
37
#include <wtf/text/WTFString.h>
38
39
namespace WebCore {
40
41
using namespace HTMLNames;
42
43
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeFieldElement);
44
45
DateTimeFieldElement::FieldOwner::~FieldOwner()
46
{
47
}
48
49
DateTimeFieldElement::DateTimeFieldElement(Document& document, FieldOwner& fieldOwner)
50
    : HTMLDivElement(divTag, document)
51
    , m_fieldOwner(&fieldOwner)
52
{
53
}
54
55
void DateTimeFieldElement::initialize(const AtomString& pseudo)
56
{
57
    setPseudo(pseudo);
58
}
59
60
Locale& DateTimeFieldElement::localeForOwner() const
61
{
62
    return document().getCachedLocale(localeIdentifier());
63
}
64
65
AtomString DateTimeFieldElement::localeIdentifier() const
66
{
67
    return m_fieldOwner ? m_fieldOwner->localeIdentifier() : nullAtom();
68
}
69
70
void DateTimeFieldElement::updateVisibleValue()
71
{
72
    if (!firstChild())
73
        appendChild(Text::create(document(), emptyString()));
74
75
    Text& textNode = downcast<Text>(*firstChild());
76
    const String newVisibleValue = visibleValue();
77
    if (textNode.wholeText() == newVisibleValue)
78
        return;
79
80
    textNode.replaceWholeText(newVisibleValue);
81
}
82
83
bool DateTimeFieldElement::supportsFocus() const
84
{
85
    return true;
86
}
87
88
} // namespace WebCore
89
90
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeFieldElement.h +69 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeFieldElement.h_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#pragma once
28
29
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
30
31
#include "HTMLDivElement.h"
32
33
namespace WebCore {
34
35
class DateComponents;
36
37
class DateTimeFieldElement : public HTMLDivElement {
38
    WTF_MAKE_ISO_ALLOCATED(DateTimeFieldElement);
39
public:
40
    class FieldOwner {
41
    public:
42
        virtual ~FieldOwner();
43
        virtual AtomString localeIdentifier() const = 0;
44
    };
45
46
    virtual bool hasValue() const = 0;
47
    virtual void setEmptyValue() = 0;
48
    virtual void setValueAsDate(const DateComponents&) = 0;
49
    virtual void setValueAsInteger(int) = 0;
50
    virtual String value() const = 0;
51
    virtual String visibleValue() const = 0;
52
53
protected:
54
    DateTimeFieldElement(Document&, FieldOwner&);
55
    void initialize(const AtomString& pseudo);
56
    Locale& localeForOwner() const;
57
    AtomString localeIdentifier() const;
58
    void updateVisibleValue();
59
    virtual int valueAsInteger() const = 0;
60
61
private:
62
    bool supportsFocus() const override;
63
64
    FieldOwner* m_fieldOwner;
65
};
66
67
} // namespace WebCore
68
69
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeFieldElements.cpp +115 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeFieldElements.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "DateTimeFieldElements.h"
29
30
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
31
32
#include "DateComponents.h"
33
#include <wtf/IsoMallocInlines.h>
34
35
namespace WebCore {
36
37
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeDayFieldElement);
38
39
DateTimeDayFieldElement::DateTimeDayFieldElement(Document& document, FieldOwner& fieldOwner)
40
    : DateTimeNumericFieldElement(document, fieldOwner, "--"_s)
41
{
42
    static MainThreadNeverDestroyed<const AtomString> dayPsuedoId("-webkit-datetime-edit-day-field", AtomString::ConstructFromLiteral);
43
    initialize(dayPsuedoId);
44
}
45
46
Ref<DateTimeDayFieldElement> DateTimeDayFieldElement::create(Document& document, FieldOwner& fieldOwner)
47
{
48
    return adoptRef(*new DateTimeDayFieldElement(document, fieldOwner));
49
}
50
51
void DateTimeDayFieldElement::setValueAsDate(const DateComponents& date)
52
{
53
    setValueAsInteger(date.monthDay());
54
}
55
56
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeMonthFieldElement);
57
58
DateTimeMonthFieldElement::DateTimeMonthFieldElement(Document& document, FieldOwner& fieldOwner)
59
    : DateTimeNumericFieldElement(document, fieldOwner, "--"_s)
60
{
61
    static MainThreadNeverDestroyed<const AtomString> monthPsuedoId("-webkit-datetime-edit-month-field", AtomString::ConstructFromLiteral);
62
    initialize(monthPsuedoId);
63
}
64
65
Ref<DateTimeMonthFieldElement> DateTimeMonthFieldElement::create(Document& document, FieldOwner& fieldOwner)
66
{
67
    return adoptRef(*new DateTimeMonthFieldElement(document, fieldOwner));
68
}
69
70
void DateTimeMonthFieldElement::setValueAsDate(const DateComponents& date)
71
{
72
    setValueAsInteger(date.month() + 1);
73
}
74
75
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeSymbolicMonthFieldElement);
76
77
DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement(Document& document, FieldOwner& fieldOwner, const Vector<String>& labels)
78
    : DateTimeSymbolicFieldElement(document, fieldOwner, labels)
79
{
80
    static MainThreadNeverDestroyed<const AtomString> monthPsuedoId("-webkit-datetime-edit-month-field", AtomString::ConstructFromLiteral);
81
    initialize(monthPsuedoId);
82
}
83
84
Ref<DateTimeSymbolicMonthFieldElement> DateTimeSymbolicMonthFieldElement::create(Document& document, FieldOwner& fieldOwner, const Vector<String>& labels)
85
{
86
    return adoptRef(*new DateTimeSymbolicMonthFieldElement(document, fieldOwner, labels));
87
}
88
89
void DateTimeSymbolicMonthFieldElement::setValueAsDate(const DateComponents& date)
90
{
91
    setValueAsInteger(date.month());
92
}
93
94
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeYearFieldElement);
95
96
DateTimeYearFieldElement::DateTimeYearFieldElement(Document& document, FieldOwner& fieldOwner)
97
    : DateTimeNumericFieldElement(document, fieldOwner, "----"_s)
98
{
99
    static MainThreadNeverDestroyed<const AtomString> yearPsuedoId("-webkit-datetime-edit-year-field", AtomString::ConstructFromLiteral);
100
    initialize(yearPsuedoId);
101
}
102
103
Ref<DateTimeYearFieldElement> DateTimeYearFieldElement::create(Document& document, FieldOwner& fieldOwner)
104
{
105
    return adoptRef(*new DateTimeYearFieldElement(document, fieldOwner));
106
}
107
108
void DateTimeYearFieldElement::setValueAsDate(const DateComponents& date)
109
{
110
    setValueAsInteger(date.fullYear());
111
}
112
113
} // namespace WebCore
114
115
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeFieldElements.h +90 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeFieldElements.h_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#pragma once
28
29
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
30
31
#include "DateTimeNumericFieldElement.h"
32
#include "DateTimeSymbolicFieldElement.h"
33
34
namespace WebCore {
35
36
class DateTimeDayFieldElement final : public DateTimeNumericFieldElement {
37
    WTF_MAKE_ISO_ALLOCATED(DateTimeDayFieldElement);
38
39
public:
40
    static Ref<DateTimeDayFieldElement> create(Document&, FieldOwner&);
41
42
private:
43
    DateTimeDayFieldElement(Document&, FieldOwner&);
44
45
    // DateTimeFieldElement functions:
46
    void setValueAsDate(const DateComponents&) final;
47
};
48
49
class DateTimeMonthFieldElement final : public DateTimeNumericFieldElement {
50
    WTF_MAKE_ISO_ALLOCATED(DateTimeMonthFieldElement);
51
52
public:
53
    static Ref<DateTimeMonthFieldElement> create(Document&, FieldOwner&);
54
55
private:
56
    DateTimeMonthFieldElement(Document&, FieldOwner&);
57
58
    // DateTimeFieldElement functions:
59
    void setValueAsDate(const DateComponents&) final;
60
};
61
62
class DateTimeSymbolicMonthFieldElement final : public DateTimeSymbolicFieldElement {
63
    WTF_MAKE_ISO_ALLOCATED(DateTimeSymbolicMonthFieldElement);
64
65
public:
66
    static Ref<DateTimeSymbolicMonthFieldElement> create(Document&, FieldOwner&, const Vector<String>&);
67
68
private:
69
    DateTimeSymbolicMonthFieldElement(Document&, FieldOwner&, const Vector<String>&);
70
71
    // DateTimeFieldElement functions:
72
    void setValueAsDate(const DateComponents&) final;
73
};
74
75
class DateTimeYearFieldElement final : public DateTimeNumericFieldElement {
76
    WTF_MAKE_ISO_ALLOCATED(DateTimeYearFieldElement);
77
78
public:
79
    static Ref<DateTimeYearFieldElement> create(Document&, FieldOwner&);
80
81
private:
82
    DateTimeYearFieldElement(Document&, FieldOwner&);
83
84
    // DateTimeFieldElement functions:
85
    void setValueAsDate(const DateComponents&) final;
86
};
87
88
} // namespace WebCore
89
90
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp +94 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "DateTimeNumericFieldElement.h"
29
30
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
31
32
#include "PlatformLocale.h"
33
#include <wtf/IsoMallocInlines.h>
34
35
namespace WebCore {
36
37
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeNumericFieldElement);
38
39
DateTimeNumericFieldElement::DateTimeNumericFieldElement(Document& document, FieldOwner& fieldOwner, const String& placeholder)
40
    : DateTimeFieldElement(document, fieldOwner)
41
    , m_placeholder(placeholder)
42
    , m_value(0)
43
    , m_hasValue(false)
44
{
45
}
46
47
String DateTimeNumericFieldElement::formatValue(int value) const
48
{
49
    Locale& locale = localeForOwner();
50
    return locale.convertToLocalizedNumber(makeString(pad('0', 2, value)));
51
}
52
53
bool DateTimeNumericFieldElement::hasValue() const
54
{
55
    return m_hasValue;
56
}
57
58
void DateTimeNumericFieldElement::initialize(const AtomString& pseudo)
59
{
60
    DateTimeFieldElement::initialize(pseudo);
61
}
62
63
void DateTimeNumericFieldElement::setEmptyValue()
64
{
65
    m_value = 0;
66
    m_hasValue = false;
67
    updateVisibleValue();
68
}
69
70
void DateTimeNumericFieldElement::setValueAsInteger(int value)
71
{
72
    m_value = value;
73
    m_hasValue = true;
74
    updateVisibleValue();
75
}
76
77
String DateTimeNumericFieldElement::value() const
78
{
79
    return m_hasValue ? formatValue(m_value) : emptyString();
80
}
81
82
int DateTimeNumericFieldElement::valueAsInteger() const
83
{
84
    return m_hasValue ? m_value : -1;
85
}
86
87
String DateTimeNumericFieldElement::visibleValue() const
88
{
89
    return m_hasValue ? value() : m_placeholder;
90
}
91
92
} // namespace WebCore
93
94
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h +63 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#pragma once
28
29
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
30
31
#include "DateTimeFieldElement.h"
32
33
namespace WebCore {
34
35
class DateTimeNumericFieldElement : public DateTimeFieldElement {
36
    WTF_MAKE_ISO_ALLOCATED(DateTimeNumericFieldElement);
37
public:
38
39
protected:
40
    DateTimeNumericFieldElement(Document&, FieldOwner&, const String&);
41
42
    // DateTimeFieldElement functions:
43
    bool hasValue() const final;
44
    void initialize(const AtomString&);
45
    void setEmptyValue() final;
46
    void setValueAsInteger(int) override;
47
    int valueAsInteger() const final;
48
    String visibleValue() const final;
49
50
private:
51
    // DateTimeFieldElement functions:
52
    String value() const final;
53
54
    String formatValue(int) const;
55
56
    const String m_placeholder;
57
    int m_value;
58
    bool m_hasValue;
59
};
60
61
} // namespace WebCore
62
63
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp +105 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "DateTimeSymbolicFieldElement.h"
29
30
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
31
32
#include <wtf/IsoMallocInlines.h>
33
#include <wtf/text/StringBuilder.h>
34
#include <wtf/text/TextBreakIterator.h>
35
36
namespace WebCore {
37
38
WTF_MAKE_ISO_ALLOCATED_IMPL(DateTimeSymbolicFieldElement);
39
40
static AtomString makeVisibleEmptyValue(const Vector<String>& symbols)
41
{
42
    unsigned maximumLength = 0;
43
    for (unsigned index = 0; index < symbols.size(); ++index)
44
        maximumLength = std::max(maximumLength, numGraphemeClusters(symbols[index]));
45
    StringBuilder builder;
46
    builder.reserveCapacity(maximumLength);
47
    for (unsigned length = 0; length < maximumLength; ++length)
48
        builder.append('-');
49
    return builder.toAtomString();
50
}
51
52
DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement(Document& document, FieldOwner& fieldOwner, const Vector<String>& symbols)
53
    : DateTimeFieldElement(document, fieldOwner)
54
    , m_symbols(symbols)
55
    , m_visibleEmptyValue(makeVisibleEmptyValue(symbols))
56
    , m_selectedIndex(-1)
57
{
58
    ASSERT(!symbols.isEmpty());
59
}
60
61
bool DateTimeSymbolicFieldElement::hasValue() const
62
{
63
    return m_selectedIndex >= 0;
64
}
65
66
void DateTimeSymbolicFieldElement::initialize(const AtomString& pseudo)
67
{
68
    DateTimeFieldElement::initialize(pseudo);
69
}
70
71
void DateTimeSymbolicFieldElement::setEmptyValue()
72
{
73
    m_selectedIndex = invalidIndex;
74
    updateVisibleValue();
75
}
76
77
void DateTimeSymbolicFieldElement::setValueAsInteger(int newSelectedIndex)
78
{
79
    m_selectedIndex = std::max(0, std::min(newSelectedIndex, static_cast<int>(m_symbols.size() - 1)));
80
    updateVisibleValue();
81
}
82
83
String DateTimeSymbolicFieldElement::value() const
84
{
85
    return hasValue() ? m_symbols[m_selectedIndex] : emptyString();
86
}
87
88
int DateTimeSymbolicFieldElement::valueAsInteger() const
89
{
90
    return m_selectedIndex;
91
}
92
93
String DateTimeSymbolicFieldElement::visibleEmptyValue() const
94
{
95
    return m_visibleEmptyValue;
96
}
97
98
String DateTimeSymbolicFieldElement::visibleValue() const
99
{
100
    return hasValue() ? m_symbols[m_selectedIndex] : visibleEmptyValue();
101
}
102
103
} // namespace WebCore
104
105
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h +63 lines
Line 0 a/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 * Copyright (C) 2020 Apple Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#pragma once
28
29
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
30
31
#include "DateTimeFieldElement.h"
32
33
namespace WebCore {
34
35
class DateTimeSymbolicFieldElement : public DateTimeFieldElement {
36
    WTF_MAKE_ISO_ALLOCATED(DateTimeSymbolicFieldElement);
37
protected:
38
    DateTimeSymbolicFieldElement(Document&, FieldOwner&, const Vector<String>&);
39
    size_t symbolsSize() const { return m_symbols.size(); }
40
    bool hasValue() const final;
41
    void initialize(const AtomString& pseudo);
42
    void setEmptyValue() final;
43
    void setValueAsInteger(int) final;
44
    int valueAsInteger() const final;
45
46
private:
47
    static const int invalidIndex = -1;
48
49
    String visibleEmptyValue() const;
50
51
    // DateTimeFieldElement functions:
52
    String value() const final;
53
    String visibleValue() const final;
54
55
    const Vector<String> m_symbols;
56
57
    const AtomString m_visibleEmptyValue;
58
    int m_selectedIndex;
59
};
60
61
} // namespace WebCore
62
63
#endif // ENABLE(DATE_AND_TIME_INPUT_TYPES)
- a/Source/WebCore/page/Settings.yaml +4 lines
Lines 974-979 inputTypeWeekEnabled: a/Source/WebCore/page/Settings.yaml_sec1
974
  initial: false
974
  initial: false
975
  conditional: INPUT_TYPE_WEEK
975
  conditional: INPUT_TYPE_WEEK
976
976
977
dateTimeInputsEditableComponentsEnabled:
978
  initial: false
979
  conditional: DATE_AND_TIME_INPUT_TYPES
980
977
# Deprecated
981
# Deprecated
978
982
979
iceCandidateFilteringEnabled:
983
iceCandidateFilteringEnabled:
- a/Source/WebKit/Shared/WebPreferences.yaml +9 lines
Lines 1833-1838 InputTypeWeekEnabled: a/Source/WebKit/Shared/WebPreferences.yaml_sec1
1833
  category: internal
1833
  category: internal
1834
  condition: ENABLE(INPUT_TYPE_WEEK)
1834
  condition: ENABLE(INPUT_TYPE_WEEK)
1835
1835
1836
DateTimeInputsEditableComponentsEnabled:
1837
  type: bool
1838
  defaultValue: DEFAULT_DATE_TIME_INPUTS_EDITABLE_COMPONENTS_ENABLED
1839
  humanReadableName: "Date/Time inputs have editable components"
1840
  humanReadableDescription: "Enable multiple editable components in date/time inputs"
1841
  category: internal
1842
  webcoreName: dateTimeInputsEditableComponentsEnabled
1843
  condition: ENABLE(DATE_AND_TIME_INPUT_TYPES)
1844
1836
DataListElementEnabled:
1845
DataListElementEnabled:
1837
  type: bool
1846
  type: bool
1838
  defaultValue: DEFAULT_DATALIST_ELEMENT_ENABLED
1847
  defaultValue: DEFAULT_DATALIST_ELEMENT_ENABLED
- a/Source/WebKit/Shared/WebPreferencesDefaultValues.h +6 lines
Lines 238-243 a/Source/WebKit/Shared/WebPreferencesDefaultValues.h_sec1
238
#define DEFAULT_DATALIST_ELEMENT_ENABLED true
238
#define DEFAULT_DATALIST_ELEMENT_ENABLED true
239
#endif
239
#endif
240
240
241
#if PLATFORM(MAC)
242
#define DEFAULT_DATE_TIME_INPUTS_EDITABLE_COMPONENTS_ENABLED true
243
#else
244
#define DEFAULT_DATE_TIME_INPUTS_EDITABLE_COMPONENTS_ENABLED false
245
#endif
246
241
#if !PLATFORM(MAC) && !PLATFORM(MACCATALYST) && !PLATFORM(APPLETV)
247
#if !PLATFORM(MAC) && !PLATFORM(MACCATALYST) && !PLATFORM(APPLETV)
242
#define DEFAULT_INPUT_TYPE_DATE_ENABLED true
248
#define DEFAULT_INPUT_TYPE_DATE_ENABLED true
243
#define DEFAULT_INPUT_TYPE_DATETIMELOCAL_ENABLED true
249
#define DEFAULT_INPUT_TYPE_DATETIMELOCAL_ENABLED true
- a/LayoutTests/ChangeLog +17 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2020-08-07  Aditya Keerthi  <akeerthi@apple.com>
2
3
        [macOS] Date inputs should contain editable components
4
        https://bugs.webkit.org/show_bug.cgi?id=215155
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Added a test to verify styling of pseudo elements within date inputs.
9
        Rebaselined existing tests to match new appearance.
10
11
        * fast/forms/date/date-pseudo-elements-expected.txt: Added.
12
        * fast/forms/date/date-pseudo-elements.html: Added.
13
        * platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt:
14
        * platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt: Added.
15
        * platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt: Added.
16
        * platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt:
17
1
2020-08-04  Andres Gonzalez  <andresg_22@apple.com>
18
2020-08-04  Andres Gonzalez  <andresg_22@apple.com>
2
19
3
        Disable isolated-tree-mode-on-off.html because it is causing other test failures..
20
        Disable isolated-tree-mode-on-off.html because it is causing other test failures..
- a/LayoutTests/fast/forms/date/date-pseudo-elements-expected.txt +18 lines
Line 0 a/LayoutTests/fast/forms/date/date-pseudo-elements-expected.txt_sec1
1
layer at (0,0) size 800x600
2
  RenderView at (0,0) size 800x600
3
layer at (0,0) size 800x600
4
  RenderBlock {HTML} at (0,0) size 800x600
5
    RenderBody {BODY} at (8,8) size 784x584
6
      RenderText {#text} at (101,2) size 4x19
7
        text run at (101,2) width 4: " "
8
      RenderText {#text} at (0,0) size 0x0
9
layer at (10,10) size 97x22 clip at (11,11) size 95x20
10
  RenderFlexibleBox {INPUT} at (2,2) size 97x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
11
    RenderBlock {DIV} at (6,4) size 57x14
12
      RenderText {#text} at (0,0) size 57x14
13
        text run at (0,0) width 57: "Apr 1, 1976"
14
layer at (115,10) size 97x22 clip at (116,11) size 95x20
15
  RenderFlexibleBox {INPUT} at (107,2) size 97x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
16
    RenderBlock {DIV} at (16,4) size 57x14
17
      RenderText {#text} at (0,0) size 57x14
18
        text run at (0,0) width 57: "Apr 1, 1976"
- a/LayoutTests/fast/forms/date/date-pseudo-elements.html +39 lines
Line 0 a/LayoutTests/fast/forms/date/date-pseudo-elements.html_sec1
1
<html>
2
<head>
3
<style>
4
input::-webkit-datetime-edit {
5
    border: 1px solid red;
6
    font-family: monospace;
7
    font-size: 15px;
8
}
9
10
input::-webkit-datetime-edit-text {
11
    color: yellow;
12
    font-family: monospace;
13
    font-size: 15px;
14
}
15
16
input::-webkit-datetime-edit-month-field {
17
    color: red;
18
    font-family: monospace;
19
    font-size: 15px;
20
}
21
22
input::-webkit-datetime-edit-day-field {
23
    color: green;
24
    font-family: monospace;
25
    font-size: 15px;
26
}
27
28
input::-webkit-datetime-edit-year-field {
29
    color: blue;
30
    font-family: monospace;
31
    font-size: 15px;
32
}
33
</style>
34
</head>
35
<body>
36
    <input type="date" dir="ltr" value="1976-04-01">
37
    <input type="date" dir="rtl" value="1976-04-01">
38
</body>
39
</html>
- a/LayoutTests/platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt -12 / +42 lines
Lines 3-18 layer at (0,0) size 800x600 a/LayoutTests/platform/mac-wk2/fast/forms/date/date-input-rendering-basic-expected.txt_sec1
3
layer at (0,0) size 800x600
3
layer at (0,0) size 800x600
4
  RenderBlock {HTML} at (0,0) size 800x600
4
  RenderBlock {HTML} at (0,0) size 800x600
5
    RenderBody {BODY} at (8,8) size 784x584
5
    RenderBody {BODY} at (8,8) size 784x584
6
      RenderText {#text} at (110,3) size 4x18
6
      RenderText {#text} at (110,2) size 4x18
7
        text run at (110,3) width 4: " "
7
        text run at (110,2) width 4: " "
8
      RenderText {#text} at (0,0) size 0x0
8
      RenderText {#text} at (0,0) size 0x0
9
layer at (8,10) size 110x21 clip at (10,12) size 106x17
9
layer at (8,10) size 110x19 clip at (10,12) size 106x15
10
  RenderFlexibleBox {INPUT} at (0,2) size 110x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
10
  RenderFlexibleBox {INPUT} at (0,2) size 110x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
11
    RenderBlock {DIV} at (7,4) size 59x13
11
layer at (11,13) size 65x13 scrollHeight 14
12
      RenderText {#text} at (0,0) size 59x13
12
  RenderBlock {DIV} at (3,3) size 66x13
13
        text run at (0,0) width 59: "Apr 1, 1976"
13
    RenderBlock {DIV} at (0,0) size 66x13
14
layer at (122,10) size 110x21 clip at (124,12) size 106x17
14
      RenderInline {DIV} at (0,0) size 17x15
15
  RenderFlexibleBox {INPUT} at (114,2) size 110x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
15
        RenderText {#text} at (1,0) size 15x13
16
    RenderBlock {DIV} at (24,4) size 59x13
16
          text run at (1,0) width 15: "04"
17
      RenderText {#text} at (0,0) size 59x13
17
      RenderInline {DIV} at (0,0) size 4x13
18
        text run at (0,0) width 59: "Apr 1, 1976"
18
        RenderText {#text} at (16,0) size 4x13
19
          text run at (16,0) width 4: "/"
20
      RenderInline {DIV} at (0,0) size 16x15
21
        RenderText {#text} at (20,0) size 14x13
22
          text run at (20,0) width 14: "01"
23
      RenderInline {DIV} at (0,0) size 4x13
24
        RenderText {#text} at (34,0) size 4x13
25
          text run at (34,0) width 4: "/"
26
      RenderInline {DIV} at (0,0) size 29x15
27
        RenderText {#text} at (38,0) size 27x13
28
          text run at (38,0) width 27: "1976"
29
layer at (122,10) size 110x19 clip at (124,12) size 106x15
30
  RenderFlexibleBox {INPUT} at (114,2) size 110x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
31
layer at (164,13) size 65x13 scrollHeight 14
32
  RenderBlock {DIV} at (41,3) size 66x13
33
    RenderBlock {DIV} at (0,0) size 66x13
34
      RenderInline {DIV} at (0,0) size 17x15
35
        RenderText {#text} at (1,0) size 15x13
36
          text run at (1,0) width 15: "04"
37
      RenderInline {DIV} at (0,0) size 4x13
38
        RenderText {#text} at (16,0) size 4x13
39
          text run at (16,0) width 4: "/"
40
      RenderInline {DIV} at (0,0) size 16x15
41
        RenderText {#text} at (20,0) size 14x13
42
          text run at (20,0) width 14: "01"
43
      RenderInline {DIV} at (0,0) size 4x13
44
        RenderText {#text} at (34,0) size 4x13
45
          text run at (34,0) width 4: "/"
46
      RenderInline {DIV} at (0,0) size 29x15
47
        RenderText {#text} at (38,0) size 27x13
48
          text run at (38,0) width 27: "1976"
- a/LayoutTests/platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt +48 lines
Line 0 a/LayoutTests/platform/mac-wk2/fast/forms/date/date-pseudo-elements-expected.txt_sec1
1
layer at (0,0) size 800x600
2
  RenderView at (0,0) size 800x600
3
layer at (0,0) size 800x600
4
  RenderBlock {HTML} at (0,0) size 800x600
5
    RenderBody {BODY} at (8,8) size 784x584
6
      RenderText {#text} at (110,5) size 4x18
7
        text run at (110,5) width 4: " "
8
      RenderText {#text} at (0,0) size 0x0
9
layer at (8,10) size 110x25 clip at (10,12) size 106x21
10
  RenderFlexibleBox {INPUT} at (0,2) size 110x25 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
11
layer at (11,13) size 98x19 clip at (12,14) size 96x17 scrollHeight 18
12
  RenderBlock {DIV} at (3,3) size 99x19 [border: (1px solid #FF0000)]
13
    RenderBlock {DIV} at (1,1) size 97x17
14
      RenderInline {DIV} at (0,0) size 21x19 [color=#FF0000]
15
        RenderText {#text} at (1,0) size 19x17
16
          text run at (1,0) width 19: "04"
17
      RenderInline {DIV} at (0,0) size 10x17 [color=#FFFF00]
18
        RenderText {#text} at (20,0) size 10x17
19
          text run at (20,0) width 10: "/"
20
      RenderInline {DIV} at (0,0) size 21x19 [color=#008000]
21
        RenderText {#text} at (30,0) size 19x17
22
          text run at (30,0) width 19: "01"
23
      RenderInline {DIV} at (0,0) size 10x17 [color=#FFFF00]
24
        RenderText {#text} at (49,0) size 10x17
25
          text run at (49,0) width 10: "/"
26
      RenderInline {DIV} at (0,0) size 39x19 [color=#0000FF]
27
        RenderText {#text} at (59,0) size 37x17
28
          text run at (59,0) width 37: "1976"
29
layer at (122,10) size 110x25 clip at (124,12) size 106x21
30
  RenderFlexibleBox {INPUT} at (114,2) size 110x25 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
31
layer at (131,13) size 98x19 clip at (132,14) size 96x17 scrollHeight 18
32
  RenderBlock {DIV} at (8,3) size 99x19 [border: (1px solid #FF0000)]
33
    RenderBlock {DIV} at (1,1) size 97x17
34
      RenderInline {DIV} at (0,0) size 21x19 [color=#FF0000]
35
        RenderText {#text} at (1,0) size 19x17
36
          text run at (1,0) width 19: "04"
37
      RenderInline {DIV} at (0,0) size 10x17 [color=#FFFF00]
38
        RenderText {#text} at (20,0) size 10x17
39
          text run at (20,0) width 10: "/"
40
      RenderInline {DIV} at (0,0) size 21x19 [color=#008000]
41
        RenderText {#text} at (30,0) size 19x17
42
          text run at (30,0) width 19: "01"
43
      RenderInline {DIV} at (0,0) size 10x17 [color=#FFFF00]
44
        RenderText {#text} at (49,0) size 10x17
45
          text run at (49,0) width 10: "/"
46
      RenderInline {DIV} at (0,0) size 39x19 [color=#0000FF]
47
        RenderText {#text} at (59,0) size 37x17
48
          text run at (59,0) width 37: "1976"
- a/LayoutTests/platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt +17 lines
Line 0 a/LayoutTests/platform/mac-wk2/fast/forms/time/time-appearance-basic-expected.txt_sec1
1
step=none  
2
step=1  
3
step=0.0001  
4
step=60  
5
step=3600  
6
step=86400  
7
step mismatched 
8
RTL 
9
Disabled, step=3600  
10
Readonly, step=3600  
11
text-align: 
12
text-transform: 
13
background, color: 
14
font-size, font-weight: 
15
font-size with fixed input width: 
16
Fixed input height: 
17
-webkit-appearance:none: 
- a/LayoutTests/platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt -14 / +6 lines
Lines 3-20 layer at (0,0) size 800x600 a/LayoutTests/platform/mac-wk2/fast/forms/time/time-input-rendering-basic-expected.txt_sec1
3
layer at (0,0) size 800x600
3
layer at (0,0) size 800x600
4
  RenderBlock {HTML} at (0,0) size 800x600
4
  RenderBlock {HTML} at (0,0) size 800x600
5
    RenderBody {BODY} at (8,8) size 784x584
5
    RenderBody {BODY} at (8,8) size 784x584
6
      RenderText {#text} at (110,3) size 4x18
6
      RenderText {#text} at (110,0) size 4x18
7
        text run at (110,3) width 4: " "
7
        text run at (110,0) width 4: " "
8
      RenderText {#text} at (0,0) size 0x0
8
      RenderText {#text} at (0,0) size 0x0
9
layer at (8,10) size 110x21 clip at (10,12) size 106x17
9
layer at (8,19) size 110x6 clip at (10,21) size 106x2
10
  RenderFlexibleBox {INPUT} at (0,2) size 110x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
10
  RenderFlexibleBox {INPUT} at (0,11) size 110x6 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
11
    RenderBlock {DIV} at (7,4) size 43x13
11
layer at (122,19) size 110x6 clip at (124,21) size 106x2
12
      RenderText {#text} at (0,0) size 43x13
12
  RenderFlexibleBox {INPUT} at (114,11) size 110x6 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
13
        text run at (0,0) width 43: "9:41 AM"
14
layer at (122,10) size 110x21 clip at (124,12) size 106x17
15
  RenderFlexibleBox {INPUT} at (114,2) size 110x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
16
    RenderBlock {DIV} at (40,4) size 43x13
17
      RenderText {#text} at (0,0) size 43x13
18
        text run at (0,0) width 18: "AM"
19
        text run at (17,0) width 4 RTL: " "
20
        text run at (20,0) width 23: "9:41"

Return to Bug 215155