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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2278283002: Implement Mac Pop-up Dictionary for OOPIF. (Closed)
Patch Set: Rebased Created 4 years, 3 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
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/common/accessibility_messages.h" 53 #include "content/common/accessibility_messages.h"
54 #include "content/common/edit_command.h" 54 #include "content/common/edit_command.h"
55 #include "content/common/input_messages.h" 55 #include "content/common/input_messages.h"
56 #include "content/common/site_isolation_policy.h" 56 #include "content/common/site_isolation_policy.h"
57 #include "content/common/text_input_state.h" 57 #include "content/common/text_input_state.h"
58 #include "content/common/view_messages.h" 58 #include "content/common/view_messages.h"
59 #include "content/public/browser/browser_context.h" 59 #include "content/public/browser/browser_context.h"
60 #include "content/public/browser/browser_plugin_guest_manager.h" 60 #include "content/public/browser/browser_plugin_guest_manager.h"
61 #include "content/public/browser/browser_thread.h" 61 #include "content/public/browser/browser_thread.h"
62 #include "content/public/browser/native_web_keyboard_event.h" 62 #include "content/public/browser/native_web_keyboard_event.h"
63 #include "content/public/browser/render_widget_host.h"
63 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 64 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
64 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 65 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
65 #include "content/public/browser/web_contents.h" 66 #include "content/public/browser/web_contents.h"
66 #include "gpu/ipc/common/gpu_messages.h" 67 #include "gpu/ipc/common/gpu_messages.h"
67 #include "skia/ext/platform_canvas.h" 68 #include "skia/ext/platform_canvas.h"
68 #include "skia/ext/skia_utils_mac.h" 69 #include "skia/ext/skia_utils_mac.h"
69 #include "third_party/WebKit/public/web/WebInputEvent.h" 70 #include "third_party/WebKit/public/web/WebInputEvent.h"
70 #import "ui/base/clipboard/clipboard_util_mac.h" 71 #import "ui/base/clipboard/clipboard_util_mac.h"
71 #include "ui/base/cocoa/animation_utils.h" 72 #include "ui/base/cocoa/animation_utils.h"
72 #import "ui/base/cocoa/appkit_utils.h" 73 #import "ui/base/cocoa/appkit_utils.h"
(...skipping 15 matching lines...) Expand all
88 #include "ui/gl/gl_switches.h" 89 #include "ui/gl/gl_switches.h"
89 90
90 using content::BrowserAccessibility; 91 using content::BrowserAccessibility;
91 using content::BrowserAccessibilityManager; 92 using content::BrowserAccessibilityManager;
92 using content::EditCommand; 93 using content::EditCommand;
93 using content::FrameTreeNode; 94 using content::FrameTreeNode;
94 using content::NativeWebKeyboardEvent; 95 using content::NativeWebKeyboardEvent;
95 using content::RenderFrameHost; 96 using content::RenderFrameHost;
96 using content::RenderViewHost; 97 using content::RenderViewHost;
97 using content::RenderViewHostImpl; 98 using content::RenderViewHostImpl;
99 using content::RenderWidgetHost;
98 using content::RenderWidgetHostImpl; 100 using content::RenderWidgetHostImpl;
99 using content::RenderWidgetHostViewMac; 101 using content::RenderWidgetHostViewMac;
100 using content::RenderWidgetHostViewMacEditCommandHelper; 102 using content::RenderWidgetHostViewMacEditCommandHelper;
101 using content::TextInputClientMac; 103 using content::TextInputClientMac;
102 using content::WebContents; 104 using content::WebContents;
103 using content::WebGestureEventBuilder; 105 using content::WebGestureEventBuilder;
104 using content::WebMouseEventBuilder; 106 using content::WebMouseEventBuilder;
105 using content::WebMouseWheelEventBuilder; 107 using content::WebMouseWheelEventBuilder;
106 using blink::WebInputEvent; 108 using blink::WebInputEvent;
107 using blink::WebMouseEvent; 109 using blink::WebMouseEvent;
(...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 renderWidgetHostView_->render_widget_host_, range, 2280 renderWidgetHostView_->render_widget_host_, range,
2279 ^(NSAttributedString* string, NSPoint baselinePoint) { 2281 ^(NSAttributedString* string, NSPoint baselinePoint) {
2280 [self showLookUpDictionaryOverlayInternal:string 2282 [self showLookUpDictionaryOverlayInternal:string
2281 baselinePoint:baselinePoint 2283 baselinePoint:baselinePoint
2282 targetView:targetView]; 2284 targetView:targetView];
2283 } 2285 }
2284 ); 2286 );
2285 } 2287 }
2286 2288
2287 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { 2289 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point {
2290 gfx::Point rootPoint(point.x, NSHeight([self frame]) - point.y);
2291 gfx::Point transformedPoint;
2292 if (!renderWidgetHostView_->render_widget_host_ ||
2293 !renderWidgetHostView_->render_widget_host_->delegate() ||
2294 !renderWidgetHostView_->render_widget_host_->delegate()
2295 ->GetInputEventRouter())
2296 return;
2297
2298 RenderWidgetHostImpl* widgetHost =
2299 renderWidgetHostView_->render_widget_host_->delegate()
2300 ->GetInputEventRouter()
2301 ->GetRenderWidgetHostAtPoint(renderWidgetHostView_.get(), rootPoint,
2302 &transformedPoint);
2303 if (!widgetHost)
2304 return;
2305
2306 gfx::Rect root_box = renderWidgetHostView_->GetViewBounds();
2307 gfx::Rect view_box = widgetHost->GetView()->GetViewBounds();
2308
2288 TextInputClientMac::GetInstance()->GetStringAtPoint( 2309 TextInputClientMac::GetInstance()->GetStringAtPoint(
2289 renderWidgetHostView_->render_widget_host_, 2310 widgetHost, transformedPoint,
2290 gfx::Point(point.x, NSHeight([self frame]) - point.y),
2291 ^(NSAttributedString* string, NSPoint baselinePoint) { 2311 ^(NSAttributedString* string, NSPoint baselinePoint) {
2312 baselinePoint.x += view_box.origin().x() - root_box.origin().x();
2313 baselinePoint.y +=
2314 root_box.bottom_left().y() - view_box.bottom_left().y();
2292 [self showLookUpDictionaryOverlayInternal:string 2315 [self showLookUpDictionaryOverlayInternal:string
2293 baselinePoint:baselinePoint 2316 baselinePoint:baselinePoint
2294 targetView:self]; 2317 targetView:self];
2295 } 2318 });
2296 );
2297 } 2319 }
2298 2320
2299 // This is invoked only on 10.8 or newer when the user taps a word using 2321 // This is invoked only on 10.8 or newer when the user taps a word using
2300 // three fingers. 2322 // three fingers.
2301 - (void)quickLookWithEvent:(NSEvent*)event { 2323 - (void)quickLookWithEvent:(NSEvent*)event {
2302 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; 2324 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
2303 [self showLookUpDictionaryOverlayAtPoint:point]; 2325 [self showLookUpDictionaryOverlayAtPoint:point];
2304 } 2326 }
2305 2327
2306 // This method handles 2 different types of hardware events. 2328 // This method handles 2 different types of hardware events.
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 2824
2803 - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint { 2825 - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint {
2804 DCHECK([self window]); 2826 DCHECK([self window]);
2805 // |thePoint| is in screen coordinates, but needs to be converted to WebKit 2827 // |thePoint| is in screen coordinates, but needs to be converted to WebKit
2806 // coordinates (upper left origin). Scroll offsets will be taken care of in 2828 // coordinates (upper left origin). Scroll offsets will be taken care of in
2807 // the renderer. 2829 // the renderer.
2808 thePoint = ui::ConvertPointFromScreenToWindow([self window], thePoint); 2830 thePoint = ui::ConvertPointFromScreenToWindow([self window], thePoint);
2809 thePoint = [self convertPoint:thePoint fromView:nil]; 2831 thePoint = [self convertPoint:thePoint fromView:nil];
2810 thePoint.y = NSHeight([self frame]) - thePoint.y; 2832 thePoint.y = NSHeight([self frame]) - thePoint.y;
2811 2833
2834 if (!renderWidgetHostView_->render_widget_host_ ||
2835 !renderWidgetHostView_->render_widget_host_->delegate() ||
2836 !renderWidgetHostView_->render_widget_host_->delegate()
2837 ->GetInputEventRouter())
2838 return NSNotFound;
2839
2840 gfx::Point rootPoint(thePoint.x, thePoint.y);
2841 gfx::Point transformedPoint;
2842 RenderWidgetHostImpl* widgetHost =
2843 renderWidgetHostView_->render_widget_host_->delegate()
2844 ->GetInputEventRouter()
2845 ->GetRenderWidgetHostAtPoint(renderWidgetHostView_.get(), rootPoint,
2846 &transformedPoint);
2847 if (!widgetHost)
2848 return NSNotFound;
2849
2812 NSUInteger index = 2850 NSUInteger index =
2813 TextInputClientMac::GetInstance()->GetCharacterIndexAtPoint( 2851 TextInputClientMac::GetInstance()->GetCharacterIndexAtPoint(
2814 renderWidgetHostView_->render_widget_host_, 2852 widgetHost, transformedPoint);
2815 gfx::Point(thePoint.x, thePoint.y));
2816 return index; 2853 return index;
2817 } 2854 }
2818 2855
2819 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange 2856 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange
2820 actualRange:(NSRangePointer)actualRange { 2857 actualRange:(NSRangePointer)actualRange {
2821 NSRect rect; 2858 NSRect rect;
2822 if (!renderWidgetHostView_->GetCachedFirstRectForCharacterRange( 2859 if (!renderWidgetHostView_->GetCachedFirstRectForCharacterRange(
2823 theRange, 2860 theRange,
2824 &rect, 2861 &rect,
2825 actualRange)) { 2862 actualRange)) {
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 3301
3265 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3302 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3266 // regions that are not draggable. (See ControlRegionView in 3303 // regions that are not draggable. (See ControlRegionView in
3267 // native_app_window_cocoa.mm). This requires the render host view to be 3304 // native_app_window_cocoa.mm). This requires the render host view to be
3268 // draggable by default. 3305 // draggable by default.
3269 - (BOOL)mouseDownCanMoveWindow { 3306 - (BOOL)mouseDownCanMoveWindow {
3270 return YES; 3307 return YES;
3271 } 3308 }
3272 3309
3273 @end 3310 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698