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

Side by Side Diff: ui/views/selection_controller.cc

Issue 2541313002: RenderTextHarfBuzz: Add support for multi line text selection. (Closed)
Patch Set: Fix test. Created 3 years, 12 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 unified diff | Download patch
« no previous file with comments | « ui/views/examples/label_example.cc ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/selection_controller.h" 5 #include "ui/views/selection_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/gfx/render_text.h" 10 #include "ui/gfx/render_text.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 gfx::RenderText* SelectionController::GetRenderText() { 189 gfx::RenderText* SelectionController::GetRenderText() {
190 return delegate_->GetRenderTextForSelectionController(); 190 return delegate_->GetRenderTextForSelectionController();
191 } 191 }
192 192
193 void SelectionController::SelectThroughLastDragLocation() { 193 void SelectionController::SelectThroughLastDragLocation() {
194 gfx::RenderText* render_text = GetRenderText(); 194 gfx::RenderText* render_text = GetRenderText();
195 DCHECK(render_text); 195 DCHECK(render_text);
196 196
197 delegate_->OnBeforePointerAction(); 197 delegate_->OnBeforePointerAction();
198 198
199 // TODO(karandeepb): See if this can be handled at the RenderText level. 199 render_text->MoveCursorTo(last_drag_location_, true);
200 const bool drags_to_end = PlatformStyle::kTextDragVerticallyDragsToEnd;
201 if (drags_to_end && last_drag_location_.y() < 0) {
202 render_text->MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT,
203 gfx::SELECTION_RETAIN);
204 } else if (drags_to_end &&
205 last_drag_location_.y() > delegate_->GetViewHeight()) {
206 render_text->MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT,
207 gfx::SELECTION_RETAIN);
208 } else {
209 render_text->MoveCursorTo(last_drag_location_, true);
210 }
211 200
212 if (aggregated_clicks_ == 1) { 201 if (aggregated_clicks_ == 1) {
213 render_text->SelectWord(); 202 render_text->SelectWord();
214 // Expand the selection so the initially selected word remains selected. 203 // Expand the selection so the initially selected word remains selected.
215 gfx::Range selection = render_text->selection(); 204 gfx::Range selection = render_text->selection();
216 const size_t min = 205 const size_t min =
217 std::min(selection.GetMin(), double_click_word_.GetMin()); 206 std::min(selection.GetMin(), double_click_word_.GetMin());
218 const size_t max = 207 const size_t max =
219 std::max(selection.GetMax(), double_click_word_.GetMax()); 208 std::max(selection.GetMax(), double_click_word_.GetMax());
220 const bool reversed = selection.is_reversed(); 209 const bool reversed = selection.is_reversed();
221 selection.set_start(reversed ? max : min); 210 selection.set_start(reversed ? max : min);
222 selection.set_end(reversed ? min : max); 211 selection.set_end(reversed ? min : max);
223 render_text->SelectRange(selection); 212 render_text->SelectRange(selection);
224 } 213 }
225 delegate_->OnAfterPointerAction(false, true); 214 delegate_->OnAfterPointerAction(false, true);
226 } 215 }
227 216
228 } // namespace views 217 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/label_example.cc ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698