OLD | NEW |
---|---|
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 Loading... | |
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 | |
343 // leftmost candidate for the end of the selection. Example: foo <a>bar</a>. | |
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 | 342 |
yosin_UTC9
2017/06/22 02:08:40
nit: we don't need to have an extra blank line bet
yoichio
2017/06/22 03:49:14
Done.
| |
343 const PositionInFlatTree start_pos = selection.Start(); | |
344 const PositionInFlatTree end_pos = selection.End(); | |
358 DCHECK(start_pos.IsNotNull()); | 345 DCHECK(start_pos.IsNotNull()); |
yosin_UTC9
2017/06/22 02:08:40
nit: Could you remove this? DCHECK_LE() can crash
yoichio
2017/06/22 03:49:14
Done.
| |
359 DCHECK(end_pos.IsNotNull()); | 346 DCHECK(end_pos.IsNotNull()); |
yosin_UTC9
2017/06/22 02:08:40
nit: Could you remove this? DCHECK_LE() can crash
yoichio
2017/06/22 03:49:14
Done.
| |
360 DCHECK_LE(start_pos, end_pos); | 347 DCHECK_LE(start_pos, end_pos); |
361 LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject(); | 348 LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject(); |
362 LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject(); | 349 LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject(); |
363 DCHECK(start_layout_object); | 350 DCHECK(start_layout_object); |
364 DCHECK(end_layout_object); | 351 DCHECK(end_layout_object); |
365 DCHECK(start_layout_object->View() == end_layout_object->View()); | 352 DCHECK(start_layout_object->View() == end_layout_object->View()); |
366 | 353 |
367 return SelectionPaintRange(start_layout_object, | 354 return SelectionPaintRange(start_layout_object, |
368 start_pos.ComputeEditingOffset(), | 355 start_pos.ComputeEditingOffset(), |
369 end_layout_object, end_pos.ComputeEditingOffset()); | 356 end_layout_object, end_pos.ComputeEditingOffset()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 | 418 |
432 runner->SetShouldInvalidateSelection(); | 419 runner->SetShouldInvalidateSelection(); |
433 } | 420 } |
434 } | 421 } |
435 | 422 |
436 DEFINE_TRACE(LayoutSelection) { | 423 DEFINE_TRACE(LayoutSelection) { |
437 visitor->Trace(frame_selection_); | 424 visitor->Trace(frame_selection_); |
438 } | 425 } |
439 | 426 |
440 } // namespace blink | 427 } // namespace blink |
OLD | NEW |