Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: content/browser/accessibility/web_contents_accessibility_android.cc

Issue 2981083002: Migrate BrowserAccessibility windows unique id handling to AXPlatformNodeWin. (Closed)
Patch Set: Use after free no more Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/web_contents_accessibility_android.cc
diff --git a/content/browser/accessibility/web_contents_accessibility_android.cc b/content/browser/accessibility/web_contents_accessibility_android.cc
index 82b82293122fa8bdba65f2ce64e552277ef15bdf..427acc2a3e215f00f8dcb23f61195682ba0290cd 100644
--- a/content/browser/accessibility/web_contents_accessibility_android.cc
+++ b/content/browser/accessibility/web_contents_accessibility_android.cc
@@ -564,7 +564,8 @@ jint WebContentsAccessibilityAndroid::GetRootId(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
if (root_manager_) {
- auto* root = root_manager_->GetRoot();
+ auto* root =
+ static_cast<BrowserAccessibilityAndroid*>(root_manager_->GetRoot());
if (root)
return static_cast<jint>(root->unique_id());
}
@@ -640,12 +641,16 @@ jboolean WebContentsAccessibilityAndroid::PopulateAccessibilityNodeInfo(
return false;
if (node->PlatformGetParent()) {
+ auto* android_node =
+ static_cast<BrowserAccessibilityAndroid*>(node->PlatformGetParent());
Java_WebContentsAccessibility_setAccessibilityNodeInfoParent(
- env, obj, info, node->PlatformGetParent()->unique_id());
+ env, obj, info, android_node->unique_id());
}
for (unsigned i = 0; i < node->PlatformChildCount(); ++i) {
+ auto* android_node =
+ static_cast<BrowserAccessibilityAndroid*>(node->PlatformGetChild(i));
Java_WebContentsAccessibility_addAccessibilityNodeInfoChild(
- env, obj, info, node->PlatformGetChild(i)->unique_id());
+ env, obj, info, android_node->unique_id());
}
Java_WebContentsAccessibility_setAccessibilityNodeInfoBooleanAttributes(
env, obj, info, unique_id, node->IsCheckable(), node->IsChecked(),
@@ -925,7 +930,9 @@ jint WebContentsAccessibilityAndroid::FindElementType(
if (tree_search.CountMatches() == 0)
return 0;
- int32_t element_id = tree_search.GetMatchAtIndex(0)->unique_id();
+ auto* android_node =
+ static_cast<BrowserAccessibilityAndroid*>(tree_search.GetMatchAtIndex(0));
+ int32_t element_id = android_node->unique_id();
// Navigate forwards to the autofill popup's proxy node if focus is currently
// on the element hosting the autofill popup. Once within the popup, a back
@@ -936,7 +943,9 @@ jint WebContentsAccessibilityAndroid::FindElementType(
if (forwards && start_id == g_element_hosting_autofill_popup_unique_id &&
g_autofill_popup_proxy_node) {
g_element_after_element_hosting_autofill_popup_unique_id = element_id;
- return g_autofill_popup_proxy_node->unique_id();
+ auto* android_node =
+ static_cast<BrowserAccessibilityAndroid*>(g_autofill_popup_proxy_node);
+ return android_node->unique_id();
}
return element_id;
@@ -1039,7 +1048,9 @@ void WebContentsAccessibilityAndroid::OnAutofillPopupDisplayed(
g_autofill_popup_proxy_node->Init(root_manager_,
g_autofill_popup_proxy_node_ax_node);
- g_element_hosting_autofill_popup_unique_id = current_focus->unique_id();
+ auto* android_node = static_cast<BrowserAccessibilityAndroid*>(current_focus);
+
+ g_element_hosting_autofill_popup_unique_id = android_node->unique_id();
}
void WebContentsAccessibilityAndroid::OnAutofillPopupDismissed(
@@ -1067,8 +1078,10 @@ jboolean WebContentsAccessibilityAndroid::IsAutofillPopupNode(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
jint unique_id) {
- return g_autofill_popup_proxy_node &&
- g_autofill_popup_proxy_node->unique_id() == unique_id;
+ auto* android_node =
+ static_cast<BrowserAccessibilityAndroid*>(g_autofill_popup_proxy_node);
+
+ return g_autofill_popup_proxy_node && android_node->unique_id() == unique_id;
}
bool WebContentsAccessibilityAndroid::Scroll(JNIEnv* env,
@@ -1085,7 +1098,7 @@ bool WebContentsAccessibilityAndroid::Scroll(JNIEnv* env,
BrowserAccessibilityAndroid* WebContentsAccessibilityAndroid::GetAXFromUniqueID(
int32_t unique_id) {
return static_cast<BrowserAccessibilityAndroid*>(
- BrowserAccessibility::GetFromUniqueID(unique_id));
+ BrowserAccessibilityAndroid::GetFromUniqueId(unique_id));
}
void WebContentsAccessibilityAndroid::UpdateFrameInfo() {
« no previous file with comments | « content/browser/accessibility/browser_accessibility_win_unittest.cc ('k') | ui/accessibility/platform/ax_platform_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698