mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1313693 - implement iterable states, part2, r=smaug
This commit is contained in:
parent
19b9d0a8d9
commit
6281dc2bac
@ -6,6 +6,7 @@
|
||||
#include "AccessibleNode.h"
|
||||
#include "mozilla/dom/AccessibleNodeBinding.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/DOMStringList.h"
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
@ -61,6 +62,20 @@ AccessibleNode::GetRole(nsAString& aRole)
|
||||
aRole.AssignLiteral("unknown");
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleNode::GetStates(nsTArray<nsString>& aStates)
|
||||
{
|
||||
if (mIntl) {
|
||||
if (!mStates) {
|
||||
mStates = GetOrCreateAccService()->GetStringStates(mIntl->State());
|
||||
}
|
||||
aStates = mStates->StringArray();
|
||||
return;
|
||||
}
|
||||
|
||||
mStates->Add(NS_LITERAL_STRING("defunct"));
|
||||
}
|
||||
|
||||
nsINode*
|
||||
AccessibleNode::GetDOMNode()
|
||||
{
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsINode;
|
||||
|
||||
@ -20,6 +22,7 @@ namespace a11y {
|
||||
|
||||
namespace dom {
|
||||
|
||||
class DOMStringList;
|
||||
struct ParentObject;
|
||||
|
||||
class AccessibleNode : public nsISupports,
|
||||
@ -35,8 +38,11 @@ public:
|
||||
virtual dom::ParentObject GetParentObject() const final;
|
||||
|
||||
void GetRole(nsAString& aRole);
|
||||
void GetStates(nsTArray<nsString>& aStates);
|
||||
nsINode* GetDOMNode();
|
||||
|
||||
a11y::Accessible* Internal() const { return mIntl; }
|
||||
|
||||
protected:
|
||||
AccessibleNode(const AccessibleNode& aCopy) = delete;
|
||||
AccessibleNode& operator=(const AccessibleNode& aCopy) = delete;
|
||||
@ -44,6 +50,7 @@ protected:
|
||||
|
||||
RefPtr<a11y::Accessible> mIntl;
|
||||
RefPtr<nsINode> mDOMNode;
|
||||
RefPtr<dom::DOMStringList> mStates;
|
||||
};
|
||||
|
||||
} // dom
|
||||
|
@ -5,11 +5,11 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'AccessibleNode.h',
|
||||
'AccessibleNode.h'
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'AccessibleNode.cpp',
|
||||
'AccessibleNode.cpp'
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
|
@ -49,6 +49,34 @@
|
||||
is(anode.role, 'document', 'correct role of a document accessible node');
|
||||
is(anode.DOMNode, ifrDoc, 'correct DOM Node of a document accessible node');
|
||||
|
||||
// States may differ depending on the document state, for example, if it is
|
||||
// loaded or is loading still.
|
||||
var states = null;
|
||||
switch (anode.states.length) {
|
||||
case 5:
|
||||
states = [
|
||||
'readonly', 'focusable', 'opaque', 'enabled', 'sensitive'
|
||||
];
|
||||
break;
|
||||
case 6:
|
||||
states = [
|
||||
'readonly', 'busy', 'focusable', 'opaque', 'enabled', 'sensitive'
|
||||
];
|
||||
break;
|
||||
case 7:
|
||||
states = [
|
||||
'readonly', 'busy', 'focusable', 'opaque', 'stale', 'enabled', 'sensitive'
|
||||
];
|
||||
break;
|
||||
default:
|
||||
ok(false, 'Unexpected amount of states');
|
||||
}
|
||||
if (states) {
|
||||
for (var i = 0; i < states.length; i++) {
|
||||
is(anode.states[i], states[i], `${states[i]} state is expected at ${i}th index`);
|
||||
}
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
</script>
|
||||
|
@ -7,5 +7,7 @@
|
||||
[Pref="accessibility.AOM.enabled"]
|
||||
interface AccessibleNode {
|
||||
readonly attribute DOMString role;
|
||||
[Frozen, Cached, Pure]
|
||||
readonly attribute sequence<DOMString> states;
|
||||
readonly attribute Node? DOMNode;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user