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/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "content/browser/android/content_view_core_impl.h" | 11 #include "content/browser/android/content_view_core_impl.h" |
12 #include "content/browser/android/draw_delegate_impl.h" | 12 #include "content/browser/android/draw_delegate_impl.h" |
13 #include "content/browser/gpu/gpu_surface_tracker.h" | 13 #include "content/browser/gpu/gpu_surface_tracker.h" |
14 #include "content/browser/renderer_host/compositor_impl_android.h" | 14 #include "content/browser/renderer_host/compositor_impl_android.h" |
15 #include "content/browser/renderer_host/image_transport_factory_android.h" | 15 #include "content/browser/renderer_host/image_transport_factory_android.h" |
16 #include "content/browser/renderer_host/render_widget_host_impl.h" | 16 #include "content/browser/renderer_host/render_widget_host_impl.h" |
17 #include "content/common/android/device_info.h" | 17 #include "content/common/android/device_info.h" |
18 #include "content/common/gpu/gpu_messages.h" | 18 #include "content/common/gpu/gpu_messages.h" |
19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
| 24 namespace { |
| 25 |
| 26 // TODO(pliard): http://crbug.com/142585. Remove this helper function and update |
| 27 // the clients to deal directly with WebKit::WebTextDirection. |
| 28 base::i18n::TextDirection ConvertTextDirection(WebKit::WebTextDirection dir) { |
| 29 switch (dir) { |
| 30 case WebKit::WebTextDirectionDefault: return base::i18n::UNKNOWN_DIRECTION; |
| 31 case WebKit::WebTextDirectionLeftToRight: return base::i18n::LEFT_TO_RIGHT; |
| 32 case WebKit::WebTextDirectionRightToLeft: return base::i18n::RIGHT_TO_LEFT; |
| 33 } |
| 34 NOTREACHED() << "Unsupported text direction " << dir; |
| 35 return base::i18n::UNKNOWN_DIRECTION; |
| 36 } |
| 37 |
| 38 } // namespace |
| 39 |
24 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( | 40 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( |
25 RenderWidgetHostImpl* widget_host, | 41 RenderWidgetHostImpl* widget_host, |
26 ContentViewCoreImpl* content_view_core) | 42 ContentViewCoreImpl* content_view_core) |
27 : host_(widget_host), | 43 : host_(widget_host), |
28 // ContentViewCoreImpl represents the native side of the Java | 44 // ContentViewCoreImpl represents the native side of the Java |
29 // ContentViewCore. It being NULL means that it is not attached to the | 45 // ContentViewCore. It being NULL means that it is not attached to the |
30 // View system yet, so we treat it as hidden. | 46 // View system yet, so we treat it as hidden. |
31 is_hidden_(!content_view_core), | 47 is_hidden_(!content_view_core), |
32 content_view_core_(content_view_core), | 48 content_view_core_(content_view_core), |
33 ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 49 ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if (pos >= text.length()) { | 260 if (pos >= text.length()) { |
245 NOTREACHED() << "The text can not cover range."; | 261 NOTREACHED() << "The text can not cover range."; |
246 return; | 262 return; |
247 } | 263 } |
248 | 264 |
249 std::string utf8_selection = UTF16ToUTF8(text.substr(pos, n)); | 265 std::string utf8_selection = UTF16ToUTF8(text.substr(pos, n)); |
250 | 266 |
251 content_view_core_->OnSelectionChanged(utf8_selection); | 267 content_view_core_->OnSelectionChanged(utf8_selection); |
252 } | 268 } |
253 | 269 |
| 270 void RenderWidgetHostViewAndroid::SelectionBoundsChanged( |
| 271 const gfx::Rect& start_rect, |
| 272 WebKit::WebTextDirection start_direction, |
| 273 const gfx::Rect& end_rect, |
| 274 WebKit::WebTextDirection end_direction) { |
| 275 if (content_view_core_) { |
| 276 content_view_core_->OnSelectionBoundsChanged( |
| 277 start_rect, |
| 278 ConvertTextDirection(start_direction), |
| 279 end_rect, |
| 280 ConvertTextDirection(end_direction)); |
| 281 } |
| 282 } |
| 283 |
254 BackingStore* RenderWidgetHostViewAndroid::AllocBackingStore( | 284 BackingStore* RenderWidgetHostViewAndroid::AllocBackingStore( |
255 const gfx::Size& size) { | 285 const gfx::Size& size) { |
256 NOTIMPLEMENTED(); | 286 NOTIMPLEMENTED(); |
257 return NULL; | 287 return NULL; |
258 } | 288 } |
259 | 289 |
260 void RenderWidgetHostViewAndroid::SetBackground(const SkBitmap& background) { | 290 void RenderWidgetHostViewAndroid::SetBackground(const SkBitmap& background) { |
261 RenderWidgetHostViewBase::SetBackground(background); | 291 RenderWidgetHostViewBase::SetBackground(background); |
262 host_->Send(new ViewMsg_SetBackground(host_->GetRoutingID(), background)); | 292 host_->Send(new ViewMsg_SetBackground(host_->GetRoutingID(), background)); |
263 } | 293 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // RenderWidgetHostView, public: | 502 // RenderWidgetHostView, public: |
473 | 503 |
474 // static | 504 // static |
475 RenderWidgetHostView* | 505 RenderWidgetHostView* |
476 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 506 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
477 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 507 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
478 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 508 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
479 } | 509 } |
480 | 510 |
481 } // namespace content | 511 } // namespace content |
OLD | NEW |