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

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, 4 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 53f1aedbefce6f8c2a75c2cec8569b8a75bccb48..599550a17397ecb1f784ee7d663806cfb963e663 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);
@@ -150,10 +152,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() {
@@ -340,8 +339,17 @@ 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);
+
+ // Webkit can send spurious selection-change on text-input (e.g. when
rjkroege 2011/09/02 19:15:25 So per our discussion, this is a temporary fix pen
sadrul 2011/09/02 19:39:44 Yep. Done
+ // 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) {
@@ -810,3 +818,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_);
+}

Powered by Google App Engine
This is Rietveld 408576698