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

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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/events/scoped/editing-commands.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..03c2cc1609799e9d0a6400cb4192047c94667df1 100644
--- a/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp
@@ -74,10 +74,22 @@ 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);
+ 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 +115,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;
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/events/scoped/editing-commands.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698