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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac_dictionary_helper.mm

Issue 1313553006: Implement "Look Up In Dictionary" context menu item asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac_dictionary_helper.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac_dictionary_helper.mm b/content/browser/renderer_host/render_widget_host_view_mac_dictionary_helper.mm
index 92f10bc2688d6d9e84c2a68b9bc772205fc97c83..aad93f9cb9d6839b678fe55ee3c3764c8b7ae550 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac_dictionary_helper.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac_dictionary_helper.mm
@@ -22,38 +22,13 @@ void RenderWidgetHostViewMacDictionaryHelper::SetTargetView(
void RenderWidgetHostViewMacDictionaryHelper::ShowDefinitionForSelection() {
NSRange selection_range = [view_->cocoa_view() selectedRange];
- NSAttributedString* attr_string =
- [view_->cocoa_view() attributedSubstringForProposedRange:selection_range
- actualRange:nil];
- if (!attr_string) {
- if (view_->selected_text().empty())
- return;
- // The PDF plugin does not support getting the attributed string. Until it
- // does, use NSPerformService(), which opens Dictionary.app.
- // http://crbug.com/152438
Alexei Svitkine (slow) 2015/09/02 15:10:25 Nit: I guess triple-finger tap also doesn't work P
Shu Chen 2015/09/03 14:43:02 Done.
- // TODO(asvitkine): This should be removed after the above support is added.
- NSString* text = base::SysUTF8ToNSString(view_->selected_text());
- NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName];
- NSArray* types = [NSArray arrayWithObject:NSStringPboardType];
- [pasteboard declareTypes:types owner:nil];
- if ([pasteboard setString:text forType:NSStringPboardType])
- NSPerformService(@"Look Up in Dictionary", pasteboard);
- return;
- }
-
NSRect rect =
[view_->cocoa_view() firstViewRectForCharacterRange:selection_range
actualRange:nil];
-
- NSDictionary* attrs = [attr_string attributesAtIndex:0 effectiveRange:nil];
- NSFont* font = [attrs objectForKey:NSFontAttributeName];
- rect.origin.y += NSHeight(rect) - [font ascender];
Alexei Svitkine (slow) 2015/09/02 15:10:25 Looks like you're no longer subtracting the font's
Shu Chen 2015/09/03 14:43:01 Yes, it still shows up in the right place. Because
-
+ rect.origin.y += NSHeight(rect);
Alexei Svitkine (slow) 2015/09/02 15:10:25 Nit: Combine this with line 30.
Shu Chen 2015/09/03 14:43:02 Done.
rect.origin.x += offset_.x();
rect.origin.y += offset_.y();
-
- [target_view_->cocoa_view() showDefinitionForAttributedString:attr_string
- atPoint:rect.origin];
+ [view_->cocoa_view() showLookUpDictionaryOverlayAtPoint:rect.origin];
}
} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698