Title: [95050] trunk
Revision
95050
Author
commit-qu...@webkit.org
Date
2011-09-13 15:31:24 -0700 (Tue, 13 Sep 2011)

Log Message

For compatibility, execCommand should support deprecated 'useCSS' alias for 'styleWithCSS'
https://bugs.webkit.org/show_bug.cgi?id=36683

Patch by Kiyoto Tamura <owenes...@gmail.com> on 2011-09-13
Reviewed by Ryosuke Niwa.

Source/WebCore:

In addition to supporting the deprecated 'useCSS', 'styleWithCSS' now accepts any argument other than
the boolean false or the case-insensitive string "false". This is per
http://aryeh.name/spec/editing/editing.html#the-stylewithcss-command

Tests: editing/execCommand/style-with-css.html
       editing/execCommand/use-css.html

* editing/EditorCommand.cpp:
(WebCore::executeStyleWithCSS):
(WebCore::executeUseCSS):
(WebCore::createCommandMap):

LayoutTests:

Testing useCSS, the command previously unsupported by WebKit. Also, we are testing
styleWithCSS accepts anything that is not the boolean false or the string "false" as true.
Furthermore, we test that queryCommandValue/State('useCSS') return boolean false and
queryCommandValue/State('useStyleWithCSS') returns booleans (as opposed to 'true'/'false'
strings)

* editing/execCommand/style-with-css-expected.txt: Added.
* editing/execCommand/style-with-css.html: Added.
* editing/execCommand/use-css-expected.txt: Added.
* editing/execCommand/use-css.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (95049 => 95050)


--- trunk/LayoutTests/ChangeLog	2011-09-13 22:28:53 UTC (rev 95049)
+++ trunk/LayoutTests/ChangeLog	2011-09-13 22:31:24 UTC (rev 95050)
@@ -1,3 +1,21 @@
+2011-09-13  Kiyoto Tamura  <owenes...@gmail.com>
+
+        For compatibility, execCommand should support deprecated 'useCSS' alias for 'styleWithCSS'
+        https://bugs.webkit.org/show_bug.cgi?id=36683
+
+        Reviewed by Ryosuke Niwa.
+
+        Testing useCSS, the command previously unsupported by WebKit. Also, we are testing
+        styleWithCSS accepts anything that is not the boolean false or the string "false" as true.
+        Furthermore, we test that queryCommandValue/State('useCSS') return boolean false and
+        queryCommandValue/State('useStyleWithCSS') returns booleans (as opposed to 'true'/'false'
+        strings)
+
+        * editing/execCommand/style-with-css-expected.txt: Added.
+        * editing/execCommand/style-with-css.html: Added.
+        * editing/execCommand/use-css-expected.txt: Added.
+        * editing/execCommand/use-css.html: Added.
+
 2011-09-13  Tim Horton  <timothy_hor...@apple.com>
 
         REGRESSION (64275): Shape pattern-image fill turns black

Added: trunk/LayoutTests/editing/execCommand/style-with-css-expected.txt (0 => 95050)


--- trunk/LayoutTests/editing/execCommand/style-with-css-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/style-with-css-expected.txt	2011-09-13 22:31:24 UTC (rev 95050)
@@ -0,0 +1,18 @@
+Test styleWithCSS command
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS styleWithCSS changed the state successfully
+PASS styleWithCSS changed the state successfully
+PASS styleWithCSS changed the state successfully
+PASS styleWithCSS changed the state successfully
+PASS styleWithCSS changed the state successfully
+PASS queryCommandState('styleWithCSS') returns true
+PASS queryCommandValue('styleWithCSS') returns 'true'
+PASS queryCommandState('styleWithCSS') returns false
+PASS queryCommandValue('styleWithCSS') returns 'false'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/execCommand/style-with-css.html (0 => 95050)


--- trunk/LayoutTests/editing/execCommand/style-with-css.html	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/style-with-css.html	2011-09-13 22:31:24 UTC (rev 95050)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Test styleWithCSS command');
+
+function testStyleWithCSS(styleArg, expectedState)
+{
+    document.execCommand('styleWithCSS', false, styleArg); 
+    if (document.queryCommandState('styleWithCSS') === expectedState)
+        testPassed('styleWithCSS changed the state successfully');
+    else
+        testFailed('styleWithCSS failed with the argument ' + styleArg);
+}
+
+testStyleWithCSS(true, true);
+testStyleWithCSS('false', false);
+testStyleWithCSS('FALSE', false);
+testStyleWithCSS('random string', true);
+testStyleWithCSS(null, true);
+
+document.execCommand('styleWithCSS', false, true);
+if (document.queryCommandState('styleWithCSS') === true)
+    testPassed("queryCommandState('styleWithCSS') returns true");
+else
+    testFailed("queryCommandState('styleWithCSS') should return boolean true");
+
+if (document.queryCommandValue('styleWithCSS') === 'true')
+    testPassed("queryCommandValue('styleWithCSS') returns 'true'");
+else
+    testFailed("queryCommandValue('styleWithCSS') should return 'true'");
+
+document.execCommand('styleWithCSS', false, false);
+if (document.queryCommandState('styleWithCSS') === false)
+    testPassed("queryCommandState('styleWithCSS') returns false");
+else
+    testFailed("queryCommandState('styleWithCSS') should return boolean false");
+
+if (document.queryCommandValue('styleWithCSS') === 'false')
+    testPassed("queryCommandValue('styleWithCSS') returns 'false'");
+else
+    testFailed("queryCommandValue('styleWithCSS') should return 'false'");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/editing/execCommand/use-css-expected.txt (0 => 95050)


--- trunk/LayoutTests/editing/execCommand/use-css-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/use-css-expected.txt	2011-09-13 22:31:24 UTC (rev 95050)
@@ -0,0 +1,17 @@
+Test useCSS command
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS useCSS changed the state successfully
+PASS useCSS changed the state successfully
+PASS useCSS changed the state successfully
+PASS useCSS changed the state successfully
+PASS useCSS changed the state successfully
+PASS queryCommandState('useCSS') returns false
+PASS queryCommandValue('useCSS') returns false
+PASS one underline command converted test to <span style="text-decoration: underline;">test</span>
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/execCommand/use-css.html (0 => 95050)


--- trunk/LayoutTests/editing/execCommand/use-css.html	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/use-css.html	2011-09-13 22:31:24 UTC (rev 95050)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Test useCSS command');
+
+var testContainer = document.createElement("div");
+testContainer.contentEditable = true;
+document.body.appendChild(testContainer);
+
+function testUseCSS(styleArg, expectedState)
+{
+    document.execCommand('useCSS', false, styleArg); 
+    if (document.queryCommandState('styleWithCSS') === expectedState)
+        testPassed('useCSS changed the state successfully');
+    else
+        testFailed('useCSS failed with the argument ' + styleArg);
+}
+
+function testSingleToggle(toggleCommand, initialContents, expectedContents)
+{
+    testContainer.innerHTML = initialContents;
+    window.getSelection().selectAllChildren(testContainer);
+    document.execCommand("useCSS", false, false);
+    document.execCommand(toggleCommand, false, null);
+    if (testContainer.innerHTML === expectedContents)
+        testPassed("one " + toggleCommand + " command converted " + initialContents + " to " + expectedContents);
+    else
+        testFailed("one " + toggleCommand + " command converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
+}
+
+testUseCSS(false, true);
+testUseCSS('false', true);
+testUseCSS('FALSE', true);
+testUseCSS(true, false);
+testUseCSS('random string', false);
+
+if (document.queryCommandState('useCSS') === false)
+    testPassed("queryCommandState('useCSS') returns false");
+else
+    testFailed("queryCommandState('useCSS') should return boolean false");
+
+if (document.queryCommandValue('useCSS') === false)
+    testPassed("queryCommandValue('useCSS') returns false");
+else
+    testFailed("queryCommandValue('useCSS') should return boolean false");
+
+testSingleToggle("underline", "test", "<span style=\"text-decoration: underline;\">test</span>");
+
+document.body.removeChild(testContainer);
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (95049 => 95050)


--- trunk/Source/WebCore/ChangeLog	2011-09-13 22:28:53 UTC (rev 95049)
+++ trunk/Source/WebCore/ChangeLog	2011-09-13 22:31:24 UTC (rev 95050)
@@ -1,3 +1,22 @@
+2011-09-13  Kiyoto Tamura  <owenes...@gmail.com>
+
+        For compatibility, execCommand should support deprecated 'useCSS' alias for 'styleWithCSS'
+        https://bugs.webkit.org/show_bug.cgi?id=36683
+
+        Reviewed by Ryosuke Niwa.
+
+        In addition to supporting the deprecated 'useCSS', 'styleWithCSS' now accepts any argument other than
+        the boolean false or the case-insensitive string "false". This is per
+        http://aryeh.name/spec/editing/editing.html#the-stylewithcss-command
+
+        Tests: editing/execCommand/style-with-css.html
+               editing/execCommand/use-css.html
+
+        * editing/EditorCommand.cpp:
+        (WebCore::executeStyleWithCSS):
+        (WebCore::executeUseCSS):
+        (WebCore::createCommandMap):
+
 2011-09-13  Anders Carlsson  <ander...@apple.com>
 
         Disable C++ exceptions when building with clang

Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (95049 => 95050)


--- trunk/Source/WebCore/editing/EditorCommand.cpp	2011-09-13 22:28:53 UTC (rev 95049)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp	2011-09-13 22:31:24 UTC (rev 95050)
@@ -1017,13 +1017,16 @@
 
 static bool executeStyleWithCSS(Frame* frame, Event*, EditorCommandSource, const String& value)
 {
-    if (value != "false" && value != "true")
-        return false;
-    
-    frame->editor()->setShouldStyleWithCSS(value == "true" ? true : false);
+    frame->editor()->setShouldStyleWithCSS(!equalIgnoringCase(value, "false"));
     return true;
 }
 
+static bool executeUseCSS(Frame* frame, Event*, EditorCommandSource, const String& value)
+{
+    frame->editor()->setShouldStyleWithCSS(equalIgnoringCase(value, "false"));
+    return true;
+}
+
 static bool executeSubscript(Frame* frame, Event*, EditorCommandSource source, const String&)
 {
     return executeToggleStyle(frame, source, EditActionSubscript, CSSPropertyVerticalAlign, "baseline", "sub");
@@ -1534,6 +1537,7 @@
         { "Unlink", { executeUnlink, supported, enabledRangeInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "Unscript", { executeUnscript, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "Unselect", { executeUnselect, supported, enabledVisibleSelection, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+        { "UseCSS", { executeUseCSS, supported, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "Yank", { executeYank, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "YankAndSelect", { executeYankAndSelect, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to