| 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 c80f3807a0452485b0435e9e3c5f2b024c7dcb05..354301b359c614261b9d2cfef5f53dd5f1c4e576 100644
|
| --- a/content/browser/renderer_host/text_input_manager.cc
|
| +++ b/content/browser/renderer_host/text_input_manager.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "content/browser/renderer_host/render_widget_host_impl.h"
|
| #include "content/browser/renderer_host/render_widget_host_view_base.h"
|
| +#include "content/common/view_messages.h"
|
|
|
| namespace content {
|
|
|
| @@ -54,6 +55,14 @@ RenderWidgetHostImpl* TextInputManager::GetActiveWidget() const {
|
| : nullptr;
|
| }
|
|
|
| +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) {
|
| @@ -78,6 +87,51 @@ void TextInputManager::UpdateTextInputState(
|
| NotifyObserversAboutInputStateUpdate(view, changed);
|
| }
|
|
|
| +void TextInputManager::SelectionBoundsChanged(
|
| + 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));
|
|
|
|
|