Index: ui/views/cocoa/bridged_content_view.mm |
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
index 1623e32b8ede82ff2b578ad5500010dca09f991c..c7b908eec2144474aad21d698f88602d6db2ef96 100644 |
--- a/ui/views/cocoa/bridged_content_view.mm |
+++ b/ui/views/cocoa/bridged_content_view.mm |
@@ -17,6 +17,7 @@ |
#include "ui/base/ime/text_input_client.h" |
#include "ui/compositor/canvas_painter.h" |
#import "ui/events/cocoa/cocoa_event_utils.h" |
+#include "ui/events/event_utils.h" |
#include "ui/events/keycodes/dom/dom_code.h" |
#import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
#include "ui/gfx/canvas_paint_mac.h" |
@@ -740,6 +741,33 @@ - (void)scrollWheel:(NSEvent*)theEvent { |
hostedView_->GetWidget()->OnMouseEvent(&event); |
} |
+- (void)quickLookWithEvent:(NSEvent*)theEvent { |
+ if (!hostedView_) |
+ return; |
+ |
+ 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.
|
+ views::View* target = hostedView_->GetEventHandlerForPoint(locationInContent); |
+ if (!target) |
+ return; |
+ |
+ gfx::Point locationInTarget = locationInContent; |
+ // Todo check if ConvertPointToTarget is safe. |
+ views::View::ConvertPointToTarget(hostedView_, target, &locationInTarget); |
+ 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
|
+ [[[NSMutableAttributedString alloc] init] autorelease]; |
+ gfx::Point baselinePoint; |
+ bool retreived = |
+ 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
|
+ if (!retreived) |
+ return; |
+ |
+ // Convert |baselinePoint| to coordinate system of |hostedView_|. |
+ views::View::ConvertPointToTarget(target, hostedView_, &baselinePoint); |
+ NSPoint baselinePointAppKit = NSMakePoint( |
+ baselinePoint.x(), NSHeight([self frame]) - baselinePoint.y()); |
+ [self showDefinitionForAttributedString:word atPoint:baselinePointAppKit]; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// NSResponder Action Messages. Keep sorted according NSResponder.h (from the |
// 10.9 SDK). The list should eventually be complete. Anything not defined will |