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

Unified 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: Addressed #36. Added ImeLollipopTest for IMMEDIATE case. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 71bde17b44c3d978dee81d1b5c9e99ab48666b4f..62cff944a74e6b2eda1cfe0c4a2b77017b312004 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -19,6 +19,7 @@
#include "cc/layers/layer.h"
#include "cc/layers/solid_color_layer.h"
#include "cc/output/begin_frame_args.h"
+#include "cc/output/viewport_selection_bound.h"
#include "content/browser/accessibility/browser_accessibility_state_impl.h"
#include "content/browser/android/gesture_event_type.h"
#include "content/browser/android/interstitial_page_delegate_android.h"
@@ -419,7 +420,8 @@ void ContentViewCoreImpl::UpdateFrameInfo(
const gfx::SizeF& viewport_size,
const gfx::Vector2dF& controls_offset,
const gfx::Vector2dF& content_offset,
- bool is_mobile_optimized_hint) {
+ bool is_mobile_optimized_hint,
+ const cc::ViewportSelectionBound& selection_start) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null() || !window_android_)
@@ -430,6 +432,25 @@ void ContentViewCoreImpl::UpdateFrameInfo(
page_scale_ = page_scale_factor;
+ // We are interested only in zero width selection bounds here because non-zero
+ // width selection bounds cannot be represented in CursorAnchorInfo API in
+ // 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.
+ // selection bounds in CursorAnchorInfo API was once considered in the design
+ // phase of that API, but the idea was abandoned because the IME is still able
+ // to retrieve the same information from the following parameters in
+ // CursorAnchorInfo:
+ // - CursorAnchorInfo#getCharacterBounds and
+ // - CursorAnchorInfo#getSelection{Start, End}.
+ const jboolean has_insertion_marker =
+ 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
+ const jboolean is_insertion_marker_visible = selection_start.visible;
+ const jfloat insertion_marker_horizontal =
+ has_insertion_marker ? selection_start.edge_top.x() : 0.0f;
+ const jfloat insertion_marker_top =
+ has_insertion_marker ? selection_start.edge_top.y() : 0.0f;
+ const jfloat insertion_marker_bottom =
+ has_insertion_marker ? selection_start.edge_bottom.y() : 0.0f;
+
Java_ContentViewCore_updateFrameInfo(
env, obj.obj(),
scroll_offset.x(),
@@ -443,7 +464,12 @@ void ContentViewCoreImpl::UpdateFrameInfo(
viewport_size.height(),
controls_offset.y(),
content_offset.y(),
- is_mobile_optimized_hint);
+ is_mobile_optimized_hint,
+ has_insertion_marker,
+ is_insertion_marker_visible,
+ insertion_marker_horizontal,
+ insertion_marker_top,
+ insertion_marker_bottom);
}
void ContentViewCoreImpl::SetTitle(const base::string16& title) {

Powered by Google App Engine
This is Rietveld 408576698