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 {
38 static PassRefPtrWillBeRawPtr<HTMLOptionElement> create(Document&);
39 static PassRefPtrWillBeRawPtr<HTMLOptionElement> createForJSConstructor(Document&, const String& data, const AtomicString& value,
40 bool defaultSelected, bool selected, ExceptionState&);
43 void setText(const String&, ExceptionState&);
48 void setValue(const AtomicString&);
50 bool selected() const;
51 void setSelected(bool);
53 HTMLDataListElement* ownerDataListElement() const;
54 HTMLSelectElement* ownerSelectElement() const;
57 void setLabel(const AtomicString&);
59 bool ownElementDisabled() const { return m_disabled; }
61 virtual bool isDisabledFormControl() const OVERRIDE;
63 String textIndentedToRespectGroupLabel() const;
65 void setSelectedState(bool);
67 HTMLFormElement* form() const;
69 bool isDisplayNone() const;
72 explicit HTMLOptionElement(Document&);
74 virtual bool rendererIsFocusable() const OVERRIDE;
75 virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE { return false; }
76 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
77 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
79 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
81 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
82 virtual void accessKeyAction(bool) OVERRIDE;
84 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
86 // <option> never has a renderer so we manually manage a cached style.
87 void updateNonRenderStyle();
88 virtual RenderStyle* nonRendererStyle() const OVERRIDE;
89 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
90 virtual void didRecalcStyle(StyleRecalcChange) OVERRIDE;
92 String collectOptionInnerText() const;
96 RefPtr<RenderStyle> m_style;
99 } // namespace WebCore