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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 // Note that viewport_width/height is a best effort based. | 413 // Note that viewport_width/height is a best effort based. |
413 // ContentViewCore has the actual information about the physical viewport size. | 414 // ContentViewCore has the actual information about the physical viewport size. |
414 void ContentViewCoreImpl::UpdateFrameInfo( | 415 void ContentViewCoreImpl::UpdateFrameInfo( |
415 const gfx::Vector2dF& scroll_offset, | 416 const gfx::Vector2dF& scroll_offset, |
416 float page_scale_factor, | 417 float page_scale_factor, |
417 const gfx::Vector2dF& page_scale_factor_limits, | 418 const gfx::Vector2dF& page_scale_factor_limits, |
418 const gfx::SizeF& content_size, | 419 const gfx::SizeF& content_size, |
419 const gfx::SizeF& viewport_size, | 420 const gfx::SizeF& viewport_size, |
420 const gfx::Vector2dF& controls_offset, | 421 const gfx::Vector2dF& controls_offset, |
421 const gfx::Vector2dF& content_offset, | 422 const gfx::Vector2dF& content_offset, |
422 bool is_mobile_optimized_hint) { | 423 bool is_mobile_optimized_hint, |
424 const cc::ViewportSelectionBound& selection_start) { | |
423 JNIEnv* env = AttachCurrentThread(); | 425 JNIEnv* env = AttachCurrentThread(); |
424 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 426 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
425 if (obj.is_null() || !window_android_) | 427 if (obj.is_null() || !window_android_) |
426 return; | 428 return; |
427 | 429 |
428 window_android_->set_content_offset( | 430 window_android_->set_content_offset( |
429 gfx::ScaleVector2d(content_offset, dpi_scale_)); | 431 gfx::ScaleVector2d(content_offset, dpi_scale_)); |
430 | 432 |
431 page_scale_ = page_scale_factor; | 433 page_scale_ = page_scale_factor; |
432 | 434 |
435 // We are interested only in zero width selection bounds here because non-zero | |
436 // width selection bounds cannot be represented in CursorAnchorInfo API in | |
437 // Android Framework as of API Level 21. Actually supporting non-zero width | |
Ted C
2016/03/07 21:31:45
While I think this comment is informative, it seem
kinaba
2016/03/10 06:24:12
Done.
| |
438 // selection bounds in CursorAnchorInfo API was once considered in the design | |
439 // phase of that API, but the idea was abandoned because the IME is still able | |
440 // to retrieve the same information from the following parameters in | |
441 // CursorAnchorInfo: | |
442 // - CursorAnchorInfo#getCharacterBounds and | |
443 // - CursorAnchorInfo#getSelection{Start, End}. | |
444 const jboolean has_insertion_marker = | |
445 selection_start.type == cc::SELECTION_BOUND_CENTER; | |
Ted C
2016/03/07 21:31:45
I assume SELECTION_BOUND_CENTER is the only bit th
kinaba
2016/03/10 06:24:12
Yes.
To be precice it's an enum with 4 possible va
| |
446 const jboolean is_insertion_marker_visible = selection_start.visible; | |
447 const jfloat insertion_marker_horizontal = | |
448 has_insertion_marker ? selection_start.edge_top.x() : 0.0f; | |
449 const jfloat insertion_marker_top = | |
450 has_insertion_marker ? selection_start.edge_top.y() : 0.0f; | |
451 const jfloat insertion_marker_bottom = | |
452 has_insertion_marker ? selection_start.edge_bottom.y() : 0.0f; | |
453 | |
433 Java_ContentViewCore_updateFrameInfo( | 454 Java_ContentViewCore_updateFrameInfo( |
434 env, obj.obj(), | 455 env, obj.obj(), |
435 scroll_offset.x(), | 456 scroll_offset.x(), |
436 scroll_offset.y(), | 457 scroll_offset.y(), |
437 page_scale_factor, | 458 page_scale_factor, |
438 page_scale_factor_limits.x(), | 459 page_scale_factor_limits.x(), |
439 page_scale_factor_limits.y(), | 460 page_scale_factor_limits.y(), |
440 content_size.width(), | 461 content_size.width(), |
441 content_size.height(), | 462 content_size.height(), |
442 viewport_size.width(), | 463 viewport_size.width(), |
443 viewport_size.height(), | 464 viewport_size.height(), |
444 controls_offset.y(), | 465 controls_offset.y(), |
445 content_offset.y(), | 466 content_offset.y(), |
446 is_mobile_optimized_hint); | 467 is_mobile_optimized_hint, |
468 has_insertion_marker, | |
469 is_insertion_marker_visible, | |
470 insertion_marker_horizontal, | |
471 insertion_marker_top, | |
472 insertion_marker_bottom); | |
447 } | 473 } |
448 | 474 |
449 void ContentViewCoreImpl::SetTitle(const base::string16& title) { | 475 void ContentViewCoreImpl::SetTitle(const base::string16& title) { |
450 JNIEnv* env = AttachCurrentThread(); | 476 JNIEnv* env = AttachCurrentThread(); |
451 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 477 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
452 if (obj.is_null()) | 478 if (obj.is_null()) |
453 return; | 479 return; |
454 ScopedJavaLocalRef<jstring> jtitle = | 480 ScopedJavaLocalRef<jstring> jtitle = |
455 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); | 481 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); |
456 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); | 482 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 return ScopedJavaLocalRef<jobject>(); | 1563 return ScopedJavaLocalRef<jobject>(); |
1538 | 1564 |
1539 return view->GetJavaObject(); | 1565 return view->GetJavaObject(); |
1540 } | 1566 } |
1541 | 1567 |
1542 bool RegisterContentViewCore(JNIEnv* env) { | 1568 bool RegisterContentViewCore(JNIEnv* env) { |
1543 return RegisterNativesImpl(env); | 1569 return RegisterNativesImpl(env); |
1544 } | 1570 } |
1545 | 1571 |
1546 } // namespace content | 1572 } // namespace content |
OLD | NEW |