Chromium Code Reviews| Index: content/browser/renderer_host/input/web_input_event_builders_mac.mm |
| diff --git a/content/browser/renderer_host/input/web_input_event_builders_mac.mm b/content/browser/renderer_host/input/web_input_event_builders_mac.mm |
| index 2e8ea376b856638125284351bfa9cf527ce25316..dcf2ef4a8d1f3de7e275777bf475d535bd338739 100644 |
| --- a/content/browser/renderer_host/input/web_input_event_builders_mac.mm |
| +++ b/content/browser/renderer_host/input/web_input_event_builders_mac.mm |
| @@ -663,12 +663,16 @@ blink::WebKeyboardEvent WebKeyboardEventBuilder::Build(NSEvent* event) { |
| // WebMouseEvent -------------------------------------------------------------- |
| -blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) { |
| +blink::WebMouseEvent WebMouseEventBuilder::Build( |
| + NSEvent* event, |
| + NSView* view, |
| + blink::WebPointerProperties::PointerType pointerType) { |
|
mustaq
2016/06/02 15:39:12
Please rename the |pointerType| param to |pointerT
lanwei
2016/06/03 14:13:15
Done.
|
| blink::WebMouseEvent result; |
| result.clickCount = 0; |
| - switch ([event type]) { |
| + NSEventType type = [event type]; |
| + switch (type) { |
| case NSMouseExited: |
| result.type = blink::WebInputEvent::MouseLeave; |
| result.button = blink::WebMouseEvent::ButtonNone; |
| @@ -729,6 +733,27 @@ blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) { |
| result.timeStampSeconds = [event timestamp]; |
| + // Currently, NSMouseExited and NSMouseEntered do not have the 'subtype' and |
| + // 'deviceID' properties. |
| + // This is a simple solution which works only for a single input device. |
| + if (type == NSMouseExited || type == NSMouseEntered) { |
| + // Set the pointerType based on if there is a stylus in the proximity of |
| + // the tablet |
| + result.pointerType = pointerType; |
| + return result; |
| + } |
| + |
| + // For the mouse events and the touchpad events, the pointer type is mouse. |
| + // For all tablet events, the pointer type will be just pen. |
| + NSEventSubtype subtype = [event subtype]; |
| + if (subtype == NSTabletPointEventSubtype || |
| + subtype == NSTabletProximityEventSubtype) { |
| + result.pointerType = blink::WebPointerProperties::PointerType::Pen; |
| + } else { |
| + result.pointerType = blink::WebPointerProperties::PointerType::Mouse; |
| + } |
| + result.id = [event deviceID]; |
| + result.force = [event pressure]; |
| return result; |
| } |