| 1 | /* |
| 2 | * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 | * Copyright (C) 2018 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'' AND |
| 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 17 | * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE |
| 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 21 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 24 | * SUCH DAMAGE. |
| 25 | */ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #if ENABLE(DATE_AND_TIME_INPUT_TYPES) |
| 30 | |
| 31 | #include "BaseClickableWithKeyInputType.h" |
| 32 | #include "BaseDateAndTimeInputType.h" |
| 33 | #include "DateTimeChooser.h" |
| 34 | #include "DateTimeChooserClient.h" |
| 35 | |
| 36 | namespace WebCore { |
| 37 | |
| 38 | class BaseChooserOnlyDateAndTimeInputType : public BaseDateAndTimeInputType, private DateTimeChooserClient { |
| 39 | protected: |
| 40 | explicit BaseChooserOnlyDateAndTimeInputType(HTMLInputElement& element) : BaseDateAndTimeInputType(element) { } |
| 41 | ~BaseChooserOnlyDateAndTimeInputType(); |
| 42 | |
| 43 | private: |
| 44 | void updateInnerTextValue() override; |
| 45 | void closeDateTimeChooser(); |
| 46 | |
| 47 | // InputType functions: |
| 48 | void createShadowSubtree() override; |
| 49 | void detach() override; |
| 50 | void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override; |
| 51 | void handleDOMActivateEvent(Event&) override; |
| 52 | ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) override; |
| 53 | void handleKeypressEvent(KeyboardEvent&) override; |
| 54 | void handleKeyupEvent(KeyboardEvent&) override; |
| 55 | void accessKeyAction(bool sendMouseEvents) override; |
| 56 | bool isMouseFocusable() const override; |
| 57 | void attributeChanged(const QualifiedName&) override; |
| 58 | |
| 59 | // DateTimeChooserClient functions: |
| 60 | void didChooseValue(const String&) final; |
| 61 | void didEndChooser() final; |
| 62 | |
| 63 | RefPtr<DateTimeChooser> m_dateTimeChooser; |
| 64 | }; |
| 65 | |
| 66 | } // namespace WebCore |
| 67 | |
| 68 | #endif |
| 69 | |