Commit 26399bca authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Match security chip visibility with focus ring

Instantly hides or shows the IconLabelBubbleView separator when focus
rings are available to prevent showing the separator when a focus ring
overlaps it.

Bug: chromium:865029
Change-Id: I21a4c296c1da06b81dc91d66101d46e8ad52ad99
Reviewed-on: https://chromium-review.googlesource.com/1142442
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576358}
parent a24c798a
......@@ -72,6 +72,18 @@ void IconLabelBubbleView::SeparatorView::UpdateOpacity() {
if (!visible())
return;
if (!layer())
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
// When using focus rings are visible we should hide the separator instantly
// when the IconLabelBubbleView is focused. Otherwise we should follow the
// inkdrop.
if (views::PlatformStyle::kPreferFocusRings && owner_->is_focused()) {
layer()->SetOpacity(0.0f);
return;
}
views::InkDrop* ink_drop = owner_->GetInkDrop();
DCHECK(ink_drop);
......@@ -88,10 +100,6 @@ void IconLabelBubbleView::SeparatorView::UpdateOpacity() {
duration = kFadeInDurationMs;
}
if (!layer())
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
if (disable_animation_for_test_) {
layer()->SetOpacity(opacity);
} else {
......@@ -373,6 +381,18 @@ void IconLabelBubbleView::NotifyClick(const ui::Event& event) {
OnActivate(event);
}
void IconLabelBubbleView::OnFocus() {
is_focused_ = true;
separator_view_->UpdateOpacity();
Button::OnFocus();
}
void IconLabelBubbleView::OnBlur() {
is_focused_ = false;
separator_view_->UpdateOpacity();
Button::OnBlur();
}
void IconLabelBubbleView::OnWidgetDestroying(views::Widget* widget) {
widget->RemoveObserver(this);
}
......
......@@ -87,6 +87,8 @@ class IconLabelBubbleView : public views::InkDropObserver,
void OnBubbleCreated(views::Widget* bubble_widget);
bool is_focused() const { return is_focused_; }
protected:
static constexpr int kOpenTimeMS = 150;
......@@ -148,6 +150,8 @@ class IconLabelBubbleView : public views::InkDropObserver,
bool IsTriggerableEvent(const ui::Event& event) override;
bool ShouldUpdateInkDropOnClickCanceled() const override;
void NotifyClick(const ui::Event& event) override;
void OnFocus() override;
void OnBlur() override;
// views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override;
......@@ -182,6 +186,7 @@ class IconLabelBubbleView : public views::InkDropObserver,
views::Label* label_;
views::InkDropContainerView* ink_drop_container_;
SeparatorView* separator_view_;
bool is_focused_ = false;
// The padding of the element that will be displayed after |this|. This value
// is relevant for calculating the amount of space to reserve after the
......
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