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

Unified Diff: content/browser/renderer_host/text_input_manager.cc

Issue 2213503002: Tracking SelectionBounds for all RenderWidgets on the Browser Side (Mac) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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
« no previous file with comments | « content/browser/renderer_host/text_input_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/text_input_manager.cc
diff --git a/content/browser/renderer_host/text_input_manager.cc b/content/browser/renderer_host/text_input_manager.cc
index 7c46df06f69587fbac6b444a401b51cde1e11bb5..6ba3e857ba744ff019b2661d72d26ebd3b007d28 100644
--- a/content/browser/renderer_host/text_input_manager.cc
+++ b/content/browser/renderer_host/text_input_manager.cc
@@ -61,13 +61,12 @@ const TextInputState* TextInputManager::GetTextInputState() const {
return !!active_view_ ? &text_input_state_map_.at(active_view_) : nullptr;
}
-gfx::Rect TextInputManager::GetSelectionBoundsRect() const {
- if (!active_view_)
- return gfx::Rect();
-
- return gfx::RectBetweenSelectionBounds(
- selection_region_map_.at(active_view_).anchor,
- selection_region_map_.at(active_view_).focus);
+const TextInputManager::SelectionRegion* TextInputManager::GetSelectionRegion(
+ RenderWidgetHostViewBase* view) const {
+ DCHECK(!view || IsRegistered(view));
+ if (!view)
+ view = active_view_;
+ return view ? &selection_region_map_.at(view) : nullptr;
}
const TextInputManager::CompositionRangeInfo*
@@ -149,14 +148,14 @@ void TextInputManager::SelectionBoundsChanged(
RenderWidgetHostViewBase* view,
const ViewHostMsg_SelectionBounds_Params& params) {
DCHECK(IsRegistered(view));
-
-// TODO(ekaramad): Implement the logic for other platforms (crbug.com/578168).
+ // Converting the anchor point to root's coordinate space (for child frame
+ // views).
+ gfx::Point anchor_origin_transformed =
+ view->TransformPointToRootCoordSpace(params.anchor_rect.origin());
#if defined(USE_AURA)
gfx::SelectionBound anchor_bound, focus_bound;
- // Converting the points to the |view|'s root coordinate space (for child
- // frame views).
- anchor_bound.SetEdge(gfx::PointF(view->TransformPointToRootCoordSpace(
- params.anchor_rect.origin())),
+
+ anchor_bound.SetEdge(gfx::PointF(anchor_origin_transformed),
gfx::PointF(view->TransformPointToRootCoordSpace(
params.anchor_rect.bottom_left())));
focus_bound.SetEdge(gfx::PointF(view->TransformPointToRootCoordSpace(
@@ -193,10 +192,19 @@ void TextInputManager::SelectionBoundsChanged(
selection_region_map_[view].anchor = anchor_bound;
selection_region_map_[view].focus = focus_bound;
-
+#else
+ if (params.anchor_rect == params.focus_rect) {
+ selection_region_map_[view].caret_rect.set_origin(
+ anchor_origin_transformed);
+ selection_region_map_[view].caret_rect.set_size(params.anchor_rect.size());
+ }
+ selection_region_map_[view].first_selection_rect.set_origin(
+ anchor_origin_transformed);
+ selection_region_map_[view].first_selection_rect.set_size(
+ params.anchor_rect.size());
+#endif // USE_AURA
FOR_EACH_OBSERVER(Observer, observer_list_,
OnSelectionBoundsChanged(this, view));
-#endif
}
// TODO(ekaramad): We use |range| only on Mac OS; but we still track its value
« 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