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 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "skia/ext/skia_utils_mac.h" | 11 #include "skia/ext/skia_utils_mac.h" |
12 #include "ui/base/cocoa/cocoa_base_utils.h" | 12 #include "ui/base/cocoa/cocoa_base_utils.h" |
13 #include "ui/base/dragdrop/drag_drop_types.h" | 13 #include "ui/base/dragdrop/drag_drop_types.h" |
14 #include "ui/base/dragdrop/os_exchange_data_provider_mac.h" | 14 #include "ui/base/dragdrop/os_exchange_data_provider_mac.h" |
15 #include "ui/base/ime/input_method.h" | 15 #include "ui/base/ime/input_method.h" |
16 #include "ui/base/ime/text_edit_commands.h" | 16 #include "ui/base/ime/text_edit_commands.h" |
17 #include "ui/base/ime/text_input_client.h" | 17 #include "ui/base/ime/text_input_client.h" |
18 #include "ui/compositor/canvas_painter.h" | 18 #include "ui/compositor/canvas_painter.h" |
19 #import "ui/events/cocoa/cocoa_event_utils.h" | 19 #import "ui/events/cocoa/cocoa_event_utils.h" |
20 #include "ui/events/event_utils.h" | |
20 #include "ui/events/keycodes/dom/dom_code.h" | 21 #include "ui/events/keycodes/dom/dom_code.h" |
21 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 22 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
22 #include "ui/gfx/canvas_paint_mac.h" | 23 #include "ui/gfx/canvas_paint_mac.h" |
23 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
24 #import "ui/gfx/mac/coordinate_conversion.h" | 25 #import "ui/gfx/mac/coordinate_conversion.h" |
25 #include "ui/gfx/path.h" | 26 #include "ui/gfx/path.h" |
26 #import "ui/gfx/path_mac.h" | 27 #import "ui/gfx/path_mac.h" |
27 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 28 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
28 #import "ui/views/cocoa/bridged_native_widget.h" | 29 #import "ui/views/cocoa/bridged_native_widget.h" |
29 #import "ui/views/cocoa/drag_drop_client_mac.h" | 30 #import "ui/views/cocoa/drag_drop_client_mac.h" |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 } | 734 } |
734 | 735 |
735 - (void)scrollWheel:(NSEvent*)theEvent { | 736 - (void)scrollWheel:(NSEvent*)theEvent { |
736 if (!hostedView_) | 737 if (!hostedView_) |
737 return; | 738 return; |
738 | 739 |
739 ui::MouseWheelEvent event(theEvent); | 740 ui::MouseWheelEvent event(theEvent); |
740 hostedView_->GetWidget()->OnMouseEvent(&event); | 741 hostedView_->GetWidget()->OnMouseEvent(&event); |
741 } | 742 } |
742 | 743 |
744 - (void)quickLookWithEvent:(NSEvent*)theEvent { | |
745 if (!hostedView_) | |
746 return; | |
747 | |
748 const gfx::Point& locationInContent = ui::EventLocationFromNative(theEvent); | |
tapted
2016/09/21 04:06:56
no reference (I know C++ allows this to extend the
karandeepb
2016/09/22 08:17:39
Done.
| |
749 views::View* target = hostedView_->GetEventHandlerForPoint(locationInContent); | |
750 if (!target) | |
751 return; | |
752 | |
753 gfx::Point locationInTarget = locationInContent; | |
754 // Todo check if ConvertPointToTarget is safe. | |
755 views::View::ConvertPointToTarget(hostedView_, target, &locationInTarget); | |
756 NSMutableAttributedString* word = | |
tapted
2016/09/21 04:06:56
Use scoped_nsobject - autorelease has additional o
karandeepb
2016/09/22 08:17:39
I guess it's preferred to return an autoreleased N
| |
757 [[[NSMutableAttributedString alloc] init] autorelease]; | |
758 gfx::Point baselinePoint; | |
759 bool retreived = | |
760 target->GetWordAtPoint(locationInTarget, word, &baselinePoint); | |
tapted
2016/09/21 04:06:56
If there's an existing selection, does quickLook l
tapted
2016/09/21 04:44:14
Ah, I checked this, and it doesn't :). But you can
karandeepb
2016/09/21 05:37:12
Yeah I had thought about that. The private RenderT
| |
761 if (!retreived) | |
762 return; | |
763 | |
764 // Convert |baselinePoint| to coordinate system of |hostedView_|. | |
765 views::View::ConvertPointToTarget(target, hostedView_, &baselinePoint); | |
766 NSPoint baselinePointAppKit = NSMakePoint( | |
767 baselinePoint.x(), NSHeight([self frame]) - baselinePoint.y()); | |
768 [self showDefinitionForAttributedString:word atPoint:baselinePointAppKit]; | |
769 } | |
770 | |
743 //////////////////////////////////////////////////////////////////////////////// | 771 //////////////////////////////////////////////////////////////////////////////// |
744 // NSResponder Action Messages. Keep sorted according NSResponder.h (from the | 772 // NSResponder Action Messages. Keep sorted according NSResponder.h (from the |
745 // 10.9 SDK). The list should eventually be complete. Anything not defined will | 773 // 10.9 SDK). The list should eventually be complete. Anything not defined will |
746 // beep when interpretKeyEvents: would otherwise call it. | 774 // beep when interpretKeyEvents: would otherwise call it. |
747 // TODO(tapted): Make this list complete, except for insert* methods which are | 775 // TODO(tapted): Make this list complete, except for insert* methods which are |
748 // dispatched as regular key events in doCommandBySelector:. | 776 // dispatched as regular key events in doCommandBySelector:. |
749 | 777 |
750 // views::Textfields are single-line only, map Paragraph and Document commands | 778 // views::Textfields are single-line only, map Paragraph and Document commands |
751 // to Line. Also, Up/Down commands correspond to beginning/end of line. | 779 // to Line. Also, Up/Down commands correspond to beginning/end of line. |
752 | 780 |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1356 } | 1384 } |
1357 | 1385 |
1358 return [super accessibilityAttributeValue:attribute]; | 1386 return [super accessibilityAttributeValue:attribute]; |
1359 } | 1387 } |
1360 | 1388 |
1361 - (id)accessibilityHitTest:(NSPoint)point { | 1389 - (id)accessibilityHitTest:(NSPoint)point { |
1362 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 1390 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
1363 } | 1391 } |
1364 | 1392 |
1365 @end | 1393 @end |
OLD | NEW |