mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1499188 - Make accessibility entry input type an int in bundle message. r=jchen,Jamie
Differential Revision: https://phabricator.services.mozilla.com/D8871 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c7a8a18e88
commit
d220e1c023
@ -6,6 +6,7 @@
|
||||
#include "AccessibleWrap.h"
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
#include "AndroidInputType.h"
|
||||
#include "DocAccessibleWrap.h"
|
||||
#include "IDSet.h"
|
||||
#include "JavaBuiltins.h"
|
||||
@ -286,10 +287,11 @@ AccessibleWrap::CreateBundle(int32_t aParentID,
|
||||
GECKOBUNDLE_PUT(nodeInfo, "rangeInfo", rangeInfo);
|
||||
}
|
||||
|
||||
nsString inputType;
|
||||
nsAccUtils::GetAccAttr(aAttributes, nsGkAtoms::textInputType, inputType);
|
||||
if (!inputType.IsEmpty()) {
|
||||
GECKOBUNDLE_PUT(nodeInfo, "inputType", jni::StringParam(inputType));
|
||||
nsString inputTypeAttr;
|
||||
nsAccUtils::GetAccAttr(aAttributes, nsGkAtoms::textInputType, inputTypeAttr);
|
||||
int32_t inputType = GetInputType(inputTypeAttr);
|
||||
if (inputType) {
|
||||
GECKOBUNDLE_PUT(nodeInfo, "inputType", java::sdk::Integer::ValueOf(inputType));
|
||||
}
|
||||
|
||||
nsString posinset;
|
||||
@ -462,6 +464,36 @@ AccessibleWrap::GetAndroidClass(role aRole)
|
||||
#undef ROLE
|
||||
}
|
||||
|
||||
int32_t
|
||||
AccessibleWrap::GetInputType(const nsString& aInputTypeAttr)
|
||||
{
|
||||
if (aInputTypeAttr.EqualsIgnoreCase("email")) {
|
||||
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
|
||||
}
|
||||
|
||||
if (aInputTypeAttr.EqualsIgnoreCase("number")) {
|
||||
return java::sdk::InputType::TYPE_CLASS_NUMBER;
|
||||
}
|
||||
|
||||
if (aInputTypeAttr.EqualsIgnoreCase("password")) {
|
||||
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_PASSWORD;
|
||||
}
|
||||
|
||||
if (aInputTypeAttr.EqualsIgnoreCase("tel")) {
|
||||
return java::sdk::InputType::TYPE_CLASS_PHONE;
|
||||
}
|
||||
|
||||
if (aInputTypeAttr.EqualsIgnoreCase("text")) {
|
||||
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
|
||||
}
|
||||
|
||||
if (aInputTypeAttr.EqualsIgnoreCase("url")) {
|
||||
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_URI;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleWrap::DOMNodeID(nsString& aDOMNodeID)
|
||||
{
|
||||
|
@ -57,6 +57,8 @@ protected:
|
||||
|
||||
static int32_t GetAndroidClass(role aRole);
|
||||
|
||||
static int32_t GetInputType(const nsString& aInputTypeAttr);
|
||||
|
||||
int32_t mID;
|
||||
|
||||
private:
|
||||
|
@ -333,7 +333,7 @@ public class SessionAccessibility {
|
||||
// Set bundle keys like role and hint
|
||||
Bundle bundle = node.getExtras();
|
||||
if (nodeInfo.containsKey("hint")) {
|
||||
final String hint = nodeInfo.getString("hint");
|
||||
final String hint = nodeInfo.getString("hint");
|
||||
bundle.putCharSequence("AccessibilityNodeInfo.hint", hint);
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
node.setHintText(hint);
|
||||
@ -397,33 +397,7 @@ public class SessionAccessibility {
|
||||
node.setCollectionInfo(collectionInfo);
|
||||
}
|
||||
|
||||
// Set inputType
|
||||
switch (nodeInfo.getString("inputType", "").toLowerCase()) {
|
||||
case "email":
|
||||
node.setInputType(InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);
|
||||
break;
|
||||
case "number":
|
||||
node.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
break;
|
||||
case "password":
|
||||
node.setInputType(InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD);
|
||||
break;
|
||||
case "tel":
|
||||
node.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||
break;
|
||||
case "text":
|
||||
node.setInputType(InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT);
|
||||
break;
|
||||
case "url":
|
||||
node.setInputType(InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_VARIATION_URI);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
node.setInputType(nodeInfo.getInt("inputType"));
|
||||
}
|
||||
|
||||
// SDK 23 and above
|
||||
|
@ -1,3 +1,3 @@
|
||||
# We only use constants from KeyEvent
|
||||
# We only use constants from AccessibilityEvent
|
||||
[android.view.accessibility.AccessibilityEvent = skip:true]
|
||||
<field> = skip:false
|
||||
|
3
widget/android/bindings/AndroidInputType-classes.txt
Normal file
3
widget/android/bindings/AndroidInputType-classes.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# We only use constants from InputType
|
||||
[android.text.InputType = skip:true]
|
||||
<field> = skip:false
|
@ -12,6 +12,7 @@ with Files("**"):
|
||||
generated = [
|
||||
'AccessibilityEvent',
|
||||
'AndroidBuild',
|
||||
'AndroidInputType',
|
||||
'AndroidRect',
|
||||
'JavaBuiltins',
|
||||
'KeyEvent',
|
||||
|
Loading…
x
Reference in New Issue
Block a user