LayoutTests:
authorlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2006 23:44:03 +0000 (23:44 +0000)
committerlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2006 23:44:03 +0000 (23:44 +0000)
        Reviewed by justin

        <rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
        <rdar://problem/4590763> FormatBlock for paragraph style doesn't work

        * editing/execCommand/format-block-with-braces-expected.checksum: Added.
        * editing/execCommand/format-block-with-braces-expected.png: Added.
        * editing/execCommand/format-block-with-braces-expected.txt: Added.
        * editing/execCommand/format-block-with-braces.html: Added.
        * editing/execCommand/indent-list-item-expected.checksum: Added.
        * editing/execCommand/indent-list-item-expected.png: Added.
        * editing/execCommand/indent-list-item-expected.txt: Added.
        * editing/execCommand/indent-list-item.html: Added.
        * editing/execCommand/indent-selection-expected.checksum: Added.
        * editing/execCommand/indent-selection-expected.png: Added.
        * editing/execCommand/indent-selection-expected.txt: Added.
        * editing/execCommand/indent-selection.html: Added.
        * editing/execCommand/outdent-selection-expected.checksum: Added.
        * editing/execCommand/outdent-selection-expected.png: Added.
        * editing/execCommand/outdent-selection-expected.txt: Added.
        * editing/execCommand/outdent-selection.html: Added.

WebCore:

        Reviewed by justin

        <rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
        <rdar://problem/4590763> FormatBlock for paragraph style doesn't work

        * dom/Node.cpp:
        (WebCore::Node::rootEditableElement): Return inline nodes
        * editing/FormatBlockCommand.cpp:
        (WebCore::FormatBlockCommand::doApply): Keep from inserting before editable content
        * editing/JSEditor.cpp: Support html braces (<>) around tag names

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/format-block-with-braces-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-with-braces-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-with-braces-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-with-braces.html [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-list-item-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-list-item-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-list-item-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-list-item.html [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-selection-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-selection-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-selection-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-selection.html [new file with mode: 0644]
LayoutTests/editing/execCommand/outdent-selection-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/outdent-selection-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/outdent-selection-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/outdent-selection.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Node.cpp
WebCore/editing/FormatBlockCommand.cpp
WebCore/editing/JSEditor.cpp

index b9bc95c5faa8a6b797e75bac852708b524cd105b..ae7f48f93ae04169968995aba99d4cd1a82db06b 100644 (file)
@@ -1,3 +1,33 @@
+2006-06-28  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin
+
+        <rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
+        <rdar://problem/4590763> FormatBlock for paragraph style doesn't work
+
+        * editing/execCommand/format-block-with-braces-expected.checksum: Added.
+        * editing/execCommand/format-block-with-braces-expected.png: Added.
+        * editing/execCommand/format-block-with-braces-expected.txt: Added.
+        * editing/execCommand/format-block-with-braces.html: Added.
+        * editing/execCommand/indent-list-item-expected.checksum: Added.
+        * editing/execCommand/indent-list-item-expected.png: Added.
+        * editing/execCommand/indent-list-item-expected.txt: Added.
+        * editing/execCommand/indent-list-item.html: Added.
+        * editing/execCommand/indent-selection-expected.checksum: Added.
+        * editing/execCommand/indent-selection-expected.png: Added.
+        * editing/execCommand/indent-selection-expected.txt: Added.
+        * editing/execCommand/indent-selection.html: Added.
+        * editing/execCommand/outdent-selection-expected.checksum: Added.
+        * editing/execCommand/outdent-selection-expected.png: Added.
+        * editing/execCommand/outdent-selection-expected.txt: Added.
+        * editing/execCommand/outdent-selection.html: Added.
+
+2006-06-28  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin
+
+        Missed the layout tests themselves in the first checkin! Whoops!
+
 2006-06-28  Levi Weintraub  <lweintraub@apple.com>
 
         Reviewed by justin
diff --git a/LayoutTests/editing/execCommand/format-block-with-braces-expected.checksum b/LayoutTests/editing/execCommand/format-block-with-braces-expected.checksum
new file mode 100644 (file)
index 0000000..3edac0a
--- /dev/null
@@ -0,0 +1 @@
+234a16a1f6c067f0d87b41565e6dbcba
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/format-block-with-braces-expected.png b/LayoutTests/editing/execCommand/format-block-with-braces-expected.png
new file mode 100644 (file)
index 0000000..55a16a5
Binary files /dev/null and b/LayoutTests/editing/execCommand/format-block-with-braces-expected.png differ
diff --git a/LayoutTests/editing/execCommand/format-block-with-braces-expected.txt b/LayoutTests/editing/execCommand/format-block-with-braces-expected.txt
new file mode 100644 (file)
index 0000000..d99caa7
--- /dev/null
@@ -0,0 +1,25 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of H1 > DIV > BODY > HTML > #document to 0 of H1 > 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 784x571
+      RenderBlock {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 557x18
+          text run at (0,0) width 557: "This test uses FormatBlock with html brackets in the tag string passed to execCommand."
+      RenderBlock (anonymous) at (0,18) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+        RenderInline {DIV} at (0,0) size 0x0
+      RenderBlock (anonymous) at (0,57) size 784x37
+        RenderBlock {H1} at (0,0) size 784x37
+          RenderInline {DIV} at (0,0) size 156x37
+            RenderText {#text} at (0,0) size 156x37
+              text run at (0,0) width 156: "Format Me"
+      RenderBlock (anonymous) at (0,115) size 784x0
+        RenderInline {DIV} at (0,0) size 0x0
+caret: position 0 of child 0 {#text} of child 0 {DIV} of child 0 {H1} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/format-block-with-braces.html b/LayoutTests/editing/execCommand/format-block-with-braces.html
new file mode 100644 (file)
index 0000000..2bd013c
--- /dev/null
@@ -0,0 +1,13 @@
+<div id="description">This test uses FormatBlock with html brackets in the tag string passed to execCommand.</div>
+<br>
+<div style="display:inline" contenteditable="true" id="item1">
+Format Me
+</div>
+
+<script>
+var s = window.getSelection();
+var r = document.createRange();
+var p1 = document.getElementById("item1");
+s.setPosition(p1, 0);
+document.execCommand("FormatBlock", false, "<h1>");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/indent-list-item-expected.checksum b/LayoutTests/editing/execCommand/indent-list-item-expected.checksum
new file mode 100644 (file)
index 0000000..f1b3d05
--- /dev/null
@@ -0,0 +1 @@
+9e610294e20545bacfc2bedfb37899fa
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/indent-list-item-expected.png b/LayoutTests/editing/execCommand/indent-list-item-expected.png
new file mode 100644 (file)
index 0000000..73bd0b5
Binary files /dev/null and b/LayoutTests/editing/execCommand/indent-list-item-expected.png differ
diff --git a/LayoutTests/editing/execCommand/indent-list-item-expected.txt b/LayoutTests/editing/execCommand/indent-list-item-expected.txt
new file mode 100644 (file)
index 0000000..ba53104
--- /dev/null
@@ -0,0 +1,32 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of LI > UL > UL > DIV > BODY > HTML > #document to 0 of LI > UL > UL > 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 784x576
+      RenderBlock {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 374x18
+          text run at (0,0) width 374: "This test uses the execCommand to Outdent the text below."
+      RenderBlock (anonymous) at (0,18) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+      RenderBlock {DIV} at (0,52) size 784x54
+        RenderBlock {UL} at (0,0) size 784x54
+          RenderListItem {LI} at (40,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18
+            RenderText {#text} at (0,0) size 25x18
+              text run at (0,0) width 25: "Foo"
+          RenderBlock {UL} at (40,18) size 744x18
+            RenderListItem {LI} at (40,0) size 704x18
+              RenderListMarker at (-17,0) size 7x18
+              RenderText {#text} at (0,0) size 23x18
+                text run at (0,0) width 23: "Bar"
+          RenderListItem {LI} at (40,36) size 744x18
+            RenderListMarker at (-17,0) size 7x18
+            RenderText {#text} at (0,0) size 25x18
+              text run at (0,0) width 25: "Baz"
+caret: position 0 of child 0 {#text} of child 0 {LI} of child 3 {UL} of child 1 {UL} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/indent-list-item.html b/LayoutTests/editing/execCommand/indent-list-item.html
new file mode 100644 (file)
index 0000000..1fcdc2e
--- /dev/null
@@ -0,0 +1,17 @@
+<div id="description">
+This test uses the execCommand to Outdent the text below.
+</div>
+<br>
+<div contenteditable="true">
+<ul>
+<li>Foo</li>
+<li id="item1">Bar</li>
+<li>Baz</li>
+</ul>
+</div>
+<script>
+var s = window.getSelection();
+var p1 = document.getElementById("item1");
+s.setPosition(p1, 0);
+document.execCommand("Indent", false, "");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/indent-selection-expected.checksum b/LayoutTests/editing/execCommand/indent-selection-expected.checksum
new file mode 100644 (file)
index 0000000..f8a41f4
--- /dev/null
@@ -0,0 +1 @@
+d1074841553c7b04760fab12d8da6e9e
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/indent-selection-expected.png b/LayoutTests/editing/execCommand/indent-selection-expected.png
new file mode 100644 (file)
index 0000000..cb657d3
Binary files /dev/null and b/LayoutTests/editing/execCommand/indent-selection-expected.png differ
diff --git a/LayoutTests/editing/execCommand/indent-selection-expected.txt b/LayoutTests/editing/execCommand/indent-selection-expected.txt
new file mode 100644 (file)
index 0000000..2fa5ca1
--- /dev/null
@@ -0,0 +1,60 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 10 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > BLOCKQUOTE > DIV > BODY > HTML > #document to 5 of #text > SPAN > BLOCKQUOTE > 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 784x576
+      RenderBlock {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 362x18
+          text run at (0,0) width 362: "This test uses the execCommand to indent the text below."
+      RenderBlock (anonymous) at (0,18) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+      RenderBlock {DIV} at (0,52) size 784x244
+        RenderBlock {BLOCKQUOTE} at (40,0) size 704x70
+          RenderBlock (anonymous) at (0,0) size 704x36
+            RenderInline {SPAN} at (0,0) size 42x18
+              RenderText {#text} at (0,0) size 42x18
+                text run at (0,0) width 42: "Lorem"
+            RenderBR {BR} at (42,14) size 0x0
+            RenderText {#text} at (0,18) size 83x18
+              text run at (0,18) width 83: "more Lorem!"
+          RenderBlock {BLOCKQUOTE} at (40,52) size 624x18
+            RenderText {#text} at (0,0) size 38x18
+              text run at (0,0) width 38: "ipsum"
+        RenderBlock (anonymous) at (0,86) size 784x0
+        RenderBlock {BLOCKQUOTE} at (40,86) size 704x54
+          RenderBlock {UL} at (0,0) size 704x54
+            RenderBlock {UL} at (40,0) size 664x54
+              RenderListItem {LI} at (40,0) size 624x18
+                RenderListMarker at (-17,0) size 7x18
+                RenderText {#text} at (0,0) size 25x18
+                  text run at (0,0) width 25: "Foo"
+              RenderListItem {LI} at (40,18) size 624x18
+                RenderListMarker at (-17,0) size 7x18
+                RenderText {#text} at (0,0) size 23x18
+                  text run at (0,0) width 23: "Bar"
+              RenderListItem {LI} at (40,36) size 624x18
+                RenderListMarker at (-17,0) size 7x18
+                RenderText {#text} at (0,0) size 25x18
+                  text run at (0,0) width 25: "Baz"
+        RenderBlock {BLOCKQUOTE} at (40,156) size 704x88
+          RenderBlock {BLOCKQUOTE} at (40,0) size 624x18
+            RenderText {#text} at (0,0) size 37x18
+              text run at (0,0) width 37: "Dolor"
+          RenderBlock (anonymous) at (0,34) size 704x54
+            RenderBR {BR} at (0,0) size 0x18
+            RenderText {#text} at (0,18) size 34x18
+              text run at (0,18) width 34: "Sum!"
+            RenderBR {BR} at (34,32) size 0x0
+            RenderInline {SPAN} at (0,0) size 38x18
+              RenderText {#text} at (0,36) size 38x18
+                text run at (0,36) width 38: "Thing"
+        RenderBlock (anonymous) at (0,260) size 784x0
+selection start: position 0 of child 0 {#text} of child 4 {SPAN} of child 3 {BLOCKQUOTE} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end:   position 5 of child 0 {#text} of child 4 {SPAN} of child 3 {BLOCKQUOTE} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/indent-selection.html b/LayoutTests/editing/execCommand/indent-selection.html
new file mode 100644 (file)
index 0000000..e39f5bc
--- /dev/null
@@ -0,0 +1,28 @@
+<div id="description">
+This test uses the execCommand to indent the text below.
+</div>
+<br>
+<div contenteditable="true">
+<span id="item1">Lorem</span><br>
+more Lorem!
+<blockquote>
+ipsum<br>
+
+<ul>
+<li>Foo</li>
+<li>Bar</li>
+<li>Baz</li>
+</ul>
+Dolor
+</blockquote>
+Sum!<br>
+<span id="item2">Thing</span>
+</div>
+<script>
+var s = window.getSelection();
+var p1 = document.getElementById("item1");
+var p2 = document.getElementById("item2");
+s.setPosition(p1, 0);
+s.setBaseAndExtent(p1, 0, p2, 2);
+document.execCommand("Indent", false, "");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/outdent-selection-expected.checksum b/LayoutTests/editing/execCommand/outdent-selection-expected.checksum
new file mode 100644 (file)
index 0000000..e69205d
--- /dev/null
@@ -0,0 +1 @@
+73cbe29f64487852600dbe71dd92532a
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/outdent-selection-expected.png b/LayoutTests/editing/execCommand/outdent-selection-expected.png
new file mode 100644 (file)
index 0000000..998265a
Binary files /dev/null and b/LayoutTests/editing/execCommand/outdent-selection-expected.png differ
diff --git a/LayoutTests/editing/execCommand/outdent-selection-expected.txt b/LayoutTests/editing/execCommand/outdent-selection-expected.txt
new file mode 100644 (file)
index 0000000..f95dc08
--- /dev/null
@@ -0,0 +1,58 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 12 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 5 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 5 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+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 {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 374x18
+          text run at (0,0) width 374: "This test uses the execCommand to Outdent the text below."
+      RenderBlock (anonymous) at (0,18) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+      RenderBlock {DIV} at (0,36) size 784x210
+        RenderBlock (anonymous) at (0,0) size 784x54
+          RenderInline {SPAN} at (0,0) size 42x18
+            RenderText {#text} at (0,0) size 42x18
+              text run at (0,0) width 42: "Lorem"
+          RenderBR {BR} at (42,14) size 0x0
+          RenderText {#text} at (0,18) size 87x18
+            text run at (0,18) width 87: "more Lorem! "
+          RenderText {#text} at (87,18) size 38x18
+            text run at (87,18) width 38: "ipsum"
+          RenderBR {BR} at (125,32) size 0x0
+          RenderText {#text} at (0,36) size 37x18
+            text run at (0,36) width 37: "Dolor"
+          RenderBR {BR} at (37,50) size 0x0
+        RenderBlock {BLOCKQUOTE} at (40,70) size 704x54
+          RenderBlock (anonymous) at (0,0) size 704x54
+            RenderText {#text} at (0,0) size 25x18
+              text run at (0,0) width 25: "Foo"
+            RenderBR {BR} at (25,14) size 0x0
+            RenderText {#text} at (0,18) size 23x18
+              text run at (0,18) width 23: "Bar"
+            RenderBR {BR} at (23,32) size 0x0
+            RenderText {#text} at (0,36) size 25x18
+              text run at (0,36) width 25: "Baz"
+            RenderBR {BR} at (25,50) size 0x0
+          RenderBlock {UL} at (0,70) size 704x0
+          RenderBlock (anonymous) at (0,70) size 704x0
+        RenderBlock (anonymous) at (0,140) size 784x18
+          RenderText {#text} at (0,0) size 82x18
+            text run at (0,0) width 82: "Dinner time?"
+          RenderBR {BR} at (82,14) size 0x0
+        RenderBlock {UL} at (0,174) size 784x0
+        RenderBlock (anonymous) at (0,174) size 784x36
+          RenderText {#text} at (0,0) size 34x18
+            text run at (0,0) width 34: "Sum!"
+          RenderBR {BR} at (34,14) size 0x0
+          RenderInline {SPAN} at (0,0) size 38x18
+            RenderText {#text} at (0,18) size 38x18
+              text run at (0,18) width 38: "Thing"
+          RenderText {#text} at (0,0) size 0x0
+selection start: position 0 of child 0 {#text} of child 1 {SPAN} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end:   position 5 of child 0 {#text} of child 16 {SPAN} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/outdent-selection.html b/LayoutTests/editing/execCommand/outdent-selection.html
new file mode 100644 (file)
index 0000000..e05b11a
--- /dev/null
@@ -0,0 +1,31 @@
+<div id="description">
+This test uses the execCommand to Outdent the text below.
+</div>
+<br>
+<div contenteditable="true">
+<span id="item1">Lorem</span><br>
+more Lorem!
+<blockquote>
+ipsum<br>
+
+<ul>
+<li>Foo</li>
+<li>Bar</li>
+<li>Baz</li>
+</ul>
+Dolor
+</blockquote>
+<ul>
+  <li>Dinner time?</li>
+</ul>
+Sum!<br>
+<span id="item2">Thing</span>
+</div>
+<script>
+var s = window.getSelection();
+var p1 = document.getElementById("item1");
+var p2 = document.getElementById("item2");
+s.setPosition(p1, 0);
+s.setBaseAndExtent(p1, 0, p2, 2);
+document.execCommand("Outdent", false, "");
+</script>
\ No newline at end of file
index 92cd56533eb831c9055a0f43b65d29e6904a7a2e..26a5f878aede376630a13a0eaf03b12e4f3d55fd 100644 (file)
@@ -1,3 +1,16 @@
+2006-06-28  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin
+
+        <rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
+        <rdar://problem/4590763> FormatBlock for paragraph style doesn't work
+
+        * dom/Node.cpp:
+        (WebCore::Node::rootEditableElement): Return inline nodes
+        * editing/FormatBlockCommand.cpp:
+        (WebCore::FormatBlockCommand::doApply): Keep from inserting before editable content
+        * editing/JSEditor.cpp: Support html braces (<>) around tag names
+
 2006-06-28  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
index 3c1dda0159c67433dbadd16bf60d3b2f2c3acfc5..1ad95b8d0aebaf5708056ae56c3970004d1ebb68 100644 (file)
@@ -1054,7 +1054,7 @@ Element* Node::rootEditableElement() const
 {
     Element* result = 0;
     for (Node* n = const_cast<Node*>(this); n && n->isContentEditable(); n = n->parentNode()) {
-        if (n->isBlockFlow() && n->isElementNode())
+        if (n->isElementNode())
             result = static_cast<Element*>(n);
         if (n->hasTagName(bodyTag))
             break;
index 61cc3c8c7b337cfa601890ed0cae107df2c9d822..0c8fd725017dd47b226277fd19ed21584f2d4932 100644 (file)
@@ -85,8 +85,8 @@ void FormatBlockCommand::doApply()
         return;
     QualifiedName qTypeOfBlock = QualifiedName(AtomicString(prefix), AtomicString(localName), xhtmlNamespaceURI);
     
-    Node* enclosingBlock = enclosingBlockFlowElement(endingSelection().visibleStart());
-    if (enclosingBlock->hasTagName(qTypeOfBlock))
+    Node* refNode = enclosingBlockFlowElement(endingSelection().visibleStart());
+    if (refNode->hasTagName(qTypeOfBlock))
         // We're already in a block with the format we want, so we don't have to do anything
         return;
     
@@ -97,11 +97,16 @@ void FormatBlockCommand::doApply()
     RefPtr<Node> blockNode = createElement(document(), m_tagName);
     RefPtr<Node> placeholder = createBreakElement(document());
     
-    if (validBlockTag(enclosingBlock->nodeName().lower()) && paragraphStart == blockStart && paragraphEnd == blockEnd)
+    Node* root = endingSelection().start().node()->rootEditableElement();
+    if (refNode == root || root->isAncestor(refNode))
+        refNode = paragraphStart.deepEquivalent().node();
+    
+    Position upstreamStart = paragraphStart.deepEquivalent().upstream();
+    if ((validBlockTag(refNode->nodeName().lower()) && paragraphStart == blockStart && paragraphEnd == blockEnd) ||
+        !upstreamStart.node()->isAncestor(root))
         // Already in a valid block tag that only contains the current paragraph, so we can swap with the new tag
-        insertNodeBefore(blockNode.get(), enclosingBlock);
+        insertNodeBefore(blockNode.get(), refNode);
     else {
-        Position upstreamStart = paragraphStart.deepEquivalent().upstream();
         insertNodeAt(blockNode.get(), upstreamStart.node(), upstreamStart.offset());
     }
     appendNode(placeholder.get(), blockNode.get());
index 2dd85a89f443b15e7a91ca553c1c59d60050fda3..1a5730cf9809cbaeec21b0afcabf6ce365af11a8 100644 (file)
@@ -264,6 +264,8 @@ bool execForeColor(Frame *frame, bool userInterface, const String &value)
 bool execFormatBlock(Frame *frame, bool userInterface, const String &value)
 {
     String tagName = value.lower();
+    if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
+        tagName = tagName.substring(1, tagName.length() - 2);
     if (!validBlockTag(tagName))
         return false;