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 |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/common/text_input_client_messages.h" | 12 #include "content/common/text_input_client_messages.h" |
13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
14 #include "content/renderer/render_frame_impl.h" | 14 #include "content/renderer/render_frame_impl.h" |
15 #include "content/renderer/render_view_impl.h" | 15 #include "content/renderer/render_view_impl.h" |
16 #include "content/renderer/render_widget.h" | 16 #include "content/renderer/render_widget.h" |
17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
| 18 #include "ppapi/features/features.h" |
18 #include "third_party/WebKit/public/platform/WebPoint.h" | 19 #include "third_party/WebKit/public/platform/WebPoint.h" |
19 #include "third_party/WebKit/public/platform/WebRect.h" | 20 #include "third_party/WebKit/public/platform/WebRect.h" |
20 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" |
21 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 22 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
22 #include "third_party/WebKit/public/web/WebView.h" | 23 #include "third_party/WebKit/public/web/WebView.h" |
23 #include "third_party/WebKit/public/web/mac/WebSubstringUtil.h" | 24 #include "third_party/WebKit/public/web/mac/WebSubstringUtil.h" |
24 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 blink::WebLocalFrame* TextInputClientObserver::GetFocusedFrame() const { | 64 blink::WebLocalFrame* TextInputClientObserver::GetFocusedFrame() const { |
64 blink::WebLocalFrame* focused = | 65 blink::WebLocalFrame* focused = |
65 RenderFrameImpl::FromWebFrame(GetWebFrameWidget()->localRoot()) | 66 RenderFrameImpl::FromWebFrame(GetWebFrameWidget()->localRoot()) |
66 ->render_view() | 67 ->render_view() |
67 ->webview() | 68 ->webview() |
68 ->focusedFrame(); | 69 ->focusedFrame(); |
69 return focused->localRoot() == GetWebFrameWidget()->localRoot() ? focused | 70 return focused->localRoot() == GetWebFrameWidget()->localRoot() ? focused |
70 : nullptr; | 71 : nullptr; |
71 } | 72 } |
72 | 73 |
73 #if defined(ENABLE_PLUGINS) | 74 #if BUILDFLAG(ENABLE_PLUGINS) |
74 PepperPluginInstanceImpl* TextInputClientObserver::GetFocusedPepperPlugin() | 75 PepperPluginInstanceImpl* TextInputClientObserver::GetFocusedPepperPlugin() |
75 const { | 76 const { |
76 blink::WebLocalFrame* focusedFrame = GetFocusedFrame(); | 77 blink::WebLocalFrame* focusedFrame = GetFocusedFrame(); |
77 return focusedFrame | 78 return focusedFrame |
78 ? RenderFrameImpl::FromWebFrame(focusedFrame) | 79 ? RenderFrameImpl::FromWebFrame(focusedFrame) |
79 ->focused_pepper_plugin() | 80 ->focused_pepper_plugin() |
80 : nullptr; | 81 : nullptr; |
81 } | 82 } |
82 #endif | 83 #endif |
83 | 84 |
(...skipping 15 matching lines...) Expand all Loading... |
99 void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) { | 100 void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) { |
100 blink::WebPoint web_point(point); | 101 blink::WebPoint web_point(point); |
101 uint32_t index = static_cast<uint32_t>( | 102 uint32_t index = static_cast<uint32_t>( |
102 GetFocusedFrame()->characterIndexForPoint(web_point)); | 103 GetFocusedFrame()->characterIndexForPoint(web_point)); |
103 Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint( | 104 Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint( |
104 render_widget_->routing_id(), index)); | 105 render_widget_->routing_id(), index)); |
105 } | 106 } |
106 | 107 |
107 void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) { | 108 void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) { |
108 gfx::Rect rect; | 109 gfx::Rect rect; |
109 #if defined(ENABLE_PLUGINS) | 110 #if BUILDFLAG(ENABLE_PLUGINS) |
110 PepperPluginInstanceImpl* focused_plugin = GetFocusedPepperPlugin(); | 111 PepperPluginInstanceImpl* focused_plugin = GetFocusedPepperPlugin(); |
111 if (focused_plugin) { | 112 if (focused_plugin) { |
112 rect = focused_plugin->GetCaretBounds(); | 113 rect = focused_plugin->GetCaretBounds(); |
113 } else | 114 } else |
114 #endif | 115 #endif |
115 { | 116 { |
116 blink::WebLocalFrame* frame = GetFocusedFrame(); | 117 blink::WebLocalFrame* frame = GetFocusedFrame(); |
117 // TODO(yabinh): Null check should not be necessary. | 118 // TODO(yabinh): Null check should not be necessary. |
118 // See crbug.com/304341 | 119 // See crbug.com/304341 |
119 if (frame) { | 120 if (frame) { |
(...skipping 21 matching lines...) Expand all Loading... |
141 std::unique_ptr<const mac::AttributedStringCoder::EncodedString> encoded( | 142 std::unique_ptr<const mac::AttributedStringCoder::EncodedString> encoded( |
142 mac::AttributedStringCoder::Encode(string)); | 143 mac::AttributedStringCoder::Encode(string)); |
143 Send(new TextInputClientReplyMsg_GotStringForRange( | 144 Send(new TextInputClientReplyMsg_GotStringForRange( |
144 render_widget_->routing_id(), *encoded.get(), baselinePoint)); | 145 render_widget_->routing_id(), *encoded.get(), baselinePoint)); |
145 #else | 146 #else |
146 NOTIMPLEMENTED(); | 147 NOTIMPLEMENTED(); |
147 #endif | 148 #endif |
148 } | 149 } |
149 | 150 |
150 } // namespace content | 151 } // namespace content |
OLD | NEW |