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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 2130133004: Tracking text selection on the browser side in OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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 unified diff | Download patch
OLDNEW
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
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
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 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms.
118 // Also, remove the following local variables when that happens
119 // (https://crbug.com/578168 and https://crbug.com/602427).
120 #if defined(USE_AURA)
121 if (GetTextInputManager())
122 GetTextInputManager()->SelectionChanged(this, text, offset, range);
123 #else
114 selection_text_ = text; 124 selection_text_ = text;
115 selection_text_offset_ = offset; 125 selection_text_offset_ = offset;
116 selection_range_.set_start(range.start()); 126 selection_range_.set_start(range.start());
117 selection_range_.set_end(range.end()); 127 selection_range_.set_end(range.end());
128 #endif
118 } 129 }
119 130
120 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const { 131 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const {
121 return GetViewBounds().size(); 132 return GetViewBounds().size();
122 } 133 }
123 134
124 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() { 135 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() {
125 NOTREACHED(); 136 NOTREACHED();
126 return NULL; 137 return NULL;
127 } 138 }
128 139
129 bool RenderWidgetHostViewBase::IsShowingContextMenu() const { 140 bool RenderWidgetHostViewBase::IsShowingContextMenu() const {
130 return showing_context_menu_; 141 return showing_context_menu_;
131 } 142 }
132 143
133 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { 144 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) {
134 DCHECK_NE(showing_context_menu_, showing); 145 DCHECK_NE(showing_context_menu_, showing);
135 showing_context_menu_ = showing; 146 showing_context_menu_ = showing;
136 } 147 }
137 148
138 base::string16 RenderWidgetHostViewBase::GetSelectedText() { 149 base::string16 RenderWidgetHostViewBase::GetSelectedText() {
150 // TODO(ekaramad): Use TextInputManager code paths for IME onother platforms.
Charlie Reis 2016/07/20 23:00:30 nit: on other
EhsanK 2016/07/21 16:52:55 Done. Thanks!
151 // Also, remove the following local variables when that happens
152 // (https://crbug.com/578168 and https://crbug.com/602427).
153 #if defined(USE_AURA)
154 if (!GetTextInputManager())
155 return base::string16();
156
157 const TextInputManager::TextSelection* selection =
158 GetTextInputManager()->GetTextSelection(this);
159
160 if (!selection || !selection->range.IsValid())
161 return base::string16();
162
163 return selection->text.substr(selection->range.GetMin() - selection->offset,
164 selection->range.length());
165 #else
139 if (!selection_range_.IsValid()) 166 if (!selection_range_.IsValid())
140 return base::string16(); 167 return base::string16();
141 return selection_text_.substr( 168 return selection_text_.substr(
142 selection_range_.GetMin() - selection_text_offset_, 169 selection_range_.GetMin() - selection_text_offset_,
143 selection_range_.length()); 170 selection_range_.length());
171 #endif
144 } 172 }
145 173
146 bool RenderWidgetHostViewBase::IsMouseLocked() { 174 bool RenderWidgetHostViewBase::IsMouseLocked() {
147 return mouse_locked_; 175 return mouse_locked_;
148 } 176 }
149 177
150 InputEventAckState RenderWidgetHostViewBase::FilterInputEvent( 178 InputEventAckState RenderWidgetHostViewBase::FilterInputEvent(
151 const blink::WebInputEvent& input_event) { 179 const blink::WebInputEvent& input_event) {
152 // By default, input events are simply forwarded to the renderer. 180 // By default, input events are simply forwarded to the renderer.
153 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 181 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 494
467 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { 495 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const {
468 return false; 496 return false;
469 } 497 }
470 498
471 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { 499 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const {
472 return cc::SurfaceId(); 500 return cc::SurfaceId();
473 } 501 }
474 502
475 } // namespace content 503 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698