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, 2010 Apple Inc. All rights reserved.
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.
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.
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.
24 #ifndef HTMLTextAreaElement_h
25 #define HTMLTextAreaElement_h
27 #include "HTMLTextFormControlElement.h"
31 class BeforeTextInsertedEvent;
32 class VisibleSelection;
34 class HTMLTextAreaElement : public HTMLTextFormControlElement {
36 static PassRefPtr<HTMLTextAreaElement> create(const QualifiedName&, Document*, HTMLFormElement*);
38 int cols() const { return m_cols; }
39 int rows() const { return m_rows; }
41 bool shouldWrapText() const { return m_wrap != NoWrap; }
43 virtual String value() const;
44 void setValue(const String&);
45 String defaultValue() const;
46 void setDefaultValue(const String&);
47 int textLength() const { return value().length(); }
48 virtual int maxLength() const;
49 void setMaxLength(int, ExceptionCode&);
50 bool valueMissing(const String& value) const { return isRequiredFormControl() && !disabled() && !readOnly() && value.isEmpty(); }
51 bool tooLong(const String&, NeedsToCheckDirtyFlag) const;
52 bool isValidValue(const String&) const;
54 virtual HTMLElement* innerTextElement() const;
56 void rendererWillBeDestroyed();
62 HTMLTextAreaElement(const QualifiedName&, Document*, HTMLFormElement*);
64 enum WrapMethod { NoWrap, SoftWrap, HardWrap };
66 void createShadowSubtree();
68 void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*) const;
69 static String sanitizeUserInputValue(const String&, unsigned maxLength);
70 void updateValue() const;
71 void setNonDirtyValue(const String&);
72 void setValueCommon(const String&);
74 virtual bool supportsPlaceholder() const { return true; }
75 virtual HTMLElement* placeholderElement() const;
76 virtual void updatePlaceholderText();
77 virtual bool isEmptyValue() const { return value().isEmpty(); }
79 virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); }
80 virtual bool isRequiredFormControl() const { return required(); }
82 virtual void defaultEventHandler(Event*);
84 virtual void subtreeHasChanged();
86 virtual bool isEnumeratable() const { return true; }
88 virtual const AtomicString& formControlType() const;
90 virtual bool saveFormControlState(String& value) const;
91 virtual void restoreFormControlState(const String&);
93 virtual bool isTextFormControl() const { return true; }
95 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
96 virtual void parseMappedAttribute(Attribute*);
97 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
98 virtual bool appendFormData(FormDataList&, bool);
100 virtual bool isMouseFocusable() const;
101 virtual bool isKeyboardFocusable(KeyboardEvent*) const;
102 virtual void updateFocusAppearance(bool restorePreviousSelection);
104 virtual void accessKeyAction(bool sendToAnyElement);
106 virtual bool shouldUseInputMethod();
111 RefPtr<HTMLElement> m_placeholder;
112 mutable String m_value;
113 mutable bool m_isDirty;
114 mutable bool m_wasModifiedByUser;