Commit 140477cf authored by Anupam Snigdha's avatar Anupam Snigdha Committed by Commit Bot

Fix indenting textarea/input elements wrapped inside inline

This fix is a follow-up from a previous fix that changed the way we
split the elements wrapped inside inline elements during indenting of
more than one paragraphs. In this fix we also include elements such
as textarea/input elements which are not inline/block level elements.
This was found as a result of a clusterfuzz bug and I've included
tests to check these cases.

Test: web_tests/editing/execCommand/indent/indent_blockquote_with_inline_nested_paragraphs.html

Bug: 1148859
Change-Id: I17b306a684fad185f60a433ab4d264a961ffb11d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538532
Auto-Submit: Anupam Snigdha <snianu@microsoft.com>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827699}
parent 3803e6f0
......@@ -192,11 +192,18 @@ void IndentOutdentCommand::IndentIntoBlockquote(const Position& start,
// </div> </blockquote>
// <div><span><div>Line
// 2</div></span></div>
//
// <div>Line <blockquote>
// <span> 1<br>Line 2</span> -> Line<span> 1</span>
// </div> </blockquote>
// <div><span>Line
// 2</span></div>
// The below steps are essentially trying to figure out where the split
// needs to happen:
// 1. If the next paragraph is enclosed with nested block level elements.
// 2. If the next paragraph is enclosed with nested inline elements.
// 3. If the next paragraph doesn't have any inline or block level
// elements, but has elements like textarea/input/img etc.
Node* split_point = HighestEnclosingNodeOfType(
next_position, IsEnclosingBlock, kCannotCrossEditingBoundary,
highest_inline_node);
......@@ -205,6 +212,7 @@ void IndentOutdentCommand::IndentIntoBlockquote(const Position& start,
: HighestEnclosingNodeOfType(next_position, IsInline,
kCannotCrossEditingBoundary,
highest_inline_node);
split_point = split_point ? split_point : next_position.AnchorNode();
// Split the element to separate the paragraphs.
SplitElement(DynamicTo<Element>(highest_inline_node), split_point);
}
......
......@@ -84,4 +84,52 @@ selection_test(
],
'Indent content enclosed inside inline separated by br and inline elements');
selection_test(
[
'<div contenteditable>',
'<div>Line|<span> 1<br/><input value="text"></span></div>',
'</div>',
],
'indent',
[
'<div contenteditable>',
'<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">',
'<div>Line|<span> 1<br></span></div></blockquote><div><span>',
'<input value="text"></span></div>',
'</div>',
],
'Indent content enclosed inside inline separated by br and input element');
selection_test(
[
'<div contenteditable>',
'<div>Line|<span> 1<br/><textarea></textarea></span></div>',
'</div>',
],
'indent',
[
'<div contenteditable>',
'<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">',
'<div>Line|<span> 1<br></span></div></blockquote><div><span>',
'<textarea></textarea></span></div>',
'</div>',
],
'Indent content enclosed inside inline separated by br and textarea element');
selection_test(
[
'<div contenteditable>',
'<div>Line|<span> 1<br/><i><textarea></textarea></i></span></div>',
'</div>',
],
'indent',
[
'<div contenteditable>',
'<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">',
'<div>Line|<span> 1<br></span></div></blockquote><div><span>',
'<i><textarea></textarea></i></span></div>',
'</div>',
],
'Indent content enclosed inside inline separated by br and textarea element wrapped inside inline');
</script>
\ No newline at end of file
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