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

Unified Diff: third_party/WebKit/Source/core/editing/LayoutSelection.cpp

Issue 2970653003: Make CalcSelection return EphemeralRange. (Closed)
Patch Set: update Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..633bfb729e545e86325248c9d3d1a440f351ec2e 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 EphemeralRangeInFlatTree CalcSelection(
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,12 @@ static SelectionPaintRange CalcSelectionPaintRange(
if (selection_in_dom.IsNone())
return SelectionPaintRange();
- const VisibleSelectionInFlatTree& selection = CalcSelection(frame_selection);
- if (!selection.IsRange() || frame_selection.IsHidden())
+ const EphemeralRangeInFlatTree& selection = CalcSelection(frame_selection);
+ if (selection.IsCollapsed() || 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.StartPosition();
+ const PositionInFlatTree end_pos = selection.EndPosition();
DCHECK_LE(start_pos, end_pos);
LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject();
LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject();
« 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