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

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

Issue 425493004: [Android] Fix several selection handle-related issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 5 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
« no previous file with comments | « content/browser/renderer_host/input/touch_selection_controller_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7cfd2d2a1816aaaddc170707910d9d2b61a31ac8..a0b0bc143dd582d6f219cdd0b69c5a75472aef02 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -511,6 +511,15 @@ long RenderWidgetHostViewAndroid::GetNativeImeAdapter() {
void RenderWidgetHostViewAndroid::TextInputStateChanged(
const ViewHostMsg_TextInputState_Params& params) {
+ if (selection_controller_) {
+ // This call is semi-redundant with that in |OnFocusedNodeChanged|. The
+ // latter is guaranteed to be called before |OnSelectionBoundsChanged|,
+ // while this call is present to ensure consistency with IME after
+ // navigation and tab focus changes
+ const bool is_editable_node = params.type != ui::TEXT_INPUT_TYPE_NONE;
+ selection_controller_->OnSelectionEditable(is_editable_node);
+ }
+
// If the change is not originated from IME (e.g. Javascript, autofill),
// send back the renderer an acknowledgement, regardless of how we exit from
// this method.
@@ -658,6 +667,9 @@ void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text,
const gfx::Range& range) {
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
+ if (selection_controller_)
+ selection_controller_->OnSelectionEmpty(text.empty());
+
if (text.empty() || range.is_empty() || !content_view_core_)
return;
size_t pos = range.GetMin() - offset;
@@ -1245,12 +1257,10 @@ InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent(
if (selection_controller_) {
switch (input_event.type) {
case blink::WebInputEvent::GestureLongPress:
- case blink::WebInputEvent::GestureLongTap:
- selection_controller_->ShowInsertionHandleAutomatically();
- selection_controller_->ShowSelectionHandlesAutomatically();
+ selection_controller_->OnLongPressEvent();
break;
case blink::WebInputEvent::GestureTap:
- selection_controller_->ShowInsertionHandleAutomatically();
+ selection_controller_->OnTapEvent();
break;
default:
break;
@@ -1362,7 +1372,7 @@ void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) {
void RenderWidgetHostViewAndroid::HideTextHandles() {
if (selection_controller_)
- selection_controller_->HideAndDisallowAutomaticShowing();
+ selection_controller_->HideAndDisallowShowingAutomatically();
}
SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const {
@@ -1603,8 +1613,9 @@ SkColorType RenderWidgetHostViewAndroid::PreferredReadbackFormat() {
}
void RenderWidgetHostViewAndroid::ShowSelectionHandlesAutomatically() {
+ // Fake a long press to allow automatic selection handle showing.
if (selection_controller_)
- selection_controller_->ShowSelectionHandlesAutomatically();
+ selection_controller_->OnLongPressEvent();
}
void RenderWidgetHostViewAndroid::SelectRange(
« no previous file with comments | « content/browser/renderer_host/input/touch_selection_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698