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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1412923009: Route touch-events for WebViewGuest directly to guest renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Mac code, rebase to master@{#361742}. Created 5 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 44 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
45 #import "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" 45 #import "content/browser/renderer_host/input/synthetic_gesture_target_mac.h"
46 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 46 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h"
47 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 47 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
48 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" 48 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h"
49 #import "content/browser/renderer_host/text_input_client_mac.h" 49 #import "content/browser/renderer_host/text_input_client_mac.h"
50 #include "content/common/accessibility_messages.h" 50 #include "content/common/accessibility_messages.h"
51 #include "content/common/edit_command.h" 51 #include "content/common/edit_command.h"
52 #include "content/common/gpu/gpu_messages.h" 52 #include "content/common/gpu/gpu_messages.h"
53 #include "content/common/input_messages.h" 53 #include "content/common/input_messages.h"
54 #include "content/common/site_isolation_policy.h"
54 #include "content/common/view_messages.h" 55 #include "content/common/view_messages.h"
55 #include "content/common/webplugin_geometry.h" 56 #include "content/common/webplugin_geometry.h"
56 #include "content/public/browser/browser_context.h" 57 #include "content/public/browser/browser_context.h"
57 #include "content/public/browser/browser_plugin_guest_manager.h" 58 #include "content/public/browser/browser_plugin_guest_manager.h"
58 #include "content/public/browser/browser_thread.h" 59 #include "content/public/browser/browser_thread.h"
59 #include "content/public/browser/native_web_keyboard_event.h" 60 #include "content/public/browser/native_web_keyboard_event.h"
60 #include "content/public/browser/notification_service.h" 61 #include "content/public/browser/notification_service.h"
61 #include "content/public/browser/notification_types.h" 62 #include "content/public/browser/notification_types.h"
62 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 63 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
63 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 64 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 transformed_point); 1604 transformed_point);
1604 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point); 1605 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point);
1605 1606
1606 // It is possible that the renderer has not yet produced a surface, in which 1607 // It is possible that the renderer has not yet produced a surface, in which
1607 // case we return our current namespace. 1608 // case we return our current namespace.
1608 if (id.is_null()) 1609 if (id.is_null())
1609 return GetSurfaceIdNamespace(); 1610 return GetSurfaceIdNamespace();
1610 return cc::SurfaceIdAllocator::NamespaceForId(id); 1611 return cc::SurfaceIdAllocator::NamespaceForId(id);
1611 } 1612 }
1612 1613
1614 bool RenderWidgetHostViewMac::ShouldRouteEvent(
1615 const WebInputEvent& event) const {
1616 bool result = render_widget_host_->delegate() &&
1617 render_widget_host_->delegate()->GetInputEventRouter();
1618 if (WebInputEvent::isMouseEventType(event.type) ||
1619 event.type == WebInputEvent::MouseWheel) {
1620 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible();
Charlie Reis 2015/11/30 18:09:12 Same concerns as in RWHVAura.
wjmaclean 2015/12/10 16:09:07 This will only (at present) be called for Mouse/Wh
Charlie Reis 2015/12/10 21:58:14 This still needs a comment.
1621 }
1622 return result;
1623 }
1624
1613 void RenderWidgetHostViewMac::ProcessMouseEvent( 1625 void RenderWidgetHostViewMac::ProcessMouseEvent(
1614 const blink::WebMouseEvent& event) { 1626 const blink::WebMouseEvent& event) {
1615 render_widget_host_->ForwardMouseEvent(event); 1627 render_widget_host_->ForwardMouseEvent(event);
1616 } 1628 }
1617 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( 1629 void RenderWidgetHostViewMac::ProcessMouseWheelEvent(
1618 const blink::WebMouseWheelEvent& event) { 1630 const blink::WebMouseWheelEvent& event) {
1619 render_widget_host_->ForwardWheelEvent(event); 1631 render_widget_host_->ForwardWheelEvent(event);
1620 } 1632 }
1621 1633
1622 void RenderWidgetHostViewMac::TransformPointToLocalCoordSpace( 1634 void RenderWidgetHostViewMac::TransformPointToLocalCoordSpace(
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 return; 1961 return;
1950 } 1962 }
1951 1963
1952 if (mouseEventWasIgnored_) { 1964 if (mouseEventWasIgnored_) {
1953 // If this is the first mouse event after a previous event that was ignored 1965 // If this is the first mouse event after a previous event that was ignored
1954 // due to the hitTest, send a mouse enter event to the host view. 1966 // due to the hitTest, send a mouse enter event to the host view.
1955 if (renderWidgetHostView_->render_widget_host_) { 1967 if (renderWidgetHostView_->render_widget_host_) {
1956 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); 1968 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self);
1957 enterEvent.type = WebInputEvent::MouseMove; 1969 enterEvent.type = WebInputEvent::MouseMove;
1958 enterEvent.button = WebMouseEvent::ButtonNone; 1970 enterEvent.button = WebMouseEvent::ButtonNone;
1959 if (renderWidgetHostView_->render_widget_host_->delegate() && 1971 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) {
1960 renderWidgetHostView_->render_widget_host_->delegate()
1961 ->GetInputEventRouter()) {
1962 renderWidgetHostView_->render_widget_host_->delegate() 1972 renderWidgetHostView_->render_widget_host_->delegate()
1963 ->GetInputEventRouter() 1973 ->GetInputEventRouter()
1964 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); 1974 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent);
1965 } else { 1975 } else {
1966 renderWidgetHostView_->ForwardMouseEvent(enterEvent); 1976 renderWidgetHostView_->ProcessMouseEvent(enterEvent);
1967 } 1977 }
1968 } 1978 }
1969 } 1979 }
1970 mouseEventWasIgnored_ = NO; 1980 mouseEventWasIgnored_ = NO;
1971 1981
1972 // Don't cancel child popups; killing them on a mouse click would prevent the 1982 // Don't cancel child popups; killing them on a mouse click would prevent the
1973 // user from positioning the insertion point in the text field spawning the 1983 // user from positioning the insertion point in the text field spawning the
1974 // popup. A click outside the text field would cause the text field to drop 1984 // popup. A click outside the text field would cause the text field to drop
1975 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel 1985 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel
1976 // the popup anyway, so we're OK. 1986 // the popup anyway, so we're OK.
1977 1987
1978 NSEventType type = [theEvent type]; 1988 NSEventType type = [theEvent type];
1979 if (type == NSLeftMouseDown) 1989 if (type == NSLeftMouseDown)
1980 hasOpenMouseDown_ = YES; 1990 hasOpenMouseDown_ = YES;
1981 else if (type == NSLeftMouseUp) 1991 else if (type == NSLeftMouseUp)
1982 hasOpenMouseDown_ = NO; 1992 hasOpenMouseDown_ = NO;
1983 1993
1984 // TODO(suzhe): We should send mouse events to the input method first if it 1994 // TODO(suzhe): We should send mouse events to the input method first if it
1985 // wants to handle them. But it won't work without implementing method 1995 // wants to handle them. But it won't work without implementing method
1986 // - (NSUInteger)characterIndexForPoint:. 1996 // - (NSUInteger)characterIndexForPoint:.
1987 // See: http://code.google.com/p/chromium/issues/detail?id=47141 1997 // See: http://code.google.com/p/chromium/issues/detail?id=47141
1988 // Instead of sending mouse events to the input method first, we now just 1998 // Instead of sending mouse events to the input method first, we now just
1989 // simply confirm all ongoing composition here. 1999 // simply confirm all ongoing composition here.
1990 if (type == NSLeftMouseDown || type == NSRightMouseDown || 2000 if (type == NSLeftMouseDown || type == NSRightMouseDown ||
1991 type == NSOtherMouseDown) { 2001 type == NSOtherMouseDown) {
1992 [self confirmComposition]; 2002 [self confirmComposition];
1993 } 2003 }
1994 2004
1995 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); 2005 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self);
1996 if (renderWidgetHostView_->render_widget_host_->delegate() && 2006 if (renderWidgetHostView_->ShouldRouteEvent(event)) {
1997 renderWidgetHostView_->render_widget_host_->delegate()
1998 ->GetInputEventRouter()) {
1999 renderWidgetHostView_->render_widget_host_->delegate() 2007 renderWidgetHostView_->render_widget_host_->delegate()
2000 ->GetInputEventRouter() 2008 ->GetInputEventRouter()
2001 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); 2009 ->RouteMouseEvent(renderWidgetHostView_.get(), &event);
2002 } else { 2010 } else {
2003 renderWidgetHostView_->ForwardMouseEvent(event); 2011 renderWidgetHostView_->ProcessMouseEvent(event);
2004 } 2012 }
2005 } 2013 }
2006 2014
2007 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { 2015 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent {
2008 // |performKeyEquivalent:| is sent to all views of a window, not only down the 2016 // |performKeyEquivalent:| is sent to all views of a window, not only down the
2009 // responder chain (cf. "Handling Key Equivalents" in 2017 // responder chain (cf. "Handling Key Equivalents" in
2010 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html 2018 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html
2011 // ). We only want to handle key equivalents if we're first responder. 2019 // ). We only want to handle key equivalents if we're first responder.
2012 if ([[self window] firstResponder] != self) 2020 if ([[self window] firstResponder] != self)
2013 return NO; 2021 return NO;
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 }]; 2503 }];
2496 } 2504 }
2497 2505
2498 // This is responsible for content scrolling! 2506 // This is responsible for content scrolling!
2499 if (renderWidgetHostView_->render_widget_host_) { 2507 if (renderWidgetHostView_->render_widget_host_) {
2500 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; 2508 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self];
2501 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; 2509 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self];
2502 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( 2510 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(
2503 event, self, canRubberbandLeft, canRubberbandRight); 2511 event, self, canRubberbandLeft, canRubberbandRight);
2504 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); 2512 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent);
2505 if (renderWidgetHostView_->render_widget_host_->delegate() && 2513 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) {
2506 renderWidgetHostView_->render_widget_host_->delegate()
2507 ->GetInputEventRouter()) {
2508 renderWidgetHostView_->render_widget_host_->delegate() 2514 renderWidgetHostView_->render_widget_host_->delegate()
2509 ->GetInputEventRouter() 2515 ->GetInputEventRouter()
2510 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); 2516 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent);
2511 } else { 2517 } else {
2512 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); 2518 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent);
2513 } 2519 }
2514 } 2520 }
2515 } 2521 }
2516 2522
2517 // Called repeatedly during a pinch gesture, with incremental change values. 2523 // Called repeatedly during a pinch gesture, with incremental change values.
2518 - (void)magnifyWithEvent:(NSEvent*)event { 2524 - (void)magnifyWithEvent:(NSEvent*)event {
2519 if (!renderWidgetHostView_->render_widget_host_) 2525 if (!renderWidgetHostView_->render_widget_host_)
2520 return; 2526 return;
2521 2527
2522 // If, due to nesting of multiple gestures (e.g, from multiple touch 2528 // If, due to nesting of multiple gestures (e.g, from multiple touch
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 3451
3446 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3452 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3447 // regions that are not draggable. (See ControlRegionView in 3453 // regions that are not draggable. (See ControlRegionView in
3448 // native_app_window_cocoa.mm). This requires the render host view to be 3454 // native_app_window_cocoa.mm). This requires the render host view to be
3449 // draggable by default. 3455 // draggable by default.
3450 - (BOOL)mouseDownCanMoveWindow { 3456 - (BOOL)mouseDownCanMoveWindow {
3451 return YES; 3457 return YES;
3452 } 3458 }
3453 3459
3454 @end 3460 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698