- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / HTMLOptionElement.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, 2010, 2011 Apple Inc. All rights reserved.
6  * Copyright (C) 2010 Google Inc. All rights reserved.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24
25 #ifndef HTMLOptionElement_h
26 #define HTMLOptionElement_h
27
28 #include "core/html/HTMLElement.h"
29
30 namespace WebCore {
31
32 class ExceptionState;
33 class HTMLDataListElement;
34 class HTMLSelectElement;
35
36 class HTMLOptionElement FINAL : public HTMLElement {
37 public:
38     static PassRefPtr<HTMLOptionElement> create(Document&);
39     static PassRefPtr<HTMLOptionElement> create(const QualifiedName&, Document&);
40     static PassRefPtr<HTMLOptionElement> createForJSConstructor(Document&, const String& data, const String& value,
41         bool defaultSelected, bool selected, ExceptionState&);
42
43     virtual String text() const;
44     void setText(const String&, ExceptionState&);
45
46     int index() const;
47
48     String value() const;
49     void setValue(const String&);
50
51     bool selected();
52     void setSelected(bool);
53
54     HTMLDataListElement* ownerDataListElement() const;
55     HTMLSelectElement* ownerSelectElement() const;
56
57     String label() const;
58     void setLabel(const String&);
59
60     bool ownElementDisabled() const { return m_disabled; }
61
62     virtual bool isDisabledFormControl() const OVERRIDE;
63
64     String textIndentedToRespectGroupLabel() const;
65
66     void setSelectedState(bool);
67
68 private:
69     HTMLOptionElement(const QualifiedName&, Document&);
70
71     virtual bool rendererIsFocusable() const OVERRIDE;
72     virtual bool rendererIsNeeded(const RenderStyle&) { return false; }
73     virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
74     virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
75
76     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
77
78     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
79     virtual void accessKeyAction(bool);
80
81     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
82
83     // <option> never has a renderer so we manually manage a cached style.
84     void updateNonRenderStyle();
85     virtual RenderStyle* nonRendererStyle() const OVERRIDE;
86     virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
87
88     void didRecalcStyle(StyleRecalcChange) OVERRIDE;
89
90     String collectOptionInnerText() const;
91
92     bool m_disabled;
93     bool m_isSelected;
94     RefPtr<RenderStyle> m_style;
95 };
96
97 DEFINE_NODE_TYPE_CASTS(HTMLOptionElement, hasTagName(HTMLNames::optionTag));
98
99 } // namespace WebCore
100
101 #endif