OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 #include <gtk/gtkwindow.h> | 36 #include <gtk/gtkwindow.h> |
37 #include <gdk/gdkx.h> | 37 #include <gdk/gdkx.h> |
38 #endif | 38 #endif |
39 | 39 |
40 #if defined(TOUCH_UI) | 40 #if defined(TOUCH_UI) |
41 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h" | 41 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h" |
42 #endif | 42 #endif |
43 | 43 |
44 static const int kMaxWindowWidth = 4000; | 44 static const int kMaxWindowWidth = 4000; |
45 static const int kMaxWindowHeight = 4000; | 45 static const int kMaxWindowHeight = 4000; |
46 static const int kTouchControllerUpdateDelay = 150; | |
46 | 47 |
47 // static | 48 // static |
48 const char RenderWidgetHostViewViews::kViewClassName[] = | 49 const char RenderWidgetHostViewViews::kViewClassName[] = |
49 "browser/renderer_host/RenderWidgetHostViewViews"; | 50 "browser/renderer_host/RenderWidgetHostViewViews"; |
50 | 51 |
51 using WebKit::WebInputEventFactory; | 52 using WebKit::WebInputEventFactory; |
52 using WebKit::WebMouseWheelEvent; | 53 using WebKit::WebMouseWheelEvent; |
53 using WebKit::WebTouchEvent; | 54 using WebKit::WebTouchEvent; |
54 | 55 |
55 namespace { | 56 namespace { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 about_to_validate_and_paint_(false), | 89 about_to_validate_and_paint_(false), |
89 is_hidden_(false), | 90 is_hidden_(false), |
90 is_loading_(false), | 91 is_loading_(false), |
91 native_cursor_(NULL), | 92 native_cursor_(NULL), |
92 is_showing_context_menu_(false), | 93 is_showing_context_menu_(false), |
93 visually_deemphasized_(false), | 94 visually_deemphasized_(false), |
94 touch_event_(), | 95 touch_event_(), |
95 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 96 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
96 has_composition_text_(false), | 97 has_composition_text_(false), |
97 ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_( | 98 ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_( |
98 views::TouchSelectionController::create(this))) { | 99 views::TouchSelectionController::create(this))), |
100 ALLOW_THIS_IN_INITIALIZER_LIST(update_touch_selection_(this)) { | |
99 set_focusable(true); | 101 set_focusable(true); |
100 host_->SetView(this); | 102 host_->SetView(this); |
101 | 103 |
102 #if defined(TOUCH_UI) | 104 #if defined(TOUCH_UI) |
103 SetPaintToLayer(true); | 105 SetPaintToLayer(true); |
104 SetFillsBoundsOpaquely(true); | 106 SetFillsBoundsOpaquely(true); |
105 #endif | 107 #endif |
106 } | 108 } |
107 | 109 |
108 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { | 110 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 void RenderWidgetHostViewViews::DidBecomeSelected() { | 151 void RenderWidgetHostViewViews::DidBecomeSelected() { |
150 if (!is_hidden_) | 152 if (!is_hidden_) |
151 return; | 153 return; |
152 | 154 |
153 if (tab_switch_paint_time_.is_null()) | 155 if (tab_switch_paint_time_.is_null()) |
154 tab_switch_paint_time_ = base::TimeTicks::Now(); | 156 tab_switch_paint_time_ = base::TimeTicks::Now(); |
155 is_hidden_ = false; | 157 is_hidden_ = false; |
156 if (host_) | 158 if (host_) |
157 host_->WasRestored(); | 159 host_->WasRestored(); |
158 | 160 |
159 if (touch_selection_controller_.get()) { | 161 UpdateTouchSelectionController(); |
160 touch_selection_controller_->SelectionChanged(selection_start_, | |
161 selection_end_); | |
162 } | |
163 } | 162 } |
164 | 163 |
165 void RenderWidgetHostViewViews::WasHidden() { | 164 void RenderWidgetHostViewViews::WasHidden() { |
166 if (is_hidden_) | 165 if (is_hidden_) |
167 return; | 166 return; |
168 | 167 |
169 // If we receive any more paint messages while we are hidden, we want to | 168 // If we receive any more paint messages while we are hidden, we want to |
170 // ignore them so we don't re-allocate the backing store. We will paint | 169 // ignore them so we don't re-allocate the backing store. We will paint |
171 // everything again when we become selected again. | 170 // everything again when we become selected again. |
172 is_hidden_ = true; | 171 is_hidden_ = true; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 } | 338 } |
340 | 339 |
341 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text, | 340 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text, |
342 const ui::Range& range, | 341 const ui::Range& range, |
343 const gfx::Point& start, | 342 const gfx::Point& start, |
344 const gfx::Point& end) { | 343 const gfx::Point& end) { |
345 // TODO(anicolao): deal with the clipboard without GTK | 344 // TODO(anicolao): deal with the clipboard without GTK |
346 NOTIMPLEMENTED(); | 345 NOTIMPLEMENTED(); |
347 selection_start_ = start; | 346 selection_start_ = start; |
348 selection_end_ = end; | 347 selection_end_ = end; |
349 if (touch_selection_controller_.get()) | 348 |
350 touch_selection_controller_->SelectionChanged(start, end); | 349 // TODO(sad): This is a workaround for a webkit bug: |
350 // https://bugs.webkit.org/show_bug.cgi?id=67464 | |
351 // Remove this when the bug gets fixed. | |
352 // | |
353 // Webkit can send spurious selection-change on text-input (e.g. when | |
354 // inserting text at the beginning of a non-empty text control). But in those | |
355 // cases, it does send the correct selection information quickly afterwards. | |
356 // So delay the notification to the touch-selection controller. | |
357 if (update_touch_selection_.empty()) { | |
358 MessageLoop::current()->PostDelayedTask(FROM_HERE, | |
359 update_touch_selection_.NewRunnableMethod( | |
sky
2011/09/06 17:43:27
Make sure we don't send this if we've lost focus b
sadrul
2011/09/06 20:23:31
Good point. Done.
| |
360 &RenderWidgetHostViewViews::UpdateTouchSelectionController), | |
361 kTouchControllerUpdateDelay); | |
362 } | |
351 } | 363 } |
352 | 364 |
353 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) { | 365 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) { |
354 is_showing_context_menu_ = showing; | 366 is_showing_context_menu_ = showing; |
355 } | 367 } |
356 | 368 |
357 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( | 369 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( |
358 const gfx::Size& size) { | 370 const gfx::Size& size) { |
359 return new BackingStoreSkia(host_, size); | 371 return new BackingStoreSkia(host_, size); |
360 } | 372 } |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 | 821 |
810 void RenderWidgetHostViewViews::FinishImeCompositionSession() { | 822 void RenderWidgetHostViewViews::FinishImeCompositionSession() { |
811 if (!has_composition_text_) | 823 if (!has_composition_text_) |
812 return; | 824 return; |
813 if (host_) | 825 if (host_) |
814 host_->ImeConfirmComposition(); | 826 host_->ImeConfirmComposition(); |
815 DCHECK(GetInputMethod()); | 827 DCHECK(GetInputMethod()); |
816 GetInputMethod()->CancelComposition(this); | 828 GetInputMethod()->CancelComposition(this); |
817 has_composition_text_ = false; | 829 has_composition_text_ = false; |
818 } | 830 } |
831 | |
832 void RenderWidgetHostViewViews::UpdateTouchSelectionController() { | |
833 if (touch_selection_controller_.get()) | |
834 touch_selection_controller_->SelectionChanged(selection_start_, | |
835 selection_end_); | |
836 } | |
OLD | NEW |