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

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

Issue 2056053002: We did not set the pointer type for WebMouseEvent, which is created from NSEvent in WebMouseEventBu… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 return result; 661 return result;
662 } 662 }
663 663
664 // WebMouseEvent -------------------------------------------------------------- 664 // WebMouseEvent --------------------------------------------------------------
665 665
666 blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) { 666 blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) {
667 blink::WebMouseEvent result; 667 blink::WebMouseEvent result;
668 668
669 result.clickCount = 0; 669 result.clickCount = 0;
670 670
671 switch ([event type]) { 671 NSEventType type = [event type];
672 switch (type) {
672 case NSMouseExited: 673 case NSMouseExited:
673 result.type = blink::WebInputEvent::MouseLeave; 674 result.type = blink::WebInputEvent::MouseLeave;
674 result.button = blink::WebMouseEvent::ButtonNone; 675 result.button = blink::WebMouseEvent::ButtonNone;
675 break; 676 break;
676 case NSLeftMouseDown: 677 case NSLeftMouseDown:
677 result.type = blink::WebInputEvent::MouseDown; 678 result.type = blink::WebInputEvent::MouseDown;
678 result.clickCount = [event clickCount]; 679 result.clickCount = [event clickCount];
679 result.button = blink::WebMouseEvent::ButtonLeft; 680 result.button = blink::WebMouseEvent::ButtonLeft;
680 break; 681 break;
681 case NSOtherMouseDown: 682 case NSOtherMouseDown:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 default: 723 default:
723 NOTIMPLEMENTED(); 724 NOTIMPLEMENTED();
724 } 725 }
725 726
726 SetWebEventLocationFromEventInView(&result, event, view); 727 SetWebEventLocationFromEventInView(&result, event, view);
727 728
728 result.modifiers = ModifiersFromEvent(event); 729 result.modifiers = ModifiersFromEvent(event);
729 730
730 result.timeStampSeconds = [event timestamp]; 731 result.timeStampSeconds = [event timestamp];
731 732
733 // For NSMouseExited and NSMouseEntered, they do not have a subtype. Styluses
734 // and mouses share the same cursor, so we will set their pointerType as
735 // Unknown for now.
736 if (type == NSMouseExited || type == NSMouseEntered) {
737 result.pointerType = blink::WebPointerProperties::PointerType::Unknown;
738 return result;
739 }
740
741 // For other mouse events and touchpad events, the pointer type is mouse.
742 // For all other tablet events, the pointer type will be just pen.
743 NSEventSubtype subtype = [event subtype];
744 if (subtype == NSTabletPointEventSubtype ||
745 subtype == NSTabletProximityEventSubtype) {
746 result.pointerType = blink::WebPointerProperties::PointerType::Pen;
747 } else {
748 result.pointerType = blink::WebPointerProperties::PointerType::Mouse;
749 }
750 result.id = [event deviceID];
751 result.force = [event pressure];
732 return result; 752 return result;
733 } 753 }
734 754
735 // WebMouseWheelEvent --------------------------------------------------------- 755 // WebMouseWheelEvent ---------------------------------------------------------
736 756
737 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build( 757 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build(
738 NSEvent* event, 758 NSEvent* event,
739 NSView* view, 759 NSView* view,
740 bool can_rubberband_left, 760 bool can_rubberband_left,
741 bool can_rubberband_right) { 761 bool can_rubberband_right) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 break; 951 break;
932 default: 952 default:
933 NOTIMPLEMENTED(); 953 NOTIMPLEMENTED();
934 result.type = blink::WebInputEvent::Undefined; 954 result.type = blink::WebInputEvent::Undefined;
935 } 955 }
936 956
937 return result; 957 return result;
938 } 958 }
939 959
940 } // namespace content 960 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698