| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) { | 82 void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) { |
| 83 gfx::Rect rect; | 83 gfx::Rect rect; |
| 84 #if defined(ENABLE_PLUGINS) | 84 #if defined(ENABLE_PLUGINS) |
| 85 if (render_view_impl_->GetFocusedPepperPlugin()) { | 85 if (render_view_impl_->GetFocusedPepperPlugin()) { |
| 86 rect = render_view_impl_->GetFocusedPepperPlugin()->GetCaretBounds(); | 86 rect = render_view_impl_->GetFocusedPepperPlugin()->GetCaretBounds(); |
| 87 } else | 87 } else |
| 88 #endif | 88 #endif |
| 89 { | 89 { |
| 90 blink::WebFrame* frame = webview()->focusedFrame(); | 90 blink::WebLocalFrame* frame = webview()->focusedFrame(); |
| 91 if (frame) { | 91 blink::WebRect web_rect; |
| 92 blink::WebRect web_rect; | 92 frame->firstRectForCharacterRange(range.start(), range.length(), web_rect); |
| 93 frame->firstRectForCharacterRange(range.start(), range.length(), | 93 rect = web_rect; |
| 94 web_rect); | |
| 95 rect = web_rect; | |
| 96 } | |
| 97 } | 94 } |
| 98 Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect)); | 95 Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect)); |
| 99 } | 96 } |
| 100 | 97 |
| 101 void TextInputClientObserver::OnStringForRange(gfx::Range range) { | 98 void TextInputClientObserver::OnStringForRange(gfx::Range range) { |
| 102 #if defined(OS_MACOSX) | 99 #if defined(OS_MACOSX) |
| 103 blink::WebPoint baselinePoint; | 100 blink::WebPoint baselinePoint; |
| 104 NSAttributedString* string = nil; | 101 NSAttributedString* string = nil; |
| 105 blink::WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame(); | 102 blink::WebLocalFrame* frame = webview()->focusedFrame(); |
| 106 if (frame) { | 103 string = blink::WebSubstringUtil::attributedSubstringInRange( |
| 107 string = blink::WebSubstringUtil::attributedSubstringInRange( | 104 frame, range.start(), range.length(), &baselinePoint); |
| 108 frame, range.start(), range.length(), &baselinePoint); | |
| 109 } | |
| 110 std::unique_ptr<const mac::AttributedStringCoder::EncodedString> encoded( | 105 std::unique_ptr<const mac::AttributedStringCoder::EncodedString> encoded( |
| 111 mac::AttributedStringCoder::Encode(string)); | 106 mac::AttributedStringCoder::Encode(string)); |
| 112 Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(), | 107 Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(), |
| 113 *encoded.get(), baselinePoint)); | 108 *encoded.get(), baselinePoint)); |
| 114 #else | 109 #else |
| 115 NOTIMPLEMENTED(); | 110 NOTIMPLEMENTED(); |
| 116 #endif | 111 #endif |
| 117 } | 112 } |
| 118 | 113 |
| 119 } // namespace content | 114 } // namespace content |
| OLD | NEW |