Commit 599362e8 authored by Wojciech Dzierżanowski's avatar Wojciech Dzierżanowski Committed by Chromium LUCI CQ

Simplify visibility changes of SkipAdLabelButton, TrackImageButton

The custom visibility handling was introduced in
https://chromium-review.googlesource.com/c/chromium/src/+/1443011.  The
accessibility issue (tooltip shown for an invisible label) does not
reproduce anymore.  The issue of interfering with dragging is still
there, so we keep the workaround for that.

Bug: 985303
Change-Id: I2a8380aa68c7bebe837246b672625d21b774cdb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575026
Commit-Queue: Wojciech Dzierżanowski <wdzierzanowski@opera.com>
Reviewed-by: default avatarFrançois Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#835650}
parent 84ac0586
......@@ -554,15 +554,11 @@ void OverlayWindowViews::UpdateControlsVisibility(bool is_visible) {
GetControlsScrimLayer()->SetVisible(is_visible);
GetCloseControlsLayer()->SetVisible(is_visible);
GetBackToTabControlsLayer()->SetVisible(is_visible);
previous_track_controls_view_->ToggleVisibility(is_visible &&
previous_track_controls_view_->SetVisible(is_visible &&
show_previous_track_button_);
play_pause_controls_view_->SetVisible(is_visible && show_play_pause_button_);
next_track_controls_view_->ToggleVisibility(is_visible &&
show_next_track_button_);
// We need to do more than usual visibility change because otherwise control
// is accessible via accessibility tools.
skip_ad_controls_view_->ToggleVisibility(is_visible && show_skip_ad_button_);
next_track_controls_view_->SetVisible(is_visible && show_next_track_button_);
skip_ad_controls_view_->SetVisible(is_visible && show_skip_ad_button_);
#if BUILDFLAG(IS_CHROMEOS_ASH)
GetResizeHandleLayer()->SetVisible(is_visible);
......
......@@ -46,10 +46,11 @@ void SkipAdLabelButton::SetPosition(const gfx::Size& size) {
size.height() - kSkipAdButtonHeight - kSkipAdButtonMarginBottom));
}
void SkipAdLabelButton::ToggleVisibility(bool is_visible) {
layer()->SetVisible(is_visible);
SetEnabled(is_visible);
SetSize(is_visible ? gfx::Size(kSkipAdButtonWidth, kSkipAdButtonHeight)
void SkipAdLabelButton::SetVisible(bool visible) {
// We need to do more than the usual visibility change because otherwise the
// overlay window cannot be dragged when grabbing within the label area.
LabelButton::SetVisible(visible);
SetSize(visible ? gfx::Size(kSkipAdButtonWidth, kSkipAdButtonHeight)
: gfx::Size());
}
......
......@@ -14,13 +14,12 @@ namespace views {
class SkipAdLabelButton : public views::LabelButton {
public:
explicit SkipAdLabelButton(PressedCallback callback);
~SkipAdLabelButton() override = default;
// Sets the position of itself with an offset from the given window size.
void SetPosition(const gfx::Size& size);
// Toggle visibility.
void ToggleVisibility(bool is_visible);
// Overridden from views::View.
void SetVisible(bool is_visible) override;
private:
DISALLOW_COPY_AND_ASSIGN(SkipAdLabelButton);
......
......@@ -37,8 +37,11 @@ TrackImageButton::TrackImageButton(PressedCallback callback,
SetInstallFocusRingOnFocus(true);
}
gfx::Size TrackImageButton::GetLastVisibleSize() const {
return size().IsEmpty() ? last_visible_size_ : size();
void TrackImageButton::SetVisible(bool visible) {
// We need to do more than the usual visibility change because otherwise the
// overlay window cannot be dragged when grabbing within the button area.
ImageButton::SetVisible(visible);
SetSize(visible ? last_visible_size_ : gfx::Size());
}
void TrackImageButton::OnBoundsChanged(const gfx::Rect&) {
......@@ -46,10 +49,4 @@ void TrackImageButton::OnBoundsChanged(const gfx::Rect&) {
last_visible_size_ = size();
}
void TrackImageButton::ToggleVisibility(bool is_visible) {
SetVisible(is_visible);
SetEnabled(is_visible);
SetSize(is_visible ? GetLastVisibleSize() : gfx::Size());
}
} // namespace views
......@@ -20,13 +20,9 @@ class TrackImageButton : public views::ImageButton {
explicit TrackImageButton(PressedCallback callback,
const gfx::VectorIcon& icon,
base::string16 label);
~TrackImageButton() override = default;
// Get button size when visible.
gfx::Size GetLastVisibleSize() const;
// Toggle visibility.
void ToggleVisibility(bool is_visible);
// Overridden from views::View.
void SetVisible(bool is_visible) override;
protected:
// Overridden from views::View.
......
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