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 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.
24 #ifndef HTMLOptionElement_h
25 #define HTMLOptionElement_h
27 #include "HTMLFormControlElement.h"
28 #include "OptionElement.h"
32 class HTMLSelectElement;
34 class HTMLOptionElement : public HTMLFormControlElement, public OptionElement {
35 friend class HTMLSelectElement;
36 friend class RenderMenuList;
39 static PassRefPtr<HTMLOptionElement> create(Document*, HTMLFormElement*);
40 static PassRefPtr<HTMLOptionElement> create(const QualifiedName&, Document*, HTMLFormElement*);
41 static PassRefPtr<HTMLOptionElement> createForJSConstructor(Document*, const String& data, const String& value,
42 bool defaultSelected, bool selected, ExceptionCode&);
44 virtual String text() const;
45 void setText(const String&, ExceptionCode&);
49 virtual String value() const;
50 void setValue(const String&);
52 virtual bool selected();
53 void setSelected(bool);
55 HTMLSelectElement* ownerSelectElement() const;
57 bool defaultSelected() const;
58 void setDefaultSelected(bool);
62 bool ownElementDisabled() const { return HTMLFormControlElement::disabled(); }
64 virtual bool disabled() const;
67 HTMLOptionElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
69 virtual bool supportsFocus() const;
70 virtual bool isFocusable() const;
71 virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
72 virtual void attach();
73 virtual void detach();
74 virtual void setRenderStyle(PassRefPtr<RenderStyle>);
76 virtual const AtomicString& formControlType() const;
78 virtual void parseMappedAttribute(Attribute*);
80 virtual void setSelectedState(bool);
82 virtual String textIndentedToRespectGroupLabel() const;
84 virtual void insertedIntoTree(bool);
85 virtual void accessKeyAction(bool);
87 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
89 virtual RenderStyle* nonRendererRenderStyle() const;
91 OptionElementData m_data;
92 RefPtr<RenderStyle> m_style;