Chromium Code Reviews| 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 258c05ee00602ff2cf4a8ed6a1f0a76b71d15b46..6b6fd05c4a99658e81401d7bb8541f474a44839f 100644 |
| --- a/content/browser/renderer_host/text_input_manager.cc |
| +++ b/content/browser/renderer_host/text_input_manager.cc |
| @@ -5,6 +5,7 @@ |
| #include "content/browser/renderer_host/text_input_manager.h" |
| #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| +#include "content/common/view_messages.h" |
| namespace content { |
| @@ -51,6 +52,14 @@ RenderWidgetHostViewBase* TextInputManager::GetActiveView() const { |
| return active_view_; |
| } |
| +gfx::Rect TextInputManager::GetSelectionBoundsRect() { |
| + if (!active_view_) |
| + return gfx::Rect(); |
| + |
| + return gfx::RectBetweenSelectionBounds(selection_anchor_map_[active_view_], |
| + selection_focus_map_[active_view_]); |
| +} |
| + |
| void TextInputManager::UpdateTextInputState( |
| RenderWidgetHostViewBase* view, |
| const TextInputState& text_input_state) { |
| @@ -75,6 +84,51 @@ void TextInputManager::UpdateTextInputState( |
| NotifyObserversAboutInputStateUpdate(view, changed); |
| } |
| +void TextInputManager::SelectionBoundsChanged( |
|
EhsanK
2016/06/27 17:18:13
This will change when we add the same logic for Ma
|
| + RenderWidgetHostViewBase* view, |
| + const ViewHostMsg_SelectionBounds_Params& params) { |
| + DCHECK(IsRegistered(view)); |
| + |
| + gfx::SelectionBound anchor_bound, focus_bound; |
| + anchor_bound.SetEdge(gfx::PointF(params.anchor_rect.origin()), |
| + gfx::PointF(params.anchor_rect.bottom_left())); |
| + focus_bound.SetEdge(gfx::PointF(params.focus_rect.origin()), |
| + gfx::PointF(params.focus_rect.bottom_left())); |
| + |
| + if (params.anchor_rect == params.focus_rect) { |
| + anchor_bound.set_type(gfx::SelectionBound::CENTER); |
| + focus_bound.set_type(gfx::SelectionBound::CENTER); |
| + } else { |
| + // Whether text is LTR at the anchor handle. |
| + bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight; |
| + // Whether text is LTR at the focus handle. |
| + bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight; |
| + |
| + if ((params.is_anchor_first && anchor_LTR) || |
| + (!params.is_anchor_first && !anchor_LTR)) { |
| + anchor_bound.set_type(gfx::SelectionBound::LEFT); |
| + } else { |
| + anchor_bound.set_type(gfx::SelectionBound::RIGHT); |
| + } |
| + if ((params.is_anchor_first && focus_LTR) || |
| + (!params.is_anchor_first && !focus_LTR)) { |
| + focus_bound.set_type(gfx::SelectionBound::RIGHT); |
| + } else { |
| + focus_bound.set_type(gfx::SelectionBound::LEFT); |
| + } |
| + } |
| + |
| + if (anchor_bound == selection_anchor_map_[view] && |
| + focus_bound == selection_focus_map_[view]) |
| + return; |
| + |
| + selection_anchor_map_[view] = anchor_bound; |
| + selection_focus_map_[view] = focus_bound; |
| + |
| + FOR_EACH_OBSERVER(Observer, observer_list_, |
| + OnSelectionBoundsChanged(this, view)); |
| +} |
| + |
| void TextInputManager::Register(RenderWidgetHostViewBase* view) { |
| DCHECK(!IsRegistered(view)); |