Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 1589953005: Support InputMethodManager#updateCursorAnchorInfo for Android 5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Findbugs warning / Simplify the state transition. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // Note that viewport_width/height is a best effort based. 395 // Note that viewport_width/height is a best effort based.
395 // ContentViewCore has the actual information about the physical viewport size. 396 // ContentViewCore has the actual information about the physical viewport size.
396 void ContentViewCoreImpl::UpdateFrameInfo( 397 void ContentViewCoreImpl::UpdateFrameInfo(
397 const gfx::Vector2dF& scroll_offset, 398 const gfx::Vector2dF& scroll_offset,
398 float page_scale_factor, 399 float page_scale_factor,
399 const gfx::Vector2dF& page_scale_factor_limits, 400 const gfx::Vector2dF& page_scale_factor_limits,
400 const gfx::SizeF& content_size, 401 const gfx::SizeF& content_size,
401 const gfx::SizeF& viewport_size, 402 const gfx::SizeF& viewport_size,
402 const gfx::Vector2dF& controls_offset, 403 const gfx::Vector2dF& controls_offset,
403 const gfx::Vector2dF& content_offset, 404 const gfx::Vector2dF& content_offset,
404 bool is_mobile_optimized_hint) { 405 bool is_mobile_optimized_hint,
406 const cc::ViewportSelectionBound& selection_start) {
405 JNIEnv* env = AttachCurrentThread(); 407 JNIEnv* env = AttachCurrentThread();
406 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 408 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
407 if (obj.is_null()) 409 if (obj.is_null())
408 return; 410 return;
409 411
410 window_android_->set_content_offset( 412 window_android_->set_content_offset(
411 gfx::ScaleVector2d(content_offset, dpi_scale_)); 413 gfx::ScaleVector2d(content_offset, dpi_scale_));
412 414
413 page_scale_ = page_scale_factor; 415 page_scale_ = page_scale_factor;
414 416
417 // We are interested only in zero width selection bounds here because non-zero
418 // width selection bounds cannot be represented in CursorAnchorInfo API in
419 // Android Framework as of API Level 21. Actually supporting non-zero width
420 // selection bounds in CursorAnchorInfo API was once considered in the design
421 // phase of that API, but the idea was abandoned because the IME is still able
422 // to retrieve the same information from the following parameters in
423 // CursorAnchorInfo:
424 // - CursorAnchorInfo#getCharacterBounds and
425 // - CursorAnchorInfo#getSelection{Start, End}.
426 const jboolean has_insertion_marker =
427 selection_start.type == cc::SELECTION_BOUND_CENTER;
428 const jboolean is_insertion_marker_visible = selection_start.visible;
429 const jfloat insertion_marker_horizontal =
430 has_insertion_marker ? selection_start.edge_top.x() : 0.0f;
431 const jfloat insertion_marker_top =
432 has_insertion_marker ? selection_start.edge_top.y() : 0.0f;
433 const jfloat insertion_marker_bottom =
434 has_insertion_marker ? selection_start.edge_bottom.y() : 0.0f;
435
415 Java_ContentViewCore_updateFrameInfo( 436 Java_ContentViewCore_updateFrameInfo(
416 env, obj.obj(), 437 env, obj.obj(),
417 scroll_offset.x(), 438 scroll_offset.x(),
418 scroll_offset.y(), 439 scroll_offset.y(),
419 page_scale_factor, 440 page_scale_factor,
420 page_scale_factor_limits.x(), 441 page_scale_factor_limits.x(),
421 page_scale_factor_limits.y(), 442 page_scale_factor_limits.y(),
422 content_size.width(), 443 content_size.width(),
423 content_size.height(), 444 content_size.height(),
424 viewport_size.width(), 445 viewport_size.width(),
425 viewport_size.height(), 446 viewport_size.height(),
426 controls_offset.y(), 447 controls_offset.y(),
427 content_offset.y(), 448 content_offset.y(),
428 is_mobile_optimized_hint); 449 is_mobile_optimized_hint,
450 has_insertion_marker,
451 is_insertion_marker_visible,
452 insertion_marker_horizontal,
453 insertion_marker_top,
454 insertion_marker_bottom);
429 } 455 }
430 456
431 void ContentViewCoreImpl::SetTitle(const base::string16& title) { 457 void ContentViewCoreImpl::SetTitle(const base::string16& title) {
432 JNIEnv* env = AttachCurrentThread(); 458 JNIEnv* env = AttachCurrentThread();
433 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 459 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
434 if (obj.is_null()) 460 if (obj.is_null())
435 return; 461 return;
436 ScopedJavaLocalRef<jstring> jtitle = 462 ScopedJavaLocalRef<jstring> jtitle =
437 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); 463 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title));
438 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); 464 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj());
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 return ScopedJavaLocalRef<jobject>(); 1547 return ScopedJavaLocalRef<jobject>();
1522 1548
1523 return view->GetJavaObject(); 1549 return view->GetJavaObject();
1524 } 1550 }
1525 1551
1526 bool RegisterContentViewCore(JNIEnv* env) { 1552 bool RegisterContentViewCore(JNIEnv* env) {
1527 return RegisterNativesImpl(env); 1553 return RegisterNativesImpl(env);
1528 } 1554 }
1529 1555
1530 } // namespace content 1556 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698