LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2006 20:46:44 +0000 (20:46 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2006 20:46:44 +0000 (20:46 +0000)
        Reviewed by harrison
        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8250>
        REGRESSION: Interchange newlines aren't passed with the khtmlBeforeTextInsertedEvent

        * fast/forms/8250-expected.checksum: Added.
        * fast/forms/8250-expected.png: Added.
        * fast/forms/8250-expected.txt: Added.
        * fast/forms/8250.html: Added.

WebCore:

        Reviewed by harrison

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8250>
        REGRESSION: Interchange newlines aren't passed with the khtmlBeforeTextInsertedEvent

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplacementFragment::ReplacementFragment):
        Interchange content removal happened before khtmlBeforeTextInsertedEvent was sent.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13730 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/8250-expected.checksum [new file with mode: 0644]
LayoutTests/fast/forms/8250-expected.png [new file with mode: 0644]
LayoutTests/fast/forms/8250-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/8250.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/ReplaceSelectionCommand.cpp

index a649ec1..bf95413 100644 (file)
@@ -1,5 +1,16 @@
 2006-04-07  Justin Garcia  <justin.garcia@apple.com>
 
+        Reviewed by harrison
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8250>
+        REGRESSION: Interchange newlines aren't passed with the khtmlBeforeTextInsertedEvent
+
+        * fast/forms/8250-expected.checksum: Added.
+        * fast/forms/8250-expected.png: Added.
+        * fast/forms/8250-expected.txt: Added.
+        * fast/forms/8250.html: Added.
+
+2006-04-07  Justin Garcia  <justin.garcia@apple.com>
+
         Reviewed by adele
         <http://bugzilla.opendarwin.org/show_bug.cgi?id=8219>
         REGRESSION: Two extra newlines added when pasting a single styled line into a plaintext-only region
diff --git a/LayoutTests/fast/forms/8250-expected.checksum b/LayoutTests/fast/forms/8250-expected.checksum
new file mode 100644 (file)
index 0000000..5d88518
--- /dev/null
@@ -0,0 +1 @@
+b39db1f47212af41150ce92d9d19fca0
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/8250-expected.png b/LayoutTests/fast/forms/8250-expected.png
new file mode 100644 (file)
index 0000000..b5f6a0d
Binary files /dev/null and b/LayoutTests/fast/forms/8250-expected.png differ
diff --git a/LayoutTests/fast/forms/8250-expected.txt b/LayoutTests/fast/forms/8250-expected.txt
new file mode 100644 (file)
index 0000000..5875280
--- /dev/null
@@ -0,0 +1,16 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV to 0 of #text > DIV toDOMRange:range from 3 of #text > DIV to 3 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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
+      RenderTextField {INPUT} at (2,2) size 148x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+      RenderText {TEXT} at (0,0) size 0x0
+layer at (13,13) size 142x13
+  RenderBlock {DIV} at (3,3) size 142x13
+    RenderText {TEXT} at (1,0) size 18x13
+      text run at (1,0) width 18: "foo"
+caret: position 3 of child 0 {TEXT} of child 0 {DIV} of child 0 {INPUT} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/fast/forms/8250.html b/LayoutTests/fast/forms/8250.html
new file mode 100644 (file)
index 0000000..bfc663b
--- /dev/null
@@ -0,0 +1,9 @@
+<input id="test" type="text">
+
+<script>
+var e = document.getElementById("test");
+e.focus();
+e.setSelectionRange(0, 0);
+
+document.execCommand("InsertHTML", false, "<br class='Apple-interchange-newline'>foo");
+</script>
\ No newline at end of file
index fe962e2..4a9e534 100644 (file)
@@ -1,5 +1,16 @@
 2006-04-07  Justin Garcia  <justin.garcia@apple.com>
 
+        Reviewed by harrison
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8250>
+        REGRESSION: Interchange newlines aren't passed with the khtmlBeforeTextInsertedEvent
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::ReplacementFragment):
+        Interchange content removal happened before khtmlBeforeTextInsertedEvent was sent.
+
+2006-04-07  Justin Garcia  <justin.garcia@apple.com>
+
         Reviewed by adele
         
         <http://bugzilla.opendarwin.org/show_bug.cgi?id=8219>
index c79df87..6de87b0 100644 (file)
@@ -84,6 +84,27 @@ ReplacementFragment::ReplacementFragment(Document *document, DocumentFragment *f
     }
     
     m_type = TreeFragment;
+    
+    ASSERT(editableRoot);
+    if (!editableRoot)
+        return;
+            
+    RefPtr<Node> holder = insertFragmentForTestRendering();
+    
+    Selection selectionAroundFragment = Selection::selectionFromContentsOfNode(holder.get());
+    RefPtr<Range> range = selectionAroundFragment.toRange();
+    String text = plainText(range.get());
+    String newText = text.copy();
+    // Give the root a chance to change the text.
+    RefPtr<Event> evt = new BeforeTextInsertedEvent(newText);
+    ExceptionCode ec = 0;
+    editableRoot->dispatchEvent(evt, ec, true);
+    ASSERT(ec == 0);
+    if (text != newText || !editableRoot->isContentRichlyEditable()) {
+        removeNode(holder);
+        m_fragment = createFragmentFromText(document, newText.deprecatedString());
+        holder = insertFragmentForTestRendering();
+     }
 
     Node *node = fragment->firstChild();
     Node *newlineAtStartNode = 0;
@@ -117,28 +138,7 @@ ReplacementFragment::ReplacementFragment(Document *document, DocumentFragment *f
         removeNode(newlineAtStartNode);
     if (newlineAtEndNode)
         removeNode(newlineAtEndNode);
-    
-    ASSERT(editableRoot);
-    if (!editableRoot)
-        return;
-            
-    RefPtr<Node> holder = insertFragmentForTestRendering();
-    
-    Selection selectionAroundFragment = Selection::selectionFromContentsOfNode(holder.get());
-    RefPtr<Range> range = selectionAroundFragment.toRange();
-    String text = plainText(range.get());
-    String newText = text.copy();
-    // Give the root a chance to change the text.
-    RefPtr<Event> evt = new BeforeTextInsertedEvent(newText);
-    ExceptionCode ec = 0;
-    editableRoot->dispatchEvent(evt, ec, true);
-    ASSERT(ec == 0);
-    if (text != newText || !editableRoot->isContentRichlyEditable()) {
-        removeNode(holder);
-        m_fragment = createFragmentFromText(document, newText.deprecatedString());
-        holder = insertFragmentForTestRendering();
-     }
-    
+        
     saveRenderingInfo(holder.get());
     removeUnrenderedNodes(holder.get());
     m_hasMoreThanOneBlock = renderedBlocks(holder.get()) > 1;