~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/html/FormAssociatedElement.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, 2008, 2009, 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 FormAssociatedElement_h
 
25
#define FormAssociatedElement_h
 
26
 
 
27
#include <wtf/text/WTFString.h>
 
28
 
 
29
namespace WebCore {
 
30
 
 
31
class ContainerNode;
 
32
class Document;
 
33
class FormAttributeTargetObserver;
 
34
class FormDataList;
 
35
class HTMLElement;
 
36
class HTMLFormElement;
 
37
class Node;
 
38
class ShadowRoot;
 
39
class ValidationMessage;
 
40
class ValidityState;
 
41
class VisibleSelection;
 
42
 
 
43
class FormAssociatedElement {
 
44
public:
 
45
    virtual ~FormAssociatedElement();
 
46
 
 
47
    void ref() { refFormAssociatedElement(); }
 
48
    void deref() { derefFormAssociatedElement(); }
 
49
 
 
50
    static HTMLFormElement* findAssociatedForm(const HTMLElement*, HTMLFormElement*);
 
51
    HTMLFormElement* form() const { return m_form; }
 
52
    ValidityState* validity();
 
53
 
 
54
    ShadowRoot* ensureUserAgentShadowRoot();
 
55
 
 
56
    virtual bool isFormControlElement() const = 0;
 
57
    virtual bool isFormControlElementWithState() const;
 
58
    virtual bool isEnumeratable() const = 0;
 
59
 
 
60
    // Returns the 'name' attribute value. If this element has no name
 
61
    // attribute, it returns an empty string instead of null string.
 
62
    // Note that the 'name' IDL attribute doesn't use this function.
 
63
    virtual const AtomicString& name() const;
 
64
 
 
65
    // Override in derived classes to get the encoded name=value pair for submitting.
 
66
    // Return true for a successful control (see HTML4-17.13.2).
 
67
    virtual bool appendFormData(FormDataList&, bool) { return false; }
 
68
 
 
69
    void formWillBeDestroyed();
 
70
 
 
71
    void resetFormOwner();
 
72
 
 
73
    void formRemovedFromTree(const Node* formRoot);
 
74
 
 
75
    // ValidityState attribute implementations
 
76
    bool customError() const;
 
77
 
 
78
    // Override functions for patterMismatch, rangeOverflow, rangerUnderflow,
 
79
    // stepMismatch, tooLong and valueMissing must call willValidate method.
 
80
    virtual bool hasBadInput() const;
 
81
    virtual bool patternMismatch() const;
 
82
    virtual bool rangeOverflow() const;
 
83
    virtual bool rangeUnderflow() const;
 
84
    virtual bool stepMismatch() const;
 
85
    virtual bool tooLong() const;
 
86
    virtual bool typeMismatch() const;
 
87
    virtual bool valueMissing() const;
 
88
    virtual String validationMessage() const;
 
89
    bool valid() const;
 
90
    virtual void setCustomValidity(const String&);
 
91
 
 
92
    void formAttributeTargetChanged();
 
93
 
 
94
protected:
 
95
    FormAssociatedElement();
 
96
 
 
97
    void insertedInto(ContainerNode*);
 
98
    void removedFrom(ContainerNode*);
 
99
    void didMoveToNewDocument(Document* oldDocument);
 
100
 
 
101
    void setForm(HTMLFormElement*);
 
102
    void formAttributeChanged();
 
103
 
 
104
    // If you add an override of willChangeForm() or didChangeForm() to a class
 
105
    // derived from this one, you will need to add a call to setForm(0) to the
 
106
    // destructor of that class.
 
107
    virtual void willChangeForm();
 
108
    virtual void didChangeForm();
 
109
 
 
110
    String customValidationMessage() const;
 
111
 
 
112
private:
 
113
    virtual void refFormAssociatedElement() = 0;
 
114
    virtual void derefFormAssociatedElement() = 0;
 
115
 
 
116
    void resetFormAttributeTargetObserver();
 
117
 
 
118
    OwnPtr<FormAttributeTargetObserver> m_formAttributeTargetObserver;
 
119
    HTMLFormElement* m_form;
 
120
    OwnPtr<ValidityState> m_validityState;
 
121
    String m_customValidationMessage;
 
122
};
 
123
 
 
124
HTMLElement* toHTMLElement(FormAssociatedElement*);
 
125
const HTMLElement* toHTMLElement(const FormAssociatedElement*);
 
126
 
 
127
} // namespace
 
128
 
 
129
#endif // FormAssociatedElement_h