Commit 480d1516 authored by Amirhossein Simjour's avatar Amirhossein Simjour Committed by Commit Bot

Scroll support for hosted dialogs in VR

Now that VR supports html <select>, we should send scroll events
to dialogs.

Bug: 836292
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr
Change-Id: I45d44af2069e21bedd0662d3f26ab6c89ff82288
Reviewed-on: https://chromium-review.googlesource.com/1028584
Commit-Queue: Amirhossein Simjour <asimjour@chromium.org>
Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555454}
parent 1badbcec
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/android/vr/vr_shell_delegate.h" #include "chrome/browser/android/vr/vr_shell_delegate.h"
#include "third_party/blink/public/platform/web_gesture_event.h"
#include "third_party/blink/public/platform/web_mouse_event.h" #include "third_party/blink/public/platform/web_mouse_event.h"
using base::android::JavaParamRef; using base::android::JavaParamRef;
...@@ -30,39 +31,8 @@ void VrDialog::SetSize(int width, int height) { ...@@ -30,39 +31,8 @@ void VrDialog::SetSize(int width, int height) {
width_ = width; width_ = width;
height_ = height; height_ = height;
} }
void VrDialog::OnContentEnter(const gfx::PointF& normalized_hit_point) {}
void VrDialog::OnContentLeave() {} void VrDialog::SendGestureToTarget(
void VrDialog::OnContentMove(const gfx::PointF& normalized_hit_point) {
SendGestureToDialog(
MakeMouseEvent(blink::WebInputEvent::kMouseMove, normalized_hit_point));
}
void VrDialog::OnContentDown(const gfx::PointF& normalized_hit_point) {
SendGestureToDialog(
MakeMouseEvent(blink::WebInputEvent::kMouseDown, normalized_hit_point));
}
void VrDialog::OnContentUp(const gfx::PointF& normalized_hit_point) {
SendGestureToDialog(
MakeMouseEvent(blink::WebInputEvent::kMouseUp, normalized_hit_point));
}
void VrDialog::OnContentFlingCancel(
std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) {}
void VrDialog::OnContentScrollBegin(
std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) {}
void VrDialog::OnContentScrollUpdate(
std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) {}
void VrDialog::OnContentScrollEnd(
std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) {}
void VrDialog::SendGestureToDialog(
std::unique_ptr<blink::WebInputEvent> event) { std::unique_ptr<blink::WebInputEvent> event) {
if (!event || !dialog_) if (!event || !dialog_)
return; return;
...@@ -91,4 +61,10 @@ std::unique_ptr<blink::WebMouseEvent> VrDialog::MakeMouseEvent( ...@@ -91,4 +61,10 @@ std::unique_ptr<blink::WebMouseEvent> VrDialog::MakeMouseEvent(
return mouse_event; return mouse_event;
} }
void VrDialog::UpdateGesture(const gfx::PointF& normalized_content_hit_point,
blink::WebGestureEvent& gesture) {
gesture.SetPositionInWidget(
ScalePoint(normalized_content_hit_point, width_, height_));
}
} // namespace vr } // namespace vr
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
using base::android::JavaParamRef; using base::android::JavaParamRef;
namespace vr { namespace vr {
// TODO(bshe): refactor content_input_delegate and vr_dialog so the common
// code can be shared in a more clear way (https://crbug.com/838925).
class VrDialog : public ContentInputDelegate { class VrDialog : public ContentInputDelegate {
public: public:
VrDialog(int width, int height); VrDialog(int width, int height);
...@@ -36,24 +38,14 @@ class VrDialog : public ContentInputDelegate { ...@@ -36,24 +38,14 @@ class VrDialog : public ContentInputDelegate {
ContentInputForwarder* dialog_ = nullptr; ContentInputForwarder* dialog_ = nullptr;
// ContentInputDelegate. // ContentInputDelegate.
void OnContentEnter(const gfx::PointF& normalized_hit_point) override; void SendGestureToTarget(
void OnContentLeave() override; std::unique_ptr<blink::WebInputEvent> event) override;
void OnContentMove(const gfx::PointF& normalized_hit_point) override; void UpdateGesture(const gfx::PointF& normalized_content_hit_point,
void OnContentDown(const gfx::PointF& normalized_hit_point) override; blink::WebGestureEvent& gesture) override;
void OnContentUp(const gfx::PointF& normalized_hit_point) override;
void OnContentFlingCancel(std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) override;
void OnContentScrollBegin(std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) override;
void OnContentScrollUpdate(std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) override;
void OnContentScrollEnd(std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) override;
void SendGestureToDialog(std::unique_ptr<blink::WebInputEvent> event);
std::unique_ptr<blink::WebMouseEvent> MakeMouseEvent( std::unique_ptr<blink::WebMouseEvent> MakeMouseEvent(
blink::WebInputEvent::Type type, blink::WebInputEvent::Type type,
const gfx::PointF& normalized_web_content_location); const gfx::PointF& normalized_web_content_location) override;
int width_; int width_;
int height_; int height_;
......
...@@ -27,7 +27,7 @@ ContentInputDelegate::~ContentInputDelegate() = default; ...@@ -27,7 +27,7 @@ ContentInputDelegate::~ContentInputDelegate() = default;
void ContentInputDelegate::OnContentEnter( void ContentInputDelegate::OnContentEnter(
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
SendGestureToContent( SendGestureToTarget(
MakeMouseEvent(blink::WebInputEvent::kMouseEnter, normalized_hit_point)); MakeMouseEvent(blink::WebInputEvent::kMouseEnter, normalized_hit_point));
} }
...@@ -37,25 +37,25 @@ void ContentInputDelegate::OnContentLeave() { ...@@ -37,25 +37,25 @@ void ContentInputDelegate::OnContentLeave() {
// Layout. Sending a mouse leave event at 0,0 will result continuous // Layout. Sending a mouse leave event at 0,0 will result continuous
// MouseMove events sent to the content if the content keeps relayout itself. // MouseMove events sent to the content if the content keeps relayout itself.
// See crbug.com/762573 for details. // See crbug.com/762573 for details.
SendGestureToContent( SendGestureToTarget(
MakeMouseEvent(blink::WebInputEvent::kMouseLeave, kOutOfBoundsPoint)); MakeMouseEvent(blink::WebInputEvent::kMouseLeave, kOutOfBoundsPoint));
} }
void ContentInputDelegate::OnContentMove( void ContentInputDelegate::OnContentMove(
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
SendGestureToContent( SendGestureToTarget(
MakeMouseEvent(blink::WebInputEvent::kMouseMove, normalized_hit_point)); MakeMouseEvent(blink::WebInputEvent::kMouseMove, normalized_hit_point));
} }
void ContentInputDelegate::OnContentDown( void ContentInputDelegate::OnContentDown(
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
SendGestureToContent( SendGestureToTarget(
MakeMouseEvent(blink::WebInputEvent::kMouseDown, normalized_hit_point)); MakeMouseEvent(blink::WebInputEvent::kMouseDown, normalized_hit_point));
} }
void ContentInputDelegate::OnContentUp( void ContentInputDelegate::OnContentUp(
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
SendGestureToContent( SendGestureToTarget(
MakeMouseEvent(blink::WebInputEvent::kMouseUp, normalized_hit_point)); MakeMouseEvent(blink::WebInputEvent::kMouseUp, normalized_hit_point));
} }
...@@ -87,28 +87,28 @@ void ContentInputDelegate::OnContentFlingCancel( ...@@ -87,28 +87,28 @@ void ContentInputDelegate::OnContentFlingCancel(
std::unique_ptr<blink::WebGestureEvent> gesture, std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
UpdateGesture(normalized_hit_point, *gesture); UpdateGesture(normalized_hit_point, *gesture);
SendGestureToContent(std::move(gesture)); SendGestureToTarget(std::move(gesture));
} }
void ContentInputDelegate::OnContentScrollBegin( void ContentInputDelegate::OnContentScrollBegin(
std::unique_ptr<blink::WebGestureEvent> gesture, std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
UpdateGesture(normalized_hit_point, *gesture); UpdateGesture(normalized_hit_point, *gesture);
SendGestureToContent(std::move(gesture)); SendGestureToTarget(std::move(gesture));
} }
void ContentInputDelegate::OnContentScrollUpdate( void ContentInputDelegate::OnContentScrollUpdate(
std::unique_ptr<blink::WebGestureEvent> gesture, std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
UpdateGesture(normalized_hit_point, *gesture); UpdateGesture(normalized_hit_point, *gesture);
SendGestureToContent(std::move(gesture)); SendGestureToTarget(std::move(gesture));
} }
void ContentInputDelegate::OnContentScrollEnd( void ContentInputDelegate::OnContentScrollEnd(
std::unique_ptr<blink::WebGestureEvent> gesture, std::unique_ptr<blink::WebGestureEvent> gesture,
const gfx::PointF& normalized_hit_point) { const gfx::PointF& normalized_hit_point) {
UpdateGesture(normalized_hit_point, *gesture); UpdateGesture(normalized_hit_point, *gesture);
SendGestureToContent(std::move(gesture)); SendGestureToTarget(std::move(gesture));
} }
void ContentInputDelegate::OnSwapContents(int new_content_id) { void ContentInputDelegate::OnSwapContents(int new_content_id) {
...@@ -123,7 +123,7 @@ void ContentInputDelegate::UpdateGesture( ...@@ -123,7 +123,7 @@ void ContentInputDelegate::UpdateGesture(
content_tex_css_height_)); content_tex_css_height_));
} }
void ContentInputDelegate::SendGestureToContent( void ContentInputDelegate::SendGestureToTarget(
std::unique_ptr<blink::WebInputEvent> event) { std::unique_ptr<blink::WebInputEvent> event) {
if (!event || !content_ || ContentGestureIsLocked(event->GetType())) if (!event || !content_ || ContentGestureIsLocked(event->GetType()))
return; return;
......
...@@ -108,18 +108,20 @@ class ContentInputDelegate { ...@@ -108,18 +108,20 @@ class ContentInputDelegate {
void ClearTextInputState(); void ClearTextInputState();
protected:
virtual void UpdateGesture(const gfx::PointF& normalized_content_hit_point,
blink::WebGestureEvent& gesture);
virtual void SendGestureToTarget(std::unique_ptr<blink::WebInputEvent> event);
virtual std::unique_ptr<blink::WebMouseEvent> MakeMouseEvent(
blink::WebInputEvent::Type type,
const gfx::PointF& normalized_web_content_location);
private: private:
enum TextRequestState { enum TextRequestState {
kNoPendingRequest, kNoPendingRequest,
kRequested, kRequested,
kResponseReceived, kResponseReceived,
}; };
void UpdateGesture(const gfx::PointF& normalized_content_hit_point,
blink::WebGestureEvent& gesture);
void SendGestureToContent(std::unique_ptr<blink::WebInputEvent> event);
std::unique_ptr<blink::WebMouseEvent> MakeMouseEvent(
blink::WebInputEvent::Type type,
const gfx::PointF& normalized_web_content_location);
bool ContentGestureIsLocked(blink::WebInputEvent::Type type); bool ContentGestureIsLocked(blink::WebInputEvent::Type type);
void OnWebInputTextChanged(const base::string16& text); void OnWebInputTextChanged(const base::string16& text);
......
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