• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 blink {
31 
32 class ExceptionState;
33 class HTMLDataListElement;
34 class HTMLSelectElement;
35 
36 class HTMLOptionElement FINAL : public HTMLElement {
37     DEFINE_WRAPPERTYPEINFO();
38 public:
39     static PassRefPtrWillBeRawPtr<HTMLOptionElement> create(Document&);
40     static PassRefPtrWillBeRawPtr<HTMLOptionElement> createForJSConstructor(Document&, const String& data, const AtomicString& value,
41         bool defaultSelected, bool selected, ExceptionState&);
42 
43     String text() const;
44     void setText(const String&, ExceptionState&);
45 
46     int index() const;
47 
48     String value() const;
49     void setValue(const AtomicString&);
50 
51     bool selected() const;
52     void setSelected(bool);
53 
54     HTMLDataListElement* ownerDataListElement() const;
55     HTMLSelectElement* ownerSelectElement() const;
56 
57     String label() const;
58     void setLabel(const AtomicString&);
59 
ownElementDisabled()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     HTMLFormElement* form() const;
69     bool spatialNavigationFocused() const;
70 
71     bool isDisplayNone() const;
72 private:
73     explicit HTMLOptionElement(Document&);
74     virtual ~HTMLOptionElement();
75 
rendererIsFocusable()76     virtual bool rendererIsFocusable() const OVERRIDE { return true; }
77     virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
78     virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
79     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
80     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
81     virtual void removedFrom(ContainerNode*) OVERRIDE;
82     virtual void accessKeyAction(bool) OVERRIDE;
83     virtual void childrenChanged(const ChildrenChange&) OVERRIDE;
84 
85     // <option> never has a renderer so we manually manage a cached style.
86     void updateNonRenderStyle();
87     virtual RenderStyle* nonRendererStyle() const OVERRIDE;
88     virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
89     virtual void didRecalcStyle(StyleRecalcChange) OVERRIDE;
90     virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE;
91 
92     String collectOptionInnerText() const;
93 
94     void updateLabel();
95 
96     bool m_disabled;
97     bool m_isSelected;
98     RefPtr<RenderStyle> m_style;
99 };
100 
101 } // namespace blink
102 
103 #endif // HTMLOptionElement_h
104