Changeset 70810 in webkit


Ignore:
Timestamp:
Oct 28, 2010 2:38:45 PM (14 years ago)
Author:
rniwa@webkit.org
Message:

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):
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70808 r70810  
     12010-10-28  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        queryCommandValue should fall back to queryCommandState
     6        https://bugs.webkit.org/show_bug.cgi?id=48479
     7
     8        Modified the existing tests to ensure queryCommandValue returns 'true' or 'false'
     9        for commands that supports queryCommandState.
     10
     11        * editing/execCommand/script-tests/query-command-state.js:
     12        (testQueryCommandState):
     13        * editing/execCommand/script-tests/query-text-alignment.js:
     14        (isEquivalentBoolean):
     15        (queryTextAlignment):
     16
    1172010-10-28  Martin Robinson  <mrobinson@igalia.com>
    218
  • trunk/LayoutTests/editing/execCommand/script-tests/query-command-state.js

    r68423 r70810  
    1010    var selected = selector(testContainer);
    1111    var actualState = document.queryCommandState(command);
     12    var actualValue = document.queryCommandValue(command);
    1213    var action = 'queryCommandState("' + command + '") returns ' + actualState + ' when selecting ' + selected + ' of "' + contents + '"';
    13     if (actualState === expectedState)
     14    if (actualState != expectedState)
     15        testFailed(action + ', expected ' + expectedState + '');
     16    else if (actualValue != actualState.toString())
     17        testFailed(action + ' but queryCommandValue returned ' + actualValue);
     18    else
    1419        testPassed(action);
    15     else
    16         testFailed(action + ', expected ' + expectedState + '');
    1720}
    1821
  • trunk/LayoutTests/editing/execCommand/script-tests/query-text-alignment.js

    r68904 r70810  
    1313    var left = document.queryCommandState('justifyLeft');
    1414    var right = document.queryCommandState('justifyRight');
     15    var centerValue = document.queryCommandValue('justifyCenter');
     16    var fullValue = document.queryCommandValue('justifyFull');
     17    var leftValue = document.queryCommandValue('justifyLeft');
     18    var rightValue = document.queryCommandValue('justifyRight');
    1519    if ((center && full) || (full && left) || (left && right) || (right && center))
    1620        testFailed('Inconsistent state when selecting ' + selected + ' of "' + content + '".  More than one of justifyCenter, justifyFull, justifyRight, and justifyLeft returned true.')
     
    1822    var actual = center ? 'center' : full ? 'full' : left ? 'left' : right ? 'right' : '';
    1923    var action = "queryCommand('format') returns \"" + actual + '" when selecting ' + selected + ' of "' + content + '"';
    20     if (actual == expected)
     24    if (actual != expected)
     25        testFailed(action + ' but expected "' + expected + '"');
     26    else if (centerValue != center.toString() || fullValue != full.toString()
     27        || leftValue != left.toString() || rightValue != right.toString())
     28        testFailed(action + ' but values returned by queryCommandState and queryCommandValue did not match');
     29    else
    2130        testPassed(action);
    22     else
    23         testFailed(action + ' but expected "' + expected + '"');
    2431}
    2532
  • trunk/WebCore/ChangeLog

    r70805 r70810  
     12010-10-28  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        queryCommandValue should fall back to queryCommandState
     6        https://bugs.webkit.org/show_bug.cgi?id=48479
     7
     8        Added a fallback to Command::value so that commands with a state function without a value function
     9        returns the value returned by the state function as a string.
     10
     11        * editing/EditorCommand.cpp:
     12        (WebCore::Editor::Command::value):
     13
    1142010-10-28  Pavel Feldman  <pfeldman@chromium.org>
    215
  • trunk/WebCore/editing/EditorCommand.cpp

    r69876 r70810  
    16391639    if (!isSupported() || !m_frame)
    16401640        return String();
     1641    if (m_command->value == valueNull && m_command->state != stateNone)
     1642        return m_command->state(m_frame.get(), triggeringEvent) == TrueTriState ? "true" : "false";
    16411643    return m_command->value(m_frame.get(), triggeringEvent);
    16421644}
Note: See TracChangeset for help on using the changeset viewer.