2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef BaseMultipleFieldsDateAndTimeInputType_h
32 #define BaseMultipleFieldsDateAndTimeInputType_h
34 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
35 #include "core/html/forms/BaseDateAndTimeInputType.h"
37 #include "core/html/shadow/ClearButtonElement.h"
38 #include "core/html/shadow/DateTimeEditElement.h"
39 #include "core/html/shadow/PickerIndicatorElement.h"
40 #include "core/html/shadow/SpinButtonElement.h"
44 struct DateTimeChooserParameters;
46 class BaseMultipleFieldsDateAndTimeInputType
47 : public BaseDateAndTimeInputType
48 , protected DateTimeEditElement::EditControlOwner
49 , protected PickerIndicatorElement::PickerIndicatorOwner
50 , protected SpinButtonElement::SpinButtonOwner
51 , protected ClearButtonElement::ClearButtonOwner {
52 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BaseMultipleFieldsDateAndTimeInputType);
55 virtual bool isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const = 0;
57 virtual void trace(Visitor* visitor) override { BaseDateAndTimeInputType::trace(visitor); }
60 BaseMultipleFieldsDateAndTimeInputType(HTMLInputElement&);
61 virtual ~BaseMultipleFieldsDateAndTimeInputType();
63 virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const = 0;
64 bool shouldHaveSecondField(const DateComponents&) const;
67 // DateTimeEditElement::EditControlOwner functions
68 virtual void didBlurFromControl() override final;
69 virtual void didFocusOnControl() override final;
70 virtual void editControlValueChanged() override final;
71 virtual bool isEditControlOwnerDisabled() const override final;
72 virtual bool isEditControlOwnerReadOnly() const override final;
73 virtual AtomicString localeIdentifier() const override final;
74 virtual void editControlDidChangeValueByKeyboard() override final;
76 // SpinButtonElement::SpinButtonOwner functions.
77 virtual void focusAndSelectSpinButtonOwner() override;
78 virtual bool shouldSpinButtonRespondToMouseEvents() override;
79 virtual bool shouldSpinButtonRespondToWheelEvents() override;
80 virtual void spinButtonStepDown() override;
81 virtual void spinButtonStepUp() override;
82 virtual void spinButtonDidReleaseMouseCapture(SpinButtonElement::EventDispatch) override;
84 // PickerIndicatorElement::PickerIndicatorOwner functions
85 virtual bool isPickerIndicatorOwnerDisabledOrReadOnly() const override final;
86 virtual void pickerIndicatorChooseValue(const String&) override final;
87 virtual void pickerIndicatorChooseValue(double) override final;
88 virtual Element& pickerOwnerElement() const override final;
89 virtual bool setupDateTimeChooserParameters(DateTimeChooserParameters&) override final;
91 // ClearButtonElement::ClearButtonOwner functions.
92 virtual void focusAndSelectClearButtonOwner() override;
93 virtual bool shouldClearButtonRespondToMouseEvents() override;
94 virtual void clearValue() override;
96 // InputType functions
97 virtual String badInputText() const override;
98 virtual void blur() override final;
99 virtual PassRefPtr<RenderStyle> customStyleForRenderer(PassRefPtr<RenderStyle>) override;
100 virtual void createShadowSubtree() override final;
101 virtual void destroyShadowSubtree() override final;
102 virtual void disabledAttributeChanged() override final;
103 virtual void forwardEvent(Event*) override final;
104 virtual void handleFocusInEvent(Element* oldFocusedElement, FocusType) override final;
105 virtual void handleKeydownEvent(KeyboardEvent*) override final;
106 virtual bool hasBadInput() const override;
107 virtual bool hasCustomFocusLogic() const override final;
108 virtual void minOrMaxAttributeChanged() override final;
109 virtual void readonlyAttributeChanged() override final;
110 virtual void requiredAttributeChanged() override final;
111 virtual void restoreFormControlState(const FormControlState&) override final;
112 virtual FormControlState saveFormControlState() const override final;
113 virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override final;
114 virtual void stepAttributeChanged() override final;
115 virtual void updateView() override final;
116 virtual void valueAttributeChanged() override;
117 virtual void listAttributeTargetChanged() override final;
118 virtual void updateClearButtonVisibility() override final;
119 virtual TextDirection computedTextDirection() override final;
120 virtual AXObject* popupRootAXObject() override final;
122 DateTimeEditElement* dateTimeEditElement() const;
123 SpinButtonElement* spinButtonElement() const;
124 ClearButtonElement* clearButtonElement() const;
125 PickerIndicatorElement* pickerIndicatorElement() const;
126 bool containsFocusedShadowElement() const;
127 void showPickerIndicator();
128 void hidePickerIndicator();
129 void updatePickerIndicatorVisibility();
131 bool m_isDestroyingShadowSubtree;
132 bool m_pickerIndicatorIsVisible;
133 bool m_pickerIndicatorIsAlwaysVisible;
139 #endif // BaseMultipleFieldsDateAndTimeInputType_h