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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_views.cc

Issue 7778039: touchui: Fine-tune selection-controller visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 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: chrome/browser/renderer_host/render_widget_host_view_views.cc
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc
index b2ade9a0a944302c40fcf8289a4cf4c3c2636123..2914465165f0082160dbb7f845f95f74548e4978 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
@@ -43,6 +43,7 @@
static const int kMaxWindowWidth = 4000;
static const int kMaxWindowHeight = 4000;
+static const int kTouchControllerUpdateDelay = 150;
// static
const char RenderWidgetHostViewViews::kViewClassName[] =
@@ -95,7 +96,8 @@ RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host)
text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
has_composition_text_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_(
- views::TouchSelectionController::create(this))) {
+ views::TouchSelectionController::create(this))),
+ ALLOW_THIS_IN_INITIALIZER_LIST(update_touch_selection_(this)) {
set_focusable(true);
host_->SetView(this);
@@ -156,10 +158,7 @@ void RenderWidgetHostViewViews::DidBecomeSelected() {
if (host_)
host_->WasRestored();
- if (touch_selection_controller_.get()) {
- touch_selection_controller_->SelectionChanged(selection_start_,
- selection_end_);
- }
+ UpdateTouchSelectionController();
}
void RenderWidgetHostViewViews::WasHidden() {
@@ -176,6 +175,9 @@ void RenderWidgetHostViewViews::WasHidden() {
if (host_)
host_->WasHidden();
+ if (!update_touch_selection_.empty())
+ update_touch_selection_.RevokeAll();
+
if (touch_selection_controller_.get())
touch_selection_controller_->ClientViewLostFocus();
}
@@ -346,8 +348,21 @@ void RenderWidgetHostViewViews::SelectionChanged(const std::string& text,
NOTIMPLEMENTED();
selection_start_ = start;
selection_end_ = end;
- if (touch_selection_controller_.get())
- touch_selection_controller_->SelectionChanged(start, end);
+
+ // TODO(sad): This is a workaround for a webkit bug:
+ // https://bugs.webkit.org/show_bug.cgi?id=67464
+ // Remove this when the bug gets fixed.
+ //
+ // Webkit can send spurious selection-change on text-input (e.g. when
+ // inserting text at the beginning of a non-empty text control). But in those
+ // cases, it does send the correct selection information quickly afterwards.
+ // So delay the notification to the touch-selection controller.
+ if (update_touch_selection_.empty()) {
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ update_touch_selection_.NewRunnableMethod(
+ &RenderWidgetHostViewViews::UpdateTouchSelectionController),
+ kTouchControllerUpdateDelay);
+ }
}
void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) {
@@ -816,3 +831,9 @@ void RenderWidgetHostViewViews::FinishImeCompositionSession() {
GetInputMethod()->CancelComposition(this);
has_composition_text_ = false;
}
+
+void RenderWidgetHostViewViews::UpdateTouchSelectionController() {
+ if (touch_selection_controller_.get())
+ touch_selection_controller_->SelectionChanged(selection_start_,
+ selection_end_);
+}
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_views.h ('k') | views/touchui/touch_selection_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698