18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*
28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 1999 Antti Koivisto (koivisto@kde.org)
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 2000 Dirk Mueller (mueller@kde.org)
55af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is free software; you can redistribute it and/or
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modify it under the terms of the GNU Library General Public
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * License as published by the Free Software Foundation; either
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * version 2 of the License, or (at your option) any later version.
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is distributed in the hope that it will be useful,
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * but WITHOUT ANY WARRANTY; without even the implied warranty of
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Library General Public License for more details.
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * You should have received a copy of the GNU Library General Public License
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * along with this library; see the file COPYING.LIB.  If not, write to
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Boston, MA 02110-1301, USA.
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef HTMLTextAreaElement_h
258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define HTMLTextAreaElement_h
268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "HTMLFormControlElement.h"
288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore {
308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
31231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockclass BeforeTextInsertedEvent;
328f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qianclass VisibleSelection;
338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
34231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockclass HTMLTextAreaElement : public HTMLTextFormControlElement {
358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectpublic:
365af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    static PassRefPtr<HTMLTextAreaElement> create(const QualifiedName&, Document*, HTMLFormElement*);
378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int cols() const { return m_cols; }
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int rows() const { return m_rows; }
408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    bool shouldWrapText() const { return m_wrap != NoWrap; }
428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
436b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner    virtual String value() const;
448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    void setValue(const String&);
458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    String defaultValue() const;
468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    void setDefaultValue(const String&);
47231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    int textLength() const { return value().length(); }
486b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner    virtual int maxLength() const;
49231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    void setMaxLength(int, ExceptionCode&);
505ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    bool valueMissing(const String& value) const { return isRequiredFormControl() && !disabled() && !readOnly() && value.isEmpty(); }
515ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    bool tooLong(const String&, NeedsToCheckDirtyFlag) const;
525ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    bool isValidValue(const String&) const;
538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    void rendererWillBeDestroyed();
558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    void setCols(int);
578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    void setRows(int);
582bde8e466a4451c7319e3a072d118917957d6554Steve Block
592bde8e466a4451c7319e3a072d118917957d6554Steve Block    bool lastChangeWasUserEdit() const;
602bde8e466a4451c7319e3a072d118917957d6554Steve Block
618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    void cacheSelection(int s, int e) { m_cachedSelectionStart = s; m_cachedSelectionEnd = e; };
628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectprivate:
645af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    HTMLTextAreaElement(const QualifiedName&, Document*, HTMLFormElement*);
655af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    enum WrapMethod { NoWrap, SoftWrap, HardWrap };
678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
68231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*) const;
69231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    static String sanitizeUserInputValue(const String&, unsigned maxLength);
708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    void updateValue() const;
718a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block    void setNonDirtyValue(const String&);
72bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    void setValueCommon(const String&);
738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
74231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    virtual bool supportsPlaceholder() const { return true; }
75231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    virtual bool isEmptyValue() const { return value().isEmpty(); }
76231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    virtual int cachedSelectionStart() const { return m_cachedSelectionStart; }
77231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    virtual int cachedSelectionEnd() const { return m_cachedSelectionEnd; }
78231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block
790bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch    virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); }
800bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch    virtual bool isRequiredFormControl() const { return required(); }
810bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch
8221939df44de1705786c545cd1bf519d47250322dBen Murdoch    virtual void defaultEventHandler(Event*);
8321939df44de1705786c545cd1bf519d47250322dBen Murdoch
845af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual bool isEnumeratable() const { return true; }
855af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
865af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual const AtomicString& formControlType() const;
875af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
885af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual bool saveFormControlState(String& value) const;
895af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual void restoreFormControlState(const String&);
905af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
915af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual bool isTextFormControl() const { return true; }
925af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
935af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
945af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual void parseMappedAttribute(Attribute*);
955af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
965af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual bool appendFormData(FormDataList&, bool);
975af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual void reset();
985af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual bool isMouseFocusable() const;
995af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual bool isKeyboardFocusable(KeyboardEvent*) const;
1005af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual void updateFocusAppearance(bool restorePreviousSelection);
1015af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
1025af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual void accessKeyAction(bool sendToAnyElement);
1035af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
1045af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke    virtual bool shouldUseInputMethod() const;
1055af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke
1068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int m_rows;
1078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int m_cols;
1088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    WrapMethod m_wrap;
1098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    mutable String m_value;
1108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int m_cachedSelectionStart;
1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int m_cachedSelectionEnd;
112231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block    mutable bool m_isDirty;
1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project};
1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} //namespace
1168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif
118