Commit 28d0c7a7 authored by yosin@chromium.org's avatar yosin@chromium.org

Don't move uneditable paragraph contents in...

Don't move uneditable paragraph contents in CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary

This patch makes CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary
not to move uneditable paragraph contents.

In attached test case, Blink tried to move contents in uneditable ABBR element.

BUG=381076, 383811
TEST=LayoutTests/editing/execCommand/justy-center-with-uneditable-crash.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176172 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c9fcd518
<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner)
testRunner.dumpAsText();
onload = function() {
document.execCommand('SelectAll');
document.execCommand('JustifyCenter');
document.body.textContent = 'PASS if Blink doesn\'t crash.';
};
</script>
</head>
<body contenteditable="true">
<kbd>foo</kbd>
<sup>bar<abbr contenteditable="false">baz</abbr></sup>
</body>
</html>
...@@ -269,8 +269,9 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style) ...@@ -269,8 +269,9 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style)
StyleChange styleChange(style, paragraphStart.deepEquivalent()); StyleChange styleChange(style, paragraphStart.deepEquivalent());
if (styleChange.cssStyle().length() || m_removeOnly) { if (styleChange.cssStyle().length() || m_removeOnly) {
RefPtrWillBeRawPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent().deprecatedNode()); RefPtrWillBeRawPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent().deprecatedNode());
if (!m_removeOnly) { const Position& paragraphStartToMove = paragraphStart.deepEquivalent();
RefPtrWillBeRawPtr<Element> newBlock = moveParagraphContentsToNewBlockIfNecessary(paragraphStart.deepEquivalent()); if (!m_removeOnly && isEditablePosition(paragraphStartToMove)) {
RefPtrWillBeRawPtr<Element> newBlock = moveParagraphContentsToNewBlockIfNecessary(paragraphStartToMove);
if (newBlock) if (newBlock)
block = newBlock; block = newBlock;
} }
......
...@@ -897,10 +897,7 @@ PassRefPtrWillBeRawPtr<Element> CompositeEditCommand::insertNewDefaultParagraphE ...@@ -897,10 +897,7 @@ PassRefPtrWillBeRawPtr<Element> CompositeEditCommand::insertNewDefaultParagraphE
// it, and return that block. Otherwise return 0. // it, and return that block. Otherwise return 0.
PassRefPtrWillBeRawPtr<Element> CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Position& pos) PassRefPtrWillBeRawPtr<Element> CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Position& pos)
{ {
if (pos.isNull()) ASSERT(isEditablePosition(pos, ContentIsEditable, DoNotUpdateStyle));
return nullptr;
document().updateLayoutIgnorePendingStylesheets();
// It's strange that this function is responsible for verifying that pos has not been invalidated // It's strange that this function is responsible for verifying that pos has not been invalidated
// by an earlier call to this function. The caller, applyBlockStyle, should do this. // by an earlier call to this function. The caller, applyBlockStyle, should do this.
......
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