OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_base.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/browser/accessibility/browser_accessibility_manager.h" | 9 #include "content/browser/accessibility/browser_accessibility_manager.h" |
10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 // How many microseconds apart input events should be flushed. | 29 // How many microseconds apart input events should be flushed. |
30 const int kFlushInputRateInUs = 16666; | 30 const int kFlushInputRateInUs = 16666; |
31 | 31 |
32 } | 32 } |
33 | 33 |
34 RenderWidgetHostViewBase::RenderWidgetHostViewBase() | 34 RenderWidgetHostViewBase::RenderWidgetHostViewBase() |
35 : popup_type_(blink::WebPopupTypeNone), | 35 : popup_type_(blink::WebPopupTypeNone), |
36 background_color_(SK_ColorWHITE), | 36 background_color_(SK_ColorWHITE), |
37 mouse_locked_(false), | 37 mouse_locked_(false), |
38 showing_context_menu_(false), | 38 showing_context_menu_(false), |
39 #if !defined(USE_AURA) | |
39 selection_text_offset_(0), | 40 selection_text_offset_(0), |
40 selection_range_(gfx::Range::InvalidRange()), | 41 selection_range_(gfx::Range::InvalidRange()), |
42 #endif | |
41 current_device_scale_factor_(0), | 43 current_device_scale_factor_(0), |
42 current_display_rotation_(display::Display::ROTATE_0), | 44 current_display_rotation_(display::Display::ROTATE_0), |
43 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), | 45 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), |
44 text_input_manager_(nullptr), | 46 text_input_manager_(nullptr), |
45 renderer_frame_number_(0), | 47 renderer_frame_number_(0), |
46 weak_factory_(this) {} | 48 weak_factory_(this) { |
49 } | |
47 | 50 |
48 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { | 51 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
49 DCHECK(!mouse_locked_); | 52 DCHECK(!mouse_locked_); |
50 // We call this here to guarantee that observers are notified before we go | 53 // We call this here to guarantee that observers are notified before we go |
51 // away. However, some subclasses may wish to call this earlier in their | 54 // away. However, some subclasses may wish to call this earlier in their |
52 // shutdown process, e.g. to force removal from | 55 // shutdown process, e.g. to force removal from |
53 // RenderWidgetHostInputEventRouter's surface map before relinquishing a | 56 // RenderWidgetHostInputEventRouter's surface map before relinquishing a |
54 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling | 57 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling |
55 // NotifyObserversAboutShutdown() twice, as the observers are required to | 58 // NotifyObserversAboutShutdown() twice, as the observers are required to |
56 // de-register on the first call, and so the second call does nothing. | 59 // de-register on the first call, and so the second call does nothing. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 | 107 |
105 void RenderWidgetHostViewBase::SelectionBoundsChanged( | 108 void RenderWidgetHostViewBase::SelectionBoundsChanged( |
106 const ViewHostMsg_SelectionBounds_Params& params) { | 109 const ViewHostMsg_SelectionBounds_Params& params) { |
107 if (GetTextInputManager()) | 110 if (GetTextInputManager()) |
108 GetTextInputManager()->SelectionBoundsChanged(this, params); | 111 GetTextInputManager()->SelectionBoundsChanged(this, params); |
109 } | 112 } |
110 | 113 |
111 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text, | 114 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text, |
112 size_t offset, | 115 size_t offset, |
113 const gfx::Range& range) { | 116 const gfx::Range& range) { |
117 #if defined(USE_AURA) | |
kenrb
2016/07/12 19:15:25
Shouldn't the SelectionChanged() override in Rende
EhsanK
2016/07/12 19:33:48
Yes, definitely. Sorry it was missing in this patc
| |
118 if (GetTextInputManager()) | |
119 GetTextInputManager()->SelectionChanged(this, text, offset, range); | |
120 #else | |
114 selection_text_ = text; | 121 selection_text_ = text; |
115 selection_text_offset_ = offset; | 122 selection_text_offset_ = offset; |
116 selection_range_.set_start(range.start()); | 123 selection_range_.set_start(range.start()); |
117 selection_range_.set_end(range.end()); | 124 selection_range_.set_end(range.end()); |
125 #endif | |
118 } | 126 } |
119 | 127 |
120 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const { | 128 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const { |
121 return GetViewBounds().size(); | 129 return GetViewBounds().size(); |
122 } | 130 } |
123 | 131 |
124 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() { | 132 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() { |
125 NOTREACHED(); | 133 NOTREACHED(); |
126 return NULL; | 134 return NULL; |
127 } | 135 } |
128 | 136 |
129 bool RenderWidgetHostViewBase::IsShowingContextMenu() const { | 137 bool RenderWidgetHostViewBase::IsShowingContextMenu() const { |
130 return showing_context_menu_; | 138 return showing_context_menu_; |
131 } | 139 } |
132 | 140 |
133 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { | 141 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { |
134 DCHECK_NE(showing_context_menu_, showing); | 142 DCHECK_NE(showing_context_menu_, showing); |
135 showing_context_menu_ = showing; | 143 showing_context_menu_ = showing; |
136 } | 144 } |
137 | 145 |
138 base::string16 RenderWidgetHostViewBase::GetSelectedText() const { | 146 base::string16 RenderWidgetHostViewBase::GetSelectedText() const { |
147 #if defined(USE_AURA) | |
148 return const_cast<RenderWidgetHostViewBase*>(this) | |
149 ->GetSelectedTextFromTextInputManager(); | |
150 #else | |
139 if (!selection_range_.IsValid()) | 151 if (!selection_range_.IsValid()) |
140 return base::string16(); | 152 return base::string16(); |
141 return selection_text_.substr( | 153 return selection_text_.substr( |
142 selection_range_.GetMin() - selection_text_offset_, | 154 selection_range_.GetMin() - selection_text_offset_, |
143 selection_range_.length()); | 155 selection_range_.length()); |
156 #endif | |
144 } | 157 } |
145 | 158 |
146 bool RenderWidgetHostViewBase::IsMouseLocked() { | 159 bool RenderWidgetHostViewBase::IsMouseLocked() { |
147 return mouse_locked_; | 160 return mouse_locked_; |
148 } | 161 } |
149 | 162 |
150 InputEventAckState RenderWidgetHostViewBase::FilterInputEvent( | 163 InputEventAckState RenderWidgetHostViewBase::FilterInputEvent( |
151 const blink::WebInputEvent& input_event) { | 164 const blink::WebInputEvent& input_event) { |
152 // By default, input events are simply forwarded to the renderer. | 165 // By default, input events are simply forwarded to the renderer. |
153 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 166 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 | 298 |
286 void RenderWidgetHostViewBase::FlushInput() { | 299 void RenderWidgetHostViewBase::FlushInput() { |
287 RenderWidgetHostImpl* impl = NULL; | 300 RenderWidgetHostImpl* impl = NULL; |
288 if (GetRenderWidgetHost()) | 301 if (GetRenderWidgetHost()) |
289 impl = RenderWidgetHostImpl::From(GetRenderWidgetHost()); | 302 impl = RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
290 if (!impl) | 303 if (!impl) |
291 return; | 304 return; |
292 impl->FlushInput(); | 305 impl->FlushInput(); |
293 } | 306 } |
294 | 307 |
308 base::string16 RenderWidgetHostViewBase::GetSelectedTextFromTextInputManager() { | |
309 if (!GetTextInputManager()) | |
310 return base::string16(); | |
311 | |
312 const TextInputManager::TextSelection* selection = | |
313 GetTextInputManager()->GetTextSelection(this); | |
314 | |
315 if (!selection || !selection->range.IsValid()) | |
316 return base::string16(); | |
317 | |
318 return selection->text.substr(selection->range.GetMin() - selection->offset, | |
319 selection->range.length()); | |
320 } | |
321 | |
295 void RenderWidgetHostViewBase::OnTextSurroundingSelectionResponse( | 322 void RenderWidgetHostViewBase::OnTextSurroundingSelectionResponse( |
296 const base::string16& content, | 323 const base::string16& content, |
297 size_t start_offset, | 324 size_t start_offset, |
298 size_t end_offset) { | 325 size_t end_offset) { |
299 NOTIMPLEMENTED(); | 326 NOTIMPLEMENTED(); |
300 } | 327 } |
301 | 328 |
302 void RenderWidgetHostViewBase::ShowDisambiguationPopup( | 329 void RenderWidgetHostViewBase::ShowDisambiguationPopup( |
303 const gfx::Rect& rect_pixels, | 330 const gfx::Rect& rect_pixels, |
304 const SkBitmap& zoomed_bitmap) { | 331 const SkBitmap& zoomed_bitmap) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 | 481 |
455 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { | 482 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { |
456 return false; | 483 return false; |
457 } | 484 } |
458 | 485 |
459 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { | 486 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { |
460 return cc::SurfaceId(); | 487 return cc::SurfaceId(); |
461 } | 488 } |
462 | 489 |
463 } // namespace content | 490 } // namespace content |
OLD | NEW |