LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2006 21:51:27 +0000 (21:51 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2006 21:51:27 +0000 (21:51 +0000)
        Reviewed by darin

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8335>
        Implement execCommand(InsertHorizontalRule)

        * editing/deleting/merge-unrendered-space.html:
        * editing/execCommand/insertHorizontalRule-expected.checksum: Added.
        * editing/execCommand/insertHorizontalRule-expected.png: Added.
        * editing/execCommand/insertHorizontalRule-expected.txt: Added.
        * editing/execCommand/insertHorizontalRule.html: Added.

WebCore:

        Reviewed by darin

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8335>
        Implement execCommand(InsertHorizontalRule)

        * editing/JSEditor.cpp:

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

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/insertHorizontalRule-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/insertHorizontalRule-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/insertHorizontalRule-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/insertHorizontalRule.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/JSEditor.cpp

index 429fd5b39735e91bb1c66a07189a1fcb81d57176..8d5a5734857f4ab832f16a0845d25cfb386a093d 100644 (file)
@@ -1,3 +1,16 @@
+2006-04-12  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by darin
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8335>
+        Implement execCommand(InsertHorizontalRule)
+
+        * editing/deleting/merge-unrendered-space.html:
+        * editing/execCommand/insertHorizontalRule-expected.checksum: Added.
+        * editing/execCommand/insertHorizontalRule-expected.png: Added.
+        * editing/execCommand/insertHorizontalRule-expected.txt: Added.
+        * editing/execCommand/insertHorizontalRule.html: Added.
+
 2006-04-11  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/editing/execCommand/insertHorizontalRule-expected.checksum b/LayoutTests/editing/execCommand/insertHorizontalRule-expected.checksum
new file mode 100644 (file)
index 0000000..7fa53b6
--- /dev/null
@@ -0,0 +1 @@
+adc199b8ada428db127eb34ec46e8d73
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/insertHorizontalRule-expected.png b/LayoutTests/editing/execCommand/insertHorizontalRule-expected.png
new file mode 100644 (file)
index 0000000..14cbbfa
Binary files /dev/null and b/LayoutTests/editing/execCommand/insertHorizontalRule-expected.png differ
diff --git a/LayoutTests/editing/execCommand/insertHorizontalRule-expected.txt b/LayoutTests/editing/execCommand/insertHorizontalRule-expected.txt
new file mode 100644 (file)
index 0000000..8c23b32
--- /dev/null
@@ -0,0 +1,47 @@
+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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of HR > DIV > BODY > HTML > #document to 0 of HR > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of HR > DIV > BODY > HTML > #document to 0 of HR > DIV > BODY > HTML > #document 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
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {TEXT} at (0,0) size 359x18
+          text run at (0,0) width 359: "These are tests for execCommand(InsertHorizontalRule)."
+      RenderBlock {P} at (0,34) size 784x18
+        RenderText {TEXT} at (0,0) size 282x18
+          text run at (0,0) width 282: "This test inserts an hr between 'foo' and 'bar'."
+      RenderBlock {DIV} at (0,68) size 784x56 [border: (1px solid #0000FF)]
+        RenderBlock (anonymous) at (1,1) size 782x18
+          RenderText {TEXT} at (0,0) size 21x18
+            text run at (0,0) width 21: "foo"
+        RenderBlock {HR} at (1,27) size 782x2 [border: (1px inset #000000)]
+        RenderBlock (anonymous) at (1,37) size 782x18
+          RenderText {TEXT} at (0,0) size 20x18
+            text run at (0,0) width 20: "bar"
+      RenderBlock {P} at (0,140) size 784x18
+        RenderText {TEXT} at (0,0) size 634x18
+          text run at (0,0) width 634: "This test inserts an hr with id=\"hr\" between 'foo' and 'bar', fetches the hr using its id, then removes it."
+      RenderBlock {DIV} at (0,174) size 784x20 [border: (1px solid #0000FF)]
+        RenderText {TEXT} at (1,1) size 21x18
+          text run at (1,1) width 21: "foo"
+        RenderText {TEXT} at (22,1) size 20x18
+          text run at (22,1) width 20: "bar"
diff --git a/LayoutTests/editing/execCommand/insertHorizontalRule.html b/LayoutTests/editing/execCommand/insertHorizontalRule.html
new file mode 100644 (file)
index 0000000..a5cfd85
--- /dev/null
@@ -0,0 +1,32 @@
+<style>div { border: 1px solid blue; }</style>
+
+<p>These are tests for execCommand(InsertHorizontalRule).</p>
+
+<p>This test inserts an hr between 'foo' and 'bar'.</p>
+<div id="test1" contenteditable="true">foobar</div>
+
+<p>This test inserts an hr with id="hr" between 'foo' and 'bar', fetches the hr using its id, then removes it.</p>
+<div id="test2" contenteditable="true">foobar</div>
+
+<script type="text/javascript" src="../editing.js"></script>
+<script>
+var s = window.getSelection();
+var e;
+
+e = document.getElementById("test1");
+s.setPosition(e, 0);
+moveSelectionForwardByCharacterCommand();
+moveSelectionForwardByCharacterCommand();
+moveSelectionForwardByCharacterCommand();
+document.execCommand("InsertHorizontalRule", false, "");
+
+e = document.getElementById("test2");
+s.setPosition(e, 0);
+moveSelectionForwardByCharacterCommand();
+moveSelectionForwardByCharacterCommand();
+moveSelectionForwardByCharacterCommand();
+var id = "hr";
+document.execCommand("InsertHorizontalRule", false, id);
+var hr = document.getElementById(id);
+hr.parentNode.removeChild(hr);
+</script>
\ No newline at end of file
index 56b70c24383e33f907b03f4dafdcc861316edd10..687e08f5ea7b1d7203a844d446d5dd0761f16ca1 100644 (file)
@@ -1,3 +1,12 @@
+2006-04-12  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by darin
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8335>
+        Implement execCommand(InsertHorizontalRule)
+
+        * editing/JSEditor.cpp:
+
 2006-04-12  Darin Adler  <darin@apple.com>
 
         Rubber-stamped by Hyatt.
index e6eea3598fb5d8f6a7c958040f7709d56ac65b75..7bb8561fe6926dfc3ff68a0cc0d9af9fe1e9bf7b 100644 (file)
@@ -252,6 +252,21 @@ bool execForeColor(Frame *frame, bool userInterface, const String &value)
     return execStyleChange(frame,  CSS_PROP_COLOR, value);
 }
 
+bool execInsertHorizontalRule(Frame* frame, bool userInterface, const String& value)
+{
+    RefPtr<HTMLElement> hr = new HTMLElement(hrTag, frame->document());
+    if (!value.isEmpty())
+        hr->setId(value);
+    RefPtr<DocumentFragment> fragment = new DocumentFragment(frame->document());
+    ExceptionCode ec = 0;
+    fragment->appendChild(hr, ec);
+    if (ec)
+        return false;
+    
+    EditCommandPtr(new ReplaceSelectionCommand(frame->document(), fragment.get(), false)).apply();
+    return true;
+}
+
 bool execInsertHTML(Frame* frame, bool userInterface, const String& value)
 {
     DeprecatedString baseURL = "";
@@ -596,6 +611,7 @@ CommandMap *createCommandDictionary()
         { "ForeColor", { execForeColor, enabledAnySelection, stateNone, valueForeColor } },
         { "ForwardDelete", { execForwardDelete, enabledAnyEditableSelection, stateNone, valueNull } },
         { "Indent", { execIndent, enabledAnyRichlyEditableSelection, stateNone, valueNull } },
+        { "InsertHorizontalRule", { execInsertHorizontalRule, enabledAnyRichlyEditableSelection, stateNone, valueNull } },
         { "InsertHTML", { execInsertHTML, enabledAnyEditableSelection, stateNone, valueNull } },
         { "InsertImage", { execInsertImage, enabledAnyRichlyEditableSelection, stateNone, valueNull } },
         { "InsertLineBreak", { execInsertLineBreak, enabledAnyEditableSelection, stateNone, valueNull } },
@@ -643,7 +659,6 @@ CommandMap *createCommandDictionary()
         // InlineDirRTL (not supported)
         // InsertButton (not supported)
         // InsertFieldSet (not supported)
-        // InsertHorizontalRule (not supported)
         // InsertIFrame (not supported)
         // InsertInputButton (not supported)
         // InsertInputCheckbox (not supported)