Fix for these two bugs:
<rdar://problem/
3938935> REGRESSION (Mail): Pasting into an empty document mangles content
<rdar://problem/
3939148> REGRESSION (Mail): Pasting mistakenly reverses lines
* khtml/editing/htmlediting.cpp:
(khtml::ReplaceSelectionCommand::doApply): For
3938935, add one more case to handle an empty document; merge
neither start nor end. For
3939148, improve the code which adjusts the insertion point during
the process of pasting. It formerly handled only one of the possible cases.
* layout-tests/editing/pasteboard/paste-text-015-expected.txt: Added.
* layout-tests/editing/pasteboard/paste-text-015.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8296
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {TEXT} at (0,0) size 21x18
+ text run at (0,0) width 21: "foo"
+ RenderBlock {P} at (0,18) size 784x18
+ RenderText {TEXT} at (0,0) size 20x18
+ text run at (0,0) width 20: "bar"
+ RenderBlock {P} at (0,36) size 784x18
+ RenderText {TEXT} at (0,0) size 21x18
+ text run at (0,0) width 21: "foo"
+ RenderBlock {P} at (0,54) size 784x18
+ RenderText {TEXT} at (0,0) size 20x18
+ text run at (0,0) width 20: "bar"
+selection is CARET:
+start: position 3 of child 1 {TEXT} of child 4 {P} of child 2 {BODY} of child 1 {HTML} of root {}
+upstream: position 3 of child 1 {TEXT} of child 4 {P} of child 2 {BODY} of child 1 {HTML} of root {}
+downstream: position 3 of child 1 {TEXT} of child 4 {P} of child 2 {BODY} of child 1 {HTML} of root {}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+ font-size: 24px;
+}
+p {
+ margin: 0;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ for (i = 0; i < 7; i++)
+ extendSelectionForwardByCharacterCommand();
+ copyCommand();
+ selectAllCommand();
+ deleteCommand();
+ pasteCommand();
+ insertParagraphCommand();
+ pasteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body contenteditable>
+<div id="root">
+<div id="test" class="editing"><p>foo</p><p>bar</p></div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
+2005-01-04 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by John
+
+ Fix for these two bugs:
+
+ <rdar://problem/3938935> REGRESSION (Mail): Pasting into an empty document mangles content
+ <rdar://problem/3939148> REGRESSION (Mail): Pasting mistakenly reverses lines
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::ReplaceSelectionCommand::doApply): For 3938935, add one more case to handle an empty document; merge
+ neither start nor end. For 3939148, improve the code which adjusts the insertion point during
+ the process of pasting. It formerly handled only one of the possible cases.
+ * layout-tests/editing/pasteboard/paste-text-015-expected.txt: Added.
+ * layout-tests/editing/pasteboard/paste-text-015.html: Added.
+
2005-01-04 David Hyatt <hyatt@apple.com>
Fix for 3936571, placeholder attribute should work for normal inputs for Dashboard.
bool startAtBlockBoundary = startAtStartOfBlock || startAtEndOfBlock;
NodeImpl *startBlock = selection.start().node()->enclosingBlockFlowElement();
NodeImpl *endBlock = selection.end().node()->enclosingBlockFlowElement();
-
bool mergeStart = false;
bool mergeEnd = false;
- if (startBlock == endBlock && startAtStartOfBlock && startAtEndOfBlock) {
+ if (startBlock == startBlock->rootEditableElement() && startAtStartOfBlock && startAtEndOfBlock) {
+ // Empty document. Merge neither start nor end.
+ mergeStart = mergeEnd = false;
+ }
+ else if (startBlock == endBlock && startAtStartOfBlock && startAtEndOfBlock) {
// Merge start only if insertion point is in an empty block.
mergeStart = true;
}
node = next;
}
}
- if (insertionNode)
- insertionPos = Position(insertionNode, insertionNode->caretMaxOffset());
+ if (insertionNode) {
+ if (insertionNode->isTextNode())
+ insertionPos = Position(insertionNode, insertionNode->caretMaxOffset());
+ else if (insertionNode->childNodeCount() > 0)
+ insertionPos = Position(insertionNode, insertionNode->childNodeCount());
+ else
+ insertionPos = Position(insertionNode->parentNode(), insertionNode->nodeIndex() + 1);
+ }
insertBlocksBefore = false;
}