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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_guest.cc

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Rebased, fixed a comment in web_input_event_builders_mac.mm Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/render_widget_host_view_guest.h" 5 #include "content/browser/frame_host/render_widget_host_view_guest.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 DCHECK(guest_->GetOwnerRenderWidgetHostView()); 177 DCHECK(guest_->GetOwnerRenderWidgetHostView());
178 RenderWidgetHost* embedder = 178 RenderWidgetHost* embedder =
179 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost(); 179 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost();
180 if (!embedder->GetView()->HasFocus()) 180 if (!embedder->GetView()->HasFocus())
181 embedder->GetView()->Focus(); 181 embedder->GetView()->Focus();
182 182
183 // With direct routing, the embedder would not know to focus the guest on 183 // With direct routing, the embedder would not know to focus the guest on
184 // click. Sends a synthetic event for the focusing side effect. 184 // click. Sends a synthetic event for the focusing side effect.
185 // TODO(wjmaclean): When we remove BrowserPlugin, delete this code. 185 // TODO(wjmaclean): When we remove BrowserPlugin, delete this code.
186 // http://crbug.com/533069 186 // http://crbug.com/533069
187 MaybeSendSyntheticTapGesture( 187 MaybeSendSyntheticTapGesture(event.positionInWidget(),
188 blink::WebFloatPoint(event.x, event.y), 188 event.positionInScreen());
189 blink::WebFloatPoint(event.globalX, event.globalY));
190 } 189 }
191 host_->ForwardMouseEventWithLatencyInfo(event, latency); 190 host_->ForwardMouseEventWithLatencyInfo(event, latency);
192 } 191 }
193 192
194 void RenderWidgetHostViewGuest::ProcessTouchEvent( 193 void RenderWidgetHostViewGuest::ProcessTouchEvent(
195 const blink::WebTouchEvent& event, 194 const blink::WebTouchEvent& event,
196 const ui::LatencyInfo& latency) { 195 const ui::LatencyInfo& latency) {
197 if (event.type() == blink::WebInputEvent::TouchStart) { 196 if (event.type() == blink::WebInputEvent::TouchStart) {
198 DCHECK(guest_->GetOwnerRenderWidgetHostView()); 197 DCHECK(guest_->GetOwnerRenderWidgetHostView());
199 RenderWidgetHost* embedder = 198 RenderWidgetHost* embedder =
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 int browser_plugin_instance_id, 556 int browser_plugin_instance_id,
558 const blink::WebInputEvent* event) { 557 const blink::WebInputEvent* event) {
559 // WebMouseWheelEvents go into a queue, and may not be forwarded to the 558 // WebMouseWheelEvents go into a queue, and may not be forwarded to the
560 // renderer until after this method goes out of scope. Therefore we need to 559 // renderer until after this method goes out of scope. Therefore we need to
561 // explicitly remove the additional device scale factor from the coordinates 560 // explicitly remove the additional device scale factor from the coordinates
562 // before allowing the event to be queued. 561 // before allowing the event to be queued.
563 if (IsUseZoomForDSFEnabled() && 562 if (IsUseZoomForDSFEnabled() &&
564 event->type() == blink::WebInputEvent::MouseWheel) { 563 event->type() == blink::WebInputEvent::MouseWheel) {
565 blink::WebMouseWheelEvent rescaled_event = 564 blink::WebMouseWheelEvent rescaled_event =
566 *static_cast<const blink::WebMouseWheelEvent*>(event); 565 *static_cast<const blink::WebMouseWheelEvent*>(event);
567 rescaled_event.x /= current_device_scale_factor(); 566 rescaled_event.setPositionInWidget(
568 rescaled_event.y /= current_device_scale_factor(); 567 rescaled_event.positionInWidget().x / current_device_scale_factor(),
568 rescaled_event.positionInWidget().y / current_device_scale_factor());
569 rescaled_event.deltaX /= current_device_scale_factor(); 569 rescaled_event.deltaX /= current_device_scale_factor();
570 rescaled_event.deltaY /= current_device_scale_factor(); 570 rescaled_event.deltaY /= current_device_scale_factor();
571 rescaled_event.wheelTicksX /= current_device_scale_factor(); 571 rescaled_event.wheelTicksX /= current_device_scale_factor();
572 rescaled_event.wheelTicksY /= current_device_scale_factor(); 572 rescaled_event.wheelTicksY /= current_device_scale_factor();
573 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); 573 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL);
574 host_->ForwardWheelEventWithLatencyInfo(rescaled_event, latency_info); 574 host_->ForwardWheelEventWithLatencyInfo(rescaled_event, latency_info);
575 return; 575 return;
576 } 576 }
577 577
578 ScopedInputScaleDisabler disable(host_, current_device_scale_factor()); 578 ScopedInputScaleDisabler disable(host_, current_device_scale_factor());
579 if (blink::WebInputEvent::isMouseEventType(event->type())) { 579 if (blink::WebInputEvent::isMouseEventType(event->type())) {
580 // The mouse events for BrowserPlugin are modified by all 580 // The mouse events for BrowserPlugin are modified by all
581 // the CSS transforms applied on the <object> and embedder. As a result of 581 // the CSS transforms applied on the <object> and embedder. As a result of
582 // this, the coordinates passed on to the guest renderer are potentially 582 // this, the coordinates passed on to the guest renderer are potentially
583 // incorrect to determine the position of the context menu(they are not the 583 // incorrect to determine the position of the context menu(they are not the
584 // actual X, Y of the window). As a hack, we report the last location of a 584 // actual X, Y of the window). As a hack, we report the last location of a
585 // right mouse up to the BrowserPluginGuest to inform it of the next 585 // right mouse up to the BrowserPluginGuest to inform it of the next
586 // potential location for context menu (BUG=470087). 586 // potential location for context menu (BUG=470087).
587 // TODO(ekaramad): Find a better and more fundamental solution. Could the 587 // TODO(ekaramad): Find a better and more fundamental solution. Could the
588 // ContextMenuParams be based on global X, Y? 588 // ContextMenuParams be based on global X, Y?
589 const blink::WebMouseEvent& mouse_event = 589 const blink::WebMouseEvent& mouse_event =
590 static_cast<const blink::WebMouseEvent&>(*event); 590 static_cast<const blink::WebMouseEvent&>(*event);
591 // A MouseDown on the ButtonRight could suggest a ContextMenu. 591 // A MouseDown on the ButtonRight could suggest a ContextMenu.
592 if (guest_ && mouse_event.type() == blink::WebInputEvent::MouseDown && 592 if (guest_ && mouse_event.type() == blink::WebInputEvent::MouseDown &&
593 mouse_event.button == blink::WebPointerProperties::Button::Right) 593 mouse_event.button == blink::WebPointerProperties::Button::Right)
594 guest_->SetContextMenuPosition( 594 guest_->SetContextMenuPosition(
595 gfx::Point(mouse_event.globalX - GetViewBounds().x(), 595 gfx::Point(mouse_event.positionInScreen().x - GetViewBounds().x(),
596 mouse_event.globalY - GetViewBounds().y())); 596 mouse_event.positionInScreen().y - GetViewBounds().y()));
597 host_->ForwardMouseEvent(mouse_event); 597 host_->ForwardMouseEvent(mouse_event);
598 return; 598 return;
599 } 599 }
600 600
601 if (event->type() == blink::WebInputEvent::MouseWheel) { 601 if (event->type() == blink::WebInputEvent::MouseWheel) {
602 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); 602 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL);
603 host_->ForwardWheelEventWithLatencyInfo( 603 host_->ForwardWheelEventWithLatencyInfo(
604 *static_cast<const blink::WebMouseWheelEvent*>(event), latency_info); 604 *static_cast<const blink::WebMouseWheelEvent*>(event), latency_info);
605 return; 605 return;
606 } 606 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 host_->ForwardGestureEvent(gesture_event); 644 host_->ForwardGestureEvent(gesture_event);
645 return; 645 return;
646 } 646 }
647 } 647 }
648 648
649 bool RenderWidgetHostViewGuest::HasEmbedderChanged() { 649 bool RenderWidgetHostViewGuest::HasEmbedderChanged() {
650 return guest_ && guest_->has_attached_since_surface_set(); 650 return guest_ && guest_->has_attached_since_surface_set();
651 } 651 }
652 652
653 } // namespace content 653 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/input_handler.cc ('k') | content/browser/pointer_lock_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698