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

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

Issue 2354413003: Implement support for Mac Zoom following focus and caret (Closed)
Patch Set: Fix typo Created 4 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 unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/text_input_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/text_input_manager.h" 5 #include "content/browser/renderer_host/text_input_manager.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h" 8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 #include "content/browser/renderer_host/render_widget_host_view_base.h" 9 #include "content/browser/renderer_host/render_widget_host_view_base.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 void TextInputManager::SelectionBoundsChanged( 147 void TextInputManager::SelectionBoundsChanged(
148 RenderWidgetHostViewBase* view, 148 RenderWidgetHostViewBase* view,
149 const ViewHostMsg_SelectionBounds_Params& params) { 149 const ViewHostMsg_SelectionBounds_Params& params) {
150 DCHECK(IsRegistered(view)); 150 DCHECK(IsRegistered(view));
151 // Converting the anchor point to root's coordinate space (for child frame 151 // Converting the anchor point to root's coordinate space (for child frame
152 // views). 152 // views).
153 gfx::Point anchor_origin_transformed = 153 gfx::Point anchor_origin_transformed =
154 view->TransformPointToRootCoordSpace(params.anchor_rect.origin()); 154 view->TransformPointToRootCoordSpace(params.anchor_rect.origin());
155 #if defined(USE_AURA) 155
156 gfx::SelectionBound anchor_bound, focus_bound; 156 gfx::SelectionBound anchor_bound, focus_bound;
157 157
158 anchor_bound.SetEdge(gfx::PointF(anchor_origin_transformed), 158 anchor_bound.SetEdge(gfx::PointF(anchor_origin_transformed),
159 gfx::PointF(view->TransformPointToRootCoordSpace( 159 gfx::PointF(view->TransformPointToRootCoordSpace(
160 params.anchor_rect.bottom_left()))); 160 params.anchor_rect.bottom_left())));
161 focus_bound.SetEdge(gfx::PointF(view->TransformPointToRootCoordSpace( 161 focus_bound.SetEdge(gfx::PointF(view->TransformPointToRootCoordSpace(
162 params.focus_rect.origin())), 162 params.focus_rect.origin())),
163 gfx::PointF(view->TransformPointToRootCoordSpace( 163 gfx::PointF(view->TransformPointToRootCoordSpace(
164 params.focus_rect.bottom_left()))); 164 params.focus_rect.bottom_left())));
165 165
(...skipping 19 matching lines...) Expand all
185 focus_bound.set_type(gfx::SelectionBound::LEFT); 185 focus_bound.set_type(gfx::SelectionBound::LEFT);
186 } 186 }
187 } 187 }
188 188
189 if (anchor_bound == selection_region_map_[view].anchor && 189 if (anchor_bound == selection_region_map_[view].anchor &&
190 focus_bound == selection_region_map_[view].focus) 190 focus_bound == selection_region_map_[view].focus)
191 return; 191 return;
192 192
193 selection_region_map_[view].anchor = anchor_bound; 193 selection_region_map_[view].anchor = anchor_bound;
194 selection_region_map_[view].focus = focus_bound; 194 selection_region_map_[view].focus = focus_bound;
195 #else 195
196 if (params.anchor_rect == params.focus_rect) { 196 if (params.anchor_rect == params.focus_rect) {
197 selection_region_map_[view].caret_rect.set_origin( 197 selection_region_map_[view].caret_rect.set_origin(
198 anchor_origin_transformed); 198 anchor_origin_transformed);
199 selection_region_map_[view].caret_rect.set_size(params.anchor_rect.size()); 199 selection_region_map_[view].caret_rect.set_size(params.anchor_rect.size());
200 } 200 }
201 selection_region_map_[view].first_selection_rect.set_origin( 201 selection_region_map_[view].first_selection_rect.set_origin(
202 anchor_origin_transformed); 202 anchor_origin_transformed);
203 selection_region_map_[view].first_selection_rect.set_size( 203 selection_region_map_[view].first_selection_rect.set_size(
204 params.anchor_rect.size()); 204 params.anchor_rect.size());
205 #endif // USE_AURA 205
206 FOR_EACH_OBSERVER(Observer, observer_list_, 206 FOR_EACH_OBSERVER(Observer, observer_list_,
207 OnSelectionBoundsChanged(this, view)); 207 OnSelectionBoundsChanged(this, view));
208 } 208 }
209 209
210 // TODO(ekaramad): We use |range| only on Mac OS; but we still track its value 210 // TODO(ekaramad): We use |range| only on Mac OS; but we still track its value
211 // here for other platforms. See if there is a nice way around this with minimal 211 // here for other platforms. See if there is a nice way around this with minimal
212 // #ifdefs for platform specific code (https://crbug.com/602427). 212 // #ifdefs for platform specific code (https://crbug.com/602427).
213 void TextInputManager::ImeCompositionRangeChanged( 213 void TextInputManager::ImeCompositionRangeChanged(
214 RenderWidgetHostViewBase* view, 214 RenderWidgetHostViewBase* view,
215 const gfx::Range& range, 215 const gfx::Range& range,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 "point exceeds text length)."; 342 "point exceeds text length).";
343 return false; 343 return false;
344 } 344 }
345 345
346 selected_text->clear(); 346 selected_text->clear();
347 selected_text->append(text.substr(pos, n)); 347 selected_text->append(text.substr(pos, n));
348 return true; 348 return true;
349 } 349 }
350 350
351 } // namespace content 351 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/text_input_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698