--- /dev/null
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+ RenderView 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 784x36
+ RenderText {#text} at (0,0) size 769x36
+ text run at (0,0) width 660: "This tests for a bug when creating markup for a selection that contained unrendered nodes with children. "
+ text run at (660,0) width 109: "You should see a"
+ text run at (0,18) width 248: "picture of abe followed by a select box."
+ RenderBlock {P} at (0,52) size 784x18
+ RenderInline {B} at (0,0) size 639x18
+ RenderText {#text} at (0,0) size 195x18
+ text run at (0,0) width 195: "This currently demonstrates "
+ RenderInline {A} at (0,0) size 56x18 [color=#0000EE]
+ RenderText {#text} at (195,0) size 56x18
+ text run at (195,0) width 56: "4641033"
+ RenderText {#text} at (251,0) size 384x18
+ text run at (251,0) width 384: " Copy/paste of a select element fails to include the options"
+ RenderText {#text} at (635,0) size 4x18
+ text run at (635,0) width 4: "."
+ RenderBlock {DIV} at (0,86) size 784x128
+ RenderBlock (anonymous) at (0,0) size 784x110
+ RenderImage {IMG} at (0,0) size 76x103
+ RenderText {#text} at (76,89) size 4x18
+ text run at (76,89) width 4: " "
+ RenderMenuList {SELECT} at (82,90) size 36x18
+ RenderBlock {DIV} at (0,110) size 784x18
+ RenderBR {BR} at (0,0) size 0x18
+ RenderBlock (anonymous) at (0,214) size 784x110
+ RenderImage {IMG} at (0,0) size 76x103
+ RenderText {#text} at (76,89) size 4x18
+ text run at (76,89) width 4: " "
+ RenderMenuList {SELECT} at (82,90) size 52x18
+ RenderBlock (anonymous) at (8,2) size 21x13
+ RenderText at (0,0) size 19x13
+ text run at (0,0) width 19: " 1"
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+caret: position 0 of child 0 {BR} of child 3 {DIV} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
--- /dev/null
+<p>This tests for a bug when creating markup for a selection that contained unrendered nodes with children. You should see a picture of abe followed by a select box.</p>
+<p><b>This currently demonstrates <a href="rdar://problem/4641033">4641033</a> Copy/paste of a select element fails to include the options</a>.</b></p>
+<div id="paste" contenteditable="true"></div>
+
+<img id="start" src="../resources/abe.jpg">
+<select id="end"><optgroup><option>1</option><option>2</option><option>3</option></optgroup></select>
+</select>
+<script>
+function runTest() {
+ var start = document.getElementById("start");
+ var end = document.getElementById("end");
+
+ var s = window.getSelection();
+ s.setBaseAndExtent(start, 0, end, end.childNodes.length);
+
+ document.execCommand("Copy");
+
+ s.setPosition(document.getElementById("paste"), 0);
+ document.execCommand("Paste");
+
+ if (window.layoutTestController)
+ window.layoutTestController.notifyDone();
+
+}
+if (window.layoutTestController)
+ window.layoutTestController.waitUntilDone();
+window.setTimeout(runTest, 100);
+
+</script>
\ No newline at end of file
+2006-07-20 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by john
+
+ <rdar://problem/4641033>
+ REGRESSION: Pasting from web pages into Mail (or Blot) often loses most of the content
+
+ * editing/markup.cpp:
+ (WebCore::createMarkup): We surround the currently accumulated markup with markup
+ for ancestors of the startNode when the pre-order traversal leaves the trees rooted
+ at those ancestors. We assumed that any ancestors of the current node not in the
+ ancestorsToClose list were those kind of ancestors. But we don't add renderer-less
+ containers to the ancestorsToClose list. So, we were incorrectly surrounding the
+ currently accumulated markup with markup for render-less containers. Most of the
+ content at apple.com was being put inside an <optgroup> inside a <select> element.
+ Then on Paste createContextualFragment would drop it.
+
2006-07-21 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
continue;
// Add the node to the markup.
+ // FIXME: Add markup for nodes without renderers to fix <rdar://problem/4062865>. Also see the three checks below.
if (n->renderer()) {
markups.append(startMarkup(n, range, annotate, defaultStyle.get()));
if (nodes)
if (!ancestorsToClose.isEmpty()) {
// Close up the ancestors.
while (Node *ancestor = ancestorsToClose.last()) {
- if (next != pastEnd && ancestor == next->parentNode())
+ if (next != pastEnd && next->isAncestor(ancestor))
break;
// Not at the end of the range, close ancestors up to sibling of next node.
markups.append(endMarkup(ancestor));
ancestorsToClose.removeLast();
}
} else {
- // No ancestors to close, but need to add ancestors not in range since next node is in another tree.
if (next != pastEnd) {
Node *nextParent = next->parentNode();
if (n != nextParent) {
for (Node *parent = n->parent(); parent != 0 && parent != nextParent; parent = parent->parentNode()) {
+ // All ancestors not in the ancestorsToClose list should either be a) unrendered:
+ if (!parent->renderer())
+ continue;
+ // or b) ancestors that we never encountered during a pre-order traversal starting at startNode:
+ ASSERT(startNode->isAncestor(parent));
markups.prepend(startMarkup(parent, range, annotate, defaultStyle.get()));
markups.append(endMarkup(parent));
if (nodes)