2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef InputTypeView_h
34 #define InputTypeView_h
36 #include "core/page/FocusType.h"
37 #include "platform/heap/Handle.h"
38 #include "wtf/FastAllocBase.h"
39 #include "wtf/Forward.h"
40 #include "wtf/Noncopyable.h"
41 #include "wtf/RefCounted.h"
42 #include "wtf/RefPtr.h"
47 class BeforeTextInsertedEvent;
50 class HTMLFormElement;
51 class HTMLInputElement;
58 struct ClickHandlingState final : public NoBaseWillBeGarbageCollected<ClickHandlingState> {
59 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
66 RefPtrWillBeMember<HTMLInputElement> checkedRadioButton;
69 // An InputTypeView object represents the UI-specific part of an
70 // HTMLInputElement. Do not expose instances of InputTypeView and classes
71 // derived from it to classes other than HTMLInputElement.
72 class InputTypeView : public RefCountedWillBeGarbageCollectedFinalized<InputTypeView> {
73 WTF_MAKE_NONCOPYABLE(InputTypeView);
74 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
77 static PassRefPtrWillBeRawPtr<InputTypeView> create(HTMLInputElement&);
78 virtual ~InputTypeView();
79 virtual void trace(Visitor*);
81 virtual bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const;
82 virtual void handleClickEvent(MouseEvent*);
83 virtual void handleMouseDownEvent(MouseEvent*);
84 virtual PassOwnPtrWillBeRawPtr<ClickHandlingState> willDispatchClick();
85 virtual void didDispatchClick(Event*, const ClickHandlingState&);
86 virtual void handleKeydownEvent(KeyboardEvent*);
87 virtual void handleKeypressEvent(KeyboardEvent*);
88 virtual void handleKeyupEvent(KeyboardEvent*);
89 virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*);
90 virtual void handleTouchEvent(TouchEvent*);
91 virtual void forwardEvent(Event*);
92 virtual bool shouldSubmitImplicitly(Event*);
93 virtual PassRefPtrWillBeRawPtr<HTMLFormElement> formForSubmission() const;
94 virtual bool hasCustomFocusLogic() const;
95 virtual void handleFocusEvent(Element* oldFocusedElement, FocusType);
96 virtual void handleFocusInEvent(Element* oldFocusedElement, FocusType);
97 virtual void handleBlurEvent();
98 virtual void subtreeHasChanged();
99 virtual bool hasTouchEventHandler() const;
101 virtual RenderObject* createRenderer(RenderStyle*) const;
102 virtual PassRefPtr<RenderStyle> customStyleForRenderer(PassRefPtr<RenderStyle>);
103 virtual void startResourceLoading();
104 virtual void closePopupView();
105 virtual void createShadowSubtree();
106 virtual void destroyShadowSubtree();
107 virtual void minOrMaxAttributeChanged();
108 virtual void stepAttributeChanged();
109 virtual void altAttributeChanged();
110 virtual void srcAttributeChanged();
111 virtual void updateView();
112 virtual void attributeChanged();
113 virtual void multipleAttributeChanged();
114 virtual void disabledAttributeChanged();
115 virtual void readonlyAttributeChanged();
116 virtual void requiredAttributeChanged();
117 virtual void valueAttributeChanged();
118 virtual void listAttributeTargetChanged();
119 virtual void updateClearButtonVisibility();
120 virtual void updatePlaceholderText();
121 virtual AXObject* popupRootAXObject();
124 InputTypeView(HTMLInputElement& element) : m_element(&element) { }
125 HTMLInputElement& element() const { return *m_element; }
128 // Not a RefPtr because the HTMLInputElement object owns this InputTypeView
130 RawPtrWillBeMember<HTMLInputElement> m_element;