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/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/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
10 #include "third_party/WebKit/public/platform/WebPoint.h" | 10 #include "third_party/WebKit/public/platform/WebPoint.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return render_view()->GetWebView(); | 42 return render_view()->GetWebView(); |
43 } | 43 } |
44 | 44 |
45 void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) { | 45 void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) { |
46 WebKit::WebPoint web_point(point); | 46 WebKit::WebPoint web_point(point); |
47 size_t index = webview()->focusedFrame()->characterIndexForPoint(web_point); | 47 size_t index = webview()->focusedFrame()->characterIndexForPoint(web_point); |
48 Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint(routing_id(), | 48 Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint(routing_id(), |
49 index)); | 49 index)); |
50 } | 50 } |
51 | 51 |
52 void TextInputClientObserver::OnFirstRectForCharacterRange(ui::Range range) { | 52 void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) { |
53 gfx::Rect rect; | 53 gfx::Rect rect; |
54 #if defined(ENABLE_PLUGINS) | 54 #if defined(ENABLE_PLUGINS) |
55 if (!render_view_impl_->GetPepperCaretBounds(&rect)) | 55 if (!render_view_impl_->GetPepperCaretBounds(&rect)) |
56 #endif | 56 #endif |
57 { | 57 { |
58 WebKit::WebFrame* frame = webview()->focusedFrame(); | 58 WebKit::WebFrame* frame = webview()->focusedFrame(); |
59 if (frame) { | 59 if (frame) { |
60 WebKit::WebRect web_rect; | 60 WebKit::WebRect web_rect; |
61 frame->firstRectForCharacterRange(range.start(), range.length(), | 61 frame->firstRectForCharacterRange(range.start(), range.length(), |
62 web_rect); | 62 web_rect); |
63 rect = web_rect; | 63 rect = web_rect; |
64 } | 64 } |
65 } | 65 } |
66 Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect)); | 66 Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect)); |
67 } | 67 } |
68 | 68 |
69 void TextInputClientObserver::OnStringForRange(ui::Range range) { | 69 void TextInputClientObserver::OnStringForRange(gfx::Range range) { |
70 #if defined(OS_MACOSX) | 70 #if defined(OS_MACOSX) |
71 NSAttributedString* string = nil; | 71 NSAttributedString* string = nil; |
72 WebKit::WebFrame* frame = webview()->focusedFrame(); | 72 WebKit::WebFrame* frame = webview()->focusedFrame(); |
73 if (frame) { | 73 if (frame) { |
74 string = WebKit::WebSubstringUtil::attributedSubstringInRange( | 74 string = WebKit::WebSubstringUtil::attributedSubstringInRange( |
75 frame, range.start(), range.length()); | 75 frame, range.start(), range.length()); |
76 } | 76 } |
77 scoped_ptr<const mac::AttributedStringCoder::EncodedString> encoded( | 77 scoped_ptr<const mac::AttributedStringCoder::EncodedString> encoded( |
78 mac::AttributedStringCoder::Encode(string)); | 78 mac::AttributedStringCoder::Encode(string)); |
79 Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(), | 79 Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(), |
80 *encoded.get())); | 80 *encoded.get())); |
81 #else | 81 #else |
82 NOTIMPLEMENTED(); | 82 NOTIMPLEMENTED(); |
83 #endif | 83 #endif |
84 } | 84 } |
85 | 85 |
86 } // namespace content | 86 } // namespace content |
OLD | NEW |