Commit b844ddd6 authored by joone.hur's avatar joone.hur Committed by Commit bot

Remove the unnecessary blockquote after indenting an empty blockquote

Here is a DOM state when we only add a blockquote.
<div contenteditable><blockquote>|<br></blockquote></div>

After indenting the blockquote, the change is as follows:
<div contenteditable>
  <blockquote>
    <blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
      <blockquote>|<br></blockquote>
    </blockquote>
  </blockquote>
</div>

There is an unnecessary blockquote so the result should be as follows:

<div contenteditable>
  <blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
    <blockquote>|<br></blockquote>
  </blockquote>
</div>

This CL removes the additional blockquote.

BUG=625802
TEST=editing/execCommand/indent-empty-quote.html

Review-Url: https://codereview.chromium.org/2175433002
Cr-Commit-Position: refs/heads/master@{#407091}
parent 37314fa3
<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<div id="log"></div>
<script>
test(() => {
assert_selection(
'<div contenteditable><blockquote>|<br></blockquote></div>',
'indent',
'<div contenteditable><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote>|<br></blockquote></blockquote></div>');
}, 'indent empty <blockquote>');
test(() => {
assert_selection(
'<div contenteditable><blockquote>1|</blockquote></div>',
'indent',
'<div contenteditable><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote>1|</blockquote></blockquote></div>');
}, 'indent <blockquote> with text');
</script>
......@@ -136,9 +136,14 @@ void IndentOutdentCommand::indentIntoBlockquote(const Position& start, const Pos
// Create a new blockquote and insert it as a child of the root editable element. We accomplish
// this by splitting all parents of the current paragraph up to that point.
targetBlockquote = createBlockElement();
if (outerBlock == start.computeContainerNode())
insertNodeAt(targetBlockquote, start, editingState);
else
if (outerBlock == start.computeContainerNode()) {
// When we apply indent to an empty <blockquote>, we should call insertNodeAfter().
// See http://crbug.com/625802 for more details.
if (outerBlock->hasTagName(blockquoteTag))
insertNodeAfter(targetBlockquote, outerBlock, editingState);
else
insertNodeAt(targetBlockquote, start, editingState);
} else
insertNodeBefore(targetBlockquote, outerBlock, editingState);
if (editingState->isAborted())
return;
......
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