mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-09 08:38:41 +01:00
Add MouseWheelPhaseHandler for OSR (issue #2214)
This commit is contained in:
parent
96bd993d99
commit
fad6aec5d0
@ -223,6 +223,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
|
||||
is_showing_(!render_widget_host_->is_hidden()),
|
||||
is_destroyed_(false),
|
||||
is_scroll_offset_changed_pending_(false),
|
||||
mouse_wheel_phase_handler_(this),
|
||||
weak_ptr_factory_(this) {
|
||||
DCHECK(render_widget_host_);
|
||||
DCHECK(!render_widget_host_->GetView());
|
||||
@ -1122,21 +1123,32 @@ void CefRenderWidgetHostViewOSR::SendMouseEvent(
|
||||
void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
||||
const blink::WebMouseWheelEvent& event) {
|
||||
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 (browser_impl_.get())
|
||||
browser_impl_->CancelContextMenu();
|
||||
|
||||
if (popup_host_view_) {
|
||||
if (popup_host_view_->popup_position_.Contains(
|
||||
event.PositionInWidget().x, event.PositionInWidget().y)) {
|
||||
blink::WebMouseWheelEvent popup_event(event);
|
||||
popup_event.SetPositionInWidget(
|
||||
event.PositionInWidget().x - popup_host_view_->popup_position_.x(),
|
||||
event.PositionInWidget().y - popup_host_view_->popup_position_.y());
|
||||
popup_event.SetPositionInScreen(popup_event.PositionInWidget().x,
|
||||
popup_event.PositionInWidget().y);
|
||||
mouse_wheel_event.PositionInWidget().x,
|
||||
mouse_wheel_event.PositionInWidget().y)) {
|
||||
blink::WebMouseWheelEvent popup_mouse_wheel_event(mouse_wheel_event);
|
||||
popup_mouse_wheel_event.SetPositionInWidget(
|
||||
mouse_wheel_event.PositionInWidget().x -
|
||||
popup_host_view_->popup_position_.x(),
|
||||
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;
|
||||
} else {
|
||||
// Scrolling outside of the popup widget so destroy it.
|
||||
@ -1155,16 +1167,17 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
||||
}
|
||||
const gfx::Rect& guest_bounds =
|
||||
guest_host_view->render_widget_host_->GetView()->GetViewBounds();
|
||||
if (guest_bounds.Contains(event.PositionInWidget().x,
|
||||
event.PositionInWidget().y)) {
|
||||
blink::WebMouseWheelEvent guest_event(event);
|
||||
guest_event.SetPositionInWidget(
|
||||
event.PositionInWidget().x - guest_bounds.x(),
|
||||
event.PositionInWidget().y - guest_bounds.y());
|
||||
guest_event.SetPositionInScreen(guest_event.PositionInWidget().x,
|
||||
guest_event.PositionInWidget().y);
|
||||
if (guest_bounds.Contains(mouse_wheel_event.PositionInWidget().x,
|
||||
mouse_wheel_event.PositionInWidget().y)) {
|
||||
blink::WebMouseWheelEvent guest_mouse_wheel_event(mouse_wheel_event);
|
||||
guest_mouse_wheel_event.SetPositionInWidget(
|
||||
mouse_wheel_event.PositionInWidget().x - guest_bounds.x(),
|
||||
mouse_wheel_event.PositionInWidget().y - guest_bounds.y());
|
||||
guest_mouse_wheel_event.SetPositionInScreen(
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1174,7 +1187,7 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
||||
if (render_widget_host_ && render_widget_host_->GetView()) {
|
||||
// Direct routing requires that mouse events go directly to the View.
|
||||
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/surfaces/parent_local_surface_id_allocator.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 "ui/compositor/compositor.h"
|
||||
|
||||
@ -369,6 +370,8 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
gfx::Vector2dF last_scroll_offset_;
|
||||
bool is_scroll_offset_changed_pending_;
|
||||
|
||||
content::MouseWheelPhaseHandler mouse_wheel_phase_handler_;
|
||||
|
||||
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_ =
|
||||
nullptr;
|
||||
|
||||
|
@ -12,6 +12,27 @@ index 6f32f97e3f92..66da6d5cec53 100644
|
||||
public:
|
||||
explicit ContentServiceManagerMainDelegate(const ContentMainParams& params);
|
||||
~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
|
||||
index 20d1994e156e..45102558569f 100644
|
||||
--- third_party/blink/renderer/controller/BUILD.gn
|
||||
|
Loading…
x
Reference in New Issue
Block a user