Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
| index 8d87696471ccc12588e00077d133d8478233925b..3f74aa4de251f8af20bf3bc278b0087739a690a3 100644 |
| --- a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
| +++ b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
| @@ -120,20 +120,21 @@ static bool ShouldShowBlockCursor(const FrameSelection& frame_selection, |
| return true; |
| } |
| -static VisibleSelectionInFlatTree CalcSelection( |
| +static std::pair<PositionInFlatTree, PositionInFlatTree> CalcSelection( |
|
yosin_UTC9
2017/07/04 05:56:41
Let's use |EphemeralRangeInFlatTree()| rather than
yoichio
2017/07/04 06:31:30
I will introduce a class kind of pair<LayoutObject
yosin_UTC9
2017/07/04 07:28:43
We may want to introduce SelectionRange instead of
yoichio
2017/07/04 08:02:45
Intorducd |using SelectionRange = std::pair<Positi
|
| const FrameSelection& frame_selection) { |
| const VisibleSelectionInFlatTree& original_selection = |
| frame_selection.ComputeVisibleSelectionInFlatTree(); |
| if (!ShouldShowBlockCursor(frame_selection, original_selection)) |
| - return original_selection; |
| + return {original_selection.Start(), original_selection.End()}; |
| const PositionInFlatTree end_position = NextPositionOf( |
| original_selection.Start(), PositionMoveType::kGraphemeCluster); |
| - return CreateVisibleSelection( |
| + const VisibleSelectionInFlatTree& block_cursor = CreateVisibleSelection( |
| SelectionInFlatTree::Builder() |
| .SetBaseAndExtent(original_selection.Start(), end_position) |
| .Build()); |
| + return {block_cursor.Start(), block_cursor.End()}; |
| } |
| // Objects each have a single selection rect to examine. |
| @@ -297,13 +298,13 @@ static SelectionPaintRange CalcSelectionPaintRange( |
| if (selection_in_dom.IsNone()) |
| return SelectionPaintRange(); |
| - const VisibleSelectionInFlatTree& selection = CalcSelection(frame_selection); |
| - if (!selection.IsRange() || frame_selection.IsHidden()) |
| + const auto& selection = CalcSelection(frame_selection); |
| + if ((selection.first.IsNull() || selection.first == selection.second) || |
| + frame_selection.IsHidden()) |
| return SelectionPaintRange(); |
| - DCHECK(!selection.IsNone()); |
| - const PositionInFlatTree start_pos = selection.Start(); |
| - const PositionInFlatTree end_pos = selection.End(); |
| + const PositionInFlatTree start_pos = selection.first; |
| + const PositionInFlatTree end_pos = selection.second; |
| DCHECK_LE(start_pos, end_pos); |
| LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject(); |
| LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject(); |