mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add MouseWheelPhaseHandler for OSR (issue #2214)
This commit is contained in:
committed by
Marshall Greenblatt
parent
96bd993d99
commit
fad6aec5d0
@@ -223,6 +223,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
|
|||||||
is_showing_(!render_widget_host_->is_hidden()),
|
is_showing_(!render_widget_host_->is_hidden()),
|
||||||
is_destroyed_(false),
|
is_destroyed_(false),
|
||||||
is_scroll_offset_changed_pending_(false),
|
is_scroll_offset_changed_pending_(false),
|
||||||
|
mouse_wheel_phase_handler_(this),
|
||||||
weak_ptr_factory_(this) {
|
weak_ptr_factory_(this) {
|
||||||
DCHECK(render_widget_host_);
|
DCHECK(render_widget_host_);
|
||||||
DCHECK(!render_widget_host_->GetView());
|
DCHECK(!render_widget_host_->GetView());
|
||||||
@@ -1122,21 +1123,32 @@ void CefRenderWidgetHostViewOSR::SendMouseEvent(
|
|||||||
void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
||||||
const blink::WebMouseWheelEvent& event) {
|
const blink::WebMouseWheelEvent& event) {
|
||||||
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent");
|
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent");
|
||||||
|
|
||||||
|
blink::WebMouseWheelEvent mouse_wheel_event(event);
|
||||||
|
|
||||||
|
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded();
|
||||||
|
mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent(
|
||||||
|
mouse_wheel_event, false);
|
||||||
|
|
||||||
if (!IsPopupWidget()) {
|
if (!IsPopupWidget()) {
|
||||||
if (browser_impl_.get())
|
if (browser_impl_.get())
|
||||||
browser_impl_->CancelContextMenu();
|
browser_impl_->CancelContextMenu();
|
||||||
|
|
||||||
if (popup_host_view_) {
|
if (popup_host_view_) {
|
||||||
if (popup_host_view_->popup_position_.Contains(
|
if (popup_host_view_->popup_position_.Contains(
|
||||||
event.PositionInWidget().x, event.PositionInWidget().y)) {
|
mouse_wheel_event.PositionInWidget().x,
|
||||||
blink::WebMouseWheelEvent popup_event(event);
|
mouse_wheel_event.PositionInWidget().y)) {
|
||||||
popup_event.SetPositionInWidget(
|
blink::WebMouseWheelEvent popup_mouse_wheel_event(mouse_wheel_event);
|
||||||
event.PositionInWidget().x - popup_host_view_->popup_position_.x(),
|
popup_mouse_wheel_event.SetPositionInWidget(
|
||||||
event.PositionInWidget().y - popup_host_view_->popup_position_.y());
|
mouse_wheel_event.PositionInWidget().x -
|
||||||
popup_event.SetPositionInScreen(popup_event.PositionInWidget().x,
|
popup_host_view_->popup_position_.x(),
|
||||||
popup_event.PositionInWidget().y);
|
mouse_wheel_event.PositionInWidget().y -
|
||||||
|
popup_host_view_->popup_position_.y());
|
||||||
|
popup_mouse_wheel_event.SetPositionInScreen(
|
||||||
|
popup_mouse_wheel_event.PositionInWidget().x,
|
||||||
|
popup_mouse_wheel_event.PositionInWidget().y);
|
||||||
|
|
||||||
popup_host_view_->SendMouseWheelEvent(popup_event);
|
popup_host_view_->SendMouseWheelEvent(popup_mouse_wheel_event);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Scrolling outside of the popup widget so destroy it.
|
// Scrolling outside of the popup widget so destroy it.
|
||||||
@@ -1155,16 +1167,17 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
|||||||
}
|
}
|
||||||
const gfx::Rect& guest_bounds =
|
const gfx::Rect& guest_bounds =
|
||||||
guest_host_view->render_widget_host_->GetView()->GetViewBounds();
|
guest_host_view->render_widget_host_->GetView()->GetViewBounds();
|
||||||
if (guest_bounds.Contains(event.PositionInWidget().x,
|
if (guest_bounds.Contains(mouse_wheel_event.PositionInWidget().x,
|
||||||
event.PositionInWidget().y)) {
|
mouse_wheel_event.PositionInWidget().y)) {
|
||||||
blink::WebMouseWheelEvent guest_event(event);
|
blink::WebMouseWheelEvent guest_mouse_wheel_event(mouse_wheel_event);
|
||||||
guest_event.SetPositionInWidget(
|
guest_mouse_wheel_event.SetPositionInWidget(
|
||||||
event.PositionInWidget().x - guest_bounds.x(),
|
mouse_wheel_event.PositionInWidget().x - guest_bounds.x(),
|
||||||
event.PositionInWidget().y - guest_bounds.y());
|
mouse_wheel_event.PositionInWidget().y - guest_bounds.y());
|
||||||
guest_event.SetPositionInScreen(guest_event.PositionInWidget().x,
|
guest_mouse_wheel_event.SetPositionInScreen(
|
||||||
guest_event.PositionInWidget().y);
|
guest_mouse_wheel_event.PositionInWidget().x,
|
||||||
|
guest_mouse_wheel_event.PositionInWidget().y);
|
||||||
|
|
||||||
guest_host_view->SendMouseWheelEvent(guest_event);
|
guest_host_view->SendMouseWheelEvent(guest_mouse_wheel_event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1174,7 +1187,7 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
|||||||
if (render_widget_host_ && render_widget_host_->GetView()) {
|
if (render_widget_host_ && render_widget_host_->GetView()) {
|
||||||
// Direct routing requires that mouse events go directly to the View.
|
// Direct routing requires that mouse events go directly to the View.
|
||||||
render_widget_host_->GetView()->ProcessMouseWheelEvent(
|
render_widget_host_->GetView()->ProcessMouseWheelEvent(
|
||||||
event, ui::LatencyInfo(ui::SourceEventType::WHEEL));
|
mouse_wheel_event, ui::LatencyInfo(ui::SourceEventType::WHEEL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "components/viz/common/frame_sinks/begin_frame_source.h"
|
#include "components/viz/common/frame_sinks/begin_frame_source.h"
|
||||||
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
||||||
#include "content/browser/renderer_host/delegated_frame_host.h"
|
#include "content/browser/renderer_host/delegated_frame_host.h"
|
||||||
|
#include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||||
#include "ui/compositor/compositor.h"
|
#include "ui/compositor/compositor.h"
|
||||||
|
|
||||||
@@ -369,6 +370,8 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
|||||||
gfx::Vector2dF last_scroll_offset_;
|
gfx::Vector2dF last_scroll_offset_;
|
||||||
bool is_scroll_offset_changed_pending_;
|
bool is_scroll_offset_changed_pending_;
|
||||||
|
|
||||||
|
content::MouseWheelPhaseHandler mouse_wheel_phase_handler_;
|
||||||
|
|
||||||
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_ =
|
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_ =
|
||||||
nullptr;
|
nullptr;
|
||||||
|
|
||||||
|
@@ -12,6 +12,27 @@ index 6f32f97e3f92..66da6d5cec53 100644
|
|||||||
public:
|
public:
|
||||||
explicit ContentServiceManagerMainDelegate(const ContentMainParams& params);
|
explicit ContentServiceManagerMainDelegate(const ContentMainParams& params);
|
||||||
~ContentServiceManagerMainDelegate() override;
|
~ContentServiceManagerMainDelegate() override;
|
||||||
|
diff --git content/browser/renderer_host/input/mouse_wheel_phase_handler.h content/browser/renderer_host/input/mouse_wheel_phase_handler.h
|
||||||
|
index 305095fc420e..f5ca4eda4a66 100644
|
||||||
|
--- content/browser/renderer_host/input/mouse_wheel_phase_handler.h
|
||||||
|
+++ content/browser/renderer_host/input/mouse_wheel_phase_handler.h
|
||||||
|
@@ -7,6 +7,7 @@
|
||||||
|
|
||||||
|
#include "base/timer/timer.h"
|
||||||
|
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
||||||
|
+#include "content/common/content_export.h"
|
||||||
|
#include "content/public/common/input_event_ack_state.h"
|
||||||
|
#include "third_party/blink/public/platform/web_mouse_wheel_event.h"
|
||||||
|
|
||||||
|
@@ -55,7 +56,7 @@ enum class FirstScrollUpdateAckState {
|
||||||
|
// The MouseWheelPhaseHandler is responsible for adding the proper phase to
|
||||||
|
// wheel events. Phase information is necessary for wheel scrolling since it
|
||||||
|
// shows the start and end of a scrolling sequence.
|
||||||
|
-class MouseWheelPhaseHandler {
|
||||||
|
+class CONTENT_EXPORT MouseWheelPhaseHandler {
|
||||||
|
public:
|
||||||
|
MouseWheelPhaseHandler(RenderWidgetHostViewBase* const host_view);
|
||||||
|
~MouseWheelPhaseHandler() {}
|
||||||
diff --git third_party/blink/renderer/controller/BUILD.gn third_party/blink/renderer/controller/BUILD.gn
|
diff --git third_party/blink/renderer/controller/BUILD.gn third_party/blink/renderer/controller/BUILD.gn
|
||||||
index 20d1994e156e..45102558569f 100644
|
index 20d1994e156e..45102558569f 100644
|
||||||
--- third_party/blink/renderer/controller/BUILD.gn
|
--- third_party/blink/renderer/controller/BUILD.gn
|
||||||
|
Reference in New Issue
Block a user