Skip to content
Permalink
Browse files
2010-10-28 Ryosuke Niwa <rniwa@webkit.org>
        Reviewed by Darin Adler.

        queryCommandValue should fall back to queryCommandState
        https://bugs.webkit.org/show_bug.cgi?id=48479

        Added a fallback to Command::value so that commands with a state function without a value function
        returns the value returned by the state function as a string.

        * editing/EditorCommand.cpp:
        (WebCore::Editor::Command::value):
2010-10-28  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Darin Adler.

        queryCommandValue should fall back to queryCommandState
        https://bugs.webkit.org/show_bug.cgi?id=48479

        Modified the existing tests to ensure queryCommandValue returns 'true' or 'false'
        for commands that supports queryCommandState.

        * editing/execCommand/script-tests/query-command-state.js:
        (testQueryCommandState):
        * editing/execCommand/script-tests/query-text-alignment.js:
        (isEquivalentBoolean):
        (queryTextAlignment):


Canonical link: https://commits.webkit.org/61322@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Oct 28, 2010
1 parent af92458 commit 2f189e223a7821f5124b8869fe97838bd5425442
Showing 5 changed files with 47 additions and 6 deletions.
@@ -1,3 +1,19 @@
2010-10-28 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

queryCommandValue should fall back to queryCommandState
https://bugs.webkit.org/show_bug.cgi?id=48479

Modified the existing tests to ensure queryCommandValue returns 'true' or 'false'
for commands that supports queryCommandState.

* editing/execCommand/script-tests/query-command-state.js:
(testQueryCommandState):
* editing/execCommand/script-tests/query-text-alignment.js:
(isEquivalentBoolean):
(queryTextAlignment):

2010-10-28 Martin Robinson <mrobinson@igalia.com>

Unskip some passing canvas tests on GTK+. These were
@@ -9,11 +9,14 @@ function testQueryCommandState(command, contents, selector, expectedState)
testContainer.innerHTML = contents;
var selected = selector(testContainer);
var actualState = document.queryCommandState(command);
var actualValue = document.queryCommandValue(command);
var action = 'queryCommandState("' + command + '") returns ' + actualState + ' when selecting ' + selected + ' of "' + contents + '"';
if (actualState === expectedState)
testPassed(action);
else
if (actualState != expectedState)
testFailed(action + ', expected ' + expectedState + '');
else if (actualValue != actualState.toString())
testFailed(action + ' but queryCommandValue returned ' + actualValue);
else
testPassed(action);
}

function selectAll(container) {
@@ -12,15 +12,22 @@ function queryTextAlignment(selector, content, expected)
var full = document.queryCommandState('justifyFull');
var left = document.queryCommandState('justifyLeft');
var right = document.queryCommandState('justifyRight');
var centerValue = document.queryCommandValue('justifyCenter');
var fullValue = document.queryCommandValue('justifyFull');
var leftValue = document.queryCommandValue('justifyLeft');
var rightValue = document.queryCommandValue('justifyRight');
if ((center && full) || (full && left) || (left && right) || (right && center))
testFailed('Inconsistent state when selecting ' + selected + ' of "' + content + '". More than one of justifyCenter, justifyFull, justifyRight, and justifyLeft returned true.')

var actual = center ? 'center' : full ? 'full' : left ? 'left' : right ? 'right' : '';
var action = "queryCommand('format') returns \"" + actual + '" when selecting ' + selected + ' of "' + content + '"';
if (actual == expected)
testPassed(action);
else
if (actual != expected)
testFailed(action + ' but expected "' + expected + '"');
else if (centerValue != center.toString() || fullValue != full.toString()
|| leftValue != left.toString() || rightValue != right.toString())
testFailed(action + ' but values returned by queryCommandState and queryCommandValue did not match');
else
testPassed(action);
}

function selectFirstPosition(container) {
@@ -1,3 +1,16 @@
2010-10-28 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

queryCommandValue should fall back to queryCommandState
https://bugs.webkit.org/show_bug.cgi?id=48479

Added a fallback to Command::value so that commands with a state function without a value function
returns the value returned by the state function as a string.

* editing/EditorCommand.cpp:
(WebCore::Editor::Command::value):

2010-10-28 Pavel Feldman <pfeldman@chromium.org>

Not reviewed. Rolling out r70800.
@@ -1638,6 +1638,8 @@ String Editor::Command::value(Event* triggeringEvent) const
{
if (!isSupported() || !m_frame)
return String();
if (m_command->value == valueNull && m_command->state != stateNone)
return m_command->state(m_frame.get(), triggeringEvent) == TrueTriState ? "true" : "false";
return m_command->value(m_frame.get(), triggeringEvent);
}

0 comments on commit 2f189e2

Please sign in to comment.