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

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

Issue 1305963003: Introduce {next,previous}PositionOf() as replacement of {next,previous}() member functions in Positi (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-22T00:12:04 Rebase Created 5 years, 4 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 | « Source/core/editing/PositionTest.cpp ('k') | Source/core/editing/commands/BreakBlockquoteCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/commands/ApplyBlockElementCommand.cpp
diff --git a/Source/core/editing/commands/ApplyBlockElementCommand.cpp b/Source/core/editing/commands/ApplyBlockElementCommand.cpp
index fa4facd3c7b20e1fd22b0aa415450551ee1ce2bc..f5f006b6606ef06abfcf7e0c40d3c9ffc00a8b34 100644
--- a/Source/core/editing/commands/ApplyBlockElementCommand.cpp
+++ b/Source/core/editing/commands/ApplyBlockElementCommand.cpp
@@ -193,8 +193,10 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
bool isStartAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingTextNode(m_endOfLastParagraph) && start.computeContainerNode() == m_endOfLastParagraph.computeContainerNode();
// Avoid obtanining the start of next paragraph for start
- if (startStyle->preserveNewline() && isNewLineAtPosition(start) && !isNewLineAtPosition(start.previous()) && start.offsetInContainerNode() > 0)
- start = startOfParagraph(VisiblePosition(end.previous())).deepEquivalent();
+ // TODO(yosin) We should use |PositionMoveType::Character| for
+ // |previousPositionOf()|.
+ if (startStyle->preserveNewline() && isNewLineAtPosition(start) && !isNewLineAtPosition(previousPositionOf(start, PositionMoveType::CodePoint)) && start.offsetInContainerNode() > 0)
+ start = startOfParagraph(VisiblePosition(previousPositionOf(end, PositionMoveType::CodePoint))).deepEquivalent();
// If start is in the middle of a text node, split.
if (!startStyle->collapseWhiteSpace() && start.offsetInContainerNode() > 0) {
@@ -220,7 +222,9 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
// Include \n at the end of line if we're at an empty paragraph
if (endStyle->preserveNewline() && start == end && end.offsetInContainerNode() < end.computeContainerNode()->maxCharacterOffset()) {
int endOffset = end.offsetInContainerNode();
- if (!isNewLineAtPosition(end.previous()) && isNewLineAtPosition(end))
+ // TODO(yosin) We should use |PositionMoveType::Character| for
+ // |previousPositionOf()|.
+ if (!isNewLineAtPosition(previousPositionOf(end, PositionMoveType::CodePoint)) && isNewLineAtPosition(end))
end = Position(end.computeContainerNode(), endOffset + 1);
if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNode() >= m_endOfLastParagraph.offsetInContainerNode())
m_endOfLastParagraph = end;
« no previous file with comments | « Source/core/editing/PositionTest.cpp ('k') | Source/core/editing/commands/BreakBlockquoteCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698