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

Unified Diff: third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp

Issue 2437873008: Get rid of flat tree version of createVisibleSelection() taking two VisiblePosition (Closed)
Patch Set: 2016-10-21T16:03:11 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
Index: third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp
index 510ebf148c61bfe1822878fee1f804fbcb9e94c5..afdca95f68092be0c0a13970b2e2828554094efd 100644
--- a/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp
@@ -77,10 +77,16 @@ void ApplyBlockElementCommand::doApply(EditingState* editingState) {
// consistent and then use a left margin/padding rule here.
if (visibleEnd.deepEquivalent() != visibleStart.deepEquivalent() &&
isStartOfParagraph(visibleEnd)) {
- VisibleSelection newSelection = createVisibleSelection(
- visibleStart,
- previousPositionOf(visibleEnd, CannotCrossEditingBoundary),
- endingSelection().isDirectional());
+ const Position& newEnd =
+ previousPositionOf(visibleEnd, CannotCrossEditingBoundary)
+ .deepEquivalent();
+ SelectionInDOMTree::Builder builder;
+ builder.collapse(visibleStart.deepEquivalent());
Xiaocheng 2016/10/21 11:18:36 builder.collapse(visibleStart.positionWithAffinity
yosin_UTC9 2016/10/24 06:19:44 Done
+ if (newEnd.isNotNull())
+ builder.extend(newEnd);
+ builder.setIsDirectional(endingSelection().isDirectional());
+ const VisibleSelection newSelection =
+ createVisibleSelection(builder.build());
if (newSelection.isNone())
return;
setEndingSelection(newSelection);
@@ -109,9 +115,14 @@ void ApplyBlockElementCommand::doApply(EditingState* editingState) {
if (startScope == endScope && startIndex >= 0 && startIndex <= endIndex) {
VisiblePosition start(visiblePositionForIndex(startIndex, startScope));
VisiblePosition end(visiblePositionForIndex(endIndex, endScope));
- if (start.isNotNull() && end.isNotNull())
+ if (start.isNotNull() && end.isNotNull()) {
setEndingSelection(createVisibleSelection(
- start, end, endingSelection().isDirectional()));
+ SelectionInDOMTree::Builder()
+ .collapse(start.deepEquivalent())
Xiaocheng 2016/10/21 11:18:36 builder.collapse(start.positionWithAffinity())?
yosin_UTC9 2016/10/24 06:19:44 Done
+ .extend(end.deepEquivalent())
+ .setIsDirectional(endingSelection().isDirectional())
+ .build()));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698