Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_mac.mm |
| diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| index b5444dc934af1ad077e899962eb9a4054d536c96..b1ee6a839fe0946a1ad3e1d158020e44c4b240e4 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -1708,6 +1708,7 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| canBeKeyView_ = YES; |
| opaque_ = YES; |
| pinchHasReachedZoomThreshold_ = false; |
| + isStylusEnteringProximity_ = false; |
|
mustaq
2016/10/14 16:07:17
I think the name |isStylusInProximity| better refl
|
| // OpenGL support: |
| if ([self respondsToSelector: |
| @@ -1855,10 +1856,20 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| return; |
| } |
| + // Set the pointer type when we are receiving a NSMouseEntered event and the |
| + // following NSMouseExited event should have the same pointer type. |
| + NSEventType type = [theEvent type]; |
| + if (type == NSMouseEntered) { |
| + pointerType_ = isStylusEnteringProximity_ |
| + ? blink::WebPointerProperties::PointerType::Pen |
| + : blink::WebPointerProperties::PointerType::Mouse; |
| + } |
| + |
| if ([self shouldIgnoreMouseEvent:theEvent]) { |
| // If this is the first such event, send a mouse exit to the host view. |
| if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { |
| - WebMouseEvent exitEvent = WebMouseEventBuilder::Build(theEvent, self); |
| + WebMouseEvent exitEvent = |
| + WebMouseEventBuilder::Build(theEvent, self, pointerType_); |
| exitEvent.type = WebInputEvent::MouseLeave; |
| exitEvent.button = WebMouseEvent::Button::NoButton; |
| renderWidgetHostView_->ForwardMouseEvent(exitEvent); |
| @@ -1871,7 +1882,8 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| // If this is the first mouse event after a previous event that was ignored |
| // due to the hitTest, send a mouse enter event to the host view. |
| if (renderWidgetHostView_->render_widget_host_) { |
| - WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); |
| + WebMouseEvent enterEvent = |
| + WebMouseEventBuilder::Build(theEvent, self, pointerType_); |
| enterEvent.type = WebInputEvent::MouseMove; |
| enterEvent.button = WebMouseEvent::Button::NoButton; |
| ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
| @@ -1893,8 +1905,6 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| // popup. A click outside the text field would cause the text field to drop |
| // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel |
| // the popup anyway, so we're OK. |
| - |
| - NSEventType type = [theEvent type]; |
| if (type == NSLeftMouseDown) |
| hasOpenMouseDown_ = YES; |
| else if (type == NSLeftMouseUp) |
| @@ -1911,7 +1921,8 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| [self finishComposingText]; |
| } |
| - WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); |
| + WebMouseEvent event = |
| + WebMouseEventBuilder::Build(theEvent, self, pointerType_); |
| ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
| latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
| @@ -1923,6 +1934,11 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| } |
| } |
| +- (void)tabletEvent:(NSEvent*)theEvent { |
| + if ([theEvent type] == NSTabletProximity) |
| + isStylusEnteringProximity_ = [theEvent isEnteringProximity]; |
| +} |
| + |
| - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
| // |performKeyEquivalent:| is sent to all views of a window, not only down the |
| // responder chain (cf. "Handling Key Equivalents" in |