2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-06-06 03:27:46 -07:00
|
|
|
|
|
|
|
#ifndef mozilla_a11y_HTMLSelectAccessible_h__
|
|
|
|
#define mozilla_a11y_HTMLSelectAccessible_h__
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
#include "HTMLFormControlAccessible.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-06 03:27:46 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Selects, Listboxes and Comboboxes, are made up of a number of different
|
|
|
|
* widgets, some of which are shared between the two. This file contains
|
2012-06-06 03:27:46 -07:00
|
|
|
* all of the widgets for both of the Selects, for HTML only.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Listbox:
|
2012-06-06 03:27:46 -07:00
|
|
|
* - HTMLSelectListAccessible
|
|
|
|
* - HTMLSelectOptionAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Comboboxes:
|
2012-06-06 03:27:46 -07:00
|
|
|
* - HTMLComboboxAccessible
|
|
|
|
* - HTMLComboboxListAccessible [ inserted in accessible tree ]
|
|
|
|
* - HTMLSelectOptionAccessible(s)
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The list that contains all the options in the select.
|
|
|
|
*/
|
2012-06-06 03:27:46 -07:00
|
|
|
class HTMLSelectListAccessible : public AccessibleWrap
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-06 03:27:46 -07:00
|
|
|
|
|
|
|
HTMLSelectListAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
|
|
|
virtual ~HTMLSelectListAccessible() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeState() override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-09-01 17:46:59 -07:00
|
|
|
// SelectAccessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool SelectAll() override;
|
|
|
|
virtual bool UnselectAll() override;
|
2010-09-01 17:46:59 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Widgets
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool IsWidget() const override;
|
|
|
|
virtual bool IsActiveWidget() const override;
|
|
|
|
virtual bool AreItemsOperable() const override;
|
|
|
|
virtual Accessible* CurrentItem() override;
|
|
|
|
virtual void SetCurrentItem(Accessible* aItem) override;
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void CacheChildren() override;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Options inside the select, contained within the list
|
|
|
|
*/
|
2012-06-06 03:27:46 -07:00
|
|
|
class HTMLSelectOptionAccessible : public HyperTextAccessibleWrap
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-06 03:27:46 -07:00
|
|
|
enum { eAction_Select = 0 };
|
|
|
|
|
|
|
|
HTMLSelectOptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
|
|
|
virtual ~HTMLSelectOptionAccessible() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeState() override;
|
|
|
|
virtual uint64_t NativeInteractiveState() const override;
|
2010-01-06 02:36:50 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual int32_t GetLevelInternal() override;
|
|
|
|
virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override;
|
|
|
|
virtual void SetSelected(bool aSelect) override;
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
// ActionAccessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual uint8_t ActionCount() override;
|
|
|
|
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
|
|
|
|
virtual bool DoAction(uint8_t aIndex) override;
|
2011-06-05 12:35:43 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Widgets
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual Accessible* ContainerWidget() const override;
|
2010-06-11 01:23:18 -07:00
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
protected:
|
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual ENameValueFlag NativeName(nsString& aName) override;
|
2012-10-13 21:18:39 -07:00
|
|
|
|
2007-04-10 00:55:51 -07:00
|
|
|
private:
|
2012-06-06 03:27:46 -07:00
|
|
|
|
2007-04-10 00:55:51 -07:00
|
|
|
/**
|
2012-05-10 20:50:03 -07:00
|
|
|
* Return a select accessible the option belongs to if any.
|
2012-06-06 03:27:46 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetSelect() const
|
2012-05-10 20:50:03 -07:00
|
|
|
{
|
2012-11-10 01:41:40 -08:00
|
|
|
Accessible* parent = mParent;
|
|
|
|
if (parent && parent->IsHTMLOptGroup())
|
|
|
|
parent = parent->Parent();
|
|
|
|
|
|
|
|
if (parent && parent->IsListControl()) {
|
|
|
|
Accessible* combobox = parent->Parent();
|
2012-05-10 20:50:03 -07:00
|
|
|
return combobox && combobox->IsCombobox() ? combobox : mParent.get();
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-05-10 20:50:03 -07:00
|
|
|
}
|
2012-05-07 17:00:36 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a combobox accessible the option belongs to if any.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetCombobox() const
|
2012-05-07 17:00:36 -07:00
|
|
|
{
|
2012-11-10 01:41:40 -08:00
|
|
|
Accessible* parent = mParent;
|
|
|
|
if (parent && parent->IsHTMLOptGroup())
|
|
|
|
parent = parent->Parent();
|
|
|
|
|
|
|
|
if (parent && parent->IsListControl()) {
|
|
|
|
Accessible* combobox = parent->Parent();
|
2012-07-30 07:20:58 -07:00
|
|
|
return combobox && combobox->IsCombobox() ? combobox : nullptr;
|
2012-05-07 17:00:36 -07:00
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-05-07 17:00:36 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Opt Groups inside the select, contained within the list
|
|
|
|
*/
|
2012-06-06 03:27:46 -07:00
|
|
|
class HTMLSelectOptGroupAccessible : public HTMLSelectOptionAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-11-10 01:41:40 -08:00
|
|
|
HTMLSelectOptGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
|
|
|
HTMLSelectOptionAccessible(aContent, aDoc)
|
|
|
|
{ mType = eHTMLOptGroupType; }
|
2012-06-06 03:27:46 -07:00
|
|
|
virtual ~HTMLSelectOptGroupAccessible() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeInteractiveState() const override;
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
// ActionAccessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual uint8_t ActionCount() override;
|
|
|
|
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
|
|
|
|
virtual bool DoAction(uint8_t aIndex) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/** ------------------------------------------------------ */
|
|
|
|
/** Finally, the Combobox widgets */
|
|
|
|
/** ------------------------------------------------------ */
|
|
|
|
|
2012-06-06 03:27:46 -07:00
|
|
|
class HTMLComboboxListAccessible;
|
2007-04-18 08:56:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* A class the represents the HTML Combobox widget.
|
|
|
|
*/
|
2015-03-21 09:28:04 -07:00
|
|
|
class HTMLComboboxAccessible final : public AccessibleWrap
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum { eAction_Click = 0 };
|
|
|
|
|
2012-06-06 03:27:46 -07:00
|
|
|
HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
|
|
|
virtual ~HTMLComboboxAccessible() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void Shutdown() override;
|
|
|
|
virtual void Description(nsString& aDescription) override;
|
|
|
|
virtual void Value(nsString& aValue) override;
|
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeState() override;
|
|
|
|
virtual void InvalidateChildren() override;
|
|
|
|
virtual bool RemoveChild(Accessible* aChild) override;
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
// ActionAccessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual uint8_t ActionCount() override;
|
|
|
|
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
|
|
|
|
virtual bool DoAction(uint8_t aIndex) override;
|
2011-06-05 12:35:43 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Widgets
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool IsWidget() const override;
|
|
|
|
virtual bool IsActiveWidget() const override;
|
|
|
|
virtual bool AreItemsOperable() const override;
|
|
|
|
virtual Accessible* CurrentItem() override;
|
|
|
|
virtual void SetCurrentItem(Accessible* aItem) override;
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void CacheChildren() override;
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2010-04-23 17:40:51 -07:00
|
|
|
/**
|
2011-09-27 18:46:11 -07:00
|
|
|
* Return selected option.
|
2010-04-23 17:40:51 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* SelectedOption() const;
|
2007-04-18 08:56:29 -07:00
|
|
|
|
|
|
|
private:
|
2012-06-06 03:27:46 -07:00
|
|
|
nsRefPtr<HTMLComboboxListAccessible> mListAccessible;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A class that represents the window that lives to the right
|
|
|
|
* of the drop down button inside the Select. This is the window
|
|
|
|
* that is made visible when the button is pressed.
|
|
|
|
*/
|
2012-06-06 03:27:46 -07:00
|
|
|
class HTMLComboboxListAccessible : public HTMLSelectListAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
HTMLComboboxListAccessible(Accessible* aParent, nsIContent* aContent,
|
2012-06-06 03:27:46 -07:00
|
|
|
DocAccessible* aDoc);
|
|
|
|
virtual ~HTMLComboboxListAccessible() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual nsIFrame* GetFrame() const override;
|
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeState() override;
|
|
|
|
virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override;
|
2011-10-31 17:52:27 -07:00
|
|
|
|
|
|
|
// Widgets
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool IsActiveWidget() const override;
|
|
|
|
virtual bool AreItemsOperable() const override;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-06-06 03:27:46 -07:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|