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

Side by Side Diff: third_party/WebKit/Source/core/editing/LayoutSelection.cpp

Issue 2951893003: Remove redundant canonicalization in LayoutSelection::CalacSelectionRange (Closed)
Patch Set: nit Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // <rdar://problem/10232866>. 332 // <rdar://problem/10232866>.
333 const SelectionInFlatTree& new_selection = CalcSelection( 333 const SelectionInFlatTree& new_selection = CalcSelection(
334 original_selection, frame_selection.ShouldShowBlockCursor()); 334 original_selection, frame_selection.ShouldShowBlockCursor());
335 const VisibleSelectionInFlatTree& selection = 335 const VisibleSelectionInFlatTree& selection =
336 CreateVisibleSelection(new_selection); 336 CreateVisibleSelection(new_selection);
337 337
338 if (!selection.IsRange() || frame_selection.IsHidden()) 338 if (!selection.IsRange() || frame_selection.IsHidden())
339 return SelectionPaintRange(); 339 return SelectionPaintRange();
340 340
341 DCHECK(!selection.IsNone()); 341 DCHECK(!selection.IsNone());
342 // Use the rightmost candidate for the start of the selection, and the 342 const PositionInFlatTree start_pos = selection.Start();
343 // leftmost candidate for the end of the selection. Example: foo <a>bar</a>. 343 const PositionInFlatTree end_pos = selection.End();
344 // Imagine that a line wrap occurs after 'foo', and that 'bar' is selected.
345 // If we pass [foo, 3] as the start of the selection, the selection painting
346 // code will think that content on the line containing 'foo' is selected
347 // and will fill the gap before 'bar'.
348 PositionInFlatTree start_pos = selection.Start();
349 const PositionInFlatTree most_forward_start =
350 MostForwardCaretPosition(start_pos);
351 if (IsVisuallyEquivalentCandidate(most_forward_start))
352 start_pos = most_forward_start;
353 PositionInFlatTree end_pos = selection.End();
354 const PositionInFlatTree most_backward = MostBackwardCaretPosition(end_pos);
355 if (IsVisuallyEquivalentCandidate(most_backward))
356 end_pos = most_backward;
357
358 DCHECK(start_pos.IsNotNull());
359 DCHECK(end_pos.IsNotNull());
360 DCHECK_LE(start_pos, end_pos); 344 DCHECK_LE(start_pos, end_pos);
361 LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject(); 345 LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject();
362 LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject(); 346 LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject();
363 DCHECK(start_layout_object); 347 DCHECK(start_layout_object);
364 DCHECK(end_layout_object); 348 DCHECK(end_layout_object);
365 DCHECK(start_layout_object->View() == end_layout_object->View()); 349 DCHECK(start_layout_object->View() == end_layout_object->View());
366 350
367 return SelectionPaintRange(start_layout_object, 351 return SelectionPaintRange(start_layout_object,
368 start_pos.ComputeEditingOffset(), 352 start_pos.ComputeEditingOffset(),
369 end_layout_object, end_pos.ComputeEditingOffset()); 353 end_layout_object, end_pos.ComputeEditingOffset());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 415
432 runner->SetShouldInvalidateSelection(); 416 runner->SetShouldInvalidateSelection();
433 } 417 }
434 } 418 }
435 419
436 DEFINE_TRACE(LayoutSelection) { 420 DEFINE_TRACE(LayoutSelection) {
437 visitor->Trace(frame_selection_); 421 visitor->Trace(frame_selection_);
438 } 422 }
439 423
440 } // namespace blink 424 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698