зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1323449 - implement is() method for testing boolean characteristics, r=smaug
This commit is contained in:
Родитель
e3a96b536f
Коммит
3aacbd7973
|
@ -76,6 +76,33 @@ AccessibleNode::GetStates(nsTArray<nsString>& aStates)
|
|||
mStates->Add(NS_LITERAL_STRING("defunct"));
|
||||
}
|
||||
|
||||
bool
|
||||
AccessibleNode::Is(const Sequence<nsString>& aFlavors)
|
||||
{
|
||||
if (!mIntl) {
|
||||
for (const auto& flavor : aFlavors) {
|
||||
if (!flavor.EqualsLiteral("unknown") && !flavor.EqualsLiteral("defunct")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
nsAutoString role;
|
||||
GetOrCreateAccService()->GetStringRole(mIntl->Role(), role);
|
||||
|
||||
if (!mStates) {
|
||||
mStates = GetOrCreateAccService()->GetStringStates(mIntl->State());
|
||||
}
|
||||
|
||||
for (const auto& flavor : aFlavors) {
|
||||
if (!flavor.Equals(role) && !mStates->Contains(flavor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
nsINode*
|
||||
AccessibleNode::GetDOMNode()
|
||||
{
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
#define A11Y_AOM_ACCESSIBLENODE_H
|
||||
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
|
||||
class nsINode;
|
||||
|
||||
|
@ -41,6 +39,8 @@ public:
|
|||
void GetStates(nsTArray<nsString>& aStates);
|
||||
nsINode* GetDOMNode();
|
||||
|
||||
bool Is(const Sequence<nsString>& aFlavors);
|
||||
|
||||
a11y::Accessible* Internal() const { return mIntl; }
|
||||
|
||||
protected:
|
||||
|
|
|
@ -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 += [
|
||||
|
|
|
@ -77,6 +77,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
ok(anode.is('document', 'focusable'),
|
||||
'correct role and state on an accessible node');
|
||||
|
||||
finish();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -10,4 +10,6 @@ interface AccessibleNode {
|
|||
[Frozen, Cached, Pure]
|
||||
readonly attribute sequence<DOMString> states;
|
||||
readonly attribute Node? DOMNode;
|
||||
|
||||
boolean is(DOMString... states);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче