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

Don't call moveParagraph() with null |VisiblePositon|

This patch changes |IndentOutdentCommand::outdentParagraph()| not to call
|CompositeEditCommand::movePargrap()| with null |VisiblePositon|.

This situation can be happened in attached test case, where
|visibleStartOfParagraph| and |visibleEndOfPargraph| are second TABLE element.
Both |startOfParagraph()| and |endOfParagraph()| return null |VisiblePositon|
for them.

BUG=379058
TEST=editing/execCommand/outdent-collapse-table-crash-2.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@175258 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8b50813c
<!DOCTYPE html>
<html>
<head>
<style>
* {
visibility: visible;
}
*:only-of-type {
visibility: collapse;
}
</style>
<script>
if (window.testRunner)
testRunner.dumpAsText();
onload = function() {
document.designMode = 'on';
var blockQuote = document.querySelector('blockquote');
getSelection().collapse(blockQuote, 2);
document.execCommand('Outdent');
document.documentElement.textContent = 'PASS if Blink doesn\'t crash.';
};
</script>
</head>
<body>
<blockquote>
<table><tr><td>foo</td></tr></table>
<table><tr><td>bar</td></tr></table>
</blockquote>
</body>
</html>
......@@ -186,9 +186,13 @@ void IndentOutdentCommand::outdentParagraph()
splitElement(toElement(enclosingNode), (highestInlineNode) ? highestInlineNode : visibleStartOfParagraph.deepEquivalent().deprecatedNode());
}
}
VisiblePosition startOfParagraphToMove(startOfParagraph(visibleStartOfParagraph));
VisiblePosition endOfParagraphToMove(endOfParagraph(visibleEndOfParagraph));
if (startOfParagraphToMove.isNull() || endOfParagraphToMove.isNull())
return;
RefPtrWillBeRawPtr<Node> placeholder = createBreakElement(document());
insertNodeBefore(placeholder, splitBlockquoteNode);
moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visibleEndOfParagraph), VisiblePosition(positionBeforeNode(placeholder.get())), true);
moveParagraph(startOfParagraphToMove, endOfParagraphToMove, VisiblePosition(positionBeforeNode(placeholder.get())), true);
}
// FIXME: We should merge this function with ApplyBlockElementCommand::formatSelection
......
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