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

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

Issue 1244723003: [Mac] Update context menu dictionary lookup wording and placement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 5 years, 5 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
« no previous file with comments | « chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/strings/sys_string_conversions.h" 5 #include "base/strings/sys_string_conversions.h"
6 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 6 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h"
7 #import "content/browser/renderer_host/render_widget_host_view_mac.h" 7 #import "content/browser/renderer_host/render_widget_host_view_mac.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 RenderWidgetHostViewMacDictionaryHelper:: 11 RenderWidgetHostViewMacDictionaryHelper::
12 RenderWidgetHostViewMacDictionaryHelper(RenderWidgetHostView* view) 12 RenderWidgetHostViewMacDictionaryHelper(RenderWidgetHostView* view)
13 : view_(static_cast<RenderWidgetHostViewMac*>(view)), 13 : view_(static_cast<RenderWidgetHostViewMac*>(view)),
14 target_view_(static_cast<RenderWidgetHostViewMac*>(view)) { 14 target_view_(static_cast<RenderWidgetHostViewMac*>(view)) {
15 } 15 }
16 16
17 void RenderWidgetHostViewMacDictionaryHelper::SetTargetView( 17 void RenderWidgetHostViewMacDictionaryHelper::SetTargetView(
18 RenderWidgetHostView* target_view) { 18 RenderWidgetHostView* target_view) {
19 target_view_ = static_cast<RenderWidgetHostViewMac*>(target_view); 19 target_view_ = static_cast<RenderWidgetHostViewMac*>(target_view);
20 } 20 }
21 21
22 void RenderWidgetHostViewMacDictionaryHelper::ShowDefinitionForSelection() { 22 void RenderWidgetHostViewMacDictionaryHelper::ShowDefinitionForSelection() {
23 NSRange selection_range = [view_->cocoa_view() selectedRange]; 23 NSRange selection_range = [view_->cocoa_view() selectedRange];
24 NSAttributedString* attr_string = 24 NSAttributedString* attr_string =
25 [view_->cocoa_view() attributedSubstringForProposedRange:selection_range 25 [view_->cocoa_view() attributedSubstringForProposedRange:selection_range
26 actualRange:nil]; 26 actualRange:nil];
27 if (!attr_string) { 27 if (!attr_string) {
28 if (view_->selected_text().empty()) 28 if (view_->selected_text().empty())
29 return; 29 return;
30 // The PDF plugin does not support getting the attributed string. Until it 30 // The PDF plugin does not support getting the attributed string. Until it
31 // does, use NSPerformService(), which opens Dictionary.app. 31 // does, use NSPerformService(), which opens Dictionary.app.
32 // http://crbug.com/152438 32 // http://crbug.com/152438
33 // TODO(asvitkine): This should be removed after the above support is added. 33 // TODO(asvitkine): This should be removed after the above support is added.
34 NSString* text = base::SysUTF8ToNSString(view_->selected_text()); 34 NSString* text = base::SysUTF8ToNSString(view_->selected_text());
35 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName]; 35 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName];
36 NSArray* types = [NSArray arrayWithObject:NSStringPboardType]; 36 NSArray* types = [NSArray arrayWithObject:NSStringPboardType];
(...skipping 12 matching lines...) Expand all
49 rect.origin.y += NSHeight(rect) - [font ascender]; 49 rect.origin.y += NSHeight(rect) - [font ascender];
50 50
51 rect.origin.x += offset_.x(); 51 rect.origin.x += offset_.x();
52 rect.origin.y += offset_.y(); 52 rect.origin.y += offset_.y();
53 53
54 [target_view_->cocoa_view() showDefinitionForAttributedString:attr_string 54 [target_view_->cocoa_view() showDefinitionForAttributedString:attr_string
55 atPoint:rect.origin]; 55 atPoint:rect.origin];
56 } 56 }
57 57
58 } // namespace content 58 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698