OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2333 return; | 2333 return; |
2334 } | 2334 } |
2335 dispatch_async(dispatch_get_main_queue(), ^{ | 2335 dispatch_async(dispatch_get_main_queue(), ^{ |
2336 [view showDefinitionForAttributedString:string | 2336 [view showDefinitionForAttributedString:string |
2337 atPoint:baselinePoint]; | 2337 atPoint:baselinePoint]; |
2338 }); | 2338 }); |
2339 } | 2339 } |
2340 | 2340 |
2341 - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range | 2341 - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range |
2342 targetView:(NSView*)targetView { | 2342 targetView:(NSView*)targetView { |
2343 RenderWidgetHostImpl* widgetHost = renderWidgetHostView_->render_widget_host_; | |
2344 if (!widgetHost || !widgetHost->delegate()) | |
2345 return; | |
2346 widgetHost = widgetHost->delegate()->GetFocusedRenderWidgetHost(widgetHost); | |
2347 | |
2348 if (!widgetHost) | |
2349 return; | |
Charlie Reis
2016/10/07 19:07:21
nit: Add blank line after.
EhsanK
2016/10/11 19:31:56
Done.
| |
2350 // TODO(ekaramad): The position reported by the renderer is with respect to | |
2351 // |widgetHost|'s coordinate space with y-axis inverted to conform to AppKit | |
2352 // coordinate system. The point will need to be transformed into root view's | |
2353 // coordinate system (RenderWidgetHostViewMac in this case). However, since | |
2354 // the callback is invoked on IO thread it will require some thread hopping to | |
2355 // do so. For this reason, for now, we accept this non-ideal way of fixing the | |
2356 // point offset manually from the view bounds. This should be revisited when | |
2357 // fixing issues in TextInputClientMac (https://crbug.com/643233). | |
2358 gfx::Rect root_box = renderWidgetHostView_->GetViewBounds(); | |
2359 gfx::Rect view_box = widgetHost->GetView()->GetViewBounds(); | |
2360 | |
2343 TextInputClientMac::GetInstance()->GetStringFromRange( | 2361 TextInputClientMac::GetInstance()->GetStringFromRange( |
2344 renderWidgetHostView_->render_widget_host_, range, | 2362 widgetHost, range, ^(NSAttributedString* string, NSPoint baselinePoint) { |
2345 ^(NSAttributedString* string, NSPoint baselinePoint) { | 2363 baselinePoint.x += view_box.origin().x() - root_box.origin().x(); |
2364 baselinePoint.y += | |
2365 root_box.bottom_left().y() - view_box.bottom_left().y(); | |
2346 [self showLookUpDictionaryOverlayInternal:string | 2366 [self showLookUpDictionaryOverlayInternal:string |
2347 baselinePoint:baselinePoint | 2367 baselinePoint:baselinePoint |
2348 targetView:targetView]; | 2368 targetView:targetView]; |
2349 } | 2369 }); |
2350 ); | |
2351 } | 2370 } |
2352 | 2371 |
2353 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { | 2372 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { |
2354 gfx::Point rootPoint(point.x, NSHeight([self frame]) - point.y); | 2373 gfx::Point rootPoint(point.x, NSHeight([self frame]) - point.y); |
2355 gfx::Point transformedPoint; | 2374 gfx::Point transformedPoint; |
2356 if (!renderWidgetHostView_->render_widget_host_ || | 2375 if (!renderWidgetHostView_->render_widget_host_ || |
2357 !renderWidgetHostView_->render_widget_host_->delegate() || | 2376 !renderWidgetHostView_->render_widget_host_->delegate() || |
2358 !renderWidgetHostView_->render_widget_host_->delegate() | 2377 !renderWidgetHostView_->render_widget_host_->delegate() |
2359 ->GetInputEventRouter()) | 2378 ->GetInputEventRouter()) |
2360 return; | 2379 return; |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3363 | 3382 |
3364 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3383 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3365 // regions that are not draggable. (See ControlRegionView in | 3384 // regions that are not draggable. (See ControlRegionView in |
3366 // native_app_window_cocoa.mm). This requires the render host view to be | 3385 // native_app_window_cocoa.mm). This requires the render host view to be |
3367 // draggable by default. | 3386 // draggable by default. |
3368 - (BOOL)mouseDownCanMoveWindow { | 3387 - (BOOL)mouseDownCanMoveWindow { |
3369 return YES; | 3388 return YES; |
3370 } | 3389 } |
3371 | 3390 |
3372 @end | 3391 @end |
OLD | NEW |