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 WMLInputElement(const QualifiedName& tagName, Document*); 35 virtual ~WMLInputElement(); 36 37 virtual bool isKeyboardFocusable(KeyboardEvent*) const; 38 virtual bool isMouseFocusable() const; 39 virtual void dispatchFocusEvent(); 40 virtual void dispatchBlurEvent(); 41 virtual void updateFocusAppearance(bool restorePreviousSelection); 42 virtual void aboutToUnload(); 43 shouldUseInputMethod()44 virtual bool shouldUseInputMethod() const { return !m_isPasswordField; } isChecked()45 virtual bool isChecked() const { return false; } isAutofilled()46 virtual bool isAutofilled() const { return false; } isIndeterminate()47 virtual bool isIndeterminate() const { return false; } isTextFormControl()48 virtual bool isTextFormControl() const { return true; } isRadioButton()49 virtual bool isRadioButton() const { return false; } isTextField()50 virtual bool isTextField() const { return true; } isSearchField()51 virtual bool isSearchField() const { return false; } isInputTypeHidden()52 virtual bool isInputTypeHidden() const { return false; } isPasswordField()53 virtual bool isPasswordField() const { return m_isPasswordField; } searchEventsShouldBeDispatched()54 virtual bool searchEventsShouldBeDispatched() const { return false; } 55 56 virtual int size() const; 57 virtual const AtomicString& formControlType() const; 58 virtual const AtomicString& formControlName() const; 59 virtual String value() const; 60 virtual void setValue(const String&); placeholder()61 virtual String placeholder() const { return String(); } setPlaceholder(const String &)62 virtual void setPlaceholder(const String&) { } 63 virtual void setValueFromRenderer(const String&); 64 65 virtual bool saveFormControlState(String& value) const; 66 virtual void restoreFormControlState(const String&); 67 68 virtual void select(); 69 virtual void accessKeyAction(bool sendToAnyElement); 70 virtual void parseMappedAttribute(MappedAttribute*); 71 72 virtual void copyNonAttributeProperties(const Element* source); 73 74 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 75 virtual void detach(); 76 virtual bool appendFormData(FormDataList&, bool); 77 virtual void reset(); 78 79 virtual void defaultEventHandler(Event*); 80 virtual void cacheSelection(int start, int end); 81 82 virtual String constrainValue(const String& proposedValue) const; 83 84 virtual void documentDidBecomeActive(); 85 virtual bool placeholderShouldBeVisible() const; 86 87 virtual void willMoveToNewOwnerDocument(); 88 virtual void didMoveToNewOwnerDocument(); 89 90 bool isConformedToInputMask(const String&); 91 bool isConformedToInputMask(UChar, unsigned, bool isUserInput = true); 92 93 private: 94 friend class WMLCardElement; 95 void initialize(); 96 97 String validateInputMask(const String&); 98 unsigned cursorPositionToMaskIndex(unsigned); 99 100 InputElementData m_data; 101 bool m_isPasswordField; 102 bool m_isEmptyOk; 103 String m_formatMask; 104 unsigned m_numOfCharsAllowedByMask; 105 }; 106 107 } 108 109 #endif 110 #endif 111