Title: [169192] releases/WebKitGTK/webkit-2.4
Revision
169192
Author
[email protected]
Date
2014-05-22 02:52:35 -0700 (Thu, 22 May 2014)

Log Message

Merge r168460 - Dragging text from one paragraph to another does not render as expected
https://bugs.webkit.org/show_bug.cgi?id=132633

Reviewed by Darin Adler and Ryosuke Niwa.

Source/WebCore:
When we are dragging and dropping into a content editable field, we detect
if we are trying to put a <p> into an existing <p>, and if so, split the
outer <p> and insert the new <p> as its sibling. However, the outer <p>
might not be editable, so we don't want to do any splitting and inserting
at that location.

Test: editing/pasteboard/drag-drop-paragraph-crasher.html

* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):

LayoutTests:
The problem occurs when dragging text that includes a <p> into an editable
area that has a <p> as a parent.

* editing/pasteboard/drag-drop-paragraph-crasher-expected.txt: Added.
* editing/pasteboard/drag-drop-paragraph-crasher.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.4/LayoutTests/ChangeLog (169191 => 169192)


--- releases/WebKitGTK/webkit-2.4/LayoutTests/ChangeLog	2014-05-22 08:09:46 UTC (rev 169191)
+++ releases/WebKitGTK/webkit-2.4/LayoutTests/ChangeLog	2014-05-22 09:52:35 UTC (rev 169192)
@@ -1,3 +1,16 @@
+2014-05-06  Myles C. Maxfield  <[email protected]>
+
+        Dragging text from one paragraph to another does not render as expected
+        https://bugs.webkit.org/show_bug.cgi?id=132633
+
+        Reviewed by Darin Adler and Ryosuke Niwa.
+
+        The problem occurs when dragging text that includes a <p> into an editable
+        area that has a <p> as a parent.
+
+        * editing/pasteboard/drag-drop-paragraph-crasher-expected.txt: Added.
+        * editing/pasteboard/drag-drop-paragraph-crasher.html: Added.
+
 2014-04-22  Brent Fulgham  <[email protected]>
 
         Check (rather than assume) element is a RenderTableSection before using it

Added: releases/WebKitGTK/webkit-2.4/LayoutTests/editing/pasteboard/drag-drop-paragraph-crasher-expected.txt (0 => 169192)


--- releases/WebKitGTK/webkit-2.4/LayoutTests/editing/pasteboard/drag-drop-paragraph-crasher-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.4/LayoutTests/editing/pasteboard/drag-drop-paragraph-crasher-expected.txt	2014-05-22 09:52:35 UTC (rev 169192)
@@ -0,0 +1,4 @@
+This tests text selection drag including a <p> tag, where its parent <p> tag is not editable.
+| "and drag it here<#selection-anchor>Select"
+| <p>
+|   "me<#selection-focus>"

Added: releases/WebKitGTK/webkit-2.4/LayoutTests/editing/pasteboard/drag-drop-paragraph-crasher.html (0 => 169192)


--- releases/WebKitGTK/webkit-2.4/LayoutTests/editing/pasteboard/drag-drop-paragraph-crasher.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.4/LayoutTests/editing/pasteboard/drag-drop-paragraph-crasher.html	2014-05-22 09:52:35 UTC (rev 169192)
@@ -0,0 +1,35 @@
+<html>
+<body>
+<p>This tests text selection drag including a &lt;p&gt; tag, where its parent &lt;p&gt; tag is not editable.</p>
+To test this by hand, select the relevant text in this editable span:
+    <div id=source>Select
+        <p>me</p>
+    </div>
+    <p id=destination contenteditable>and drag it here</p>
+<br><br>If there is no crash, then the test passed.
+<script src=""
+<script>
+function selectAllOfSource() {
+    var selection = window.getSelection();
+    var range = document.createRange();
+    range.selectNodeContents(document.getElementById("source"));
+    selection.removeAllRanges();
+    selection.addRange(range);
+}
+if (window.testRunner) {
+    Markup.description(document.querySelector('p').innerText);
+    selectAllOfSource();
+
+    eventSender.mouseMoveTo(source.offsetLeft + 10, source.offsetTop + source.offsetHeight / 2);
+    eventSender.mouseDown();
+    var destination = document.getElementById("destination");
+    eventSender.leapForward(500);
+    eventSender.mouseMoveTo(destination.offsetLeft + 700, destination.offsetTop + destination.offsetHeight / 2);
+    eventSender.mouseUp();
+
+    Markup.dump("destination");
+} else
+    Markup.noAutoDump();
+</script>
+</body>
+</html>

Modified: releases/WebKitGTK/webkit-2.4/LayoutTests/platform/mac-wk2/TestExpectations (169191 => 169192)


--- releases/WebKitGTK/webkit-2.4/LayoutTests/platform/mac-wk2/TestExpectations	2014-05-22 08:09:46 UTC (rev 169191)
+++ releases/WebKitGTK/webkit-2.4/LayoutTests/platform/mac-wk2/TestExpectations	2014-05-22 09:52:35 UTC (rev 169192)
@@ -113,6 +113,7 @@
 platform/mac/editing/pasteboard/dataTransfer-set-data-file-url.html
 platform/mac/editing/pasteboard/drag-selections-to-contenteditable.html
 platform/mac/fast/forms/listbox-scrollbar-hit-test.html
+editing/pasteboard/drag-drop-paragraph-crasher.html
 
 # [WK2] [Mac] Spellcheck tests don't seem to work
 webkit.org/b/105616 editing/spelling/context-menu-suggestions-multiword-selection.html

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (169191 => 169192)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2014-05-22 08:09:46 UTC (rev 169191)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2014-05-22 09:52:35 UTC (rev 169192)
@@ -1,3 +1,21 @@
+2014-05-06  Myles C. Maxfield  <[email protected]>
+
+        Dragging text from one paragraph to another does not render as expected
+        https://bugs.webkit.org/show_bug.cgi?id=132633
+
+        Reviewed by Darin Adler and Ryosuke Niwa.
+
+        When we are dragging and dropping into a content editable field, we detect
+        if we are trying to put a <p> into an existing <p>, and if so, split the
+        outer <p> and insert the new <p> as its sibling. However, the outer <p>
+        might not be editable, so we don't want to do any splitting and inserting
+        at that location.
+
+        Test: editing/pasteboard/drag-drop-paragraph-crasher.html
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
+
 2014-05-07  Carlos Garcia Campos  <[email protected]>
 
         [SOUP] TLSErrors do not cause page load to fail when not ignored

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/editing/ReplaceSelectionCommand.cpp (169191 => 169192)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/editing/ReplaceSelectionCommand.cpp	2014-05-22 08:09:46 UTC (rev 169191)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/editing/ReplaceSelectionCommand.cpp	2014-05-22 09:52:35 UTC (rev 169192)
@@ -628,8 +628,11 @@
             continue;
 
         if (isProhibitedParagraphChild(toHTMLElement(node.get())->localName())) {
-            if (HTMLElement* paragraphElement = toHTMLElement(enclosingNodeWithTag(positionInParentBeforeNode(node.get()), pTag)))
-                moveNodeOutOfAncestor(node, paragraphElement);
+            if (auto* paragraphElement = toHTMLElement(enclosingNodeWithTag(positionInParentBeforeNode(node.get()), pTag))) {
+                auto* parent = paragraphElement->parentNode();
+                if (parent && parent->hasEditableStyle())
+                    moveNodeOutOfAncestor(node, paragraphElement);
+            }
         }
 
         if (isHeaderElement(node.get())) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to