[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 13:49:01 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5c713d95b3883a27efcb7e285cc024eba498929a
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 27 21:10:54 2010 +0000

    2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Antonio Gomes.
    
            stateStyle (@EditorCommand.cpp) should ask EditingBehavior for platform specific behavior
            https://bugs.webkit.org/show_bug.cgi?id=41989
    
            queryCommandState returns true even when in the mixed state
            https://bugs.webkit.org/show_bug.cgi?id=46382
    
            Fixed stateStyle so that it calls selectionStartHasStyle when shouldToggleStyleBasedOnStartOfSelection
            is true (Mac platforms) and calls selectionHasStyle otherwise (non-Mac platforms).
    
            Also fixed queryCommandState so that it only returns true when the state is TrueTriState
            as supposed to returning true whenever the state is not FalseTriState. New behavior matches that of
            other browsers such as Firefox and Internet Explorer.
    
            * dom/Document.cpp:
            (WebCore::Document::queryCommandState):
            * editing/EditorCommand.cpp:
            (WebCore::executeToggleStyle):
            (WebCore::stateStyle):
    2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Antonio Gomes.
    
            stateStyle (@EditorCommand.cpp) should ask EditingBehavior for platform specific behavior
            https://bugs.webkit.org/show_bug.cgi?id=41989
    
            Added a test to ensure queryCommandState returns correct values on Mac and Windows.
    
            * editing/execCommand/query-command-state-expected.txt: Added.
            * editing/execCommand/script-tests/query-command-state.js: Added.
            (testQueryCommandState):
            (selectAll):
            (selectSecondWord):
            (selectFirstTwoWords):
            (runTests):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68423 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ea604b9..312a74b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Antonio Gomes.
+
+        stateStyle (@EditorCommand.cpp) should ask EditingBehavior for platform specific behavior
+        https://bugs.webkit.org/show_bug.cgi?id=41989
+
+        Added a test to ensure queryCommandState returns correct values on Mac and Windows.
+
+        * editing/execCommand/query-command-state-expected.txt: Added.
+        * editing/execCommand/script-tests/query-command-state.js: Added.
+        (testQueryCommandState):
+        (selectAll):
+        (selectSecondWord):
+        (selectFirstTwoWords):
+        (runTests):
+
 2010-09-27  Martin Robinson  <mrobinson at igalia.com>
 
         Rebaseline some tests where results differ between my machines
diff --git a/LayoutTests/editing/execCommand/query-command-state-expected.txt b/LayoutTests/editing/execCommand/query-command-state-expected.txt
new file mode 100644
index 0000000..9804e95
--- /dev/null
+++ b/LayoutTests/editing/execCommand/query-command-state-expected.txt
@@ -0,0 +1,124 @@
+Test to make sure queryCommandState returns correct values.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Tests for win
+PASS queryCommandState("bold") returns false when selecting all of "hello"
+PASS queryCommandState("bold") returns false when selecting all of "<i>hello</i>"
+PASS queryCommandState("bold") returns true when selecting all of "<b>hello</b>"
+PASS queryCommandState("bold") returns false when selecting all of "hello <b>world</b>"
+PASS queryCommandState("bold") returns false when selecting all of "<b>hello</b> world"
+PASS queryCommandState("bold") returns true when selecting second word of "hello <b>world</b> WebKit"
+PASS queryCommandState("bold") returns false when selecting second word of "<b>hello</b> world <b>WebKit</b>"
+PASS queryCommandState("bold") returns true when selecting second word of "<i>hello <b>hello</b> WebKit</i>"
+PASS queryCommandState("bold") returns true when selecting second word of "<b>hello <i>hello</i> WebKit</b>"
+PASS queryCommandState("bold") returns true when selecting second word of "<b><div>hello <i>hello</i> WebKit</div></b>"
+PASS queryCommandState("bold") returns false when selecting all of "<b style="font-weight: normal;">hello</b>"
+PASS queryCommandState("bold") returns true when selecting all of "<i style="font-weight: bold;">hello</i>"
+PASS queryCommandState("bold") returns false when selecting all of "<b>hello</b> world <b>WebKit</b>"
+PASS queryCommandState("bold") returns true when selecting all of "<b>hello</b><b> world</b>"
+PASS queryCommandState("bold") returns true when selecting all of "<div><b>hello</b></div><p><b> WebKit</b></p>"
+PASS queryCommandState("italic") returns false when selecting all of "hello"
+PASS queryCommandState("italic") returns false when selecting all of "<b>hello</b>"
+PASS queryCommandState("italic") returns true when selecting all of "<i>hello</i>"
+PASS queryCommandState("italic") returns false when selecting all of "<i>hello</i> world"
+PASS queryCommandState("italic") returns false when selecting all of "hello <i>world</i>"
+PASS queryCommandState("italic") returns true when selecting all of "<i><div>hello world</div></i>"
+PASS queryCommandState("italic") returns false when selecting all of "<div style="font-style: italic">hello <span style="font-style: normal;">hello</span></div>"
+PASS queryCommandState("subscript") returns false when selecting all of "hello"
+PASS queryCommandState("subscript") returns false when selecting all of "<sup>hello</sup>"
+PASS queryCommandState("subscript") returns true when selecting all of "<sub>hello</sub>"
+PASS queryCommandState("subscript") returns false when selecting all of "<sub>hello</sub> world"
+PASS queryCommandState("subscript") returns false when selecting all of "hello <sub>world</sub>"
+PASS queryCommandState("subscript") returns true when selecting all of "<div style="vertical-align: sub;">hello world</div>"
+PASS queryCommandState("subscript") returns true when selecting second word of "hello <span style="vertical-align: sub;">world</span> WebKit"
+PASS queryCommandState("superscript") returns false when selecting all of "hello"
+PASS queryCommandState("superscript") returns false when selecting all of "<sub>hello</sub>"
+PASS queryCommandState("superscript") returns true when selecting all of "<sup>hello</sup>"
+PASS queryCommandState("superscript") returns false when selecting all of "<sup>hello</sup> world"
+PASS queryCommandState("superscript") returns false when selecting all of "hello <sup>world</sup>"
+PASS queryCommandState("superscript") returns false when selecting all of "<span style="vertical-align: super;">hello</span><span style="vertical-align: sub;">world</span>"
+PASS queryCommandState("superscript") returns false when selecting all of "hello<span style="vertical-align: super;">world</span>"
+PASS queryCommandState("underline") returns false when selecting all of "hello"
+PASS queryCommandState("underline") returns false when selecting all of "<s>hello</s>"
+PASS queryCommandState("underline") returns true when selecting all of "<u>hello</u>"
+PASS queryCommandState("underline") returns false when selecting all of "<u>hello</u> world"
+PASS queryCommandState("underline") returns false when selecting all of "hello <u>world</u>"
+PASS queryCommandState("underline") returns true when selecting all of "<u><div>hello world</div></u>"
+PASS queryCommandState("underline") returns true when selecting second word of "<u><s><div>hello world WebKit</div></s></u>"
+PASS queryCommandState("underline") returns false when selecting second word of "<s><u>hello</u> world</s> WebKit"
+PASS queryCommandState("underline") returns true when selecting second word of "<u><s>hello</s> world</u> WebKit"
+PASS queryCommandState("underline") returns true when selecting second word of "<s>hello <u>world</s> WebKit</u>"
+PASS queryCommandState("strikeThrough") returns false when selecting all of "hello"
+PASS queryCommandState("strikeThrough") returns false when selecting all of "<u>hello</u>"
+PASS queryCommandState("strikeThrough") returns true when selecting all of "<s>hello</s>"
+PASS queryCommandState("strikeThrough") returns false when selecting all of "<s>hello</s> world"
+PASS queryCommandState("strikeThrough") returns false when selecting all of "hello <s>world</s>"
+PASS queryCommandState("strikeThrough") returns true when selecting all of "<s><div>hello world</div></s>"
+PASS queryCommandState("strikeThrough") returns true when selecting second word of "<s><u><div>hello world WebKit</div></u></s>"
+PASS queryCommandState("strikeThrough") returns false when selecting second word of "<u><s>hello</s> world</u> WebKit"
+PASS queryCommandState("strikeThrough") returns true when selecting second word of "hello <s>world WebKit</s>"
+PASS queryCommandState("strikeThrough") returns false when selecting first two words of "hello <s>world WebKit</s>"
+
+Tests for mac
+PASS queryCommandState("bold") returns false when selecting all of "hello"
+PASS queryCommandState("bold") returns false when selecting all of "<i>hello</i>"
+PASS queryCommandState("bold") returns true when selecting all of "<b>hello</b>"
+PASS queryCommandState("bold") returns false when selecting all of "hello <b>world</b>"
+PASS queryCommandState("bold") returns true when selecting all of "<b>hello</b> world"
+PASS queryCommandState("bold") returns true when selecting second word of "hello <b>world</b> WebKit"
+PASS queryCommandState("bold") returns false when selecting second word of "<b>hello</b> world <b>WebKit</b>"
+PASS queryCommandState("bold") returns true when selecting second word of "<i>hello <b>hello</b> WebKit</i>"
+PASS queryCommandState("bold") returns true when selecting second word of "<b>hello <i>hello</i> WebKit</b>"
+PASS queryCommandState("bold") returns true when selecting second word of "<b><div>hello <i>hello</i> WebKit</div></b>"
+PASS queryCommandState("bold") returns false when selecting all of "<b style="font-weight: normal;">hello</b>"
+PASS queryCommandState("bold") returns true when selecting all of "<i style="font-weight: bold;">hello</i>"
+PASS queryCommandState("bold") returns true when selecting all of "<b>hello</b> world <b>WebKit</b>"
+PASS queryCommandState("bold") returns true when selecting all of "<b>hello</b><b> world</b>"
+PASS queryCommandState("bold") returns true when selecting all of "<div><b>hello</b></div><p><b> WebKit</b></p>"
+PASS queryCommandState("italic") returns false when selecting all of "hello"
+PASS queryCommandState("italic") returns false when selecting all of "<b>hello</b>"
+PASS queryCommandState("italic") returns true when selecting all of "<i>hello</i>"
+PASS queryCommandState("italic") returns true when selecting all of "<i>hello</i> world"
+PASS queryCommandState("italic") returns false when selecting all of "hello <i>world</i>"
+PASS queryCommandState("italic") returns true when selecting all of "<i><div>hello world</div></i>"
+PASS queryCommandState("italic") returns true when selecting all of "<div style="font-style: italic">hello <span style="font-style: normal;">hello</span></div>"
+PASS queryCommandState("subscript") returns false when selecting all of "hello"
+PASS queryCommandState("subscript") returns false when selecting all of "<sup>hello</sup>"
+PASS queryCommandState("subscript") returns true when selecting all of "<sub>hello</sub>"
+PASS queryCommandState("subscript") returns true when selecting all of "<sub>hello</sub> world"
+PASS queryCommandState("subscript") returns false when selecting all of "hello <sub>world</sub>"
+PASS queryCommandState("subscript") returns true when selecting all of "<div style="vertical-align: sub;">hello world</div>"
+PASS queryCommandState("subscript") returns true when selecting second word of "hello <span style="vertical-align: sub;">world</span> WebKit"
+PASS queryCommandState("superscript") returns false when selecting all of "hello"
+PASS queryCommandState("superscript") returns false when selecting all of "<sub>hello</sub>"
+PASS queryCommandState("superscript") returns true when selecting all of "<sup>hello</sup>"
+PASS queryCommandState("superscript") returns true when selecting all of "<sup>hello</sup> world"
+PASS queryCommandState("superscript") returns false when selecting all of "hello <sup>world</sup>"
+PASS queryCommandState("superscript") returns true when selecting all of "<span style="vertical-align: super;">hello</span><span style="vertical-align: sub;">world</span>"
+PASS queryCommandState("superscript") returns false when selecting all of "hello<span style="vertical-align: super;">world</span>"
+PASS queryCommandState("underline") returns false when selecting all of "hello"
+PASS queryCommandState("underline") returns false when selecting all of "<s>hello</s>"
+PASS queryCommandState("underline") returns true when selecting all of "<u>hello</u>"
+PASS queryCommandState("underline") returns true when selecting all of "<u>hello</u> world"
+PASS queryCommandState("underline") returns false when selecting all of "hello <u>world</u>"
+PASS queryCommandState("underline") returns true when selecting all of "<u><div>hello world</div></u>"
+PASS queryCommandState("underline") returns true when selecting second word of "<u><s><div>hello world WebKit</div></s></u>"
+PASS queryCommandState("underline") returns false when selecting second word of "<s><u>hello</u> world</s> WebKit"
+PASS queryCommandState("underline") returns true when selecting second word of "<u><s>hello</s> world</u> WebKit"
+PASS queryCommandState("underline") returns true when selecting second word of "<s>hello <u>world</s> WebKit</u>"
+PASS queryCommandState("strikeThrough") returns false when selecting all of "hello"
+PASS queryCommandState("strikeThrough") returns false when selecting all of "<u>hello</u>"
+PASS queryCommandState("strikeThrough") returns true when selecting all of "<s>hello</s>"
+PASS queryCommandState("strikeThrough") returns true when selecting all of "<s>hello</s> world"
+PASS queryCommandState("strikeThrough") returns false when selecting all of "hello <s>world</s>"
+PASS queryCommandState("strikeThrough") returns true when selecting all of "<s><div>hello world</div></s>"
+PASS queryCommandState("strikeThrough") returns true when selecting second word of "<s><u><div>hello world WebKit</div></u></s>"
+PASS queryCommandState("strikeThrough") returns false when selecting second word of "<u><s>hello</s> world</u> WebKit"
+PASS queryCommandState("strikeThrough") returns true when selecting second word of "hello <s>world WebKit</s>"
+PASS queryCommandState("strikeThrough") returns false when selecting first two words of "hello <s>world WebKit</s>"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+hello world WebKit
diff --git a/LayoutTests/editing/execCommand/query-command-state.html b/LayoutTests/editing/execCommand/query-command-state.html
new file mode 100644
index 0000000..33c9a26
--- /dev/null
+++ b/LayoutTests/editing/execCommand/query-command-state.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/query-command-state.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/editing/execCommand/script-tests/query-command-state.js b/LayoutTests/editing/execCommand/script-tests/query-command-state.js
new file mode 100644
index 0000000..7e68b78
--- /dev/null
+++ b/LayoutTests/editing/execCommand/script-tests/query-command-state.js
@@ -0,0 +1,114 @@
+description("Test to make sure queryCommandState returns correct values.")
+
+var testContainer = document.createElement("div");
+testContainer.contentEditable = true;
+document.body.appendChild(testContainer);
+
+function testQueryCommandState(command, contents, selector, expectedState)
+{
+    testContainer.innerHTML = contents;
+    var selected = selector(testContainer);
+    var actualState = document.queryCommandState(command);
+    var action = 'queryCommandState("' + command + '") returns ' + actualState + ' when selecting ' + selected + ' of "' + contents + '"';
+    if (actualState === expectedState)
+        testPassed(action);
+    else
+        testFailed(action + ', expected ' + expectedState + '');
+}
+
+function selectAll(container) {
+    window.getSelection().selectAllChildren(container);
+    return 'all';
+}
+
+function selectSecondWord(container) {
+    window.getSelection().setPosition(container, 0);
+    window.getSelection().modify('move', 'forward', 'word');
+    window.getSelection().modify('move', 'forward', 'word');
+    window.getSelection().modify('move', 'backward', 'word');
+    window.getSelection().modify('extend', 'forward', 'word');
+    return 'second word';
+}
+
+function selectFirstTwoWords(container) {
+    window.getSelection().setPosition(container, 0);
+    window.getSelection().modify('move', 'forward', 'word');
+    window.getSelection().modify('extend', 'forward', 'word');
+    window.getSelection().modify('extend', 'forward', 'word');
+    return 'first two words';
+}
+
+function runTests(editingBehavior) {
+    if (window.layoutTestController)
+        layoutTestController.setEditingBehavior(editingBehavior);
+    debug('Tests for ' + editingBehavior)
+
+    testQueryCommandState("bold", 'hello', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("bold", '<i>hello</i>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("bold", '<b>hello</b>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("bold", 'hello <b>world</b>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("bold", '<b>hello</b> world', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("bold", 'hello <b>world</b> WebKit', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("bold", '<b>hello</b> world <b>WebKit</b>', selectSecondWord, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("bold", '<i>hello <b>hello</b> WebKit</i>', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("bold", '<b>hello <i>hello</i> WebKit</b>', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("bold", '<b><div>hello <i>hello</i> WebKit</div></b>', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("bold", '<b style="font-weight: normal;">hello</b>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("bold", '<i style="font-weight: bold;">hello</i>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("bold", '<b>hello</b> world <b>WebKit</b>', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("bold", '<b>hello</b><b> world</b>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("bold", '<div><b>hello</b></div><p><b> WebKit</b></p>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+
+    testQueryCommandState("italic", 'hello', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("italic", '<b>hello</b>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("italic", '<i>hello</i>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("italic", '<i>hello</i> world', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("italic", 'hello <i>world</i>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("italic", '<i><div>hello world</div></i>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("italic", '<div style="font-style: italic">hello <span style="font-style: normal;">hello</span></div>', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+
+    testQueryCommandState("subscript", 'hello', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("subscript", '<sup>hello</sup>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("subscript", '<sub>hello</sub>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("subscript", '<sub>hello</sub> world', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("subscript", 'hello <sub>world</sub>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("subscript", '<div style="vertical-align: sub;">hello world</div>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("subscript", 'hello <span style="vertical-align: sub;">world</span> WebKit', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+
+    testQueryCommandState("superscript", 'hello', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("superscript", '<sub>hello</sub>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("superscript", '<sup>hello</sup>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("superscript", '<sup>hello</sup> world', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("superscript", 'hello <sup>world</sup>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("superscript", '<span style="vertical-align: super;">hello</span><span style="vertical-align: sub;">world</span>', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("superscript", 'hello<span style="vertical-align: super;">world</span>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+
+    testQueryCommandState("underline", 'hello', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("underline", '<s>hello</s>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("underline", '<u>hello</u>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("underline", '<u>hello</u> world', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("underline", 'hello <u>world</u>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("underline", '<u><div>hello world</div></u>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("underline", '<u><s><div>hello world WebKit</div></s></u>', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("underline", '<s><u>hello</u> world</s> WebKit', selectSecondWord, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("underline", '<u><s>hello</s> world</u> WebKit', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("underline", '<s>hello <u>world</s> WebKit</u>', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+
+    testQueryCommandState("strikeThrough", 'hello', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("strikeThrough", '<u>hello</u>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("strikeThrough", '<s>hello</s>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("strikeThrough", '<s>hello</s> world', selectAll, {'mac': true, 'win': false}[editingBehavior]);
+    testQueryCommandState("strikeThrough", 'hello <s>world</s>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("strikeThrough", '<s><div>hello world</div></s>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("strikeThrough", '<s><u><div>hello world WebKit</div></u></s>', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("strikeThrough", '<u><s>hello</s> world</u> WebKit', selectSecondWord, {'mac': false, 'win': false}[editingBehavior]);
+    testQueryCommandState("strikeThrough", 'hello <s>world WebKit</s>', selectSecondWord, {'mac': true, 'win': true}[editingBehavior]);
+    testQueryCommandState("strikeThrough", 'hello <s>world WebKit</s>', selectFirstTwoWords, {'mac': false, 'win': false}[editingBehavior]);
+}
+
+runTests('win');
+debug('')
+runTests('mac');
+
+//document.body.removeChild(testContainer);
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d528e67..05c4bc9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Antonio Gomes.
+
+        stateStyle (@EditorCommand.cpp) should ask EditingBehavior for platform specific behavior
+        https://bugs.webkit.org/show_bug.cgi?id=41989
+
+        queryCommandState returns true even when in the mixed state
+        https://bugs.webkit.org/show_bug.cgi?id=46382
+
+        Fixed stateStyle so that it calls selectionStartHasStyle when shouldToggleStyleBasedOnStartOfSelection
+        is true (Mac platforms) and calls selectionHasStyle otherwise (non-Mac platforms).
+
+        Also fixed queryCommandState so that it only returns true when the state is TrueTriState
+        as supposed to returning true whenever the state is not FalseTriState. New behavior matches that of
+        other browsers such as Firefox and Internet Explorer.
+
+        * dom/Document.cpp:
+        (WebCore::Document::queryCommandState):
+        * editing/EditorCommand.cpp:
+        (WebCore::executeToggleStyle):
+        (WebCore::stateStyle):
+
 2010-09-27  David Hyatt  <hyatt at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 27c5ef9..6ae41f6 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -3913,7 +3913,7 @@ bool Document::queryCommandIndeterm(const String& commandName)
 
 bool Document::queryCommandState(const String& commandName)
 {
-    return command(this, commandName).state() != FalseTriState;
+    return command(this, commandName).state() == TrueTriState;
 }
 
 bool Document::queryCommandSupported(const String& commandName)
diff --git a/WebCore/editing/EditorCommand.cpp b/WebCore/editing/EditorCommand.cpp
index d197568..61c4d0f 100644
--- a/WebCore/editing/EditorCommand.cpp
+++ b/WebCore/editing/EditorCommand.cpp
@@ -160,10 +160,9 @@ static bool executeToggleStyle(Frame* frame, EditorCommandSource source, EditAct
     style->setProperty(propertyID, onValue); // We need to add this style to pass it to selectionStartHasStyle / selectionHasStyle
 
     // Style is considered present when
-    // mac: present at the beginning of selection
+    // Mac: present at the beginning of selection
     // other: present throughout the selection
 
-    // FIXME: Make stateStyle() to use this editing method too for the cases where it's used for queryCommandState.
     bool styleIsPresent;
     if (frame->editor()->behavior().shouldToggleStyleBasedOnStartOfSelection())
         styleIsPresent = frame->editor()->selectionStartHasStyle(style.get());
@@ -231,6 +230,9 @@ static TriState stateStyle(Frame* frame, int propertyID, const char* desiredValu
 {
     RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
     style->setProperty(propertyID, desiredValue);
+
+    if (frame->editor()->behavior().shouldToggleStyleBasedOnStartOfSelection())
+        return frame->editor()->selectionStartHasStyle(style.get()) ? TrueTriState : FalseTriState;
     return frame->editor()->selectionHasStyle(style.get());
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list