Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp b/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp |
| index 87ba90484b225a313831e906072c805447cdb446..63ae92f952b78f1f00f107de5a1086e571c9baed 100644 |
| --- a/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp |
| +++ b/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp |
| @@ -74,10 +74,23 @@ bool isLastVisiblePositionInNode(const VisiblePosition& visiblePosition, |
| BreakBlockquoteCommand::BreakBlockquoteCommand(Document& document) |
| : CompositeEditCommand(document) {} |
| +static HTMLQuoteElement* topBlockquoteOf(const Position& start) { |
| + // This is a position equivalent to the caret. We use |downstream()| so that |
| + // |position| will be in the first node that we need to move (there are a few |
| + // exceptions to this, see |doApply|). |
| + const Position& position = mostForwardCaretPosition(start); |
| + |
|
yosin_UTC9
2017/03/21 05:30:44
nit: We don't need to have an extra blank line her
|
| + return toHTMLQuoteElement( |
| + highestEnclosingNodeOfType(position, isMailHTMLBlockquoteElement)); |
| +} |
| + |
| void BreakBlockquoteCommand::doApply(EditingState* editingState) { |
| if (endingSelection().isNone()) |
| return; |
| + if (!topBlockquoteOf(endingSelection().start())) |
| + return; |
| + |
| // Delete the current selection. |
| if (endingSelection().isRange()) { |
| deleteSelection(editingState, false, false); |
| @@ -103,8 +116,8 @@ void BreakBlockquoteCommand::doApply(EditingState* editingState) { |
| Position pos = mostForwardCaretPosition(endingSelection().start()); |
| // Find the top-most blockquote from the start. |
| - HTMLQuoteElement* topBlockquote = toHTMLQuoteElement( |
| - highestEnclosingNodeOfType(pos, isMailHTMLBlockquoteElement)); |
| + HTMLQuoteElement* const topBlockquote = |
| + topBlockquoteOf(endingSelection().start()); |
| if (!topBlockquote || !topBlockquote->parentNode()) |
| return; |