Commit df6d0375 authored by Jennifer Apacible's avatar Jennifer Apacible Committed by Commit Bot

[Picture in Picture] Remove KeyEvent handling.

OverlayWindowViews handled KeyEvents as a workaround for a11y
navigation. Now that the buttons are tab navigable, this is no longer
needed.

OnKeyEvent() also causes some issues if the initially focused button
on the window is the close button, rather than play/pause. This is
determined by the built in view::Views keyboard navigation. Keeping
track of this separately in OverlayWindowViews makes no sense.

Change-Id: Ide8cca038452781790d2d80a9545f1a2a7b474e9
Reviewed-on: https://chromium-review.googlesource.com/1136228Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: apacible <apacible@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575367}
parent 4aba67d2
......@@ -494,35 +494,6 @@ void OverlayWindowViews::OnNativeWidgetWorkspaceChanged() {
// does not trigger this function. http://crbug.com/819673
}
void OverlayWindowViews::OnKeyEvent(ui::KeyEvent* event) {
if (event->type() != ui::ET_KEY_RELEASED)
return;
if (event->key_code() == ui::VKEY_TAB) {
// Switch the control that is currently focused. When the window
// is focused, |focused_control_button_| resets to CONTROL_PLAY_PAUSE.
if (focused_control_button_ == CONTROL_PLAY_PAUSE)
focused_control_button_ = CONTROL_CLOSE;
else
focused_control_button_ = CONTROL_PLAY_PAUSE;
// The controls may be hidden after the window is already in focus, e.g.
// mouse exits the window space. If they are already shown, this is a
// no-op.
UpdateControlsVisibility(true);
event->SetHandled();
} else if (event->key_code() == ui::VKEY_RETURN) {
if (focused_control_button_ == CONTROL_PLAY_PAUSE) {
TogglePlayPause();
} else /* CONTROL_CLOSE */ {
controller_->Close(true /* should_pause_video */);
}
event->SetHandled();
}
}
void OverlayWindowViews::OnMouseEvent(ui::MouseEvent* event) {
switch (event->type()) {
// Only show the media controls when the mouse is hovering over the window.
......@@ -589,9 +560,6 @@ void OverlayWindowViews::OnNativeFocus() {
should_show_controls_ = true;
}
// Reset the first focused control to the play/pause button. This will
// always be called before key events can be handled.
focused_control_button_ = CONTROL_PLAY_PAUSE;
views::Widget::OnNativeFocus();
}
......
......@@ -19,12 +19,6 @@ class ToggleImageButton;
// implemented in views, which will support all desktop platforms.
class OverlayWindowViews : public content::OverlayWindow, public views::Widget {
public:
// The list of control buttons that appear on the window.
enum ControlButton {
CONTROL_PLAY_PAUSE,
CONTROL_CLOSE,
};
explicit OverlayWindowViews(
content::PictureInPictureWindowController* controller);
~OverlayWindowViews() override;
......@@ -48,7 +42,6 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget {
gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override;
void OnNativeWidgetWorkspaceChanged() override;
void OnKeyEvent(ui::KeyEvent* event) override;
void OnMouseEvent(ui::MouseEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
......@@ -133,10 +126,6 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget {
// ensuring factors such as aspect ratio is maintained.
gfx::Size natural_size_;
// The currently focused button on the window. This is used for keeping
// track of focus on the window while tabbing.
ControlButton focused_control_button_;
// Views to be shown.
std::unique_ptr<views::View> window_background_view_;
std::unique_ptr<views::View> video_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