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, 2016 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#pragma once
26
27#include "HTMLElement.h"
28
29namespace WebCore {
30
31class HTMLDataListElement;
32class HTMLSelectElement;
33
34class HTMLOptionElement final : public HTMLElement {
35 WTF_MAKE_ISO_ALLOCATED(HTMLOptionElement);
36public:
37 static Ref<HTMLOptionElement> create(Document&);
38 static Ref<HTMLOptionElement> create(const QualifiedName&, Document&);
39 static ExceptionOr<Ref<HTMLOptionElement>> createForJSConstructor(Document&, const String& text, const String& value, bool defaultSelected, bool selected);
40
41 WEBCORE_EXPORT String text() const;
42 void setText(const String&);
43
44 WEBCORE_EXPORT int index() const;
45
46 WEBCORE_EXPORT String value() const;
47 WEBCORE_EXPORT void setValue(const String&);
48
49 WEBCORE_EXPORT bool selected();
50 WEBCORE_EXPORT void setSelected(bool);
51
52#if ENABLE(DATALIST_ELEMENT)
53 WEBCORE_EXPORT HTMLDataListElement* ownerDataListElement() const;
54#endif
55 WEBCORE_EXPORT HTMLSelectElement* ownerSelectElement() const;
56
57 WEBCORE_EXPORT String label() const;
58 String displayLabel() const;
59 WEBCORE_EXPORT void setLabel(const String&);
60
61 bool ownElementDisabled() const { return m_disabled; }
62
63 WEBCORE_EXPORT bool isDisabledFormControl() const final;
64
65 String textIndentedToRespectGroupLabel() const;
66
67 void setSelectedState(bool);
68
69private:
70 HTMLOptionElement(const QualifiedName&, Document&);
71
72 bool isFocusable() const final;
73 bool rendererIsNeeded(const RenderStyle&) final { return false; }
74 bool matchesDefaultPseudoClass() const final;
75
76 void parseAttribute(const QualifiedName&, const AtomString&) final;
77
78 InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
79 void accessKeyAction(bool) final;
80
81 void childrenChanged(const ChildChange&) final;
82
83 void willResetComputedStyle() final;
84
85 String collectOptionInnerText() const;
86
87 bool m_disabled;
88 bool m_isSelected;
89};
90
91} // namespace
92