Chromium Code Reviews| 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())); |
| + } |
| } |
| } |