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

Side by Side Diff: content/renderer/text_input_client_observer.cc

Issue 166903005: mac: Add support for asynchronous dictionary lookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for dcheng and rebase. Created 6 years, 9 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 | « content/renderer/text_input_client_observer.h ('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 (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/renderer/text_input_client_observer.h" 5 #include "content/renderer/text_input_client_observer.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/common/text_input_client_messages.h" 8 #include "content/common/text_input_client_messages.h"
9 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 9 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
10 #include "content/renderer/render_view_impl.h" 10 #include "content/renderer/render_view_impl.h"
(...skipping 11 matching lines...) Expand all
22 : RenderViewObserver(render_view), 22 : RenderViewObserver(render_view),
23 render_view_impl_(render_view) { 23 render_view_impl_(render_view) {
24 } 24 }
25 25
26 TextInputClientObserver::~TextInputClientObserver() { 26 TextInputClientObserver::~TextInputClientObserver() {
27 } 27 }
28 28
29 bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) { 29 bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) {
30 bool handled = true; 30 bool handled = true;
31 IPC_BEGIN_MESSAGE_MAP(TextInputClientObserver, message) 31 IPC_BEGIN_MESSAGE_MAP(TextInputClientObserver, message)
32 IPC_MESSAGE_HANDLER(TextInputClientMsg_StringAtPoint,
33 OnStringAtPoint)
32 IPC_MESSAGE_HANDLER(TextInputClientMsg_CharacterIndexForPoint, 34 IPC_MESSAGE_HANDLER(TextInputClientMsg_CharacterIndexForPoint,
33 OnCharacterIndexForPoint) 35 OnCharacterIndexForPoint)
34 IPC_MESSAGE_HANDLER(TextInputClientMsg_FirstRectForCharacterRange, 36 IPC_MESSAGE_HANDLER(TextInputClientMsg_FirstRectForCharacterRange,
35 OnFirstRectForCharacterRange) 37 OnFirstRectForCharacterRange)
36 IPC_MESSAGE_HANDLER(TextInputClientMsg_StringForRange, OnStringForRange) 38 IPC_MESSAGE_HANDLER(TextInputClientMsg_StringForRange, OnStringForRange)
37 IPC_MESSAGE_UNHANDLED(handled = false) 39 IPC_MESSAGE_UNHANDLED(handled = false)
38 IPC_END_MESSAGE_MAP() 40 IPC_END_MESSAGE_MAP()
39 return handled; 41 return handled;
40 } 42 }
41 43
42 blink::WebView* TextInputClientObserver::webview() { 44 blink::WebView* TextInputClientObserver::webview() {
43 return render_view()->GetWebView(); 45 return render_view()->GetWebView();
44 } 46 }
45 47
48 void TextInputClientObserver::OnStringAtPoint(gfx::Point point) {
49 #if defined(OS_MACOSX)
50 blink::WebPoint baselinePoint;
51 NSAttributedString* string = blink::WebSubstringUtil::attributedWordAtPoint(
52 webview(), point, baselinePoint);
53
54 scoped_ptr<const mac::AttributedStringCoder::EncodedString> encoded(
55 mac::AttributedStringCoder::Encode(string));
56 Send(new TextInputClientReplyMsg_GotStringAtPoint(
57 routing_id(), *encoded.get(), baselinePoint));
58 #else
59 NOTIMPLEMENTED();
60 #endif
61 }
62
46 void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) { 63 void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) {
47 blink::WebPoint web_point(point); 64 blink::WebPoint web_point(point);
48 size_t index = webview()->focusedFrame()->characterIndexForPoint(web_point); 65 size_t index = webview()->focusedFrame()->characterIndexForPoint(web_point);
49 Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint(routing_id(), 66 Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint(routing_id(),
50 index)); 67 index));
51 } 68 }
52 69
53 void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) { 70 void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) {
54 gfx::Rect rect; 71 gfx::Rect rect;
55 #if defined(ENABLE_PLUGINS) 72 #if defined(ENABLE_PLUGINS)
(...skipping 24 matching lines...) Expand all
80 scoped_ptr<const mac::AttributedStringCoder::EncodedString> encoded( 97 scoped_ptr<const mac::AttributedStringCoder::EncodedString> encoded(
81 mac::AttributedStringCoder::Encode(string)); 98 mac::AttributedStringCoder::Encode(string));
82 Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(), 99 Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(),
83 *encoded.get())); 100 *encoded.get()));
84 #else 101 #else
85 NOTIMPLEMENTED(); 102 NOTIMPLEMENTED();
86 #endif 103 #endif
87 } 104 }
88 105
89 } // namespace content 106 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/text_input_client_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698