Home | History | Annotate | Download | only in forms
      1 /*
      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.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions are
      8  * met:
      9  *
     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
     15  * distribution.
     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.
     19  *
     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.
     31  */
     32 
     33 #ifndef InputTypeView_h
     34 #define InputTypeView_h
     35 
     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"
     43 
     44 namespace WebCore {
     45 
     46 class BeforeTextInsertedEvent;
     47 class Element;
     48 class Event;
     49 class HTMLFormElement;
     50 class HTMLInputElement;
     51 class KeyboardEvent;
     52 class MouseEvent;
     53 class RenderObject;
     54 class RenderStyle;
     55 class TouchEvent;
     56 
     57 struct ClickHandlingState FINAL : public NoBaseWillBeGarbageCollected<ClickHandlingState> {
     58     WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
     59 
     60 public:
     61     void trace(Visitor*);
     62 
     63     bool checked;
     64     bool indeterminate;
     65     RefPtrWillBeMember<HTMLInputElement> checkedRadioButton;
     66 };
     67 
     68 // An InputTypeView object represents the UI-specific part of an
     69 // HTMLInputElement. Do not expose instances of InputTypeView and classes
     70 // derived from it to classes other than HTMLInputElement.
     71 class InputTypeView : public RefCountedWillBeGarbageCollectedFinalized<InputTypeView> {
     72     WTF_MAKE_NONCOPYABLE(InputTypeView);
     73     WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
     74 
     75 public:
     76     static PassRefPtrWillBeRawPtr<InputTypeView> create(HTMLInputElement&);
     77     virtual ~InputTypeView();
     78     virtual void trace(Visitor*);
     79 
     80     virtual bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const;
     81     virtual void handleClickEvent(MouseEvent*);
     82     virtual void handleMouseDownEvent(MouseEvent*);
     83     virtual PassOwnPtrWillBeRawPtr<ClickHandlingState> willDispatchClick();
     84     virtual void didDispatchClick(Event*, const ClickHandlingState&);
     85     virtual void handleKeydownEvent(KeyboardEvent*);
     86     virtual void handleKeypressEvent(KeyboardEvent*);
     87     virtual void handleKeyupEvent(KeyboardEvent*);
     88     virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*);
     89     virtual void handleTouchEvent(TouchEvent*);
     90     virtual void forwardEvent(Event*);
     91     virtual bool shouldSubmitImplicitly(Event*);
     92     virtual PassRefPtrWillBeRawPtr<HTMLFormElement> formForSubmission() const;
     93     virtual bool hasCustomFocusLogic() const;
     94     virtual void handleFocusEvent(Element* oldFocusedElement, FocusType);
     95     virtual void handleBlurEvent();
     96     virtual void subtreeHasChanged();
     97     virtual bool hasTouchEventHandler() const;
     98     virtual void blur();
     99     virtual RenderObject* createRenderer(RenderStyle*) const;
    100     virtual PassRefPtr<RenderStyle> customStyleForRenderer(PassRefPtr<RenderStyle>);
    101     virtual void startResourceLoading();
    102     virtual void closePopupView();
    103     virtual void createShadowSubtree();
    104     virtual void destroyShadowSubtree();
    105     virtual void minOrMaxAttributeChanged();
    106     virtual void stepAttributeChanged();
    107     virtual void altAttributeChanged();
    108     virtual void srcAttributeChanged();
    109     virtual void updateView();
    110     virtual void attributeChanged();
    111     virtual void multipleAttributeChanged();
    112     virtual void disabledAttributeChanged();
    113     virtual void readonlyAttributeChanged();
    114     virtual void requiredAttributeChanged();
    115     virtual void valueAttributeChanged();
    116     virtual void listAttributeTargetChanged();
    117     virtual void updateClearButtonVisibility();
    118     virtual void updatePlaceholderText();
    119 
    120 protected:
    121     InputTypeView(HTMLInputElement& element) : m_element(&element) { }
    122     HTMLInputElement& element() const { return *m_element; }
    123 
    124 private:
    125     // Not a RefPtr because the HTMLInputElement object owns this InputTypeView
    126     // object.
    127     RawPtrWillBeMember<HTMLInputElement> m_element;
    128 };
    129 
    130 } // namespace WebCore
    131 #endif
    132