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 633bfb729e545e86325248c9d3d1a440f351ec2e..bde8150398df160f23b3ab508de9e8e66f74e268 100644 |
| --- a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
| +++ b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
| @@ -109,32 +109,44 @@ LayoutSelection::LayoutSelection(FrameSelection& frame_selection) |
| has_pending_selection_(false), |
| paint_range_(SelectionPaintRange()) {} |
| -static bool ShouldShowBlockCursor(const FrameSelection& frame_selection, |
| - const VisibleSelectionInFlatTree& selection) { |
| +enum class SelectionMode { |
| + kNone, |
| + kRange, |
| + kBlockCursor, |
| +}; |
| +static SelectionMode ComputeSelectionMode( |
|
yosin_UTC9
2017/07/05 09:32:16
nit: Could you add a blank line to separate |enum|
|
| + const FrameSelection& frame_selection, |
| + const VisibleSelectionInFlatTree& selection) { |
| + if (selection.IsRange()) |
| + return SelectionMode::kRange; |
| if (!frame_selection.ShouldShowBlockCursor()) |
| - return false; |
| - if (selection.GetSelectionType() != SelectionType::kCaretSelection) |
| - return false; |
| - if (IsLogicalEndOfLine(selection.VisibleEnd())) |
| - return false; |
| - return true; |
| + return SelectionMode::kNone; |
| + if (IsLogicalEndOfLine(selection.VisibleStart())) |
| + return SelectionMode::kNone; |
| + return SelectionMode::kBlockCursor; |
| } |
| static EphemeralRangeInFlatTree CalcSelection( |
| const FrameSelection& frame_selection) { |
| const VisibleSelectionInFlatTree& original_selection = |
| frame_selection.ComputeVisibleSelectionInFlatTree(); |
| - |
| - if (!ShouldShowBlockCursor(frame_selection, original_selection)) |
| - return {original_selection.Start(), original_selection.End()}; |
| - |
| - const PositionInFlatTree end_position = NextPositionOf( |
| - original_selection.Start(), PositionMoveType::kGraphemeCluster); |
| - const VisibleSelectionInFlatTree& block_cursor = CreateVisibleSelection( |
| - SelectionInFlatTree::Builder() |
| - .SetBaseAndExtent(original_selection.Start(), end_position) |
| - .Build()); |
| - return {block_cursor.Start(), block_cursor.End()}; |
| + switch (ComputeSelectionMode(frame_selection, original_selection)) { |
| + case SelectionMode::kNone: |
| + return {}; |
| + case SelectionMode::kRange: |
| + return {original_selection.Start(), original_selection.End()}; |
| + case SelectionMode::kBlockCursor: { |
| + const PositionInFlatTree end_position = NextPositionOf( |
| + original_selection.Start(), PositionMoveType::kGraphemeCluster); |
| + const VisibleSelectionInFlatTree& block_cursor = CreateVisibleSelection( |
| + SelectionInFlatTree::Builder() |
| + .SetBaseAndExtent(original_selection.Start(), end_position) |
| + .Build()); |
| + return {block_cursor.Start(), block_cursor.End()}; |
| + } |
| + } |
| + NOTREACHED(); |
| + return {}; |
| } |
| // Objects each have a single selection rect to examine. |