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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
17 #include "cc/layers/solid_color_layer.h" | 17 #include "cc/layers/solid_color_layer.h" |
18 #include "cc/output/begin_frame_args.h" | 18 #include "cc/output/begin_frame_args.h" |
| 19 #include "cc/output/viewport_selection_bound.h" |
19 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 20 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
20 #include "content/browser/android/gesture_event_type.h" | 21 #include "content/browser/android/gesture_event_type.h" |
21 #include "content/browser/android/interstitial_page_delegate_android.h" | 22 #include "content/browser/android/interstitial_page_delegate_android.h" |
22 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" | 23 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" |
23 #include "content/browser/android/load_url_params.h" | 24 #include "content/browser/android/load_url_params.h" |
24 #include "content/browser/android/popup_touch_handle_drawable.h" | 25 #include "content/browser/android/popup_touch_handle_drawable.h" |
25 #include "content/browser/frame_host/interstitial_page_impl.h" | 26 #include "content/browser/frame_host/interstitial_page_impl.h" |
26 #include "content/browser/geolocation/geolocation_service_context.h" | 27 #include "content/browser/geolocation/geolocation_service_context.h" |
27 #include "content/browser/media/media_web_contents_observer.h" | 28 #include "content/browser/media/media_web_contents_observer.h" |
28 #include "content/browser/renderer_host/compositor_impl_android.h" | 29 #include "content/browser/renderer_host/compositor_impl_android.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // All positions and sizes are in CSS pixels. | 373 // All positions and sizes are in CSS pixels. |
373 // Note that viewport_width/height is a best effort based. | 374 // Note that viewport_width/height is a best effort based. |
374 // ContentViewCore has the actual information about the physical viewport size. | 375 // ContentViewCore has the actual information about the physical viewport size. |
375 void ContentViewCoreImpl::UpdateFrameInfo( | 376 void ContentViewCoreImpl::UpdateFrameInfo( |
376 const gfx::Vector2dF& scroll_offset, | 377 const gfx::Vector2dF& scroll_offset, |
377 float page_scale_factor, | 378 float page_scale_factor, |
378 const gfx::Vector2dF& page_scale_factor_limits, | 379 const gfx::Vector2dF& page_scale_factor_limits, |
379 const gfx::SizeF& content_size, | 380 const gfx::SizeF& content_size, |
380 const gfx::SizeF& viewport_size, | 381 const gfx::SizeF& viewport_size, |
381 const gfx::Vector2dF& controls_offset, | 382 const gfx::Vector2dF& controls_offset, |
382 const gfx::Vector2dF& content_offset) { | 383 const gfx::Vector2dF& content_offset, |
| 384 const cc::ViewportSelectionBound& selection_start) { |
383 JNIEnv* env = AttachCurrentThread(); | 385 JNIEnv* env = AttachCurrentThread(); |
384 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 386 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
385 if (obj.is_null()) | 387 if (obj.is_null()) |
386 return; | 388 return; |
387 | 389 |
388 window_android_->set_content_offset( | 390 window_android_->set_content_offset( |
389 gfx::ScaleVector2d(content_offset, dpi_scale_)); | 391 gfx::ScaleVector2d(content_offset, dpi_scale_)); |
390 | 392 |
| 393 // We are interested only in zero width selection bounds here because non-zero |
| 394 // width selection bounds cannot be represented in CursorAnchorInfo API in |
| 395 // Android Framework as of API Level 21. Actually supporting non-zero width |
| 396 // selection bounds in CursorAnchorInfo API was once considered in the design |
| 397 // phase of that API, but the idea was abandoned because the IME is still able |
| 398 // to retrieve the same information from the following parameters in |
| 399 // CursorAnchorInfo: |
| 400 // - CursorAnchorInfo#getCharacterBounds and |
| 401 // - CursorAnchorInfo#getSelection{Start, End}. |
| 402 const jboolean has_insertion_marker = |
| 403 selection_start.type == cc::SELECTION_BOUND_CENTER; |
| 404 const jboolean is_insertion_marker_visible = selection_start.visible; |
| 405 const jfloat insertion_marker_horizontal = |
| 406 has_insertion_marker ? selection_start.edge_top.x() : 0.0f; |
| 407 const jfloat insertion_marker_top = |
| 408 has_insertion_marker ? selection_start.edge_top.y() : 0.0f; |
| 409 const jfloat insertion_marker_bottom = |
| 410 has_insertion_marker ? selection_start.edge_bottom.y() : 0.0f; |
| 411 |
391 Java_ContentViewCore_updateFrameInfo( | 412 Java_ContentViewCore_updateFrameInfo( |
392 env, obj.obj(), | 413 env, obj.obj(), |
393 scroll_offset.x(), | 414 scroll_offset.x(), |
394 scroll_offset.y(), | 415 scroll_offset.y(), |
395 page_scale_factor, | 416 page_scale_factor, |
396 page_scale_factor_limits.x(), | 417 page_scale_factor_limits.x(), |
397 page_scale_factor_limits.y(), | 418 page_scale_factor_limits.y(), |
398 content_size.width(), | 419 content_size.width(), |
399 content_size.height(), | 420 content_size.height(), |
400 viewport_size.width(), | 421 viewport_size.width(), |
401 viewport_size.height(), | 422 viewport_size.height(), |
402 controls_offset.y(), | 423 controls_offset.y(), |
403 content_offset.y()); | 424 content_offset.y(), |
| 425 has_insertion_marker, |
| 426 is_insertion_marker_visible, |
| 427 insertion_marker_horizontal, |
| 428 insertion_marker_top, |
| 429 insertion_marker_bottom); |
404 } | 430 } |
405 | 431 |
406 void ContentViewCoreImpl::SetTitle(const base::string16& title) { | 432 void ContentViewCoreImpl::SetTitle(const base::string16& title) { |
407 JNIEnv* env = AttachCurrentThread(); | 433 JNIEnv* env = AttachCurrentThread(); |
408 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 434 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
409 if (obj.is_null()) | 435 if (obj.is_null()) |
410 return; | 436 return; |
411 ScopedJavaLocalRef<jstring> jtitle = | 437 ScopedJavaLocalRef<jstring> jtitle = |
412 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); | 438 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); |
413 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); | 439 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 return NULL; | 1407 return NULL; |
1382 | 1408 |
1383 return view->GetJavaObject().Release(); | 1409 return view->GetJavaObject().Release(); |
1384 } | 1410 } |
1385 | 1411 |
1386 bool RegisterContentViewCore(JNIEnv* env) { | 1412 bool RegisterContentViewCore(JNIEnv* env) { |
1387 return RegisterNativesImpl(env); | 1413 return RegisterNativesImpl(env); |
1388 } | 1414 } |
1389 | 1415 |
1390 } // namespace content | 1416 } // namespace content |
OLD | NEW |