Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
-webkit-line-break: after-white-space sometimes truncates DOM on copy…
… & paste https://bugs.webkit.org/show_bug.cgi?id=118164 Reviewed by Sam Weinig. Source/WebCore: We can't assume that all subsequent ancestors contain exactly one child since they could have been added in the first if statement matching: currentNode->parentNode() != rootNode && isRemovableBlock(currentNode) Exit early when we encounter such an ancestor since removing its ancestor (that contains multiple children some of which aren't in nodesToRemove) can clobber more nodes than we're allowed to remove. Test: editing/pasteboard/simplfiying-markup-should-not-strip-content.html * editing/SimplifyMarkupCommand.cpp: (WebCore::SimplifyMarkupCommand::doApply): (WebCore::SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove): LayoutTests: Add a regression test. * editing/pasteboard/simplfiying-markup-should-not-strip-content-expected.txt: Added. * editing/pasteboard/simplfiying-markup-should-not-strip-content.html: Added. Canonical link: https://commits.webkit.org/136239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
5 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
LayoutTests/editing/pasteboard/simplfiying-markup-should-not-strip-content-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
This tests copying and pasting doesn't strip content. | ||
To manually test, copy the content in the first box and paste it into the second box. | ||
|
||
Original content: | ||
| " | ||
" | ||
| <font> | ||
| face="Verdana" | ||
| "hello " | ||
| <br> | ||
| " | ||
" | ||
| <font> | ||
| face="Verdana" | ||
| <div> | ||
| style="-webkit-line-break: after-white-space;" | ||
| <div> | ||
| <font> | ||
| face="Verdana" | ||
| "world" | ||
| " | ||
" | ||
| <div> | ||
| style="-webkit-line-break: after-white-space; " | ||
| <font> | ||
| face="Verdana" | ||
| "WebKit" | ||
| " | ||
" | ||
|
||
Pasted content: | ||
| <font> | ||
| face="Verdana" | ||
| "hello " | ||
| <br> | ||
| style="font-family: Helvetica;" | ||
| <font> | ||
| face="Verdana" | ||
| "worldWebKit<#selection-caret>" |
30 changes: 30 additions & 0 deletions
30
LayoutTests/editing/pasteboard/simplfiying-markup-should-not-strip-content.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body style="font-family: Helvetica"> | ||
<p id="description">This tests copying and pasting doesn't strip content. | ||
To manually test, copy the content in the first box and paste it into the second box.</p> | ||
<div id="source" contenteditable style="border: solid 1px; black; margin: 5px;"> | ||
<font face="Verdana">hello </font><br> | ||
<font face="Verdana"><div style="-webkit-line-break: after-white-space;"><div><font face="Verdana">world</font></div> | ||
<div style="-webkit-line-break: after-white-space; "><font face="Verdana">WebKit</font></div></div> | ||
</div> | ||
<div id="destination" contenteditable style="border: solid 1px black; margin: 5px;"><br></div> | ||
<script src="../../resources/dump-as-markup.js"></script> | ||
<script> | ||
|
||
Markup.description(document.getElementById('description').textContent); | ||
|
||
document.getElementById('source').focus(); | ||
document.execCommand('selectall', false, null); | ||
document.execCommand('copy', false, null); | ||
if (document.queryCommandEnabled('paste')) { | ||
document.getElementById('destination').focus(); | ||
document.execCommand('paste', false, null); | ||
|
||
Markup.dump('source', 'Original content'); | ||
Markup.dump('destination', 'Pasted content'); | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters