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

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: Fixed a crash 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
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 3207b9218d82cffcd159782e786d8e237f3d88df..6664e22bb9044f99faf4e4cd4df2b3ec921b046f 100644
--- a/content/browser/renderer_host/text_input_manager.cc
+++ b/content/browser/renderer_host/text_input_manager.cc
@@ -61,15 +61,6 @@ 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 std::vector<gfx::Rect>* TextInputManager::GetCompositionCharacterBounds()
const {
return !!active_view_
@@ -85,6 +76,32 @@ const TextInputManager::TextSelection* TextInputManager::GetTextSelection(
return !!view ? &text_selection_map_.at(view) : nullptr;
}
+#if defined(USE_AURA)
+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);
+}
+
+#elif defined(OS_MACOSX)
+const gfx::Rect* TextInputManager::GetCaretRect(
+ RenderWidgetHostImpl* widget) const {
+ RenderWidgetHostViewBase* view = widget->GetView();
+ DCHECK(IsRegistered(view));
+ return &selection_region_map_.at(view).caret_rect;
+}
+
+const gfx::Rect* TextInputManager::GetFirstSelectionRect(
+ RenderWidgetHostImpl* widget) const {
+ RenderWidgetHostViewBase* view = widget->GetView();
+ DCHECK(IsRegistered(view));
+ return &selection_region_map_.at(view).first_selection_rect;
+}
+#endif
+
void TextInputManager::UpdateTextInputState(
RenderWidgetHostViewBase* view,
const TextInputState& text_input_state) {
@@ -146,15 +163,16 @@ void TextInputManager::ImeCancelComposition(RenderWidgetHostViewBase* view) {
void TextInputManager::SelectionBoundsChanged(
RenderWidgetHostViewBase* view,
const ViewHostMsg_SelectionBounds_Params& params) {
+#if !defined(OS_ANDROID)
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(
@@ -191,10 +209,20 @@ 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
+#endif // !OS_ANDROID
}
void TextInputManager::ImeCompositionRangeChanged(

Powered by Google App Engine
This is Rietveld 408576698