Commit 06e3ca58 authored by Jiawei Li's avatar Jiawei Li Committed by Commit Bot

[Chromecast] Chromecast support for tap down gestures

- TAP_DOWN is added to CastContentWindow::GestureType
- The gesture detection is attached to the root window and handles
  tap down events. A new JS binding API: onTapDownHandler will be hosted on
  platform
- HandleTapGesture: finger is released after pressed within tap timeout window
  HandleTapDownGesture: finger is pressed

Bug: internal b/75979846
Test: build manually and test whether both tap and tap down handler callback works
Change-Id: Iaefa6df9c7a5284ba27964083fc056bf36cf480a
Reviewed-on: https://chromium-review.googlesource.com/1115418Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Jiawei Li <lijiawei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574373}
parent 00ee7c4e
......@@ -64,7 +64,7 @@ enum class VisibilityPriority {
HIDDEN = 5,
};
enum class GestureType { NO_GESTURE = 0, GO_BACK = 1, TAP = 2 };
enum class GestureType { NO_GESTURE = 0, GO_BACK = 1, TAP = 2, TAP_DOWN = 3 };
// Class that represents the "window" a WebContents is displayed in cast_shell.
// For Linux, this represents an Aura window. For Android, this is a Activity.
......
......@@ -144,15 +144,20 @@ void CastContentWindowAura::HandleSideSwipeContinue(
gesture_dispatcher_->HandleSideSwipeContinue(swipe_origin, touch_location);
}
void CastContentWindowAura::HandleTapGesture(const gfx::Point& touch_location) {
gesture_dispatcher_->HandleTapGesture(touch_location);
}
void CastContentWindowAura::HandleSideSwipeEnd(
CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) {
gesture_dispatcher_->HandleSideSwipeEnd(swipe_origin, touch_location);
}
void CastContentWindowAura::HandleTapDownGesture(
const gfx::Point& touch_location) {
gesture_dispatcher_->HandleTapDownGesture(touch_location);
}
void CastContentWindowAura::HandleTapGesture(const gfx::Point& touch_location) {
gesture_dispatcher_->HandleTapGesture(touch_location);
}
} // namespace shell
} // namespace chromecast
......@@ -44,6 +44,7 @@ class CastContentWindowAura : public CastContentWindow,
const gfx::Point& touch_location) override;
void HandleSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) override;
void HandleTapDownGesture(const gfx::Point& touch_location) override;
void HandleTapGesture(const gfx::Point& touch_location) override;
private:
......
......@@ -77,6 +77,14 @@ void CastGestureDispatcher::HandleSideSwipeEnd(
}
}
void CastGestureDispatcher::HandleTapDownGesture(
const gfx::Point& touch_location) {
if (!delegate_->CanHandleGesture(GestureType::TAP_DOWN)) {
return;
}
delegate_->ConsumeGesture(GestureType::TAP_DOWN);
}
void CastGestureDispatcher::HandleTapGesture(const gfx::Point& touch_location) {
if (!delegate_->CanHandleGesture(GestureType::TAP)) {
return;
......
......@@ -28,6 +28,7 @@ class CastGestureDispatcher : public CastGestureHandler {
const gfx::Point& touch_location) override;
void HandleSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) override;
void HandleTapDownGesture(const gfx::Point& touch_location) override;
void HandleTapGesture(const gfx::Point& touch_location) override;
private:
......
......@@ -37,7 +37,12 @@ class CastGestureHandler {
virtual void HandleSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) {}
// Triggered on the completion of a tap event.
// Triggered on the completion of a tap down event, fired when the
// finger is pressed.
virtual void HandleTapDownGesture(const gfx::Point& touch_location) {}
// Triggered on the completion of a tap event, fire after a press
// followed by a release, within the tap timeout window
virtual void HandleTapGesture(const gfx::Point& touch_location) {}
private:
......
......@@ -149,8 +149,7 @@ void CastSystemGestureEventHandler::OnTouchEvent(ui::TouchEvent* event) {
void CastSystemGestureEventHandler::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP ||
event->type() == ui::ET_GESTURE_TAP_DOWN ||
event->type() == ui::ET_GESTURE_LONG_PRESS) {
event->type() == ui::ET_GESTURE_TAP_DOWN) {
ProcessPressedEvent(event);
}
}
......@@ -161,9 +160,21 @@ void CastSystemGestureEventHandler::ProcessPressedEvent(
return;
}
gfx::Point touch_location(event->location());
for (auto* gesture_handler : gesture_handlers_) {
// Let the subscriber know about the gesture begin.
gesture_handler->HandleTapGesture(touch_location);
// Let the subscriber know about the gesture begin.
switch (event->type()) {
case ui::ET_GESTURE_TAP_DOWN: {
for (auto* gesture_handler : gesture_handlers_) {
gesture_handler->HandleTapDownGesture(touch_location);
}
break;
}
case ui::ET_GESTURE_TAP: {
for (auto* gesture_handler : gesture_handlers_) {
gesture_handler->HandleTapGesture(touch_location);
}
break;
}
default: { return; }
}
}
......
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