initial import
[vuplus_webkit] / Source / WebCore / html / HTMLTextAreaElement.h
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, 2010 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 "HTMLTextFormControlElement.h"
28
29 namespace WebCore {
30
31 class BeforeTextInsertedEvent;
32 class VisibleSelection;
33
34 class HTMLTextAreaElement : public HTMLTextFormControlElement {
35 public:
36     static PassRefPtr<HTMLTextAreaElement> create(const QualifiedName&, Document*, HTMLFormElement*);
37
38     int cols() const { return m_cols; }
39     int rows() const { return m_rows; }
40
41     bool shouldWrapText() const { return m_wrap != NoWrap; }
42
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;
53     
54     virtual HTMLElement* innerTextElement() const;
55
56     void rendererWillBeDestroyed();
57
58     void setCols(int);
59     void setRows(int);
60
61 private:
62     HTMLTextAreaElement(const QualifiedName&, Document*, HTMLFormElement*);
63
64     enum WrapMethod { NoWrap, SoftWrap, HardWrap };
65
66     void createShadowSubtree();
67
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&);
73
74     virtual bool supportsPlaceholder() const { return true; }
75     virtual HTMLElement* placeholderElement() const;
76     virtual void updatePlaceholderText();
77     virtual bool isEmptyValue() const { return value().isEmpty(); }
78
79     virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); }
80     virtual bool isRequiredFormControl() const { return required(); }
81
82     virtual void defaultEventHandler(Event*);
83     
84     virtual void subtreeHasChanged();
85
86     virtual bool isEnumeratable() const { return true; }
87
88     virtual const AtomicString& formControlType() const;
89
90     virtual bool saveFormControlState(String& value) const;
91     virtual void restoreFormControlState(const String&);
92
93     virtual bool isTextFormControl() const { return true; }
94
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);
99     virtual void reset();
100     virtual bool isMouseFocusable() const;
101     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
102     virtual void updateFocusAppearance(bool restorePreviousSelection);
103
104     virtual void accessKeyAction(bool sendToAnyElement);
105
106     virtual bool shouldUseInputMethod();
107
108     int m_rows;
109     int m_cols;
110     WrapMethod m_wrap;
111     RefPtr<HTMLElement> m_placeholder;
112     mutable String m_value;
113     mutable bool m_isDirty;
114     mutable bool m_wasModifiedByUser;
115 };
116
117 } //namespace
118
119 #endif