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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_mac.mm

Issue 2373733002: Send pointerleave and pointerenter events for styluses on Mac (Closed)
Patch Set: Ready for review Created 4 years, 2 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /* 5 /*
6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
7 * Copyright (C) 2006-2009 Google Inc. 7 * Copyright (C) 2006-2009 Google Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 NOTIMPLEMENTED(); 320 NOTIMPLEMENTED();
321 321
322 result.timeStampSeconds = [event timestamp]; 322 result.timeStampSeconds = [event timestamp];
323 result.isSystemKey = IsSystemKeyEvent(result); 323 result.isSystemKey = IsSystemKeyEvent(result);
324 324
325 return result; 325 return result;
326 } 326 }
327 327
328 // WebMouseEvent -------------------------------------------------------------- 328 // WebMouseEvent --------------------------------------------------------------
329 329
330 blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) { 330 blink::WebMouseEvent WebMouseEventBuilder::Build(
331 NSEvent* event,
332 NSView* view,
333 blink::WebPointerProperties::PointerType pointerType) {
331 blink::WebMouseEvent result; 334 blink::WebMouseEvent result;
332 335
333 result.clickCount = 0; 336 result.clickCount = 0;
334 337
335 NSEventType type = [event type]; 338 NSEventType type = [event type];
336 switch (type) { 339 switch (type) {
337 case NSMouseExited: 340 case NSMouseExited:
338 result.type = blink::WebInputEvent::MouseLeave; 341 result.type = blink::WebInputEvent::MouseLeave;
339 result.button = blink::WebMouseEvent::Button::NoButton; 342 result.button = blink::WebMouseEvent::Button::NoButton;
340 break; 343 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 default: 390 default:
388 NOTIMPLEMENTED(); 391 NOTIMPLEMENTED();
389 } 392 }
390 393
391 SetWebEventLocationFromEventInView(&result, event, view); 394 SetWebEventLocationFromEventInView(&result, event, view);
392 395
393 result.modifiers = ModifiersFromEvent(event); 396 result.modifiers = ModifiersFromEvent(event);
394 397
395 result.timeStampSeconds = [event timestamp]; 398 result.timeStampSeconds = [event timestamp];
396 399
397 // For NSMouseExited and NSMouseEntered, they do not have a subtype. Styluses 400 // For NSMouseExited and NSMouseEntered events, they do not have a subtype.
398 // and mouses share the same cursor, so we will set their pointerType as 401 // We decide their pointer types by checking if we recevied a
mustaq 2016/10/14 16:07:16 Please clarify that the check is done at the calle
399 // Unknown for now. 402 // NSTabletProximity event.
400 if (type == NSMouseExited || type == NSMouseEntered) { 403 if (type == NSMouseExited || type == NSMouseEntered) {
401 result.pointerType = blink::WebPointerProperties::PointerType::Unknown; 404 result.pointerType = pointerType;
402 return result; 405 return result;
403 } 406 }
404 407
405 // For other mouse events and touchpad events, the pointer type is mouse. 408 // For other mouse events and touchpad events, the pointer type is mouse.
406 // For all other tablet events, the pointer type will be just pen. 409 // For all other tablet events, the pointer type will be just pen.
407 NSEventSubtype subtype = [event subtype]; 410 NSEventSubtype subtype = [event subtype];
408 if (subtype != NSTabletPointEventSubtype && 411 if (subtype != NSTabletPointEventSubtype &&
409 subtype != NSTabletProximityEventSubtype) { 412 subtype != NSTabletProximityEventSubtype) {
410 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; 413 result.pointerType = blink::WebPointerProperties::PointerType::Mouse;
411 return result; 414 return result;
412 } 415 }
413 416
414 // Set stylus properties for events with a subtype of 417 // Set stylus properties for events with a subtype of
415 // NSTabletPointEventSubtype. 418 // NSTabletPointEventSubtype.
mustaq 2016/10/14 16:07:16 This comment looks a bit stale: should say "a subt
416 result.pointerType = blink::WebPointerProperties::PointerType::Pen; 419 result.pointerType = blink::WebPointerProperties::PointerType::Pen;
mustaq 2016/10/14 16:07:16 The pen must be in proximity in this case right?
417 result.id = [event deviceID]; 420 result.id = [event deviceID];
418 if (subtype == NSTabletPointEventSubtype) { 421 if (subtype == NSTabletPointEventSubtype) {
419 result.force = [event pressure]; 422 result.force = [event pressure];
420 NSPoint tilt = [event tilt]; 423 NSPoint tilt = [event tilt];
421 result.tiltX = lround(tilt.x * 90); 424 result.tiltX = lround(tilt.x * 90);
422 result.tiltY = lround(tilt.y * 90); 425 result.tiltY = lround(tilt.y * 90);
426 } else {
427 result.type = [event isEnteringProximity]
428 ? blink::WebInputEvent::MouseMove
429 : blink::WebInputEvent::MouseLeave;
423 } 430 }
424 return result; 431 return result;
425 } 432 }
426 433
427 // WebMouseWheelEvent --------------------------------------------------------- 434 // WebMouseWheelEvent ---------------------------------------------------------
428 435
429 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build( 436 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build(
430 NSEvent* event, 437 NSEvent* event,
431 NSView* view) { 438 NSView* view) {
432 blink::WebMouseWheelEvent result; 439 blink::WebMouseWheelEvent result;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 break; 622 break;
616 default: 623 default:
617 NOTIMPLEMENTED(); 624 NOTIMPLEMENTED();
618 result.type = blink::WebInputEvent::Undefined; 625 result.type = blink::WebInputEvent::Undefined;
619 } 626 }
620 627
621 return result; 628 return result;
622 } 629 }
623 630
624 } // namespace content 631 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698