Commit a87e2853 authored by yosin@chromium.org's avatar yosin@chromium.org

Make sure calling moveParagaph() with proper parameters in...

Make sure calling moveParagaph() with proper parameters in CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary()

This patch changes CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary()
to calculate start and end positions of paragraph to move before calling
moveParagraph(), because inserting paragraph element at |upstream| can change
start and end positions represented by |VisiblePosition|.

This patch is similar to http://crrev.com/311593003, for
InsertListCommand::listifyParagraph().

BUG=325222, 351291
TEST=LayoutTests/editing/execCommand/apply-style-empty-paragraph-start-crash.html

Review URL: https://codereview.chromium.org/315513003

git-svn-id: svn://svn.chromium.org/blink/trunk@175523 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 131c6b2d
<!DOCTYPE html>
<head>
<script>
if (window.testRunner)
testRunner.dumpAsText();
onload = function() {
document.execCommand('SelectAll');
document.execCommand('JustifyCenter');
document.documentElement.textContent = 'PASS if Blink doesn\'t crash.';
}
</script>
</head>
<body contenteditable="true">
<canvas contenteditable="false">text</canvas><b></b>
<textarea></textarea>
</body>
</html>
...@@ -950,6 +950,11 @@ PassRefPtrWillBeRawPtr<Node> CompositeEditCommand::moveParagraphContentsToNewBlo ...@@ -950,6 +950,11 @@ PassRefPtrWillBeRawPtr<Node> CompositeEditCommand::moveParagraphContentsToNewBlo
bool endWasBr = isHTMLBRElement(*visibleParagraphEnd.deepEquivalent().deprecatedNode()); bool endWasBr = isHTMLBRElement(*visibleParagraphEnd.deepEquivalent().deprecatedNode());
// Inserting default paragraph element can change visible position. We
// should update visible positions before use them.
visiblePos = VisiblePosition(pos, VP_DEFAULT_AFFINITY);
visibleParagraphStart = VisiblePosition(startOfParagraph(visiblePos));
visibleParagraphEnd = VisiblePosition(endOfParagraph(visiblePos));
moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(firstPositionInNode(newBlock.get()))); moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(firstPositionInNode(newBlock.get())));
if (newBlock->lastChild() && isHTMLBRElement(*newBlock->lastChild()) && !endWasBr) if (newBlock->lastChild() && isHTMLBRElement(*newBlock->lastChild()) && !endWasBr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment