OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_content_view.h" | 5 #import "ui/views/cocoa/bridged_content_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 } | 793 } |
794 | 794 |
795 - (void)scrollWheel:(NSEvent*)theEvent { | 795 - (void)scrollWheel:(NSEvent*)theEvent { |
796 if (!hostedView_) | 796 if (!hostedView_) |
797 return; | 797 return; |
798 | 798 |
799 ui::ScrollEvent event(theEvent); | 799 ui::ScrollEvent event(theEvent); |
800 hostedView_->GetWidget()->OnScrollEvent(&event); | 800 hostedView_->GetWidget()->OnScrollEvent(&event); |
801 } | 801 } |
802 | 802 |
803 // Called when we get a three-finger swipe, and they're enabled in System | |
804 // Preferences. | |
805 - (void)swipeWithEvent:(NSEvent*)event { | |
806 if (!hostedView_) | |
807 return; | |
808 | |
809 // We need to invert deltas in order to match GestureEventDetails's | |
810 // directions. | |
811 auto invert = [](CGFloat val) { return val * -1.; }; | |
tapted
2017/02/15 22:25:53
The comment is good, but (unless I'm missing somet
themblsha
2017/02/16 15:27:49
You've opened my eyes yet again. Thanks :-)
| |
812 ui::GestureEventDetails swipeDetails( | |
813 ui::ET_GESTURE_SWIPE, invert([event deltaX]), invert([event deltaY])); | |
814 swipeDetails.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD); | |
815 | |
816 gfx::PointF location = ui::EventLocationFromNative(event); | |
817 ui::GestureEvent gestureEvent(location.x(), location.y(), | |
818 ui::EventFlagsFromNative(event), | |
819 ui::EventTimeFromNative(event), swipeDetails); | |
820 | |
821 hostedView_->GetWidget()->OnGestureEvent(&gestureEvent); | |
822 } | |
823 | |
803 - (void)quickLookWithEvent:(NSEvent*)theEvent { | 824 - (void)quickLookWithEvent:(NSEvent*)theEvent { |
804 if (!hostedView_) | 825 if (!hostedView_) |
805 return; | 826 return; |
806 | 827 |
807 const gfx::Point locationInContent = | 828 const gfx::Point locationInContent = |
808 gfx::ToFlooredPoint(ui::EventLocationFromNative(theEvent)); | 829 gfx::ToFlooredPoint(ui::EventLocationFromNative(theEvent)); |
809 views::View* target = hostedView_->GetEventHandlerForPoint(locationInContent); | 830 views::View* target = hostedView_->GetEventHandlerForPoint(locationInContent); |
810 if (!target) | 831 if (!target) |
811 return; | 832 return; |
812 | 833 |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 1478 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
1458 } | 1479 } |
1459 | 1480 |
1460 - (id)accessibilityFocusedUIElement { | 1481 - (id)accessibilityFocusedUIElement { |
1461 if (!hostedView_) | 1482 if (!hostedView_) |
1462 return nil; | 1483 return nil; |
1463 return [hostedView_->GetNativeViewAccessible() accessibilityFocusedUIElement]; | 1484 return [hostedView_->GetNativeViewAccessible() accessibilityFocusedUIElement]; |
1464 } | 1485 } |
1465 | 1486 |
1466 @end | 1487 @end |
OLD | NEW |