Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: chrome/browser/android/vr_shell/vr_shell_gl.cc

Issue 2688813004: Enable scrolling of UI elements. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell_gl.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
index 0277e5bd2d4c50c63eae9f2f71326bb90b7abaf3..1ebd6b2b0e1eb5f0e9c5a6ca26500cf563a1ce67 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -528,8 +528,19 @@ void VrShellGl::UpdateController(const gvr::Vec3f& forward_vector) {
target_point_ = plane_intersection_point;
target_element_ = plane.get();
- input_target = (plane->fill == Fill::CONTENT) ? InputTarget::CONTENT
- : InputTarget::UI;
+ // For now treat UI elements, which do not show web content, as NONE input
+ // targets since they cannot make use of the input anyway.
+ switch (plane->fill) {
+ case Fill::CONTENT:
+ input_target = InputTarget::CONTENT;
+ break;
+ case Fill::SPRITE:
+ input_target = InputTarget::UI;
+ break;
+ default:
+ input_target = InputTarget::NONE;
+ break;
+ }
}
}
SendEventsToTarget(input_target, pixel_x, pixel_y);
@@ -552,22 +563,64 @@ void VrShellGl::SendEventsToTarget(InputTarget input_target,
gesture_list.push_back(std::move(event));
}
+ // Make sure the user can switch to another input target while scrolling. To
+ // make this switch work we have to send an artificial scroll end event to the
+ // previous target and an artificial scroll begin event to the new target.
+ // Otherwise we will crash.
cjgrant 2017/02/13 15:54:51 No need for the last line here, it's implied.
tiborg 2017/02/13 22:15:26 I reset this due to changes in the scrolling behav
+ if (is_scrolling_ && current_input_target_ != input_target) {
+ if (current_input_target_ != InputTarget::NONE) {
+ // End the scrolling on the previous target.
mthiesse 2017/02/13 15:47:08 Can you merge these two blocks with the "// Hover
cjgrant 2017/02/13 15:54:51 +1. Anything that makes switching input target fro
tiborg 2017/02/13 22:15:26 I reset this due to changes in the scrolling behav
+ std::unique_ptr<WebGestureEvent> scrollEndEvent(
+ new WebGestureEvent(WebInputEvent::GestureScrollEnd,
+ WebInputEvent::NoModifiers, timestamp));
+ scrollEndEvent->sourceDevice = blink::WebGestureDeviceTouchpad;
+ SendGesture(current_input_target_, std::move(scrollEndEvent));
+ }
+ if (input_target != InputTarget::NONE) {
+ // Start scrolling on the new target.
+ std::unique_ptr<WebGestureEvent> scrollBeginEvent(
+ new WebGestureEvent(WebInputEvent::GestureScrollBegin,
+ WebInputEvent::NoModifiers, timestamp));
+ scrollBeginEvent->sourceDevice = blink::WebGestureDeviceTouchpad;
+ scrollBeginEvent->x = pixel_x;
+ scrollBeginEvent->y = pixel_y;
+ SendGesture(input_target, std::move(scrollBeginEvent));
+ }
+ }
+
for (const auto& gesture : gesture_list) {
+ gesture->x = pixel_x;
+ gesture->y = pixel_y;
+ auto movableGesture = base::WrapUnique(new WebGestureEvent(*gesture));
+
switch (gesture->type()) {
case WebInputEvent::GestureScrollBegin:
+ is_scrolling_ = true;
+ if (input_target != InputTarget::NONE) {
+ SendGesture(input_target, std::move(movableGesture));
+ }
+ break;
case WebInputEvent::GestureScrollUpdate:
+ if (input_target != InputTarget::NONE) {
+ SendGesture(input_target, std::move(movableGesture));
+ }
+ break;
case WebInputEvent::GestureScrollEnd:
+ if (input_target != InputTarget::NONE) {
+ SendGesture(input_target, std::move(movableGesture));
+ }
+ is_scrolling_ = false;
+ break;
case WebInputEvent::GestureFlingCancel:
case WebInputEvent::GestureFlingStart:
- SendGesture(InputTarget::CONTENT,
- base::WrapUnique(new WebGestureEvent(*gesture)));
+ if (input_target != InputTarget::NONE) {
+ SendGesture(input_target, std::move(movableGesture));
+ }
break;
case WebInputEvent::GestureTapDown:
- gesture->x = pixel_x;
- gesture->y = pixel_y;
- if (input_target != InputTarget::NONE)
- SendGesture(input_target,
- base::WrapUnique(new WebGestureEvent(*gesture)));
+ if (input_target != InputTarget::NONE) {
+ SendGesture(input_target, std::move(movableGesture));
+ }
break;
case WebInputEvent::Undefined:
break;
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698