• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef WMLInputElement_h
22 #define WMLInputElement_h
23 
24 #if ENABLE(WML)
25 #include "WMLFormControlElement.h"
26 #include "InputElement.h"
27 
28 namespace WebCore {
29 
30 class FormDataList;
31 
32 class WMLInputElement : public WMLFormControlElement, public InputElement {
33 public:
34     static PassRefPtr<WMLInputElement> create(const QualifiedName&, Document*);
35 
36     WMLInputElement(const QualifiedName& tagName, Document*);
37     virtual ~WMLInputElement();
38 
toInputElement()39     virtual InputElement* toInputElement() { return this; }
40 
41     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
42     virtual bool isMouseFocusable() const;
43     virtual void dispatchFocusEvent();
44     virtual void dispatchBlurEvent();
45     virtual void updateFocusAppearance(bool restorePreviousSelection);
46     virtual void aboutToUnload();
47 
shouldUseInputMethod()48     virtual bool shouldUseInputMethod() const { return !m_isPasswordField; }
isChecked()49     virtual bool isChecked() const { return false; }
isAutofilled()50     virtual bool isAutofilled() const { return false; }
isIndeterminate()51     virtual bool isIndeterminate() const { return false; }
isTextFormControl()52     virtual bool isTextFormControl() const { return true; }
isRadioButton()53     virtual bool isRadioButton() const { return false; }
isCheckbox()54     virtual bool isCheckbox() const { return false; }
isTextField()55     virtual bool isTextField() const { return true; }
isSearchField()56     virtual bool isSearchField() const { return false; }
isInputTypeHidden()57     virtual bool isInputTypeHidden() const { return false; }
isPasswordField()58     virtual bool isPasswordField() const { return m_isPasswordField; }
searchEventsShouldBeDispatched()59     virtual bool searchEventsShouldBeDispatched() const { return false; }
60 
61     virtual int size() const;
62     virtual const AtomicString& formControlType() const;
63     virtual const AtomicString& formControlName() const;
64     virtual const String& suggestedValue() const;
65     virtual String value() const;
66     virtual void setValue(const String&, bool sendChangeEvent = false);
67     virtual void setValueForUser(const String&);
visibleValue()68     virtual String visibleValue() const { return value(); }
convertFromVisibleValue(const String & value)69     virtual String convertFromVisibleValue(const String& value) const { return value; }
70     virtual void setValueFromRenderer(const String&);
71 
72     virtual bool wasChangedSinceLastFormControlChangeEvent() const;
73     virtual void setChangedSinceLastFormControlChangeEvent(bool);
74 
75     virtual bool saveFormControlState(String& value) const;
76     virtual void restoreFormControlState(const String&);
77 
78     virtual void select();
79     virtual void accessKeyAction(bool sendToAnyElement);
80     virtual void parseMappedAttribute(Attribute*);
81 
82     virtual void copyNonAttributeProperties(const Element* source);
83 
84     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
85     virtual void detach();
86     virtual bool appendFormData(FormDataList&, bool);
87     virtual void reset();
88 
89     virtual void defaultEventHandler(Event*);
90     virtual void cacheSelection(int start, int end);
91 
isAcceptableValue(const String &)92     virtual bool isAcceptableValue(const String&) const { return true; }
sanitizeValue(const String & proposedValue)93     virtual String sanitizeValue(const String& proposedValue) const { return constrainValue(proposedValue); }
94 
95     virtual void documentDidBecomeActive();
96 
97     virtual void willMoveToNewOwnerDocument();
98     virtual void didMoveToNewOwnerDocument();
99 
100     bool isConformedToInputMask(const String&);
101     bool isConformedToInputMask(UChar, unsigned, bool isUserInput = true);
102 #if ENABLE(WCSS)
data()103     virtual InputElementData data() const { return m_data; }
104 #endif
105 
106 private:
107     friend class WMLCardElement;
108     void initialize();
109 
supportsMaxLength()110     virtual bool supportsMaxLength() const { return true; }
111     String validateInputMask(const String&);
112     unsigned cursorPositionToMaskIndex(unsigned);
113     String constrainValue(const String&) const;
114 
115     InputElementData m_data;
116     bool m_isPasswordField;
117     bool m_isEmptyOk;
118     bool m_wasChangedSinceLastChangeEvent;
119     String m_formatMask;
120     unsigned m_numOfCharsAllowedByMask;
121 };
122 
123 }
124 
125 #endif
126 #endif
127