LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2006 02:23:56 +0000 (02:23 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2006 02:23:56 +0000 (02:23 +0000)
        Reviewed by levi

        * editing/execCommand/remove-formatting-expected.checksum: Added.
        * editing/execCommand/remove-formatting-expected.png: Added.
        * editing/execCommand/remove-formatting-expected.txt: Added.
        * editing/execCommand/remove-formatting.html: Added.

WebCore:

        Reviewed by levi

        * editing/JSEditor.cpp: Added RemoveFormat.

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

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

index 4538183d326dedd918a806eb3fe6e8f5e0fb9605..5dcbdc68759cbf01a6fc06403f2a3448feb3b5d1 100644 (file)
@@ -1,3 +1,12 @@
+2006-06-27  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+
+        * editing/execCommand/remove-formatting-expected.checksum: Added.
+        * editing/execCommand/remove-formatting-expected.png: Added.
+        * editing/execCommand/remove-formatting-expected.txt: Added.
+        * editing/execCommand/remove-formatting.html: Added.
+
 2006-06-27  Justin Garcia  <justin.garcia@apple.com>
         
         Reviewed by levi
diff --git a/LayoutTests/editing/execCommand/remove-formatting-expected.checksum b/LayoutTests/editing/execCommand/remove-formatting-expected.checksum
new file mode 100644 (file)
index 0000000..16bd4ed
--- /dev/null
@@ -0,0 +1 @@
+0b20b5f332955ebe0fda257b29b3c264
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/remove-formatting-expected.png b/LayoutTests/editing/execCommand/remove-formatting-expected.png
new file mode 100644 (file)
index 0000000..8d21cd3
Binary files /dev/null and b/LayoutTests/editing/execCommand/remove-formatting-expected.png differ
diff --git a/LayoutTests/editing/execCommand/remove-formatting-expected.txt b/LayoutTests/editing/execCommand/remove-formatting-expected.txt
new file mode 100644 (file)
index 0000000..6872946
--- /dev/null
@@ -0,0 +1,39 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 13 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > B > DIV > BODY > HTML > #document to 3 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > 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 {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 321x18
+          text run at (0,0) width 321: "This is a test for execCommand(\"RemoveFormat\")"
+      RenderBlock {DIV} at (0,34) size 784x54
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 63x18
+            text run at (0,0) width 63: "foobarbaz"
+        RenderBlock {DIV} at (0,18) size 784x18
+          RenderText {#text} at (0,0) size 21x18
+            text run at (0,0) width 21: "foo"
+          RenderInline {SPAN} at (0,0) size 11x18
+            RenderText {#text} at (21,0) size 11x18
+              text run at (21,0) width 11: "\x{9}"
+          RenderText {#text} at (32,0) size 20x18
+            text run at (32,0) width 20: "bar"
+          RenderInline {SPAN} at (0,0) size 12x18
+            RenderText {#text} at (52,0) size 12x18
+              text run at (52,0) width 12: "\x{9}"
+          RenderText {#text} at (64,0) size 22x18
+            text run at (64,0) width 22: "baz"
+        RenderBlock {DIV} at (0,36) size 784x18
+          RenderText {#text} at (0,0) size 63x18
+            text run at (0,0) width 63: "foobarbaz"
+        RenderBlock (anonymous) at (0,54) size 784x0
+      RenderBlock {UL} at (0,104) size 784x0
+caret: position 9 of child 0 {#text} of child 2 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/remove-formatting.html b/LayoutTests/editing/execCommand/remove-formatting.html
new file mode 100644 (file)
index 0000000..c82f274
--- /dev/null
@@ -0,0 +1,30 @@
+<p>This is a test for execCommand("RemoveFormat")</p>
+<div id="test" contenteditable="true">
+<b>foo</b><a href="http://www.google.com/">bar</a><i>baz</i><br>
+<table border="1"><tr><td>foo</td><td>bar</td><td>baz</td></tr></table>
+<u>foo</u>bar<span style="text-decoration:line-through">baz</span><br>
+</div>
+<ul id="console"></ul>
+<script>
+function log(message) {
+    var console = document.getElementById("console");
+    var li = document.createElement("li");
+    var text = document.createTextNode(message);
+    
+    console.appendChild(li);
+    li.appendChild(text);
+}
+var e = document.getElementById("test");
+var s = window.getSelection();
+
+if (document.queryCommandEnabled("RemoveFormat"))
+    log("Failure: RemoveFormat enabled with no selection");
+s.setPosition(e, 0);
+if (document.queryCommandEnabled("RemoveFormat"))
+    log("Failure: RemoveFormat enabled with a caret selection");
+document.execCommand("SelectAll");
+if (!document.queryCommandEnabled("RemoveFormat"))
+    log("Failure: RemoveFormat disabled with a selection");
+if (!document.execCommand("RemoveFormat"))
+    log("Failure: execCommand('RemoveFormat') returned");
+</script>
\ No newline at end of file
index a02a88e177f5ef14ed1e7630d47b30c79cbbd607..109337af107a872c6c1595efc3d1add7e36166d3 100644 (file)
@@ -1,3 +1,9 @@
+2006-06-27  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+
+        * editing/JSEditor.cpp: Added RemoveFormat.
+
 2006-06-27  Kevin Decker    <kdecker@apple.com>
 
         Reviewed by brady.
index 4fb31bafd09e0ca59200fc252d5aadcef5a42797..81ca8e1739fa3d1f1ae3a5c482127a61fadd85e0 100644 (file)
@@ -410,6 +410,13 @@ bool execRedo(Frame *frame, bool userInterface, const String &value)
     return true;
 }
 
+bool execRemoveFormat(Frame* frame, bool userInterface, const String& value)
+{
+    RefPtr<DocumentFragment> fragment = createFragmentFromText(frame->document(), frame->selection().toString().deprecatedString());
+    EditCommandPtr(new ReplaceSelectionCommand(frame->document(), fragment.get(), false)).apply();
+    return true;
+}
+
 bool execSelectAll(Frame *frame, bool userInterface, const String &value)
 {
     frame->selectAll();
@@ -667,6 +674,7 @@ CommandMap *createCommandDictionary()
         { "PasteAndMatchStyle", { execPasteAndMatchStyle, enabledPasteAndMatchStyle, stateNone, valueNull } },
         { "Print", { execPrint, enabled, stateNone, valueNull } },
         { "Redo", { execRedo, enabledRedo, stateNone, valueNull } },
+        { "RemoveFormat", { execRemoveFormat, enabledAnyEditableRangeSelection, stateNone, valueNull } },
         { "SelectAll", { execSelectAll, enabled, stateNone, valueNull } },
         { "Strikethrough", { execStrikethrough, enabledAnyRichlyEditableSelection, stateStrikethrough, valueNull } },
         { "Subscript", { execSubscript, enabledAnyRichlyEditableSelection, stateSubscript, valueNull } },
@@ -717,7 +725,6 @@ CommandMap *createCommandDictionary()
         // Overwrite (not supported)
         // PlayImage (not supported)
         // Refresh (not supported)
-        // RemoveFormat (not supported)
         // RemoveParaFormat (not supported)
         // SaveAs (not supported)
         // SizeToControl (not supported)