OLD | NEW |
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 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 47 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
48 #import "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" | 48 #import "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" |
49 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" | 49 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" |
50 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" | 50 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" |
51 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" | 51 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" |
52 #import "content/browser/renderer_host/text_input_client_mac.h" | 52 #import "content/browser/renderer_host/text_input_client_mac.h" |
53 #include "content/common/accessibility_messages.h" | 53 #include "content/common/accessibility_messages.h" |
54 #include "content/common/edit_command.h" | 54 #include "content/common/edit_command.h" |
55 #include "content/common/gpu/gpu_messages.h" | 55 #include "content/common/gpu/gpu_messages.h" |
56 #include "content/common/input_messages.h" | 56 #include "content/common/input_messages.h" |
| 57 #include "content/common/site_isolation_policy.h" |
57 #include "content/common/view_messages.h" | 58 #include "content/common/view_messages.h" |
58 #include "content/common/webplugin_geometry.h" | 59 #include "content/common/webplugin_geometry.h" |
59 #include "content/public/browser/browser_context.h" | 60 #include "content/public/browser/browser_context.h" |
60 #include "content/public/browser/browser_plugin_guest_manager.h" | 61 #include "content/public/browser/browser_plugin_guest_manager.h" |
61 #include "content/public/browser/browser_thread.h" | 62 #include "content/public/browser/browser_thread.h" |
62 #include "content/public/browser/native_web_keyboard_event.h" | 63 #include "content/public/browser/native_web_keyboard_event.h" |
63 #include "content/public/browser/notification_service.h" | 64 #include "content/public/browser/notification_service.h" |
64 #include "content/public/browser/notification_types.h" | 65 #include "content/public/browser/notification_types.h" |
65 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 66 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
66 #import "content/public/browser/render_widget_host_view_mac_delegate.h" | 67 #import "content/public/browser/render_widget_host_view_mac_delegate.h" |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // See also RenderWidgetHostViewAura::ShouldRouteEvent. |
| 1617 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements |
| 1618 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. |
| 1619 DCHECK(WebInputEvent::isMouseEventType(event.type) || |
| 1620 event.type == WebInputEvent::MouseWheel); |
| 1621 return render_widget_host_->delegate() && |
| 1622 render_widget_host_->delegate()->GetInputEventRouter() && |
| 1623 SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 1624 } |
| 1625 |
1613 void RenderWidgetHostViewMac::ProcessMouseEvent( | 1626 void RenderWidgetHostViewMac::ProcessMouseEvent( |
1614 const blink::WebMouseEvent& event) { | 1627 const blink::WebMouseEvent& event) { |
1615 render_widget_host_->ForwardMouseEvent(event); | 1628 render_widget_host_->ForwardMouseEvent(event); |
1616 } | 1629 } |
1617 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( | 1630 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( |
1618 const blink::WebMouseWheelEvent& event) { | 1631 const blink::WebMouseWheelEvent& event) { |
1619 render_widget_host_->ForwardWheelEvent(event); | 1632 render_widget_host_->ForwardWheelEvent(event); |
1620 } | 1633 } |
1621 | 1634 |
1622 void RenderWidgetHostViewMac::TransformPointToLocalCoordSpace( | 1635 void RenderWidgetHostViewMac::TransformPointToLocalCoordSpace( |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 return; | 1962 return; |
1950 } | 1963 } |
1951 | 1964 |
1952 if (mouseEventWasIgnored_) { | 1965 if (mouseEventWasIgnored_) { |
1953 // If this is the first mouse event after a previous event that was ignored | 1966 // 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. | 1967 // due to the hitTest, send a mouse enter event to the host view. |
1955 if (renderWidgetHostView_->render_widget_host_) { | 1968 if (renderWidgetHostView_->render_widget_host_) { |
1956 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); | 1969 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); |
1957 enterEvent.type = WebInputEvent::MouseMove; | 1970 enterEvent.type = WebInputEvent::MouseMove; |
1958 enterEvent.button = WebMouseEvent::ButtonNone; | 1971 enterEvent.button = WebMouseEvent::ButtonNone; |
1959 if (renderWidgetHostView_->render_widget_host_->delegate() && | 1972 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
1960 renderWidgetHostView_->render_widget_host_->delegate() | |
1961 ->GetInputEventRouter()) { | |
1962 renderWidgetHostView_->render_widget_host_->delegate() | 1973 renderWidgetHostView_->render_widget_host_->delegate() |
1963 ->GetInputEventRouter() | 1974 ->GetInputEventRouter() |
1964 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); | 1975 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); |
1965 } else { | 1976 } else { |
1966 renderWidgetHostView_->ForwardMouseEvent(enterEvent); | 1977 renderWidgetHostView_->ProcessMouseEvent(enterEvent); |
1967 } | 1978 } |
1968 } | 1979 } |
1969 } | 1980 } |
1970 mouseEventWasIgnored_ = NO; | 1981 mouseEventWasIgnored_ = NO; |
1971 | 1982 |
1972 // Don't cancel child popups; killing them on a mouse click would prevent the | 1983 // 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 | 1984 // 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 | 1985 // popup. A click outside the text field would cause the text field to drop |
1975 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 1986 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel |
1976 // the popup anyway, so we're OK. | 1987 // the popup anyway, so we're OK. |
1977 | 1988 |
1978 NSEventType type = [theEvent type]; | 1989 NSEventType type = [theEvent type]; |
1979 if (type == NSLeftMouseDown) | 1990 if (type == NSLeftMouseDown) |
1980 hasOpenMouseDown_ = YES; | 1991 hasOpenMouseDown_ = YES; |
1981 else if (type == NSLeftMouseUp) | 1992 else if (type == NSLeftMouseUp) |
1982 hasOpenMouseDown_ = NO; | 1993 hasOpenMouseDown_ = NO; |
1983 | 1994 |
1984 // TODO(suzhe): We should send mouse events to the input method first if it | 1995 // 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 | 1996 // wants to handle them. But it won't work without implementing method |
1986 // - (NSUInteger)characterIndexForPoint:. | 1997 // - (NSUInteger)characterIndexForPoint:. |
1987 // See: http://code.google.com/p/chromium/issues/detail?id=47141 | 1998 // 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 | 1999 // Instead of sending mouse events to the input method first, we now just |
1989 // simply confirm all ongoing composition here. | 2000 // simply confirm all ongoing composition here. |
1990 if (type == NSLeftMouseDown || type == NSRightMouseDown || | 2001 if (type == NSLeftMouseDown || type == NSRightMouseDown || |
1991 type == NSOtherMouseDown) { | 2002 type == NSOtherMouseDown) { |
1992 [self confirmComposition]; | 2003 [self confirmComposition]; |
1993 } | 2004 } |
1994 | 2005 |
1995 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); | 2006 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); |
1996 if (renderWidgetHostView_->render_widget_host_->delegate() && | 2007 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
1997 renderWidgetHostView_->render_widget_host_->delegate() | |
1998 ->GetInputEventRouter()) { | |
1999 renderWidgetHostView_->render_widget_host_->delegate() | 2008 renderWidgetHostView_->render_widget_host_->delegate() |
2000 ->GetInputEventRouter() | 2009 ->GetInputEventRouter() |
2001 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); | 2010 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); |
2002 } else { | 2011 } else { |
2003 renderWidgetHostView_->ForwardMouseEvent(event); | 2012 renderWidgetHostView_->ProcessMouseEvent(event); |
2004 } | 2013 } |
2005 } | 2014 } |
2006 | 2015 |
2007 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 2016 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
2008 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 2017 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
2009 // responder chain (cf. "Handling Key Equivalents" in | 2018 // responder chain (cf. "Handling Key Equivalents" in |
2010 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html | 2019 // 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. | 2020 // ). We only want to handle key equivalents if we're first responder. |
2012 if ([[self window] firstResponder] != self) | 2021 if ([[self window] firstResponder] != self) |
2013 return NO; | 2022 return NO; |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 }]; | 2506 }]; |
2498 } | 2507 } |
2499 | 2508 |
2500 // This is responsible for content scrolling! | 2509 // This is responsible for content scrolling! |
2501 if (renderWidgetHostView_->render_widget_host_) { | 2510 if (renderWidgetHostView_->render_widget_host_) { |
2502 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; | 2511 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; |
2503 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; | 2512 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; |
2504 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( | 2513 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( |
2505 event, self, canRubberbandLeft, canRubberbandRight); | 2514 event, self, canRubberbandLeft, canRubberbandRight); |
2506 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); | 2515 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); |
2507 if (renderWidgetHostView_->render_widget_host_->delegate() && | 2516 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { |
2508 renderWidgetHostView_->render_widget_host_->delegate() | |
2509 ->GetInputEventRouter()) { | |
2510 renderWidgetHostView_->render_widget_host_->delegate() | 2517 renderWidgetHostView_->render_widget_host_->delegate() |
2511 ->GetInputEventRouter() | 2518 ->GetInputEventRouter() |
2512 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); | 2519 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); |
2513 } else { | 2520 } else { |
2514 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); | 2521 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent); |
2515 } | 2522 } |
2516 } | 2523 } |
2517 } | 2524 } |
2518 | 2525 |
2519 // Called repeatedly during a pinch gesture, with incremental change values. | 2526 // Called repeatedly during a pinch gesture, with incremental change values. |
2520 - (void)magnifyWithEvent:(NSEvent*)event { | 2527 - (void)magnifyWithEvent:(NSEvent*)event { |
2521 if (!renderWidgetHostView_->render_widget_host_) | 2528 if (!renderWidgetHostView_->render_widget_host_) |
2522 return; | 2529 return; |
2523 | 2530 |
2524 // If, due to nesting of multiple gestures (e.g, from multiple touch | 2531 // If, due to nesting of multiple gestures (e.g, from multiple touch |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3447 | 3454 |
3448 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3455 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3449 // regions that are not draggable. (See ControlRegionView in | 3456 // regions that are not draggable. (See ControlRegionView in |
3450 // native_app_window_cocoa.mm). This requires the render host view to be | 3457 // native_app_window_cocoa.mm). This requires the render host view to be |
3451 // draggable by default. | 3458 // draggable by default. |
3452 - (BOOL)mouseDownCanMoveWindow { | 3459 - (BOOL)mouseDownCanMoveWindow { |
3453 return YES; | 3460 return YES; |
3454 } | 3461 } |
3455 | 3462 |
3456 @end | 3463 @end |
OLD | NEW |