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

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

Issue 699333003: Support InputMethodManager#updateCursorAnchorInfo for Android 5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase before splitting this CL. Created 5 years, 8 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 "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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // Note that viewport_width/height is a best effort based. 375 // Note that viewport_width/height is a best effort based.
375 // ContentViewCore has the actual information about the physical viewport size. 376 // ContentViewCore has the actual information about the physical viewport size.
376 void ContentViewCoreImpl::UpdateFrameInfo( 377 void ContentViewCoreImpl::UpdateFrameInfo(
377 const gfx::Vector2dF& scroll_offset, 378 const gfx::Vector2dF& scroll_offset,
378 float page_scale_factor, 379 float page_scale_factor,
379 const gfx::Vector2dF& page_scale_factor_limits, 380 const gfx::Vector2dF& page_scale_factor_limits,
380 const gfx::SizeF& content_size, 381 const gfx::SizeF& content_size,
381 const gfx::SizeF& viewport_size, 382 const gfx::SizeF& viewport_size,
382 const gfx::Vector2dF& controls_offset, 383 const gfx::Vector2dF& controls_offset,
383 const gfx::Vector2dF& content_offset, 384 const gfx::Vector2dF& content_offset,
384 bool is_mobile_optimized_hint) { 385 bool is_mobile_optimized_hint,
386 const cc::ViewportSelectionBound& selection_start) {
385 JNIEnv* env = AttachCurrentThread(); 387 JNIEnv* env = AttachCurrentThread();
386 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 388 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
387 if (obj.is_null()) 389 if (obj.is_null())
388 return; 390 return;
389 391
390 window_android_->set_content_offset( 392 window_android_->set_content_offset(
391 gfx::ScaleVector2d(content_offset, dpi_scale_)); 393 gfx::ScaleVector2d(content_offset, dpi_scale_));
392 394
395 // We are interested only in zero width selection bounds here because non-zero
396 // width selection bounds cannot be represented in CursorAnchorInfo API in
397 // Android Framework as of API Level 21. Actually supporting non-zero width
398 // selection bounds in CursorAnchorInfo API was once considered in the design
399 // phase of that API, but the idea was abandoned because the IME is still able
400 // to retrieve the same information from the following parameters in
401 // CursorAnchorInfo:
402 // - CursorAnchorInfo#getCharacterBounds and
403 // - CursorAnchorInfo#getSelection{Start, End}.
404 const jboolean has_insertion_marker =
405 selection_start.type == cc::SELECTION_BOUND_CENTER;
406 const jboolean is_insertion_marker_visible = selection_start.visible;
407 const jfloat insertion_marker_horizontal =
408 has_insertion_marker ? selection_start.edge_top.x() : 0.0f;
409 const jfloat insertion_marker_top =
410 has_insertion_marker ? selection_start.edge_top.y() : 0.0f;
411 const jfloat insertion_marker_bottom =
412 has_insertion_marker ? selection_start.edge_bottom.y() : 0.0f;
413
393 Java_ContentViewCore_updateFrameInfo( 414 Java_ContentViewCore_updateFrameInfo(
394 env, obj.obj(), 415 env, obj.obj(),
395 scroll_offset.x(), 416 scroll_offset.x(),
396 scroll_offset.y(), 417 scroll_offset.y(),
397 page_scale_factor, 418 page_scale_factor,
398 page_scale_factor_limits.x(), 419 page_scale_factor_limits.x(),
399 page_scale_factor_limits.y(), 420 page_scale_factor_limits.y(),
400 content_size.width(), 421 content_size.width(),
401 content_size.height(), 422 content_size.height(),
402 viewport_size.width(), 423 viewport_size.width(),
403 viewport_size.height(), 424 viewport_size.height(),
404 controls_offset.y(), 425 controls_offset.y(),
405 content_offset.y(), 426 content_offset.y(),
406 is_mobile_optimized_hint); 427 is_mobile_optimized_hint,
428 has_insertion_marker,
429 is_insertion_marker_visible,
430 insertion_marker_horizontal,
431 insertion_marker_top,
432 insertion_marker_bottom);
407 } 433 }
408 434
409 void ContentViewCoreImpl::SetTitle(const base::string16& title) { 435 void ContentViewCoreImpl::SetTitle(const base::string16& title) {
410 JNIEnv* env = AttachCurrentThread(); 436 JNIEnv* env = AttachCurrentThread();
411 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 437 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
412 if (obj.is_null()) 438 if (obj.is_null())
413 return; 439 return;
414 ScopedJavaLocalRef<jstring> jtitle = 440 ScopedJavaLocalRef<jstring> jtitle =
415 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); 441 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title));
416 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); 442 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj());
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 return NULL; 1495 return NULL;
1470 1496
1471 return view->GetJavaObject().Release(); 1497 return view->GetJavaObject().Release();
1472 } 1498 }
1473 1499
1474 bool RegisterContentViewCore(JNIEnv* env) { 1500 bool RegisterContentViewCore(JNIEnv* env) {
1475 return RegisterNativesImpl(env); 1501 return RegisterNativesImpl(env);
1476 } 1502 }
1477 1503
1478 } // namespace content 1504 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/ime_adapter_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698