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

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

Issue 2425623002: Get rid of flat tree version of createVisibleSelection() taking two VisiblePositionInFlatTree (Closed)
Patch Set: 2016-10-20T13:19:29 Created 4 years, 2 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 | third_party/WebKit/Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/PendingSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/PendingSelection.cpp b/third_party/WebKit/Source/core/editing/PendingSelection.cpp
index 8641bbf17d9d2a1de8da12a627b38c934c5c2924..ef9c19d4fc1956f88d23614d4b3483d8c35f8c38 100644
--- a/third_party/WebKit/Source/core/editing/PendingSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/PendingSelection.cpp
@@ -82,17 +82,28 @@ VisibleSelectionInFlatTree PendingSelection::calcVisibleSelection(
start, selectionType == SelectionType::RangeSelection
? TextAffinity::Downstream
: affinity);
+ if (visibleStart.isNull())
+ return VisibleSelectionInFlatTree();
if (paintBlockCursor) {
- VisiblePositionInFlatTree visibleExtent =
- createVisiblePosition(end, affinity);
- visibleExtent = nextPositionOf(visibleExtent, CanSkipOverEditingBoundary);
- return createVisibleSelection(visibleStart, visibleExtent);
+ const VisiblePositionInFlatTree visibleExtent = nextPositionOf(
+ createVisiblePosition(end, affinity), CanSkipOverEditingBoundary);
+ if (visibleExtent.isNull())
+ return VisibleSelectionInFlatTree();
+ SelectionInFlatTree::Builder builder;
+ builder.collapse(visibleStart.toPositionWithAffinity());
+ builder.extend(visibleExtent.deepEquivalent());
+ return createVisibleSelection(builder.build());
}
const VisiblePositionInFlatTree visibleEnd =
createVisiblePosition(end, selectionType == SelectionType::RangeSelection
? TextAffinity::Upstream
: affinity);
- return createVisibleSelection(visibleStart, visibleEnd);
+ if (visibleEnd.isNull())
+ return VisibleSelectionInFlatTree();
+ SelectionInFlatTree::Builder builder;
+ builder.collapse(visibleStart.toPositionWithAffinity());
+ builder.extend(visibleEnd.deepEquivalent());
+ return createVisibleSelection(builder.build());
}
void PendingSelection::commit(LayoutView& layoutView) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698