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

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

Issue 2750533007: Let insertNewLineInQuotedContent not do anything out of a quote element (Closed)
Patch Set: update Created 3 years, 9 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/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..84921b3d857cc05973f8230d6c86ba36d812382c 100644
--- a/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp
@@ -74,10 +74,24 @@ bool isLastVisiblePositionInNode(const VisiblePosition& visiblePosition,
BreakBlockquoteCommand::BreakBlockquoteCommand(Document& document)
: CompositeEditCommand(document) {}
+static HTMLQuoteElement* topBlockquoteOf(const VisibleSelection& selection) {
yosin_UTC9 2017/03/17 09:27:02 Please use |Position| as parameter to reduce usage
yoichio 2017/03/21 03:48:07 Done.
+ // pos is a position equivalent to the caret. We use downstream() so that pos
yosin_UTC9 2017/03/17 09:27:02 nit: s/pos/|pos|/ nit: s/downstream()/|downstream(
yoichio 2017/03/21 03:48:07 Done.
+ // will be in the first node that we need to move (there are a few exceptions
+ // to this, see below).
+ const Position pos = mostForwardCaretPosition(selection.start());
yosin_UTC9 2017/03/17 09:27:02 nit: s/pos/position/ Blink doesn't want to use abb
yoichio 2017/03/21 03:48:07 Done.
+
+ // Find the top-most blockquote from the start.
yosin_UTC9 2017/03/17 09:27:02 not need to have a comment. The statement explains
yoichio 2017/03/21 03:48:07 Done.
+ return toHTMLQuoteElement(
+ highestEnclosingNodeOfType(pos, isMailHTMLBlockquoteElement));
+}
+
void BreakBlockquoteCommand::doApply(EditingState* editingState) {
if (endingSelection().isNone())
return;
+ if (!topBlockquoteOf(endingSelection()))
+ return;
+
// Delete the current selection.
if (endingSelection().isRange()) {
deleteSelection(editingState, false, false);
@@ -103,8 +117,7 @@ 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());
yosin_UTC9 2017/03/17 09:27:02 Can we use result of |topBlockquoteOf()| at L92 he
yoichio 2017/03/21 03:48:07 No, deletingSelection on L97 changes the result.
if (!topBlockquote || !topBlockquote->parentNode())
return;

Powered by Google App Engine
This is Rietveld 408576698