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.
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.
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.
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.
25 #ifndef HTMLOptionElement_h
26 #define HTMLOptionElement_h
28 #include "core/html/HTMLElement.h"
33 class HTMLDataListElement;
34 class HTMLSelectElement;
36 class HTMLOptionElement final : public HTMLElement {
37 DEFINE_WRAPPERTYPEINFO();
39 static PassRefPtrWillBeRawPtr<HTMLOptionElement> create(Document&);
40 static PassRefPtrWillBeRawPtr<HTMLOptionElement> createForJSConstructor(Document&, const String& data, const AtomicString& value,
41 bool defaultSelected, bool selected, ExceptionState&);
44 void setText(const String&, ExceptionState&);
49 void setValue(const AtomicString&);
51 bool selected() const;
52 void setSelected(bool);
54 HTMLDataListElement* ownerDataListElement() const;
55 HTMLSelectElement* ownerSelectElement() const;
58 void setLabel(const AtomicString&);
60 bool ownElementDisabled() const { return m_disabled; }
62 virtual bool isDisabledFormControl() const override;
64 String textIndentedToRespectGroupLabel() const;
66 void setSelectedState(bool);
68 HTMLFormElement* form() const;
69 bool spatialNavigationFocused() const;
71 bool isDisplayNone() const;
73 explicit HTMLOptionElement(Document&);
74 virtual ~HTMLOptionElement();
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;
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;
92 String collectOptionInnerText() const;
98 RefPtr<RenderStyle> m_style;
103 #endif // HTMLOptionElement_h