Home | History | Annotate | Download | only in html
      1 /*
      2  * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      4  *           (C) 2000 Dirk Mueller (mueller (at) kde.org)
      5  * Copyright (C) 2004, 2005, 2006, 2010 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 #ifndef HTMLOptionElement_h
     25 #define HTMLOptionElement_h
     26 
     27 #include "HTMLFormControlElement.h"
     28 #include "OptionElement.h"
     29 
     30 namespace WebCore {
     31 
     32 class HTMLSelectElement;
     33 
     34 class HTMLOptionElement : public HTMLFormControlElement, public OptionElement {
     35     friend class HTMLSelectElement;
     36     friend class RenderMenuList;
     37 
     38 public:
     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&);
     43 
     44     virtual String text() const;
     45     void setText(const String&, ExceptionCode&);
     46 
     47     int index() const;
     48 
     49     virtual String value() const;
     50     void setValue(const String&);
     51 
     52     virtual bool selected() const;
     53     void setSelected(bool);
     54 
     55     HTMLSelectElement* ownerSelectElement() const;
     56 
     57     bool defaultSelected() const;
     58     void setDefaultSelected(bool);
     59 
     60     String label() const;
     61 
     62     bool ownElementDisabled() const { return HTMLFormControlElement::disabled(); }
     63 
     64     virtual bool disabled() const;
     65 
     66 private:
     67     HTMLOptionElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
     68 
     69     virtual bool supportsFocus() const;
     70     virtual bool isFocusable() const;
     71     virtual bool rendererIsNeeded(RenderStyle*) { return false; }
     72     virtual void attach();
     73     virtual void detach();
     74     virtual void setRenderStyle(PassRefPtr<RenderStyle>);
     75 
     76     virtual const AtomicString& formControlType() const;
     77 
     78     virtual void parseMappedAttribute(Attribute*);
     79 
     80     virtual void setSelectedState(bool);
     81 
     82     virtual String textIndentedToRespectGroupLabel() const;
     83 
     84     virtual void insertedIntoTree(bool);
     85     virtual void accessKeyAction(bool);
     86 
     87     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     88 
     89     virtual RenderStyle* nonRendererRenderStyle() const;
     90 
     91     OptionElementData m_data;
     92     RefPtr<RenderStyle> m_style;
     93 };
     94 
     95 } //namespace
     96 
     97 #endif
     98