Commit 70809a45 authored by Kevin Bailey's avatar Kevin Bailey Committed by Commit Bot

[omnibox] Narrow tab switch button IsSelected behavior

Previously OmniboxTabSwitchButton::IsSelected() wasn't asking if
*this* result was selected, only if "the tab switch button" was
focused. This could refer to another result. This change narrows
the implementation of IsSelected() to check if this particular
result is also selected.

Bug: 886606
Change-Id: I463151848e6cefdbe3afa360d3dbc0e03d2c40ee
Reviewed-on: https://chromium-review.googlesource.com/1234033Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Kevin Bailey <krb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592825}
parent 903f480f
...@@ -206,6 +206,10 @@ void OmniboxResultView::OnSelected() { ...@@ -206,6 +206,10 @@ void OmniboxResultView::OnSelected() {
NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true);
} }
bool OmniboxResultView::IsSelected() const {
return model_->IsSelectedIndex(model_index_);
}
OmniboxPartState OmniboxResultView::GetThemeState() const { OmniboxPartState OmniboxResultView::GetThemeState() const {
if (IsSelected()) { if (IsSelected()) {
return is_hovered_ ? OmniboxPartState::HOVERED_AND_SELECTED return is_hovered_ ? OmniboxPartState::HOVERED_AND_SELECTED
...@@ -384,10 +388,6 @@ void OmniboxResultView::SetHovered(bool hovered) { ...@@ -384,10 +388,6 @@ void OmniboxResultView::SetHovered(bool hovered) {
} }
} }
bool OmniboxResultView::IsSelected() const {
return model_->IsSelectedIndex(model_index_);
}
void OmniboxResultView::OpenMatch(WindowOpenDisposition disposition, void OmniboxResultView::OpenMatch(WindowOpenDisposition disposition,
base::TimeTicks match_selection_timestamp) { base::TimeTicks match_selection_timestamp) {
model_->OpenMatch(model_index_, disposition, match_selection_timestamp); model_->OpenMatch(model_index_, disposition, match_selection_timestamp);
......
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/view.h" #include "ui/views/view.h"
class OmniboxMatchCellView;
class OmniboxPopupContentsView; class OmniboxPopupContentsView;
class OmniboxTabSwitchButton;
enum class OmniboxPart; enum class OmniboxPart;
enum class OmniboxPartState; enum class OmniboxPartState;
enum class OmniboxTint; enum class OmniboxTint;
...@@ -31,9 +33,6 @@ namespace gfx { ...@@ -31,9 +33,6 @@ namespace gfx {
class Image; class Image;
} }
class OmniboxMatchCellView;
class OmniboxTabSwitchButton;
class OmniboxResultView : public views::View, class OmniboxResultView : public views::View,
private gfx::AnimationDelegate, private gfx::AnimationDelegate,
public views::ButtonListener { public views::ButtonListener {
...@@ -56,6 +55,9 @@ class OmniboxResultView : public views::View, ...@@ -56,6 +55,9 @@ class OmniboxResultView : public views::View,
// Invoked when this result view has been selected. // Invoked when this result view has been selected.
void OnSelected(); void OnSelected();
// Whether |this| matches the model's selected index.
bool IsSelected() const;
OmniboxPartState GetThemeState() const; OmniboxPartState GetThemeState() const;
OmniboxTint GetTint() const; OmniboxTint GetTint() const;
...@@ -93,9 +95,6 @@ class OmniboxResultView : public views::View, ...@@ -93,9 +95,6 @@ class OmniboxResultView : public views::View,
// Sets the hovered state of this result. // Sets the hovered state of this result.
void SetHovered(bool hovered); void SetHovered(bool hovered);
// Whether |this| matches the model's selected index.
bool IsSelected() const;
// Call model's OpenMatch() with the selected index and provided disposition // Call model's OpenMatch() with the selected index and provided disposition
// and timestamp the match was selected (base::TimeTicks() if unknown). // and timestamp the match was selected (base::TimeTicks() if unknown).
void OpenMatch(WindowOpenDisposition disposition, void OpenMatch(WindowOpenDisposition disposition,
......
...@@ -159,7 +159,8 @@ void OmniboxTabSwitchButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -159,7 +159,8 @@ void OmniboxTabSwitchButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
} }
bool OmniboxTabSwitchButton::IsSelected() const { bool OmniboxTabSwitchButton::IsSelected() const {
return model_->IsButtonSelected(); // Is this result selected and is button selected?
return result_view_->IsSelected() && model_->IsButtonSelected();
} }
SkPath OmniboxTabSwitchButton::GetFocusRingPath() const { SkPath OmniboxTabSwitchButton::GetFocusRingPath() const {
......
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