WebCore:
authorjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2008 00:16:43 +0000 (00:16 +0000)
committerjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2008 00:16:43 +0000 (00:16 +0000)
        Reviewed by Darin Adler.

        <rdar://problem/5700414> REGRESSION (Adama-ToT): Selecting "Header 1" style in Leopard Server wiki inserts newline

        * editing/FormatBlockCommand.cpp:
        (WebCore::FormatBlockCommand::doApply): If the selected paragraph was empty,
        we may still need to call moveParagrah to remove the line break that holds that
        paragraph open because the new block of the requested type needs to to replace it.

LayoutTests:

        Reviewed by Darin Adler.

        <rdar://problem/5700414> REGRESSION (Adama-ToT): Selecting "Header 1" style in Leopard Server wiki inserts newline

        * editing/execCommand/5700414-1.html: Added.
        * editing/execCommand/5700414-2.html: Added.
        * platform/mac/editing/execCommand/5700414-1-expected.checksum: Added.
        * platform/mac/editing/execCommand/5700414-1-expected.png: Added.
        * platform/mac/editing/execCommand/5700414-1-expected.txt: Added.
        * platform/mac/editing/execCommand/5700414-2-expected.checksum: Added.
        * platform/mac/editing/execCommand/5700414-2-expected.png: Added.
        * platform/mac/editing/execCommand/5700414-2-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/5700414-1.html [new file with mode: 0644]
LayoutTests/editing/execCommand/5700414-2.html [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/FormatBlockCommand.cpp

index 989532b..97b96c2 100644 (file)
@@ -1,3 +1,18 @@
+2008-01-30  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Darin Adler.
+        
+        <rdar://problem/5700414> REGRESSION (Adama-ToT): Selecting "Header 1" style in Leopard Server wiki inserts newline
+
+        * editing/execCommand/5700414-1.html: Added.
+        * editing/execCommand/5700414-2.html: Added.
+        * platform/mac/editing/execCommand/5700414-1-expected.checksum: Added.
+        * platform/mac/editing/execCommand/5700414-1-expected.png: Added.
+        * platform/mac/editing/execCommand/5700414-1-expected.txt: Added.
+        * platform/mac/editing/execCommand/5700414-2-expected.checksum: Added.
+        * platform/mac/editing/execCommand/5700414-2-expected.png: Added.
+        * platform/mac/editing/execCommand/5700414-2-expected.txt: Added.
+
 2008-01-29  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
diff --git a/LayoutTests/editing/execCommand/5700414-1.html b/LayoutTests/editing/execCommand/5700414-1.html
new file mode 100644 (file)
index 0000000..841cebf
--- /dev/null
@@ -0,0 +1,11 @@
+<div contenteditable="true">
+    <div>There should be a single empty H1 block below.</div>
+    <div id="div"><br></div>
+    <div id="div">There should be a single empty H1 block above.</div>
+</div>
+
+<script>
+div = document.getElementById("div");
+window.getSelection().setPosition(div, 0);
+document.execCommand("FormatBlock", false, "h1");
+</script>
diff --git a/LayoutTests/editing/execCommand/5700414-2.html b/LayoutTests/editing/execCommand/5700414-2.html
new file mode 100644 (file)
index 0000000..99cc75d
--- /dev/null
@@ -0,0 +1,11 @@
+<div contenteditable="true">
+    <div>There should an empty H1 block below, followed by a normal empty paragraph.</div>
+    <div id="div"><br><br></div>
+    <div id="div">There should be a single empty paragraph above.</div>
+</div>
+
+<script>
+div = document.getElementById("div");
+window.getSelection().setPosition(div, 0);
+document.execCommand("FormatBlock", false, "h1");
+</script>
diff --git a/LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.checksum b/LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.checksum
new file mode 100644 (file)
index 0000000..db765c0
--- /dev/null
@@ -0,0 +1 @@
+511089784b9b7908bd110ac87edf4522
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.png b/LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.png
new file mode 100644 (file)
index 0000000..56c525e
Binary files /dev/null and b/LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.txt b/LayoutTests/platform/mac/editing/execCommand/5700414-1-expected.txt
new file mode 100644 (file)
index 0000000..38b1565
--- /dev/null
@@ -0,0 +1,15 @@
+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 {DIV} at (0,0) size 784x115
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 307x18
+            text run at (0,0) width 307: "There should be a single empty H1 block below."
+        RenderBlock {H1} at (0,39) size 784x37
+          RenderBR {BR} at (0,0) size 0x37
+        RenderBlock {DIV} at (0,97) size 784x18
+          RenderText {#text} at (0,0) size 306x18
+            text run at (0,0) width 306: "There should be a single empty H1 block above."
+caret: position 0 of child 0 {BR} of child 3 {H1} of child 0 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.checksum b/LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.checksum
new file mode 100644 (file)
index 0000000..0c6ff21
--- /dev/null
@@ -0,0 +1 @@
+41e11a535edf3fab47a6d73754ff99ca
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.png b/LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.png
new file mode 100644 (file)
index 0000000..927346f
Binary files /dev/null and b/LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.txt b/LayoutTests/platform/mac/editing/execCommand/5700414-2-expected.txt
new file mode 100644 (file)
index 0000000..2661473
--- /dev/null
@@ -0,0 +1,18 @@
+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 {DIV} at (0,0) size 784x133
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 508x18
+            text run at (0,0) width 508: "There should an empty H1 block below, followed by a normal empty paragraph."
+        RenderBlock {DIV} at (0,39) size 784x76
+          RenderBlock {H1} at (0,0) size 784x37
+            RenderBR {BR} at (0,0) size 0x37
+          RenderBlock (anonymous) at (0,58) size 784x18
+            RenderBR {BR} at (0,0) size 0x18
+        RenderBlock {DIV} at (0,115) size 784x18
+          RenderText {#text} at (0,0) size 310x18
+            text run at (0,0) width 310: "There should be a single empty paragraph above."
+caret: position 0 of child 0 {BR} of child 0 {H1} of child 3 {DIV} of child 0 {DIV} of child 0 {BODY} of child 0 {HTML} of document
index 7f38a34..f344bf6 100644 (file)
@@ -1,3 +1,14 @@
+2008-01-30  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/5700414> REGRESSION (Adama-ToT): Selecting "Header 1" style in Leopard Server wiki inserts newline
+
+        * editing/FormatBlockCommand.cpp:
+        (WebCore::FormatBlockCommand::doApply): If the selected paragraph was empty,
+        we may still need to call moveParagrah to remove the line break that holds that
+        paragraph open because the new block of the requested type needs to to replace it.
+
 2008-01-30  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Darin Adler.
index 06a527d..492ee40 100644 (file)
@@ -123,7 +123,7 @@ void FormatBlockCommand::doApply()
     appendNode(placeholder.get(), blockNode.get());
     
     VisiblePosition destination(Position(placeholder.get(), 0));
-    if (paragraphStart == paragraphEnd) {
+    if (paragraphStart == paragraphEnd && !lineBreakExistsAtPosition(paragraphStart)) {
         setEndingSelection(destination);
         return;
     }