Commit a7c6520a authored by yoichio@chromium.org's avatar yoichio@chromium.org

[Editing] Make InsertListCommand check endingSelection() editability.

doApply assumes |endingSelection()| has rootEditableElement as L114 checks.
However, reseting |endingSelection()| through |endOfSelection| at L171 can 
invalidate the assumption.
This CL let it return early if it does.
We should fix the reseting |endingSelection| algorithm in long term but let me fix 
the stable blocker crash.

BUG=515490
TEST=LayoutTests/editing/execCommand/insert-ordered-list-crash2.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@200709 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 18305370
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div id="log"></div>
<div contenteditable="true" id="div"><ol>
<li>AAA<br><br></li>
<li><br></li>
<li>BBB<br>CCC</li>
</ol></div>
<div>DDD</div>
<script>
test(function () {
getSelection().selectAllChildren(div);
document.execCommand("insertOrderedList");
});
</script>
</body>
</html>
\ No newline at end of file
...@@ -172,7 +172,7 @@ void InsertListCommand::doApply() ...@@ -172,7 +172,7 @@ void InsertListCommand::doApply()
// If endOfSelection is null, then some contents have been deleted from the document. // If endOfSelection is null, then some contents have been deleted from the document.
// This should never happen and if it did, exit early immediately because we've lost the loop invariant. // This should never happen and if it did, exit early immediately because we've lost the loop invariant.
ASSERT(endOfSelection.isNotNull()); ASSERT(endOfSelection.isNotNull());
if (endOfSelection.isNull()) if (endOfSelection.isNull() || !endOfSelection.rootEditableElement())
return; return;
startOfLastParagraph = startOfParagraph(endOfSelection, CanSkipOverEditingBoundary); startOfLastParagraph = startOfParagraph(endOfSelection, CanSkipOverEditingBoundary);
} }
......
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