LCOV - code coverage report
Current view: top level - dom/html - HTMLOptionElement.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 26 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_HTMLOptionElement_h__
       8             : #define mozilla_dom_HTMLOptionElement_h__
       9             : 
      10             : #include "mozilla/Attributes.h"
      11             : #include "nsGenericHTMLElement.h"
      12             : #include "nsIDOMHTMLOptionElement.h"
      13             : #include "mozilla/dom/HTMLFormElement.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : class HTMLSelectElement;
      19             : 
      20             : class HTMLOptionElement final : public nsGenericHTMLElement,
      21             :                                 public nsIDOMHTMLOptionElement
      22             : {
      23             : public:
      24             :   explicit HTMLOptionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
      25             : 
      26             :   static already_AddRefed<HTMLOptionElement>
      27             :     Option(const GlobalObject& aGlobal,
      28             :            const nsAString& aText,
      29             :            const Optional<nsAString>& aValue,
      30             :            bool aDefaultSelected,
      31             :            bool aSelected,
      32             :            ErrorResult& aError);
      33             : 
      34           0 :   NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLOptionElement, option)
      35             : 
      36             :   // nsISupports
      37             :   NS_DECL_ISUPPORTS_INHERITED
      38             : 
      39             :   // nsIDOMHTMLOptionElement
      40             :   using mozilla::dom::Element::SetText;
      41             :   using mozilla::dom::Element::GetText;
      42             :   NS_DECL_NSIDOMHTMLOPTIONELEMENT
      43             : 
      44             :   bool Selected() const;
      45             :   bool DefaultSelected() const;
      46             : 
      47           0 :   void SetSelectedChanged(bool aValue)
      48             :   {
      49           0 :     mSelectedChanged = aValue;
      50           0 :   }
      51             : 
      52             :   virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
      53             :                                               int32_t aModType) const override;
      54             : 
      55             :   virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
      56             :                                  const nsAttrValueOrString* aValue,
      57             :                                  bool aNotify) override;
      58             :   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
      59             :                                 const nsAttrValue* aValue,
      60             :                                 const nsAttrValue* aOldValue,
      61             :                                 bool aNotify) override;
      62             : 
      63             :   void SetSelectedInternal(bool aValue, bool aNotify);
      64             : 
      65             :   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
      66             :                               nsIContent* aBindingParent,
      67             :                               bool aCompileEventHandlers) override;
      68             :   virtual void UnbindFromTree(bool aDeep = true,
      69             :                               bool aNullParent = true) override;
      70             : 
      71             :   // nsIContent
      72             :   virtual EventStates IntrinsicState() const override;
      73             : 
      74             :   virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
      75             :                          bool aPreallocateChildren) const override;
      76             : 
      77             :   nsresult CopyInnerTo(mozilla::dom::Element* aDest, bool aPreallocateChildren);
      78             : 
      79           0 :   virtual bool IsDisabled() const override {
      80           0 :     return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled);
      81             :   }
      82             : 
      83           0 :   bool Disabled() const
      84             :   {
      85           0 :     return GetBoolAttr(nsGkAtoms::disabled);
      86             :   }
      87             : 
      88           0 :   void SetDisabled(bool aValue, ErrorResult& aRv)
      89             :   {
      90           0 :     SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv);
      91           0 :   }
      92             : 
      93             :   HTMLFormElement* GetForm();
      94             : 
      95             :   // The XPCOM GetLabel is OK for us
      96           0 :   void SetLabel(const nsAString& aLabel, ErrorResult& aError)
      97             :   {
      98           0 :     SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
      99           0 :   }
     100             : 
     101             :   // The XPCOM DefaultSelected is OK for us
     102           0 :   void SetDefaultSelected(bool aValue, ErrorResult& aRv)
     103             :   {
     104           0 :     SetHTMLBoolAttr(nsGkAtoms::selected, aValue, aRv);
     105           0 :   }
     106             : 
     107             :   // The XPCOM Selected is OK for us
     108           0 :   void SetSelected(bool aValue, ErrorResult& aRv)
     109             :   {
     110           0 :     aRv = SetSelected(aValue);
     111           0 :   }
     112             : 
     113             :   // The XPCOM GetValue is OK for us
     114           0 :   void SetValue(const nsAString& aValue, ErrorResult& aRv)
     115             :   {
     116           0 :     SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
     117           0 :   }
     118             : 
     119             :   // The XPCOM GetText is OK for us
     120           0 :   void SetText(const nsAString& aValue, ErrorResult& aRv)
     121             :   {
     122           0 :     aRv = SetText(aValue);
     123           0 :   }
     124             : 
     125             :   int32_t Index();
     126             : 
     127             : protected:
     128             :   virtual ~HTMLOptionElement();
     129             : 
     130             :   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
     131             : 
     132             :   /**
     133             :    * Get the select content element that contains this option, this
     134             :    * intentionally does not return nsresult, all we care about is if
     135             :    * there's a select associated with this option or not.
     136             :    */
     137             :   HTMLSelectElement* GetSelect();
     138             : 
     139             :   bool mSelectedChanged;
     140             :   bool mIsSelected;
     141             : 
     142             :   // True only while we're under the SetOptionsSelectedByIndex call when our
     143             :   // "selected" attribute is changing and mSelectedChanged is false.
     144             :   bool mIsInSetDefaultSelected;
     145             : };
     146             : 
     147             : } // namespace dom
     148             : } // namespace mozilla
     149             : 
     150             : #endif // mozilla_dom_HTMLOptionElement_h__

Generated by: LCOV version 1.13