Commit 35a52924 authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Revert "Floating Keyboard stops propagation of drag handle events"

This reverts commit 6b3d6841.

Reason for revert: Please refer to crbug.com/831521 . We need to pass tap events in the drag handle.

Original change's description:
> Floating Keyboard stops propagation of drag handle events
> 
> If a touch/mouse event occurs and it is interpreted as a floating
> keyboard drag event, do not propagate the event to the javascript
> keyboard extension as there is no reason to.
> 
> This was causing the drag event to cause the gesture swiping to be
> active while dragging the keyboard around, particularly if the keyboard
> was bounded to the bottom of the screen and the user's finger is able
> to move around on the keys while still moving the keyboard (see
> attached bug for repro/video).
> 
> Bug: 826078
> Change-Id: I40c859f979d41a5d61e88ff0bd41808dcf3940c2
> Reviewed-on: https://chromium-review.googlesource.com/997195
> Reviewed-by: Yuichiro Hanada <yhanada@chromium.org>
> Commit-Queue: Blake O'Hare <blakeo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#548374}

TBR=yhanada@chromium.org,blakeo@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 826078
Bug: 831521
Change-Id: I9dded92a6e7b2ec1f97ebd169c463686c23d5d7c
Reviewed-on: https://chromium-review.googlesource.com/1006715
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549862}
parent 58a1a768
......@@ -64,8 +64,7 @@ class KEYBOARD_EXPORT ContainerBehavior {
virtual void SavePosition(const gfx::Rect& keyboard_bounds,
const gfx::Size& screen_size) = 0;
// Returns true if propagation should be stopped.
virtual bool HandlePointerEvent(const ui::LocatedEvent& event,
virtual void HandlePointerEvent(const ui::LocatedEvent& event,
const gfx::Rect& display_bounds) = 0;
virtual ContainerType GetType() const = 0;
......
......@@ -180,7 +180,7 @@ bool ContainerFloatingBehavior::IsDragHandle(
return draggable_area_.Contains(offset.x(), offset.y());
}
bool ContainerFloatingBehavior::HandlePointerEvent(
void ContainerFloatingBehavior::HandlePointerEvent(
const ui::LocatedEvent& event,
const gfx::Rect& display_bounds) {
// Cannot call UI-backed operations without a KeyboardController
......@@ -193,7 +193,7 @@ bool ContainerFloatingBehavior::HandlePointerEvent(
// Don't handle events if this runs in a partially initialized state.
if (keyboard_bounds.height() <= 0)
return false;
return;
ui::PointerId pointer_id = -1;
if (event.IsTouchEvent()) {
......@@ -201,8 +201,6 @@ bool ContainerFloatingBehavior::HandlePointerEvent(
pointer_id = te->pointer_details().id;
}
bool handled = false;
const ui::EventType type = event.type();
switch (type) {
case ui::ET_TOUCH_PRESSED:
......@@ -213,14 +211,12 @@ bool ContainerFloatingBehavior::HandlePointerEvent(
!((const ui::MouseEvent*)&event)->IsOnlyLeftMouseButton()) {
// Mouse events are limited to just the left mouse button.
drag_descriptor_ = nullptr;
handled = true;
} else if (!drag_descriptor_) {
// If there is no active drag descriptor, start a new one.
bool drag_started_by_touch = (type == ui::ET_TOUCH_PRESSED);
drag_descriptor_.reset(
new DragDescriptor(keyboard_bounds.origin(), kb_offset,
drag_started_by_touch, pointer_id));
handled = true;
}
break;
......@@ -253,7 +249,6 @@ bool ContainerFloatingBehavior::HandlePointerEvent(
gfx::Rect(new_keyboard_location, keyboard_bounds.size());
controller_->MoveKeyboard(new_bounds);
SavePosition(container->bounds(), display_bounds.size());
handled = true;
}
break;
......@@ -261,7 +256,6 @@ bool ContainerFloatingBehavior::HandlePointerEvent(
drag_descriptor_ = nullptr;
break;
}
return handled;
}
void ContainerFloatingBehavior::SetCanonicalBounds(
......
......@@ -49,7 +49,7 @@ class KEYBOARD_EXPORT ContainerFloatingBehavior : public ContainerBehavior {
const gfx::Size& keyboard_size) const override;
void SavePosition(const gfx::Rect& keyboard_bounds,
const gfx::Size& screen_size) override;
bool HandlePointerEvent(const ui::LocatedEvent& event,
void HandlePointerEvent(const ui::LocatedEvent& event,
const gfx::Rect& display_bounds) override;
void SetCanonicalBounds(aura::Window* container,
const gfx::Rect& display_bounds) override;
......
......@@ -93,11 +93,10 @@ bool ContainerFullWidthBehavior::IsDragHandle(
return false;
}
bool ContainerFullWidthBehavior::HandlePointerEvent(
void ContainerFullWidthBehavior::HandlePointerEvent(
const ui::LocatedEvent& event,
const gfx::Rect& display_bounds) {
// No-op. Nothing special to do for pointer events.
return false;
}
void ContainerFullWidthBehavior::SetCanonicalBounds(
......
......@@ -41,7 +41,7 @@ class KEYBOARD_EXPORT ContainerFullWidthBehavior : public ContainerBehavior {
const gfx::Size& keyboard_size) const override;
void SavePosition(const gfx::Rect& keyboard_bounds,
const gfx::Size& screen_size) override;
bool HandlePointerEvent(const ui::LocatedEvent& event,
void HandlePointerEvent(const ui::LocatedEvent& event,
const gfx::Rect& display_bounds) override;
void SetCanonicalBounds(aura::Window* container,
const gfx::Rect& display_bounds) override;
......
......@@ -779,9 +779,9 @@ bool KeyboardController::IsOverscrollAllowed() const {
return container_behavior_->IsOverscrollAllowed();
}
bool KeyboardController::HandlePointerEvent(ui::LocatedEvent* event) {
return container_behavior_->HandlePointerEvent(
*event, container_->GetRootWindow()->bounds());
void KeyboardController::HandlePointerEvent(const ui::LocatedEvent& event) {
container_behavior_->HandlePointerEvent(
event, container_->GetRootWindow()->bounds());
}
void KeyboardController::SetContainerType(
......
......@@ -167,9 +167,9 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// container behavior.
bool IsOverscrollAllowed() const;
// Handle mouse and touch events on the keyboard. Returns true if the event
// has been handled and propagation should be stopped.
bool HandlePointerEvent(ui::LocatedEvent* event);
// Handle mouse and touch events on the keyboard. The effects of this method
// will not stop propagation to the keyboard extension.
void HandlePointerEvent(const ui::LocatedEvent& event);
// Moves an already loaded keyboard.
void MoveKeyboard(const gfx::Rect new_bounds);
......
......@@ -23,17 +23,17 @@ void KeyboardEventFilter::OnGestureEvent(ui::GestureEvent* event) {
}
void KeyboardEventFilter::OnMouseEvent(ui::MouseEvent* event) {
ProcessPointerEvent(event);
ProcessPointerEvent(*event);
}
void KeyboardEventFilter::OnTouchEvent(ui::TouchEvent* event) {
ProcessPointerEvent(event);
ProcessPointerEvent(*event);
}
void KeyboardEventFilter::ProcessPointerEvent(ui::LocatedEvent* event) {
void KeyboardEventFilter::ProcessPointerEvent(const ui::LocatedEvent& event) {
KeyboardController* controller = KeyboardController::GetInstance();
if (controller && controller->HandlePointerEvent(event))
event->SetHandled();
if (controller)
controller->HandlePointerEvent(event);
}
} // nemespace keyboard
......@@ -25,7 +25,7 @@ class KEYBOARD_EXPORT KeyboardEventFilter : public ui::EventHandler {
void OnMouseEvent(ui::MouseEvent* event) override;
private:
void ProcessPointerEvent(ui::LocatedEvent* event);
void ProcessPointerEvent(const ui::LocatedEvent& event);
DISALLOW_COPY_AND_ASSIGN(KeyboardEventFilter);
};
......
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