OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "cc/layers/layer.h" | 19 #include "cc/layers/layer.h" |
20 #include "cc/layers/solid_color_layer.h" | 20 #include "cc/layers/solid_color_layer.h" |
21 #include "cc/output/begin_frame_args.h" | 21 #include "cc/output/begin_frame_args.h" |
| 22 #include "cc/output/viewport_selection_bound.h" |
22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 23 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
23 #include "content/browser/android/gesture_event_type.h" | 24 #include "content/browser/android/gesture_event_type.h" |
24 #include "content/browser/android/interstitial_page_delegate_android.h" | 25 #include "content/browser/android/interstitial_page_delegate_android.h" |
25 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" | 26 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" |
26 #include "content/browser/android/load_url_params.h" | 27 #include "content/browser/android/load_url_params.h" |
27 #include "content/browser/frame_host/interstitial_page_impl.h" | 28 #include "content/browser/frame_host/interstitial_page_impl.h" |
28 #include "content/browser/geolocation/geolocation_service_context.h" | 29 #include "content/browser/geolocation/geolocation_service_context.h" |
29 #include "content/browser/media/media_web_contents_observer.h" | 30 #include "content/browser/media/media_web_contents_observer.h" |
30 #include "content/browser/renderer_host/compositor_impl_android.h" | 31 #include "content/browser/renderer_host/compositor_impl_android.h" |
31 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" | 32 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 // Note that viewport_width/height is a best effort based. | 414 // Note that viewport_width/height is a best effort based. |
414 // ContentViewCore has the actual information about the physical viewport size. | 415 // ContentViewCore has the actual information about the physical viewport size. |
415 void ContentViewCoreImpl::UpdateFrameInfo( | 416 void ContentViewCoreImpl::UpdateFrameInfo( |
416 const gfx::Vector2dF& scroll_offset, | 417 const gfx::Vector2dF& scroll_offset, |
417 float page_scale_factor, | 418 float page_scale_factor, |
418 const gfx::Vector2dF& page_scale_factor_limits, | 419 const gfx::Vector2dF& page_scale_factor_limits, |
419 const gfx::SizeF& content_size, | 420 const gfx::SizeF& content_size, |
420 const gfx::SizeF& viewport_size, | 421 const gfx::SizeF& viewport_size, |
421 const gfx::Vector2dF& controls_offset, | 422 const gfx::Vector2dF& controls_offset, |
422 const gfx::Vector2dF& content_offset, | 423 const gfx::Vector2dF& content_offset, |
423 bool is_mobile_optimized_hint) { | 424 bool is_mobile_optimized_hint, |
| 425 const cc::ViewportSelectionBound& selection_start) { |
424 JNIEnv* env = AttachCurrentThread(); | 426 JNIEnv* env = AttachCurrentThread(); |
425 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 427 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
426 if (obj.is_null() || !window_android_) | 428 if (obj.is_null() || !window_android_) |
427 return; | 429 return; |
428 | 430 |
429 window_android_->set_content_offset( | 431 window_android_->set_content_offset( |
430 gfx::ScaleVector2d(content_offset, dpi_scale_)); | 432 gfx::ScaleVector2d(content_offset, dpi_scale_)); |
431 | 433 |
432 page_scale_ = page_scale_factor; | 434 page_scale_ = page_scale_factor; |
433 | 435 |
| 436 // The CursorAnchorInfo API in Android only supports zero width selection |
| 437 // bounds. |
| 438 const jboolean has_insertion_marker = |
| 439 selection_start.type == cc::SELECTION_BOUND_CENTER; |
| 440 const jboolean is_insertion_marker_visible = selection_start.visible; |
| 441 const jfloat insertion_marker_horizontal = |
| 442 has_insertion_marker ? selection_start.edge_top.x() : 0.0f; |
| 443 const jfloat insertion_marker_top = |
| 444 has_insertion_marker ? selection_start.edge_top.y() : 0.0f; |
| 445 const jfloat insertion_marker_bottom = |
| 446 has_insertion_marker ? selection_start.edge_bottom.y() : 0.0f; |
| 447 |
434 Java_ContentViewCore_updateFrameInfo( | 448 Java_ContentViewCore_updateFrameInfo( |
435 env, obj.obj(), | 449 env, obj.obj(), |
436 scroll_offset.x(), | 450 scroll_offset.x(), |
437 scroll_offset.y(), | 451 scroll_offset.y(), |
438 page_scale_factor, | 452 page_scale_factor, |
439 page_scale_factor_limits.x(), | 453 page_scale_factor_limits.x(), |
440 page_scale_factor_limits.y(), | 454 page_scale_factor_limits.y(), |
441 content_size.width(), | 455 content_size.width(), |
442 content_size.height(), | 456 content_size.height(), |
443 viewport_size.width(), | 457 viewport_size.width(), |
444 viewport_size.height(), | 458 viewport_size.height(), |
445 controls_offset.y(), | 459 controls_offset.y(), |
446 content_offset.y(), | 460 content_offset.y(), |
447 is_mobile_optimized_hint); | 461 is_mobile_optimized_hint, |
| 462 has_insertion_marker, |
| 463 is_insertion_marker_visible, |
| 464 insertion_marker_horizontal, |
| 465 insertion_marker_top, |
| 466 insertion_marker_bottom); |
448 } | 467 } |
449 | 468 |
450 void ContentViewCoreImpl::SetTitle(const base::string16& title) { | 469 void ContentViewCoreImpl::SetTitle(const base::string16& title) { |
451 JNIEnv* env = AttachCurrentThread(); | 470 JNIEnv* env = AttachCurrentThread(); |
452 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 471 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
453 if (obj.is_null()) | 472 if (obj.is_null()) |
454 return; | 473 return; |
455 ScopedJavaLocalRef<jstring> jtitle = | 474 ScopedJavaLocalRef<jstring> jtitle = |
456 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); | 475 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); |
457 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); | 476 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 return ScopedJavaLocalRef<jobject>(); | 1559 return ScopedJavaLocalRef<jobject>(); |
1541 | 1560 |
1542 return view->GetJavaObject(); | 1561 return view->GetJavaObject(); |
1543 } | 1562 } |
1544 | 1563 |
1545 bool RegisterContentViewCore(JNIEnv* env) { | 1564 bool RegisterContentViewCore(JNIEnv* env) { |
1546 return RegisterNativesImpl(env); | 1565 return RegisterNativesImpl(env); |
1547 } | 1566 } |
1548 | 1567 |
1549 } // namespace content | 1568 } // namespace content |
OLD | NEW |