Bug 1628418 - ARIA reflection: implement AriaAttributes interface r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D71771
This commit is contained in:
Alexander Surkov 2020-04-22 11:32:18 +00:00
parent bd25b19977
commit 57f209298d
5 changed files with 202 additions and 8 deletions

View File

@ -157,6 +157,16 @@ class Grid;
} \
}
#define REFLECT_NULLABLE_DOMSTRING_ATTR(method, attr) \
void Get##method(nsAString& aValue) const { \
if (!GetAttr(nsGkAtoms::attr, aValue)) { \
SetDOMStringToNull(aValue); \
} \
} \
void Set##method(const nsAString& aValue, ErrorResult& aRv) { \
SetAttr(nsGkAtoms::attr, aValue, aRv); \
}
class Element : public FragmentOrElement {
public:
#ifdef MOZILLA_INTERNAL_API
@ -543,14 +553,50 @@ class Element : public FragmentOrElement {
}
// AccessibilityRole
void GetRole(nsAString& aValue) const {
if (!GetAttr(nsGkAtoms::role, aValue)) {
SetDOMStringToNull(aValue);
}
}
void SetRole(const nsAString& aValue, ErrorResult& aRv) {
SetAttr(nsGkAtoms::role, aValue, aRv);
}
REFLECT_NULLABLE_DOMSTRING_ATTR(Role, role)
// AriaAttributes
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaAtomic, aria_atomic)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaAutoComplete, aria_autocomplete)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaBusy, aria_busy)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaChecked, aria_checked)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColCount, aria_colcount)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColIndex, aria_colindex)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColIndexText, aria_colindextext)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColSpan, aria_colspan)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaCurrent, aria_current)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaDescription, aria_description)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaDisabled, aria_disabled)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaExpanded, aria_expanded)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaHasPopup, aria_haspopup)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaHidden, aria_hidden)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaInvalid, aria_invalid)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaKeyShortcuts, aria_keyshortcuts)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaLabel, aria_label)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaLevel, aria_level)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaLive, aria_live)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaModal, aria_modal)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaMultiLine, aria_multiline)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaMultiSelectable, aria_multiselectable)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaOrientation, aria_orientation)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaPlaceholder, aria_placeholder)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaPosInSet, aria_posinset)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaPressed, aria_pressed)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaReadOnly, aria_readonly)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRelevant, aria_relevant)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRequired, aria_required)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRoleDescription, aria_roledescription)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowCount, aria_rowcount)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowIndex, aria_rowindex)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowIndexText, aria_rowindextext)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowSpan, aria_rowspan)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaSelected, aria_selected)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaSetSize, aria_setsize)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaSort, aria_sort)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueMax, aria_valuemax)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueMin, aria_valuemin)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueNow, aria_valuenow)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueText, aria_valuetext)
protected:
/**

View File

@ -0,0 +1,136 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* https://rawgit.com/w3c/aria/master/#AriaAttributes
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface mixin AriaAttributes {
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaAtomic;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaAutoComplete;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaBusy;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaChecked;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaColCount;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaColIndex;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaColIndexText;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaColSpan;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaCurrent;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaDescription;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaDisabled;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaExpanded;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaHasPopup;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaHidden;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaInvalid;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaKeyShortcuts;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaLabel;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaLevel;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaLive;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaModal;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaMultiLine;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaMultiSelectable;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaOrientation;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaPlaceholder;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaPosInSet;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaPressed;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaReadOnly;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaRelevant;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaRequired;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaRoleDescription;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaRowCount;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaRowIndex;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaRowIndexText;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaRowSpan;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaSelected;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaSetSize;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaSort;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaValueMax;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaValueMin;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaValueNow;
[Pref="accessibility.ARIAReflection.enabled", CEReactions, SetterThrows]
attribute DOMString? ariaValueText;
};

View File

@ -287,6 +287,7 @@ Element includes ParentNode;
Element includes Animatable;
Element includes GeometryUtils;
Element includes AccessibilityRole;
Element includes AriaAttributes;
// https://fullscreen.spec.whatwg.org/#api
partial interface Element {

View File

@ -16,6 +16,9 @@ with Files("AccessibleNode.webidl"):
with Files("AccessibilityRole.webidl"):
BUG_COMPONENT = ("Core", "Disability Access APIs")
with Files("AriaAttributes.webidl"):
BUG_COMPONENT = ("Core", "Disability Access APIs")
with Files("Addon*"):
BUG_COMPONENT = ("Toolkit", "Add-ons Manager")
@ -1133,4 +1136,5 @@ if CONFIG['ACCESSIBILITY']:
WEBIDL_FILES += [
'AccessibilityRole.webidl',
'AccessibleNode.webidl',
'AriaAttributes.webidl',
]

View File

@ -2296,14 +2296,21 @@ STATIC_ATOMS = [
Atom("application", "application"),
Atom("aria_colcount", "aria-colcount"),
Atom("aria_colindex", "aria-colindex"),
Atom("aria_colindextext", "aria-colindextext"),
Atom("aria_colspan", "aria-colspan"),
Atom("aria_details", "aria-details"),
Atom("aria_errormessage", "aria-errormessage"),
Atom("aria_grabbed", "aria-grabbed"),
Atom("aria_keyshortcuts", "aria-keyshortcuts"),
Atom("aria_label", "aria-label"),
Atom("aria_modal", "aria-modal"),
Atom("aria_orientation", "aria-orientation"),
Atom("aria_placeholder", "aria-placeholder"),
Atom("aria_roledescription", "aria-roledescription"),
Atom("aria_rowcount", "aria-rowcount"),
Atom("aria_rowindex", "aria-rowindex"),
Atom("aria_rowindextext", "aria-rowindextext"),
Atom("aria_rowspan", "aria-rowspan"),
Atom("aria_valuetext", "aria-valuetext"),
Atom("auto_generated", "auto-generated"),
Atom("banner", "banner"),