mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1486671 - stop using nsIDOMXULCheckboxElement, r=jamie
This commit is contained in:
parent
39a3091a37
commit
e36505da67
@ -4,7 +4,7 @@
|
||||
|
||||
XULMAP_TYPE(browser, OuterDocAccessible)
|
||||
XULMAP_TYPE(button, XULButtonAccessible)
|
||||
XULMAP_TYPE(checkbox, XULCheckboxAccessible)
|
||||
XULMAP_TYPE(checkbox, CheckboxAccessible)
|
||||
XULMAP_TYPE(description, XULLabelAccessible)
|
||||
XULMAP_TYPE(dropMarker, XULDropmarkerAccessible)
|
||||
XULMAP_TYPE(editor, OuterDocAccessible)
|
||||
|
@ -243,7 +243,7 @@ static Accessible* New_HTMLInput(Element* aElement, Accessible* aContext)
|
||||
{
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::checkbox, eIgnoreCase)) {
|
||||
return new HTMLCheckboxAccessible(aElement, aContext->Document());
|
||||
return new CheckboxAccessible(aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::radio, eIgnoreCase)) {
|
||||
@ -1492,7 +1492,7 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
|
||||
}
|
||||
break;
|
||||
case eHTMLCheckboxType:
|
||||
newAcc = new HTMLCheckboxAccessible(aContent, document);
|
||||
newAcc = new CheckboxAccessible(aContent, document);
|
||||
break;
|
||||
case eHTMLComboboxType:
|
||||
newAcc = new HTMLComboboxAccessible(aContent, document);
|
||||
|
@ -909,9 +909,10 @@ public:
|
||||
|
||||
/**
|
||||
* Return true if the accessible state change is processed by handling proper
|
||||
* DOM UI event, if otherwise then false. For example, HTMLCheckboxAccessible
|
||||
* process nsIDocumentObserver::ContentStateChanged instead
|
||||
* 'CheckboxStateChange' event.
|
||||
* DOM UI event, if otherwise then false. For example, CheckboxAccessible
|
||||
* created for HTML:input@type="checkbox" will process
|
||||
* nsIDocumentObserver::ContentStateChanged instead of 'CheckboxStateChange'
|
||||
* event.
|
||||
*/
|
||||
bool NeedsDOMUIEvent() const
|
||||
{ return !(mStateFlags & eIgnoreDOMUIEvent); }
|
||||
|
@ -6,10 +6,10 @@
|
||||
// NOTE: alphabetically ordered
|
||||
|
||||
#include "FormControlAccessible.h"
|
||||
#include "Role.h"
|
||||
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "nsIDOMXULControlElement.h"
|
||||
#include "Role.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
@ -142,6 +142,84 @@ ProgressMeterAccessible<Max>::SetCurValue(double aValue)
|
||||
return false; // progress meters are readonly.
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CheckboxAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
role
|
||||
CheckboxAccessible::NativeRole() const
|
||||
{
|
||||
return roles::CHECKBUTTON;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
CheckboxAccessible::ActionCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
CheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
uint64_t state = NativeState();
|
||||
if (state & states::CHECKED) {
|
||||
aName.AssignLiteral("uncheck");
|
||||
} else if (state & states::MIXED) {
|
||||
aName.AssignLiteral("cycle");
|
||||
} else {
|
||||
aName.AssignLiteral("check");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CheckboxAccessible::DoAction(uint8_t aIndex) const
|
||||
{
|
||||
if (aIndex != eAction_Click) {
|
||||
return false;
|
||||
}
|
||||
DoCommand();
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
CheckboxAccessible::NativeState() const
|
||||
{
|
||||
uint64_t state = LeafAccessible::NativeState();
|
||||
|
||||
state |= states::CHECKABLE;
|
||||
dom::HTMLInputElement* input = dom::HTMLInputElement::FromNode(mContent);
|
||||
if (input) { // HTML:input@type="checkbox"
|
||||
if (input->Indeterminate()) {
|
||||
return state | states::MIXED;
|
||||
}
|
||||
|
||||
if (input->Checked()) {
|
||||
return state | states::CHECKED;
|
||||
}
|
||||
|
||||
} else if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None,
|
||||
nsGkAtoms::checked,
|
||||
nsGkAtoms::_true,
|
||||
eCaseMatters)) { // XUL checkbox
|
||||
return state | states::CHECKED;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CheckboxAccessible: Widgets
|
||||
|
||||
bool
|
||||
CheckboxAccessible::IsWidget() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// RadioButtonAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -46,6 +46,38 @@ protected:
|
||||
virtual ~ProgressMeterAccessible() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checkbox accessible.
|
||||
*/
|
||||
class CheckboxAccessible : public LeafAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
enum { eAction_Click = 0 };
|
||||
|
||||
CheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
LeafAccessible(aContent, aDoc)
|
||||
{
|
||||
// Ignore "CheckboxStateChange" DOM event in lieu of document observer
|
||||
// state change notification.
|
||||
if (aContent->IsHTMLElement()) {
|
||||
mStateFlags |= eIgnoreDOMUIEvent;
|
||||
}
|
||||
}
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole() const override;
|
||||
virtual uint64_t NativeState() const override;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount() const override;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
|
||||
virtual bool DoAction(uint8_t aIndex) const override;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generic class used for radio buttons.
|
||||
*/
|
||||
|
@ -35,75 +35,6 @@ using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLCheckboxAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
role
|
||||
HTMLCheckboxAccessible::NativeRole() const
|
||||
{
|
||||
return roles::CHECKBUTTON;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
HTMLCheckboxAccessible::ActionCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) { // 0 is the magic value for default action
|
||||
uint64_t state = NativeState();
|
||||
if (state & states::CHECKED)
|
||||
aName.AssignLiteral("uncheck");
|
||||
else if (state & states::MIXED)
|
||||
aName.AssignLiteral("cycle");
|
||||
else
|
||||
aName.AssignLiteral("check");
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLCheckboxAccessible::DoAction(uint8_t aIndex) const
|
||||
{
|
||||
if (aIndex != 0)
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
HTMLCheckboxAccessible::NativeState() const
|
||||
{
|
||||
uint64_t state = LeafAccessible::NativeState();
|
||||
|
||||
state |= states::CHECKABLE;
|
||||
HTMLInputElement* input = HTMLInputElement::FromNode(mContent);
|
||||
if (!input)
|
||||
return state;
|
||||
|
||||
if (input->Indeterminate())
|
||||
return state | states::MIXED;
|
||||
|
||||
if (input->Checked())
|
||||
return state | states::CHECKED;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLCheckboxAccessible: Widgets
|
||||
|
||||
bool
|
||||
HTMLCheckboxAccessible::IsWidget() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLRadioButtonAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -18,37 +18,6 @@ namespace a11y {
|
||||
*/
|
||||
typedef ProgressMeterAccessible<1> HTMLProgressMeterAccessible;
|
||||
|
||||
/**
|
||||
* Accessible for HTML input@type="checkbox".
|
||||
*/
|
||||
class HTMLCheckboxAccessible : public LeafAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
enum { eAction_Click = 0 };
|
||||
|
||||
HTMLCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
LeafAccessible(aContent, aDoc)
|
||||
{
|
||||
// Ignore "CheckboxStateChange" DOM event in lieu of document observer
|
||||
// state change notification.
|
||||
mStateFlags |= eIgnoreDOMUIEvent;
|
||||
}
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole() const override;
|
||||
virtual uint64_t NativeState() const override;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount() const override;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
|
||||
virtual bool DoAction(uint8_t aIndex) const override;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Accessible for HTML input@type="radio" element.
|
||||
*/
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "XULMenuAccessible.h"
|
||||
|
||||
#include "nsIDOMXULButtonElement.h"
|
||||
#include "nsIDOMXULCheckboxElement.h"
|
||||
#include "nsIDOMXULMenuListElement.h"
|
||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||
#include "nsIEditor.h"
|
||||
@ -274,71 +273,6 @@ XULDropmarkerAccessible::NativeState() const
|
||||
return DropmarkerOpen(false) ? states::PRESSED : 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// XULCheckboxAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
XULCheckboxAccessible::
|
||||
XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
LeafAccessible(aContent, aDoc)
|
||||
{
|
||||
}
|
||||
|
||||
role
|
||||
XULCheckboxAccessible::NativeRole() const
|
||||
{
|
||||
return roles::CHECKBUTTON;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
XULCheckboxAccessible::ActionCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
XULCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
if (NativeState() & states::CHECKED)
|
||||
aName.AssignLiteral("uncheck");
|
||||
else
|
||||
aName.AssignLiteral("check");
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
XULCheckboxAccessible::DoAction(uint8_t aIndex) const
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
XULCheckboxAccessible::NativeState() const
|
||||
{
|
||||
// Possible states: focused, focusable, unavailable(disabled), checked
|
||||
// Get focus and disable status from base class
|
||||
uint64_t state = LeafAccessible::NativeState();
|
||||
|
||||
state |= states::CHECKABLE;
|
||||
|
||||
// Determine Checked state
|
||||
nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement =
|
||||
do_QueryInterface(mContent);
|
||||
if (xulCheckboxElement) {
|
||||
bool checked = false;
|
||||
xulCheckboxElement->GetChecked(&checked);
|
||||
if (checked) {
|
||||
state |= states::CHECKED;
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// XULGroupboxAccessible
|
||||
|
@ -59,26 +59,6 @@ protected:
|
||||
bool ContainsMenu() const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used for XUL checkbox element.
|
||||
*/
|
||||
class XULCheckboxAccessible : public LeafAccessible
|
||||
{
|
||||
public:
|
||||
enum { eAction_Click = 0 };
|
||||
XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole() const override;
|
||||
virtual uint64_t NativeState() const override;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount() const override;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
|
||||
virtual bool DoAction(uint8_t aIndex) const override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used for XUL dropmarker element.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user