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

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

Issue 700563002: Implementing directional text selection handles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_assets_text
Patch Set: Created 6 years, 1 month 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/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..92481619d659cbeca135c6b275054eb4ee67a015 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,42 @@ 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;
+ gfx::Rect anchor_rect(params.anchor_rect);
+ gfx::Rect focus_rect(params.focus_rect);
mohsen 2014/11/07 16:52:26 I think the above copies are not needed and you ca
mfomitchev 2014/11/10 04:04:11 Done.
+
+ anchor_bound.edge_top = anchor_rect.origin();
+ anchor_bound.edge_bottom = anchor_rect.bottom_left();
+ focus_bound.edge_top = focus_rect.origin();
+ focus_bound.edge_bottom = focus_rect.bottom_left();
+
+ if (params.anchor_rect == params.focus_rect) {
+ if (params.anchor_rect.x() || params.anchor_rect.y())
mohsen 2014/11/07 16:52:26 What does this line exactly check? And, what happe
mfomitchev 2014/11/10 04:04:11 Got rid of this. I took this from the Clank code,
+ 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);
}
void RenderWidgetHostViewAura::CopyFromCompositingSurface(
@@ -1493,8 +1515,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 +2410,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_)

Powered by Google App Engine
This is Rietveld 408576698