accessible/src/html/HTMLSelectAccessible.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/html/HTMLSelectAccessible.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,236 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_a11y_HTMLSelectAccessible_h__
    1.10 +#define mozilla_a11y_HTMLSelectAccessible_h__
    1.11 +
    1.12 +#include "HTMLFormControlAccessible.h"
    1.13 +
    1.14 +class nsIMutableArray;
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace a11y {
    1.18 +
    1.19 +/**
    1.20 +  *  Selects, Listboxes and Comboboxes, are made up of a number of different
    1.21 +  *  widgets, some of which are shared between the two. This file contains
    1.22 +  *  all of the widgets for both of the Selects, for HTML only.
    1.23 +  *
    1.24 +  *  Listbox:
    1.25 +  *     - HTMLSelectListAccessible
    1.26 +  *        - HTMLSelectOptionAccessible
    1.27 +  *
    1.28 +  *  Comboboxes:
    1.29 +  *     - HTMLComboboxAccessible
    1.30 +  *        - HTMLComboboxListAccessible  [ inserted in accessible tree ]
    1.31 +  *           - HTMLSelectOptionAccessible(s)
    1.32 +  */
    1.33 +
    1.34 +/*
    1.35 + * The list that contains all the options in the select.
    1.36 + */
    1.37 +class HTMLSelectListAccessible : public AccessibleWrap
    1.38 +{
    1.39 +public:
    1.40 +
    1.41 +  HTMLSelectListAccessible(nsIContent* aContent, DocAccessible* aDoc);
    1.42 +  virtual ~HTMLSelectListAccessible() {}
    1.43 +
    1.44 +  // Accessible
    1.45 +  virtual a11y::role NativeRole();
    1.46 +  virtual uint64_t NativeState();
    1.47 +
    1.48 +  // SelectAccessible
    1.49 +  virtual bool SelectAll();
    1.50 +  virtual bool UnselectAll();
    1.51 +
    1.52 +  // Widgets
    1.53 +  virtual bool IsWidget() const;
    1.54 +  virtual bool IsActiveWidget() const;
    1.55 +  virtual bool AreItemsOperable() const;
    1.56 +  virtual Accessible* CurrentItem();
    1.57 +  virtual void SetCurrentItem(Accessible* aItem);
    1.58 +
    1.59 +protected:
    1.60 +
    1.61 +  // Accessible
    1.62 +  virtual void CacheChildren();
    1.63 +};
    1.64 +
    1.65 +/*
    1.66 + * Options inside the select, contained within the list
    1.67 + */
    1.68 +class HTMLSelectOptionAccessible : public HyperTextAccessibleWrap
    1.69 +{
    1.70 +public:
    1.71 +  enum { eAction_Select = 0 };
    1.72 +
    1.73 +  HTMLSelectOptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
    1.74 +  virtual ~HTMLSelectOptionAccessible() {}
    1.75 +
    1.76 +  // nsIAccessible
    1.77 +  NS_IMETHOD DoAction(uint8_t index);
    1.78 +  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
    1.79 +  NS_IMETHOD SetSelected(bool aSelect);
    1.80 +
    1.81 +  // Accessible
    1.82 +  virtual a11y::role NativeRole();
    1.83 +  virtual uint64_t NativeState();
    1.84 +  virtual uint64_t NativeInteractiveState() const;
    1.85 +
    1.86 +  virtual int32_t GetLevelInternal();
    1.87 +  virtual void GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame);
    1.88 +
    1.89 +  // ActionAccessible
    1.90 +  virtual uint8_t ActionCount();
    1.91 +
    1.92 +  // Widgets
    1.93 +  virtual Accessible* ContainerWidget() const;
    1.94 +
    1.95 +protected:
    1.96 +  // Accessible
    1.97 +  virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
    1.98 +
    1.99 +private:
   1.100 +
   1.101 +  /**
   1.102 +   * Return a select accessible the option belongs to if any.
   1.103 +   */
   1.104 +  Accessible* GetSelect() const
   1.105 +  {
   1.106 +    Accessible* parent = mParent;
   1.107 +    if (parent && parent->IsHTMLOptGroup())
   1.108 +      parent = parent->Parent();
   1.109 +
   1.110 +    if (parent && parent->IsListControl()) {
   1.111 +      Accessible* combobox = parent->Parent();
   1.112 +      return combobox && combobox->IsCombobox() ? combobox : mParent.get();
   1.113 +    }
   1.114 +
   1.115 +    return nullptr;
   1.116 +  }
   1.117 +
   1.118 +  /**
   1.119 +   * Return a combobox accessible the option belongs to if any.
   1.120 +   */
   1.121 +  Accessible* GetCombobox() const
   1.122 +  {
   1.123 +    Accessible* parent = mParent;
   1.124 +    if (parent && parent->IsHTMLOptGroup())
   1.125 +      parent = parent->Parent();
   1.126 +
   1.127 +    if (parent && parent->IsListControl()) {
   1.128 +      Accessible* combobox = parent->Parent();
   1.129 +      return combobox && combobox->IsCombobox() ? combobox : nullptr;
   1.130 +    }
   1.131 +
   1.132 +    return nullptr;
   1.133 +  }
   1.134 +};
   1.135 +
   1.136 +/*
   1.137 + * Opt Groups inside the select, contained within the list
   1.138 + */
   1.139 +class HTMLSelectOptGroupAccessible : public HTMLSelectOptionAccessible
   1.140 +{
   1.141 +public:
   1.142 +
   1.143 +  HTMLSelectOptGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.144 +    HTMLSelectOptionAccessible(aContent, aDoc)
   1.145 +    { mType = eHTMLOptGroupType; }
   1.146 +  virtual ~HTMLSelectOptGroupAccessible() {}
   1.147 +
   1.148 +  // nsIAccessible
   1.149 +  NS_IMETHOD DoAction(uint8_t index);
   1.150 +  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
   1.151 +
   1.152 +  // Accessible
   1.153 +  virtual a11y::role NativeRole();
   1.154 +  virtual uint64_t NativeInteractiveState() const;
   1.155 +
   1.156 +  // ActionAccessible
   1.157 +  virtual uint8_t ActionCount();
   1.158 +};
   1.159 +
   1.160 +/** ------------------------------------------------------ */
   1.161 +/**  Finally, the Combobox widgets                         */
   1.162 +/** ------------------------------------------------------ */
   1.163 +
   1.164 +class HTMLComboboxListAccessible;
   1.165 +
   1.166 +/*
   1.167 + * A class the represents the HTML Combobox widget.
   1.168 + */
   1.169 +class HTMLComboboxAccessible : public AccessibleWrap
   1.170 +{
   1.171 +public:
   1.172 +  enum { eAction_Click = 0 };
   1.173 +
   1.174 +  HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
   1.175 +  virtual ~HTMLComboboxAccessible() {}
   1.176 +
   1.177 +  // nsIAccessible
   1.178 +  NS_IMETHOD DoAction(uint8_t index);
   1.179 +  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
   1.180 +
   1.181 +  // Accessible
   1.182 +  virtual void Shutdown();
   1.183 +  virtual void Description(nsString& aDescription);
   1.184 +  virtual void Value(nsString& aValue);
   1.185 +  virtual a11y::role NativeRole();
   1.186 +  virtual uint64_t NativeState();
   1.187 +  virtual void InvalidateChildren();
   1.188 +
   1.189 +  // ActionAccessible
   1.190 +  virtual uint8_t ActionCount();
   1.191 +
   1.192 +  // Widgets
   1.193 +  virtual bool IsWidget() const;
   1.194 +  virtual bool IsActiveWidget() const;
   1.195 +  virtual bool AreItemsOperable() const;
   1.196 +  virtual Accessible* CurrentItem();
   1.197 +  virtual void SetCurrentItem(Accessible* aItem);
   1.198 +
   1.199 +protected:
   1.200 +  // Accessible
   1.201 +  virtual void CacheChildren();
   1.202 +
   1.203 +  /**
   1.204 +   * Return selected option.
   1.205 +   */
   1.206 +  Accessible* SelectedOption() const;
   1.207 +
   1.208 +private:
   1.209 +  nsRefPtr<HTMLComboboxListAccessible> mListAccessible;
   1.210 +};
   1.211 +
   1.212 +/*
   1.213 + * A class that represents the window that lives to the right
   1.214 + * of the drop down button inside the Select. This is the window
   1.215 + * that is made visible when the button is pressed.
   1.216 + */
   1.217 +class HTMLComboboxListAccessible : public HTMLSelectListAccessible
   1.218 +{
   1.219 +public:
   1.220 +
   1.221 +  HTMLComboboxListAccessible(nsIAccessible* aParent, nsIContent* aContent,
   1.222 +                             DocAccessible* aDoc);
   1.223 +  virtual ~HTMLComboboxListAccessible() {}
   1.224 +
   1.225 +  // Accessible
   1.226 +  virtual nsIFrame* GetFrame() const;
   1.227 +  virtual a11y::role NativeRole();
   1.228 +  virtual uint64_t NativeState();
   1.229 +  virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
   1.230 +
   1.231 +  // Widgets
   1.232 +  virtual bool IsActiveWidget() const;
   1.233 +  virtual bool AreItemsOperable() const;
   1.234 +};
   1.235 +
   1.236 +} // namespace a11y
   1.237 +} // namespace mozilla
   1.238 +
   1.239 +#endif

mercurial