Chromium Code Reviews| 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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1248 NSPoint location = [window mouseLocationOutsideOfEventStream]; | 1248 NSPoint location = [window mouseLocationOutsideOfEventStream]; |
| 1249 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved | 1249 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved |
| 1250 location:location | 1250 location:location |
| 1251 modifierFlags:0 | 1251 modifierFlags:0 |
| 1252 timestamp:0 | 1252 timestamp:0 |
| 1253 windowNumber:window_number() | 1253 windowNumber:window_number() |
| 1254 context:nil | 1254 context:nil |
| 1255 eventNumber:0 | 1255 eventNumber:0 |
| 1256 clickCount:0 | 1256 clickCount:0 |
| 1257 pressure:0]; | 1257 pressure:0]; |
| 1258 WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_); | 1258 WebMouseEvent web_event = WebMouseEventBuilder::Build( |
| 1259 event, cocoa_view_, blink::WebPointerProperties::PointerType::Mouse); | |
| 1259 if (showing) | 1260 if (showing) |
| 1260 web_event.type = WebInputEvent::MouseLeave; | 1261 web_event.type = WebInputEvent::MouseLeave; |
| 1261 ForwardMouseEvent(web_event); | 1262 ForwardMouseEvent(web_event); |
| 1262 } | 1263 } |
| 1263 | 1264 |
| 1264 bool RenderWidgetHostViewMac::IsPopup() const { | 1265 bool RenderWidgetHostViewMac::IsPopup() const { |
| 1265 return popup_type_ != blink::WebPopupTypeNone; | 1266 return popup_type_ != blink::WebPopupTypeNone; |
| 1266 } | 1267 } |
| 1267 | 1268 |
| 1268 void RenderWidgetHostViewMac::CopyFromCompositingSurface( | 1269 void RenderWidgetHostViewMac::CopyFromCompositingSurface( |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1982 | 1983 |
| 1983 - (void)mouseEvent:(NSEvent*)theEvent { | 1984 - (void)mouseEvent:(NSEvent*)theEvent { |
| 1984 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::mouseEvent"); | 1985 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::mouseEvent"); |
| 1985 if (responderDelegate_ && | 1986 if (responderDelegate_ && |
| 1986 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { | 1987 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { |
| 1987 BOOL handled = [responderDelegate_ handleEvent:theEvent]; | 1988 BOOL handled = [responderDelegate_ handleEvent:theEvent]; |
| 1988 if (handled) | 1989 if (handled) |
| 1989 return; | 1990 return; |
| 1990 } | 1991 } |
| 1991 | 1992 |
| 1993 // If the pointing device enters proximity of its tablet and does not leave, | |
| 1994 // the pointer type should be pen, otherwise is mouse. | |
|
Navid Zolghadr
2016/05/31 04:18:12
Just a quick question for clarification. Does this
lanwei
2016/05/31 14:33:35
Even without actually touching the tablet screen,
mustaq
2016/05/31 14:43:50
Navid: Blink gets move & leave respectively, defin
| |
| 1995 blink::WebPointerProperties::PointerType pointerType = | |
| 1996 stylusEnteringProximity_ | |
|
dtapuska
2016/05/31 13:31:05
Can we not always just use the subtype? It looks
lanwei
2016/05/31 14:33:35
Sorry, I forgot to add the comment that MouseEnter
mustaq
2016/05/31 14:43:50
The following link seems to suggest that subtype i
| |
| 1997 ? blink::WebPointerProperties::PointerType::Pen | |
| 1998 : blink::WebPointerProperties::PointerType::Mouse; | |
| 1992 if ([self shouldIgnoreMouseEvent:theEvent]) { | 1999 if ([self shouldIgnoreMouseEvent:theEvent]) { |
| 1993 // If this is the first such event, send a mouse exit to the host view. | 2000 // If this is the first such event, send a mouse exit to the host view. |
| 1994 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { | 2001 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { |
| 1995 WebMouseEvent exitEvent = WebMouseEventBuilder::Build(theEvent, self); | 2002 WebMouseEvent exitEvent = |
| 2003 WebMouseEventBuilder::Build(theEvent, self, pointerType); | |
| 1996 exitEvent.type = WebInputEvent::MouseLeave; | 2004 exitEvent.type = WebInputEvent::MouseLeave; |
| 1997 exitEvent.button = WebMouseEvent::ButtonNone; | 2005 exitEvent.button = WebMouseEvent::ButtonNone; |
| 1998 renderWidgetHostView_->ForwardMouseEvent(exitEvent); | 2006 renderWidgetHostView_->ForwardMouseEvent(exitEvent); |
| 1999 } | 2007 } |
| 2000 mouseEventWasIgnored_ = YES; | 2008 mouseEventWasIgnored_ = YES; |
| 2001 return; | 2009 return; |
| 2002 } | 2010 } |
| 2003 | 2011 |
| 2004 if (mouseEventWasIgnored_) { | 2012 if (mouseEventWasIgnored_) { |
| 2005 // If this is the first mouse event after a previous event that was ignored | 2013 // If this is the first mouse event after a previous event that was ignored |
| 2006 // due to the hitTest, send a mouse enter event to the host view. | 2014 // due to the hitTest, send a mouse enter event to the host view. |
| 2007 if (renderWidgetHostView_->render_widget_host_) { | 2015 if (renderWidgetHostView_->render_widget_host_) { |
| 2008 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); | 2016 WebMouseEvent enterEvent = |
| 2017 WebMouseEventBuilder::Build(theEvent, self, pointerType); | |
| 2009 enterEvent.type = WebInputEvent::MouseMove; | 2018 enterEvent.type = WebInputEvent::MouseMove; |
| 2010 enterEvent.button = WebMouseEvent::ButtonNone; | 2019 enterEvent.button = WebMouseEvent::ButtonNone; |
| 2011 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { | 2020 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
| 2012 renderWidgetHostView_->render_widget_host_->delegate() | 2021 renderWidgetHostView_->render_widget_host_->delegate() |
| 2013 ->GetInputEventRouter() | 2022 ->GetInputEventRouter() |
| 2014 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); | 2023 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); |
| 2015 } else { | 2024 } else { |
| 2016 renderWidgetHostView_->ProcessMouseEvent(enterEvent); | 2025 renderWidgetHostView_->ProcessMouseEvent(enterEvent); |
| 2017 } | 2026 } |
| 2018 } | 2027 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2035 // wants to handle them. But it won't work without implementing method | 2044 // wants to handle them. But it won't work without implementing method |
| 2036 // - (NSUInteger)characterIndexForPoint:. | 2045 // - (NSUInteger)characterIndexForPoint:. |
| 2037 // See: http://code.google.com/p/chromium/issues/detail?id=47141 | 2046 // See: http://code.google.com/p/chromium/issues/detail?id=47141 |
| 2038 // Instead of sending mouse events to the input method first, we now just | 2047 // Instead of sending mouse events to the input method first, we now just |
| 2039 // simply confirm all ongoing composition here. | 2048 // simply confirm all ongoing composition here. |
| 2040 if (type == NSLeftMouseDown || type == NSRightMouseDown || | 2049 if (type == NSLeftMouseDown || type == NSRightMouseDown || |
| 2041 type == NSOtherMouseDown) { | 2050 type == NSOtherMouseDown) { |
| 2042 [self confirmComposition]; | 2051 [self confirmComposition]; |
| 2043 } | 2052 } |
| 2044 | 2053 |
| 2045 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); | 2054 WebMouseEvent event = |
| 2055 WebMouseEventBuilder::Build(theEvent, self, pointerType); | |
| 2046 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 2056 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
| 2047 renderWidgetHostView_->render_widget_host_->delegate() | 2057 renderWidgetHostView_->render_widget_host_->delegate() |
| 2048 ->GetInputEventRouter() | 2058 ->GetInputEventRouter() |
| 2049 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); | 2059 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); |
| 2050 } else { | 2060 } else { |
| 2051 renderWidgetHostView_->ProcessMouseEvent(event); | 2061 renderWidgetHostView_->ProcessMouseEvent(event); |
| 2052 } | 2062 } |
| 2053 } | 2063 } |
| 2054 | 2064 |
| 2065 - (void)tabletEvent:(NSEvent*)theEvent { | |
| 2066 stylusEnteringProximity_ = [theEvent isEnteringProximity]; | |
| 2067 } | |
| 2068 | |
| 2055 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 2069 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
| 2056 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 2070 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
| 2057 // responder chain (cf. "Handling Key Equivalents" in | 2071 // responder chain (cf. "Handling Key Equivalents" in |
| 2058 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html | 2072 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html |
| 2059 // ). We only want to handle key equivalents if we're first responder. | 2073 // ). We only want to handle key equivalents if we're first responder. |
| 2060 if ([[self window] firstResponder] != self) | 2074 if ([[self window] firstResponder] != self) |
| 2061 return NO; | 2075 return NO; |
| 2062 | 2076 |
| 2063 // If the event is reserved by the system, then do not pass it to web content. | 2077 // If the event is reserved by the system, then do not pass it to web content. |
| 2064 if (EventIsReservedBySystem(theEvent)) | 2078 if (EventIsReservedBySystem(theEvent)) |
| (...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3450 | 3464 |
| 3451 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3465 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3452 // regions that are not draggable. (See ControlRegionView in | 3466 // regions that are not draggable. (See ControlRegionView in |
| 3453 // native_app_window_cocoa.mm). This requires the render host view to be | 3467 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3454 // draggable by default. | 3468 // draggable by default. |
| 3455 - (BOOL)mouseDownCanMoveWindow { | 3469 - (BOOL)mouseDownCanMoveWindow { |
| 3456 return YES; | 3470 return YES; |
| 3457 } | 3471 } |
| 3458 | 3472 |
| 3459 @end | 3473 @end |
| OLD | NEW |