Fix OSR popup view mouse wheel double event (fixes issue #2547)

This commit is contained in:
Andrei Kurushin 2020-01-08 17:02:22 +02:00 committed by Marshall Greenblatt
parent 8ca0b4580e
commit 95daea76fc
1 changed files with 15 additions and 18 deletions

View File

@ -1051,26 +1051,17 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
const blink::WebMouseWheelEvent& event) { const blink::WebMouseWheelEvent& event) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent"); TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent");
blink::WebMouseWheelEvent mouse_wheel_event(event);
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded(false);
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(
mouse_wheel_event.PositionInWidget().x, event.PositionInWidget().x, event.PositionInWidget().y)) {
mouse_wheel_event.PositionInWidget().y)) { blink::WebMouseWheelEvent popup_mouse_wheel_event(event);
blink::WebMouseWheelEvent popup_mouse_wheel_event(mouse_wheel_event);
popup_mouse_wheel_event.SetPositionInWidget( popup_mouse_wheel_event.SetPositionInWidget(
mouse_wheel_event.PositionInWidget().x - event.PositionInWidget().x - popup_host_view_->popup_position_.x(),
popup_host_view_->popup_position_.x(), event.PositionInWidget().y - popup_host_view_->popup_position_.y());
mouse_wheel_event.PositionInWidget().y -
popup_host_view_->popup_position_.y());
popup_mouse_wheel_event.SetPositionInScreen( popup_mouse_wheel_event.SetPositionInScreen(
popup_mouse_wheel_event.PositionInWidget().x, popup_mouse_wheel_event.PositionInWidget().x,
popup_mouse_wheel_event.PositionInWidget().y); popup_mouse_wheel_event.PositionInWidget().y);
@ -1094,12 +1085,12 @@ 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(mouse_wheel_event.PositionInWidget().x, if (guest_bounds.Contains(event.PositionInWidget().x,
mouse_wheel_event.PositionInWidget().y)) { event.PositionInWidget().y)) {
blink::WebMouseWheelEvent guest_mouse_wheel_event(mouse_wheel_event); blink::WebMouseWheelEvent guest_mouse_wheel_event(event);
guest_mouse_wheel_event.SetPositionInWidget( guest_mouse_wheel_event.SetPositionInWidget(
mouse_wheel_event.PositionInWidget().x - guest_bounds.x(), event.PositionInWidget().x - guest_bounds.x(),
mouse_wheel_event.PositionInWidget().y - guest_bounds.y()); event.PositionInWidget().y - guest_bounds.y());
guest_mouse_wheel_event.SetPositionInScreen( guest_mouse_wheel_event.SetPositionInScreen(
guest_mouse_wheel_event.PositionInWidget().x, guest_mouse_wheel_event.PositionInWidget().x,
guest_mouse_wheel_event.PositionInWidget().y); guest_mouse_wheel_event.PositionInWidget().y);
@ -1112,6 +1103,12 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
} }
if (render_widget_host_ && render_widget_host_->GetView()) { if (render_widget_host_ && render_widget_host_->GetView()) {
blink::WebMouseWheelEvent mouse_wheel_event(event);
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded(false);
mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent(
mouse_wheel_event, false);
if (ShouldRouteEvents()) { if (ShouldRouteEvents()) {
render_widget_host_->delegate() render_widget_host_->delegate()
->GetInputEventRouter() ->GetInputEventRouter()