1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 */ 23 24 #ifndef HTMLTextAreaElement_h 25 #define HTMLTextAreaElement_h 26 27 #include "HTMLFormControlElement.h" 28 29 namespace WebCore { 30 31 class VisibleSelection; 32 33 class HTMLTextAreaElement : public HTMLFormControlElementWithState { 34 public: 35 HTMLTextAreaElement(const QualifiedName&, Document*, HTMLFormElement* = 0); 36 checkDTD(const Node * newChild)37 virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); } 38 cols()39 int cols() const { return m_cols; } rows()40 int rows() const { return m_rows; } 41 shouldWrapText()42 bool shouldWrapText() const { return m_wrap != NoWrap; } 43 isEnumeratable()44 virtual bool isEnumeratable() const { return true; } 45 46 virtual const AtomicString& formControlType() const; 47 48 virtual bool saveFormControlState(String& value) const; 49 virtual void restoreFormControlState(const String&); 50 readOnly()51 bool readOnly() const { return isReadOnlyFormControl(); } 52 isTextFormControl()53 virtual bool isTextFormControl() const { return true; } 54 valueMissing()55 virtual bool valueMissing() const { return isRequiredFormControl() && !disabled() && !readOnly() && value().isEmpty(); } 56 57 int selectionStart(); 58 int selectionEnd(); 59 60 void setSelectionStart(int); 61 void setSelectionEnd(int); 62 63 void select(); 64 void setSelectionRange(int, int); 65 66 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 67 virtual void parseMappedAttribute(MappedAttribute*); 68 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 69 virtual bool appendFormData(FormDataList&, bool); 70 virtual void reset(); 71 virtual void defaultEventHandler(Event*); 72 virtual bool isMouseFocusable() const; 73 virtual bool isKeyboardFocusable(KeyboardEvent*) const; 74 virtual void updateFocusAppearance(bool restorePreviousSelection); 75 76 String value() const; 77 void setValue(const String&); 78 String defaultValue() const; 79 void setDefaultValue(const String&); 80 81 void rendererWillBeDestroyed(); 82 83 virtual void accessKeyAction(bool sendToAnyElement); 84 85 const AtomicString& accessKey() const; 86 void setAccessKey(const String&); 87 88 void setCols(int); 89 void setRows(int); 90 cacheSelection(int s,int e)91 void cacheSelection(int s, int e) { m_cachedSelectionStart = s; m_cachedSelectionEnd = e; }; 92 VisibleSelection selection() const; 93 94 virtual bool shouldUseInputMethod() const; 95 96 private: 97 enum WrapMethod { NoWrap, SoftWrap, HardWrap }; 98 99 void updateValue() const; 100 isOptionalFormControl()101 virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); } isRequiredFormControl()102 virtual bool isRequiredFormControl() const { return required(); } 103 104 int m_rows; 105 int m_cols; 106 WrapMethod m_wrap; 107 mutable String m_value; 108 int m_cachedSelectionStart; 109 int m_cachedSelectionEnd; 110 }; 111 112 } //namespace 113 114 #endif 115