Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
index 074a309e045a43ef514afa1c672bd7bb5a927292..12c3632cfa992b1c4b13a7b1fa2b3ee458c8eb8a 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
@@ -929,20 +929,38 @@ gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { |
void RenderWidgetHostViewAura::SelectionBoundsChanged( |
const ViewHostMsg_SelectionBounds_Params& params) { |
- if (selection_anchor_rect_ == params.anchor_rect && |
- selection_focus_rect_ == params.focus_rect) |
+ ui::SelectionBound anchor_bound, focus_bound; |
+ anchor_bound.edge_top = params.anchor_rect.origin(); |
+ anchor_bound.edge_bottom = params.anchor_rect.bottom_left(); |
+ focus_bound.edge_top = params.focus_rect.origin(); |
+ focus_bound.edge_bottom = params.focus_rect.bottom_left(); |
+ |
+ if (params.anchor_rect == params.focus_rect) { |
+ anchor_bound.type = focus_bound.type = ui::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; |
+ anchor_bound.type = |
+ params.is_anchor_first ^ anchor_LTR ? ui::SelectionBound::RIGHT |
+ : ui::SelectionBound::LEFT; |
+ focus_bound.type = |
+ params.is_anchor_first ^ focus_LTR ? ui::SelectionBound::LEFT |
+ : ui::SelectionBound::RIGHT; |
+ } |
+ |
+ if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) |
return; |
- selection_anchor_rect_ = params.anchor_rect; |
- selection_focus_rect_ = params.focus_rect; |
- |
+ selection_anchor_ = anchor_bound; |
+ selection_focus_ = focus_bound; |
if (GetInputMethod()) |
GetInputMethod()->OnCaretBoundsChanged(this); |
- if (touch_editing_client_) { |
- touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, |
- selection_focus_rect_); |
- } |
+ if (touch_editing_client_) |
+ touch_editing_client_->OnSelectionOrCursorChanged( |
+ anchor_bound, focus_bound); |
mohsen
2014/11/10 22:25:59
nit: Curly braces for multi-line block.
mfomitchev
2014/11/10 23:07:29
Acknowledged.
mfomitchev
2014/11/12 18:32:49
Done.
|
} |
void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
@@ -1493,8 +1511,8 @@ gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen( |
} |
gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { |
- const gfx::Rect rect = |
- gfx::UnionRects(selection_anchor_rect_, selection_focus_rect_); |
+ gfx::Rect rect = |
+ ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_); |
return ConvertRectToScreen(rect); |
} |
@@ -2388,8 +2406,8 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
host_->WasResized(); |
delegated_frame_host_->WasResized(); |
if (touch_editing_client_) { |
- touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, |
- selection_focus_rect_); |
+ touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_, |
+ selection_focus_); |
} |
#if defined(OS_WIN) |
if (mouse_locked_) |