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

Unified Diff: chrome/renderer/extensions/automation_internal_custom_bindings.cc

Issue 2238613002: Support output for Chrome's native find in ChromeVox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@text_markers
Patch Set: Don't forget to bit shift in SendTreeChanges (checking against cached overall tree filter). Created 4 years, 4 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: chrome/renderer/extensions/automation_internal_custom_bindings.cc
diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
index ad12627f32dc6cf6cfbd84b8659ea17ea46bcb6c..eb126283af4ba53bc01aab6815db7c03275bd188 100644
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
@@ -417,8 +417,7 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings(
ScriptContext* context)
: ObjectBackedNativeHandler(context),
is_active_profile_(true),
- tree_change_observer_overall_filter_(
- api::automation::TREE_CHANGE_OBSERVER_FILTER_NOTREECHANGES) {
+ tree_change_observer_overall_filter_(0) {
// It's safe to use base::Unretained(this) here because these bindings
// will only be called on a valid AutomationInternalCustomBindings instance
// and none of the functions have any side effects.
@@ -787,7 +786,9 @@ void AutomationInternalCustomBindings::AddTreeChangeObserver(
void AutomationInternalCustomBindings::RemoveTreeChangeObserver(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- if (args.Length() != 1 || !args[0]->IsNumber()) {
+ // The argument is an integer key for an object which is automatically
+ // converted to a string.
+ if (args.Length() != 1 || !args[0]->IsString()) {
ThrowInvalidArgumentsException(this);
return;
}
@@ -950,12 +951,9 @@ void AutomationInternalCustomBindings::GetState(
}
void AutomationInternalCustomBindings::UpdateOverallTreeChangeObserverFilter() {
- tree_change_observer_overall_filter_ =
- api::automation::TREE_CHANGE_OBSERVER_FILTER_NOTREECHANGES;
- for (const auto& observer : tree_change_observers_) {
- tree_change_observer_overall_filter_ =
- std::max(observer.filter, tree_change_observer_overall_filter_);
- }
+ tree_change_observer_overall_filter_ = 0;
+ for (const auto& observer : tree_change_observers_)
+ tree_change_observer_overall_filter_ |= 1 << observer.filter;
}
ui::AXNode* AutomationInternalCustomBindings::GetParent(
@@ -1207,20 +1205,29 @@ void AutomationInternalCustomBindings::SendTreeChangeEvent(
if (node->data().HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID))
SendChildTreeIDEvent(tree, node);
- switch (tree_change_observer_overall_filter_) {
- case api::automation::TREE_CHANGE_OBSERVER_FILTER_NOTREECHANGES:
- default:
- return;
- case api::automation::TREE_CHANGE_OBSERVER_FILTER_LIVEREGIONTREECHANGES:
- if (!node->data().HasStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS) &&
- node->data().role != ui::AX_ROLE_ALERT) {
- return;
- }
- break;
- case api::automation::TREE_CHANGE_OBSERVER_FILTER_ALLTREECHANGES:
- break;
+ bool has_filter = false;
+ if (tree_change_observer_overall_filter_ &
+ (1 <<
+ api::automation::TREE_CHANGE_OBSERVER_FILTER_LIVEREGIONTREECHANGES)) {
+ if (node->data().HasStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS) ||
+ node->data().role == ui::AX_ROLE_ALERT) {
+ has_filter = true;
+ }
}
+ if (tree_change_observer_overall_filter_ &
+ (1 << api::automation::TREE_CHANGE_OBSERVER_FILTER_TEXTMARKERCHANGES)) {
+ if (node->data().HasIntListAttribute(ui::AX_ATTR_MARKER_TYPES))
+ has_filter = true;
+ }
+
+ if (tree_change_observer_overall_filter_ &
+ (1 << api::automation::TREE_CHANGE_OBSERVER_FILTER_ALLTREECHANGES))
+ has_filter = true;
+
+ if (!has_filter)
+ return;
+
auto iter = axtree_to_tree_cache_map_.find(tree);
if (iter == axtree_to_tree_cache_map_.end())
return;
@@ -1243,6 +1250,10 @@ void AutomationInternalCustomBindings::SendTreeChangeEvent(
continue;
}
break;
+ case api::automation::TREE_CHANGE_OBSERVER_FILTER_TEXTMARKERCHANGES:
+ if (!node->data().HasIntListAttribute(ui::AX_ATTR_MARKER_TYPES))
+ continue;
+ break;
case api::automation::TREE_CHANGE_OBSERVER_FILTER_ALLTREECHANGES:
break;
}

Powered by Google App Engine
This is Rietveld 408576698