Index: content/browser/accessibility/browser_accessibility_manager_android.cc |
diff --git a/content/browser/accessibility/browser_accessibility_manager_android.cc b/content/browser/accessibility/browser_accessibility_manager_android.cc |
index 1c4057918678276fecda2308cc0e8ec4aeb3fbb9..c6b1cc20b29a5eca83336d19661497caab7654fa 100644 |
--- a/content/browser/accessibility/browser_accessibility_manager_android.cc |
+++ b/content/browser/accessibility/browser_accessibility_manager_android.cc |
@@ -117,6 +117,11 @@ AccessibilityMatchPredicate PredicateForSearchKey( |
return AllInterestingNodesPredicate; |
} |
+static int32_t potential_popup_unique_id_ = -1; |
+static int32_t current_unique_id_ = -1; |
+static BrowserAccessibility* popup_node_ = nullptr; |
+static ui::AXNode* popup_node_ax_node_ = nullptr; |
+ |
} // anonymous namespace |
namespace aria_strings { |
@@ -327,6 +332,44 @@ BrowserAccessibilityManagerAndroid::GetSupportedHtmlElementTypes( |
return base::android::ConvertUTF16ToJavaString(env, g_all_search_keys.Get()); |
} |
+void BrowserAccessibilityManagerAndroid::OnAutofillPopupDisplayed( |
+ JNIEnv* env, |
+ const JavaParamRef<jobject>& obj) { |
+ if (popup_node_) { |
+ LOG(INFO) << "BrowserAccessibilityManagerAndroid::OnAutofillPopupDisplayed " |
+ "popup_node_->unique_id()=" |
+ << popup_node_->unique_id(); |
+ } else { |
+ popup_node_ = BrowserAccessibility::Create(); |
dmazzoni
2017/03/22 16:13:54
Maybe this should be called popup_dialog_proxy_nod
csashi
2017/03/24 01:32:23
Done.
|
+ popup_node_ax_node_ = new ui::AXNode(nullptr, -1, -1); |
+ ui::AXNodeData ax_node_data; |
+ ax_node_data.role = ui::AX_ROLE_MENU; |
+ ax_node_data.SetName("Autofill"); |
+ ax_node_data.state = 0; |
+ ax_node_data.state |= 1 << ui::AX_STATE_READ_ONLY; |
+ ax_node_data.state |= 1 << ui::AX_STATE_FOCUSABLE; |
+ ax_node_data.state |= 1 << ui::AX_STATE_SELECTABLE; |
+ popup_node_ax_node_->SetData(ax_node_data); |
+ popup_node_->Init(this, popup_node_ax_node_); |
+ } |
+ LOG(INFO) << "current_unique_id_=" << current_unique_id_ |
+ << ", popup_node_->unique_id()=" << popup_node_->unique_id(); |
+ potential_popup_unique_id_ = current_unique_id_; |
dmazzoni
2017/03/22 16:13:54
To clarify, is "potential popup" the node that's t
csashi
2017/03/24 01:32:23
Done.
|
+} |
+void BrowserAccessibilityManagerAndroid::OnAutofillPopupDismissed( |
+ JNIEnv* env, |
+ const JavaParamRef<jobject>& obj) { |
+ if (potential_popup_unique_id_ != -1) { |
+ LOG(INFO) << "Clearing potential_popup_unique_id_=" |
+ << potential_popup_unique_id_; |
+ potential_popup_unique_id_ = -1; |
+ } |
+ if (popup_node_) { |
+ popup_node_->Destroy(); |
+ delete popup_node_ax_node_; |
+ popup_node_ = nullptr; |
+ } |
+} |
jint BrowserAccessibilityManagerAndroid::GetRootId( |
JNIEnv* env, |
const JavaParamRef<jobject>& obj) { |
@@ -340,7 +383,8 @@ jboolean BrowserAccessibilityManagerAndroid::IsNodeValid( |
JNIEnv* env, |
const JavaParamRef<jobject>& obj, |
jint id) { |
- return GetFromUniqueID(id) != NULL; |
+ return GetFromUniqueID(id) != NULL || |
+ (popup_node_ && id == popup_node_->unique_id()); |
} |
void BrowserAccessibilityManagerAndroid::HitTest( |
@@ -518,6 +562,12 @@ jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityEvent( |
jint id, |
jint event_type) { |
BrowserAccessibilityAndroid* node = GetFromUniqueID(id); |
+ LOG(INFO) |
+ << "BrowserAccessibilityManagerAndroid::PopulateAccessibilityEvent id=" |
+ << id << ", event_type=" << event_type |
+ << ", node->unique_id()=" << (node ? node->unique_id() : -1) |
+ << ", node->GetId()=" << (node ? node->GetId() : -1) |
+ << ", node->node()->id()=" << (node ? node->node()->id() : -1); |
if (!node) |
return false; |
@@ -607,6 +657,10 @@ void BrowserAccessibilityManagerAndroid::Click(JNIEnv* env, |
const JavaParamRef<jobject>& obj, |
jint id) { |
BrowserAccessibilityAndroid* node = GetFromUniqueID(id); |
+ LOG(INFO) << "BrowserAccessibilityManagerAndroid::Click id=" << id |
+ << ", node->unique_id()=" << (node ? node->unique_id() : -1) |
+ << ", node->GetId()=" << (node ? node->GetId() : -1) |
+ << ", node->node()->id()=" << (node ? node->node()->id() : -1); |
if (node) |
node->manager()->DoDefaultAction(*node); |
} |
@@ -743,6 +797,18 @@ jint BrowserAccessibilityManagerAndroid::FindElementType( |
jint start_id, |
const JavaParamRef<jstring>& element_type_str, |
jboolean forwards) { |
+ if (start_id == potential_popup_unique_id_) { |
+ LOG(INFO) << "FindElementType start_id=" << start_id |
+ << ", popup_node_->unique_id()=" << popup_node_->unique_id(); |
+ return popup_node_->unique_id(); |
+ } |
+ if (popup_node_ && start_id == popup_node_->unique_id()) { |
+ LOG(INFO) << "FindElementType start_id=" << start_id |
+ << ", popup_node_->unique_id()=" << popup_node_->unique_id() |
+ << ", potential_popup_unique_id_ = " |
+ << potential_popup_unique_id_; |
+ start_id = potential_popup_unique_id_; |
+ } |
BrowserAccessibilityAndroid* start_node = GetFromUniqueID(start_id); |
if (!start_node) |
return 0; |
@@ -772,7 +838,9 @@ jint BrowserAccessibilityManagerAndroid::FindElementType( |
if (tree_search.CountMatches() == 0) |
return 0; |
- return tree_search.GetMatchAtIndex(0)->unique_id(); |
+ jint return_id = tree_search.GetMatchAtIndex(0)->unique_id(); |
+ current_unique_id_ = return_id; |
+ return return_id; |
} |
jboolean BrowserAccessibilityManagerAndroid::NextAtGranularity( |
@@ -918,6 +986,10 @@ void BrowserAccessibilityManagerAndroid::SetAccessibilityFocus( |
const JavaParamRef<jobject>& obj, |
jint id) { |
BrowserAccessibilityAndroid* node = GetFromUniqueID(id); |
+ LOG(INFO) << "BrowserAccessibilityManagerAndroid::SetAccessibilityFocus id=" |
+ << id << ", node->unique_id()=" << (node ? node->unique_id() : -1) |
+ << ", node->GetId()=" << (node ? node->GetId() : -1) |
+ << ", node->node()->id()=" << (node ? node->node()->id() : -1); |
if (!node) |
return; |