Commit 91cccff1 authored by Sara Kato's avatar Sara Kato Committed by Commit Bot

Make GetWindowId to return an optional

Follow-up of crrev/c/1903171 to make GetWindowID() return an
optional. The window_id variable is also an optional.

Bug: None (follow-up CL)
Test: Do not observe crash in crbug/1020413
Change-Id: Ic3dd6a009871c725bbb97e0a565d7eec84e7c362
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930532
Commit-Queue: Sara Kato <sarakato@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719458}
parent 289d7c47
...@@ -581,10 +581,10 @@ void ArcAccessibilityHelperBridge::OnAction( ...@@ -581,10 +581,10 @@ void ArcAccessibilityHelperBridge::OnAction(
if (!tree_source) if (!tree_source)
return; return;
const int window_id = tree_source->GetWindowId(); base::Optional<int32_t> window_id = tree_source->window_id();
if (window_id == ui::AXNode::kInvalidAXID) if (!window_id)
return; return;
action_data->window_id = window_id; action_data->window_id = window_id.value();
switch (data.action) { switch (data.action) {
case ax::mojom::Action::kDoDefault: case ax::mojom::Action::kDoDefault:
......
...@@ -255,14 +255,6 @@ bool AXTreeSourceArc::IsRootOfNodeTree(int32_t id) const { ...@@ -255,14 +255,6 @@ bool AXTreeSourceArc::IsRootOfNodeTree(int32_t id) const {
return !parent_tree_it->second->IsNode(); return !parent_tree_it->second->IsNode();
} }
int32_t AXTreeSourceArc::GetWindowId() const {
if (window_id_.has_value())
return *window_id_;
// |window_id_| could be empty when called after OnNotificationStateChanged,
// but before OnAccessibilityEvent in ArcAccessibilityHelperBridge.
return ui::AXNode::kInvalidAXID;
}
bool AXTreeSourceArc::GetTreeData(ui::AXTreeData* data) const { bool AXTreeSourceArc::GetTreeData(ui::AXTreeData* data) const {
data->tree_id = ax_tree_id(); data->tree_id = ax_tree_id();
if (focused_id_.has_value()) if (focused_id_.has_value())
......
...@@ -73,9 +73,6 @@ class AXTreeSourceArc : public ui::AXTreeSource<AccessibilityInfoDataWrapper*, ...@@ -73,9 +73,6 @@ class AXTreeSourceArc : public ui::AXTreeSource<AccessibilityInfoDataWrapper*,
// parent window). // parent window).
bool IsRootOfNodeTree(int32_t id) const; bool IsRootOfNodeTree(int32_t id) const;
// Gets the window id of this tree.
int32_t GetWindowId() const;
// AXTreeSource: // AXTreeSource:
bool GetTreeData(ui::AXTreeData* data) const override; bool GetTreeData(ui::AXTreeData* data) const override;
AccessibilityInfoDataWrapper* GetRoot() const override; AccessibilityInfoDataWrapper* GetRoot() const override;
...@@ -89,6 +86,9 @@ class AXTreeSourceArc : public ui::AXTreeSource<AccessibilityInfoDataWrapper*, ...@@ -89,6 +86,9 @@ class AXTreeSourceArc : public ui::AXTreeSource<AccessibilityInfoDataWrapper*,
bool is_input_method_window() { return is_input_method_window_; } bool is_input_method_window() { return is_input_method_window_; }
// The window id of this tree.
base::Optional<int32_t> window_id() const { return window_id_; }
private: private:
friend class arc::AXTreeSourceArcTest; friend class arc::AXTreeSourceArcTest;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment