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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 699333003: Support InputMethodManager#updateCursorAnchorInfo for Android 5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed "just-in-case" checks for the simplicity Created 6 years, 1 month 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/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 3a2dc883f4031ea824c2b2088f2d1ecfceae9ecb..6f7724801d39df4365a8d3fa665f54bd3a4d8021 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -1234,11 +1234,34 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
if (!content_view_core_)
return;
+ const cc::ViewportSelectionBound& selection_start =
+ frame_metadata.selection_start;
+ const cc::ViewportSelectionBound& selection_end =
+ frame_metadata.selection_start;
if (selection_controller_) {
- selection_controller_->OnSelectionBoundsChanged(
- frame_metadata.selection_start, frame_metadata.selection_end);
+ selection_controller_->OnSelectionBoundsChanged(selection_start,
+ selection_end);
}
+ // 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
+ // 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 bool has_insertion_marker =
+ selection_start.type == cc::SELECTION_BOUND_CENTER &&
+ selection_end.type == cc::SELECTION_BOUND_CENTER;
+ const float insertion_marker_x =
+ has_insertion_marker ? selection_start.edge_top.x() : 0.0f;
+ const float insertion_marker_top =
+ has_insertion_marker ? selection_start.edge_top.y() : 0.0f;
+ const float insertion_marker_bottom =
+ has_insertion_marker ? selection_start.edge_bottom.y() : 0.0f;
+
// All offsets and sizes are in CSS pixels.
content_view_core_->UpdateFrameInfo(
frame_metadata.root_scroll_offset,
@@ -1248,7 +1271,11 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
frame_metadata.root_layer_size,
frame_metadata.scrollable_viewport_size,
frame_metadata.location_bar_offset,
- frame_metadata.location_bar_content_translation);
+ frame_metadata.location_bar_content_translation,
+ has_insertion_marker,
jdduke (slow) 2014/11/07 01:47:00 Do we have to go through ContentViewCore? Can we n
aelias_OOO_until_Jul13 2014/11/07 02:04:29 I would like to keep this method as more of a dumb
yukawa 2014/11/12 10:21:50 Technically we could plumb insertion markers direc
yukawa 2014/11/12 10:21:50 Thank you for the pointer. Done in patch set #4.
+ insertion_marker_x,
+ insertion_marker_top,
+ insertion_marker_bottom);
#if defined(VIDEO_HOLE)
if (host_ && host_->IsRenderView()) {
RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(

Powered by Google App Engine
This is Rietveld 408576698