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;
58 BaseMultipleFieldsDateAndTimeInputType(HTMLInputElement&);
59 virtual ~BaseMultipleFieldsDateAndTimeInputType();
61 virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const = 0;
62 bool shouldHaveSecondField(const DateComponents&) const;
65 // DateTimeEditElement::EditControlOwner functions
66 virtual void didBlurFromControl() OVERRIDE FINAL;
67 virtual void didFocusOnControl() OVERRIDE FINAL;
68 virtual void editControlValueChanged() OVERRIDE FINAL;
69 virtual bool isEditControlOwnerDisabled() const OVERRIDE FINAL;
70 virtual bool isEditControlOwnerReadOnly() const OVERRIDE FINAL;
71 virtual AtomicString localeIdentifier() const OVERRIDE FINAL;
72 virtual void editControlDidChangeValueByKeyboard() OVERRIDE FINAL;
74 // SpinButtonElement::SpinButtonOwner functions.
75 virtual void focusAndSelectSpinButtonOwner() OVERRIDE;
76 virtual bool shouldSpinButtonRespondToMouseEvents() OVERRIDE;
77 virtual bool shouldSpinButtonRespondToWheelEvents() OVERRIDE;
78 virtual void spinButtonStepDown() OVERRIDE;
79 virtual void spinButtonStepUp() OVERRIDE;
80 virtual void spinButtonDidReleaseMouseCapture(SpinButtonElement::EventDispatch) OVERRIDE;
82 // PickerIndicatorElement::PickerIndicatorOwner functions
83 virtual bool isPickerIndicatorOwnerDisabledOrReadOnly() const OVERRIDE FINAL;
84 virtual void pickerIndicatorChooseValue(const String&) OVERRIDE FINAL;
85 virtual void pickerIndicatorChooseValue(double) OVERRIDE FINAL;
86 virtual bool setupDateTimeChooserParameters(DateTimeChooserParameters&) OVERRIDE FINAL;
88 // ClearButtonElement::ClearButtonOwner functions.
89 virtual void focusAndSelectClearButtonOwner() OVERRIDE;
90 virtual bool shouldClearButtonRespondToMouseEvents() OVERRIDE;
91 virtual void clearValue() OVERRIDE;
93 // InputType functions
94 virtual String badInputText() const OVERRIDE;
95 virtual void blur() OVERRIDE FINAL;
96 virtual PassRefPtr<RenderStyle> customStyleForRenderer(PassRefPtr<RenderStyle>) OVERRIDE;
97 virtual void createShadowSubtree() OVERRIDE FINAL;
98 virtual void destroyShadowSubtree() OVERRIDE FINAL;
99 virtual void disabledAttributeChanged() OVERRIDE FINAL;
100 virtual void forwardEvent(Event*) OVERRIDE FINAL;
101 virtual void handleFocusEvent(Element* oldFocusedElement, FocusType) OVERRIDE;
102 virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE FINAL;
103 virtual bool hasBadInput() const OVERRIDE;
104 virtual bool hasCustomFocusLogic() const OVERRIDE FINAL;
105 virtual void minOrMaxAttributeChanged() OVERRIDE FINAL;
106 virtual void readonlyAttributeChanged() OVERRIDE FINAL;
107 virtual void requiredAttributeChanged() OVERRIDE FINAL;
108 virtual void restoreFormControlState(const FormControlState&) OVERRIDE FINAL;
109 virtual FormControlState saveFormControlState() const OVERRIDE FINAL;
110 virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE FINAL;
111 virtual bool shouldUseInputMethod() const OVERRIDE FINAL;
112 virtual void stepAttributeChanged() OVERRIDE FINAL;
113 virtual void updateView() OVERRIDE FINAL;
114 virtual void valueAttributeChanged() OVERRIDE;
115 virtual void listAttributeTargetChanged() OVERRIDE FINAL;
116 virtual void updateClearButtonVisibility() OVERRIDE FINAL;
118 DateTimeEditElement* dateTimeEditElement() const;
119 SpinButtonElement* spinButtonElement() const;
120 ClearButtonElement* clearButtonElement() const;
121 PickerIndicatorElement* pickerIndicatorElement() const;
122 bool containsFocusedShadowElement() const;
123 void showPickerIndicator();
124 void hidePickerIndicator();
125 void updatePickerIndicatorVisibility();
127 bool m_isDestroyingShadowSubtree;
128 bool m_pickerIndicatorIsVisible;
129 bool m_pickerIndicatorIsAlwaysVisible;
132 } // namespace WebCore
135 #endif // BaseMultipleFieldsDateAndTimeInputType_h