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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef mozilla_a11y_HTMLSelectAccessible_h__
       7             : #define mozilla_a11y_HTMLSelectAccessible_h__
       8             : 
       9             : #include "HTMLFormControlAccessible.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace a11y {
      13             : 
      14             : /**
      15             :   *  Selects, Listboxes and Comboboxes, are made up of a number of different
      16             :   *  widgets, some of which are shared between the two. This file contains
      17             :   *  all of the widgets for both of the Selects, for HTML only.
      18             :   *
      19             :   *  Listbox:
      20             :   *     - HTMLSelectListAccessible
      21             :   *        - HTMLSelectOptionAccessible
      22             :   *
      23             :   *  Comboboxes:
      24             :   *     - HTMLComboboxAccessible
      25             :   *        - HTMLComboboxListAccessible  [ inserted in accessible tree ]
      26             :   *           - HTMLSelectOptionAccessible(s)
      27             :   */
      28             : 
      29             : /*
      30             :  * The list that contains all the options in the select.
      31             :  */
      32             : class HTMLSelectListAccessible : public AccessibleWrap
      33             : {
      34             : public:
      35             : 
      36             :   HTMLSelectListAccessible(nsIContent* aContent, DocAccessible* aDoc);
      37           0 :   virtual ~HTMLSelectListAccessible() {}
      38             : 
      39             :   // Accessible
      40             :   virtual a11y::role NativeRole() override;
      41             :   virtual uint64_t NativeState() override;
      42             : 
      43             :   // SelectAccessible
      44             :   virtual bool SelectAll() override;
      45             :   virtual bool UnselectAll() override;
      46             : 
      47             :   // Widgets
      48             :   virtual bool IsWidget() const override;
      49             :   virtual bool IsActiveWidget() const override;
      50             :   virtual bool AreItemsOperable() const override;
      51             :   virtual Accessible* CurrentItem() override;
      52             :   virtual void SetCurrentItem(Accessible* aItem) override;
      53             : 
      54             :   virtual bool IsAcceptableChild(nsIContent* aEl) const override;
      55             : };
      56             : 
      57             : /*
      58             :  * Options inside the select, contained within the list
      59             :  */
      60             : class HTMLSelectOptionAccessible : public HyperTextAccessibleWrap
      61             : {
      62             : public:
      63             :   enum { eAction_Select = 0 };
      64             : 
      65             :   HTMLSelectOptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
      66           0 :   virtual ~HTMLSelectOptionAccessible() {}
      67             : 
      68             :   // Accessible
      69             :   virtual a11y::role NativeRole() override;
      70             :   virtual uint64_t NativeState() override;
      71             :   virtual uint64_t NativeInteractiveState() const override;
      72             : 
      73             :   virtual int32_t GetLevelInternal() override;
      74             :   virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override;
      75             :   virtual void SetSelected(bool aSelect) override;
      76             : 
      77             :   // ActionAccessible
      78             :   virtual uint8_t ActionCount() override;
      79             :   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
      80             :   virtual bool DoAction(uint8_t aIndex) override;
      81             : 
      82             :   // Widgets
      83             :   virtual Accessible* ContainerWidget() const override;
      84             : 
      85             : protected:
      86             :   // Accessible
      87             :   virtual ENameValueFlag NativeName(nsString& aName) override;
      88             : 
      89             : private:
      90             : 
      91             :   /**
      92             :    * Return a select accessible the option belongs to if any.
      93             :    */
      94           0 :   Accessible* GetSelect() const
      95             :   {
      96           0 :     Accessible* parent = mParent;
      97           0 :     if (parent && parent->IsHTMLOptGroup())
      98           0 :       parent = parent->Parent();
      99             : 
     100           0 :     if (parent && parent->IsListControl()) {
     101           0 :       Accessible* combobox = parent->Parent();
     102           0 :       return combobox && combobox->IsCombobox() ? combobox : mParent;
     103             :     }
     104             : 
     105           0 :     return nullptr;
     106             :   }
     107             : 
     108             :   /**
     109             :    * Return a combobox accessible the option belongs to if any.
     110             :    */
     111           0 :   Accessible* GetCombobox() const
     112             :   {
     113           0 :     Accessible* parent = mParent;
     114           0 :     if (parent && parent->IsHTMLOptGroup())
     115           0 :       parent = parent->Parent();
     116             : 
     117           0 :     if (parent && parent->IsListControl()) {
     118           0 :       Accessible* combobox = parent->Parent();
     119           0 :       return combobox && combobox->IsCombobox() ? combobox : nullptr;
     120             :     }
     121             : 
     122           0 :     return nullptr;
     123             :   }
     124             : };
     125             : 
     126             : /*
     127             :  * Opt Groups inside the select, contained within the list
     128             :  */
     129             : class HTMLSelectOptGroupAccessible : public HTMLSelectOptionAccessible
     130             : {
     131             : public:
     132             : 
     133           0 :   HTMLSelectOptGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     134           0 :     HTMLSelectOptionAccessible(aContent, aDoc)
     135           0 :     { mType = eHTMLOptGroupType; }
     136           0 :   virtual ~HTMLSelectOptGroupAccessible() {}
     137             : 
     138             :   // Accessible
     139             :   virtual a11y::role NativeRole() override;
     140             :   virtual uint64_t NativeInteractiveState() const override;
     141             : 
     142             :   // ActionAccessible
     143             :   virtual uint8_t ActionCount() override;
     144             :   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
     145             :   virtual bool DoAction(uint8_t aIndex) override;
     146             : };
     147             : 
     148             : /** ------------------------------------------------------ */
     149             : /**  Finally, the Combobox widgets                         */
     150             : /** ------------------------------------------------------ */
     151             : 
     152             : class HTMLComboboxListAccessible;
     153             : 
     154             : /*
     155             :  * A class the represents the HTML Combobox widget.
     156             :  */
     157             : class HTMLComboboxAccessible final : public AccessibleWrap
     158             : {
     159             : public:
     160             :   enum { eAction_Click = 0 };
     161             : 
     162             :   HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
     163           0 :   virtual ~HTMLComboboxAccessible() {}
     164             : 
     165             :   // Accessible
     166             :   virtual void Shutdown() override;
     167             :   virtual void Description(nsString& aDescription) override;
     168             :   virtual void Value(nsString& aValue) override;
     169             :   virtual a11y::role NativeRole() override;
     170             :   virtual uint64_t NativeState() override;
     171             :   virtual bool RemoveChild(Accessible* aChild) override;
     172             : 
     173             :   // ActionAccessible
     174             :   virtual uint8_t ActionCount() override;
     175             :   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
     176             :   virtual bool DoAction(uint8_t aIndex) override;
     177             : 
     178             :   // Widgets
     179             :   virtual bool IsWidget() const override;
     180             :   virtual bool IsActiveWidget() const override;
     181             :   virtual bool AreItemsOperable() const override;
     182             :   virtual Accessible* CurrentItem() override;
     183             :   virtual void SetCurrentItem(Accessible* aItem) override;
     184             : 
     185             : protected:
     186             :   /**
     187             :    * Return selected option.
     188             :    */
     189             :   Accessible* SelectedOption() const;
     190             : 
     191             : private:
     192             :   RefPtr<HTMLComboboxListAccessible> mListAccessible;
     193             : };
     194             : 
     195             : /*
     196             :  * A class that represents the window that lives to the right
     197             :  * of the drop down button inside the Select. This is the window
     198             :  * that is made visible when the button is pressed.
     199             :  */
     200             : class HTMLComboboxListAccessible : public HTMLSelectListAccessible
     201             : {
     202             : public:
     203             : 
     204             :   HTMLComboboxListAccessible(Accessible* aParent, nsIContent* aContent,
     205             :                              DocAccessible* aDoc);
     206           0 :   virtual ~HTMLComboboxListAccessible() {}
     207             : 
     208             :   // Accessible
     209             :   virtual nsIFrame* GetFrame() const override;
     210             :   virtual a11y::role NativeRole() override;
     211             :   virtual uint64_t NativeState() override;
     212             :   virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override;
     213             : 
     214             :   // Widgets
     215             :   virtual bool IsActiveWidget() const override;
     216             :   virtual bool AreItemsOperable() const override;
     217             : };
     218             : 
     219             : } // namespace a11y
     220             : } // namespace mozilla
     221             : 
     222             : #endif

Generated by: LCOV version 1.13