1 /* 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 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 13 * distribution. 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. 17 * 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. 29 */ 30 31 #ifndef BaseMultipleFieldsDateAndTimeInputType_h 32 #define BaseMultipleFieldsDateAndTimeInputType_h 33 34 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 35 #include "core/html/forms/BaseDateAndTimeInputType.h" 36 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" 41 42 namespace WebCore { 43 44 struct DateTimeChooserParameters; 45 46 class BaseMultipleFieldsDateAndTimeInputType 47 : public BaseDateAndTimeInputType 48 , protected DateTimeEditElement::EditControlOwner 49 , protected PickerIndicatorElement::PickerIndicatorOwner 50 , protected SpinButtonElement::SpinButtonOwner 51 , protected ClearButtonElement::ClearButtonOwner { 52 public: 53 virtual bool isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const = 0; 54 55 protected: 56 BaseMultipleFieldsDateAndTimeInputType(HTMLInputElement&); 57 virtual ~BaseMultipleFieldsDateAndTimeInputType(); 58 59 virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const = 0; 60 bool shouldHaveSecondField(const DateComponents&) const; 61 62 private: 63 // DateTimeEditElement::EditControlOwner functions 64 virtual void didBlurFromControl() OVERRIDE FINAL; 65 virtual void didFocusOnControl() OVERRIDE FINAL; 66 virtual void editControlValueChanged() OVERRIDE FINAL; 67 virtual bool isEditControlOwnerDisabled() const OVERRIDE FINAL; 68 virtual bool isEditControlOwnerReadOnly() const OVERRIDE FINAL; 69 virtual AtomicString localeIdentifier() const OVERRIDE FINAL; 70 71 // SpinButtonElement::SpinButtonOwner functions. 72 virtual void focusAndSelectSpinButtonOwner() OVERRIDE; 73 virtual bool shouldSpinButtonRespondToMouseEvents() OVERRIDE; 74 virtual bool shouldSpinButtonRespondToWheelEvents() OVERRIDE; 75 virtual void spinButtonStepDown() OVERRIDE; 76 virtual void spinButtonStepUp() OVERRIDE; 77 78 // PickerIndicatorElement::PickerIndicatorOwner functions 79 virtual bool isPickerIndicatorOwnerDisabledOrReadOnly() const OVERRIDE FINAL; 80 virtual void pickerIndicatorChooseValue(const String&) OVERRIDE FINAL; 81 virtual void pickerIndicatorChooseValue(double) OVERRIDE FINAL; 82 virtual bool setupDateTimeChooserParameters(DateTimeChooserParameters&) OVERRIDE FINAL; 83 84 // ClearButtonElement::ClearButtonOwner functions. 85 virtual void focusAndSelectClearButtonOwner() OVERRIDE; 86 virtual bool shouldClearButtonRespondToMouseEvents() OVERRIDE; 87 virtual void clearValue() OVERRIDE; 88 89 // InputType functions 90 virtual String badInputText() const OVERRIDE; 91 virtual void blur() OVERRIDE FINAL; 92 virtual PassRefPtr<RenderStyle> customStyleForRenderer(PassRefPtr<RenderStyle>) OVERRIDE; 93 virtual void createShadowSubtree() OVERRIDE FINAL; 94 virtual void destroyShadowSubtree() OVERRIDE FINAL; 95 virtual void disabledAttributeChanged() OVERRIDE FINAL; 96 virtual void forwardEvent(Event*) OVERRIDE FINAL; 97 virtual void handleFocusEvent(Element* oldFocusedElement, FocusDirection) OVERRIDE; 98 virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE FINAL; 99 virtual bool hasBadInput() const OVERRIDE; 100 virtual bool hasCustomFocusLogic() const OVERRIDE FINAL; 101 virtual void minOrMaxAttributeChanged() OVERRIDE FINAL; 102 virtual void readonlyAttributeChanged() OVERRIDE FINAL; 103 virtual void requiredAttributeChanged() OVERRIDE FINAL; 104 virtual void restoreFormControlState(const FormControlState&) OVERRIDE FINAL; 105 virtual FormControlState saveFormControlState() const OVERRIDE FINAL; 106 virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE FINAL; 107 virtual bool shouldUseInputMethod() const OVERRIDE FINAL; 108 virtual void stepAttributeChanged() OVERRIDE FINAL; 109 virtual void updateView() OVERRIDE FINAL; 110 virtual void valueAttributeChanged() OVERRIDE; 111 virtual void listAttributeTargetChanged() OVERRIDE FINAL; 112 virtual void updateClearButtonVisibility() OVERRIDE FINAL; 113 114 DateTimeEditElement* dateTimeEditElement() const; 115 SpinButtonElement* spinButtonElement() const; 116 ClearButtonElement* clearButtonElement() const; 117 PickerIndicatorElement* pickerIndicatorElement() const; 118 bool containsFocusedShadowElement() const; 119 void showPickerIndicator(); 120 void hidePickerIndicator(); 121 void updatePickerIndicatorVisibility(); 122 123 bool m_isDestroyingShadowSubtree; 124 bool m_pickerIndicatorIsVisible; 125 bool m_pickerIndicatorIsAlwaysVisible; 126 }; 127 128 } // namespace WebCore 129 130 #endif 131 #endif // BaseMultipleFieldsDateAndTimeInputType_h 132