Changeset 68465 in webkit


Ignore:
Timestamp:
Sep 27, 2010 6:22:57 PM (14 years ago)
Author:
rniwa@webkit.org
Message:

2010-09-27 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
https://bugs.webkit.org/show_bug.cgi?id=45910

Implemented queryCommandState for justifyCenter, justifyLeft, and justifyRight commands.
Added getTextAlignment to convert -webkit-center, -webkit-left, and -webkit-right to
center, left, and right respectively because they can be treated equally for editing purposes.

Test: editing/execCommand/query-text-alignment.html

  • editing/ApplyStyleCommand.cpp: (WebCore::getTextAlignment): Added. (WebCore::getPropertiesNotIn): Uses getTextAlignment.
  • editing/EditorCommand.cpp: (WebCore::stateJustifyCenter): Added. (WebCore::stateJustifyLeft): Added. (WebCore::stateJustifyRight): Added. (WebCore::createCommandMap): Refers to stateJustifyCenter, stateJustifyLeft, and stateJustifyRight.

2010-09-27 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
https://bugs.webkit.org/show_bug.cgi?id=45910

Added tests for queryCommandState with justifyCenter, justifyLeft, and justifyRight commands.

  • editing/execCommand/query-text-alignment-expected.txt: Added.
  • editing/execCommand/query-text-alignment.html: Added.
  • editing/execCommand/script-tests/query-text-alignment.js: Added. (queryTextAlignment): (selectFirstPosition): (selectMiddleOfHelloWorld): (runRangeTests):
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r68463 r68465  
     12010-09-27  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
     6        https://bugs.webkit.org/show_bug.cgi?id=45910
     7
     8        Added tests for queryCommandState with justifyCenter, justifyLeft, and justifyRight commands.
     9
     10        * editing/execCommand/query-text-alignment-expected.txt: Added.
     11        * editing/execCommand/query-text-alignment.html: Added.
     12        * editing/execCommand/script-tests/query-text-alignment.js: Added.
     13        (queryTextAlignment):
     14        (selectFirstPosition):
     15        (selectMiddleOfHelloWorld):
     16        (runRangeTests):
     17
    1182010-09-27  James Robinson  <jamesr@chromium.org>
    219
  • trunk/WebCore/ChangeLog

    r68464 r68465  
     12010-09-27  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
     6        https://bugs.webkit.org/show_bug.cgi?id=45910
     7
     8        Implemented queryCommandState for justifyCenter, justifyLeft, and justifyRight commands.
     9        Added getTextAlignment to convert -webkit-center, -webkit-left, and -webkit-right to
     10        center, left, and right respectively because they can be treated equally for editing purposes.
     11
     12        Test: editing/execCommand/query-text-alignment.html
     13
     14        * editing/ApplyStyleCommand.cpp:
     15        (WebCore::getTextAlignment): Added.
     16        (WebCore::getPropertiesNotIn): Uses getTextAlignment.
     17        * editing/EditorCommand.cpp:
     18        (WebCore::stateJustifyCenter): Added.
     19        (WebCore::stateJustifyLeft): Added.
     20        (WebCore::stateJustifyRight): Added.
     21        (WebCore::createCommandMap): Refers to stateJustifyCenter, stateJustifyLeft, and stateJustifyRight.
     22
    1232010-09-27  Alpha Lam  <hclam@chromium.org>
    224
  • trunk/WebCore/editing/ApplyStyleCommand.cpp

    r68072 r68465  
    389389}
    390390
     391static int getTextAlignment(CSSStyleDeclaration* style)
     392{
     393    int textAlign = getIdentifierValue(style, CSSPropertyTextAlign);
     394    switch (textAlign) {
     395    case CSSValueCenter:
     396    case CSSValueWebkitCenter:
     397        return CSSValueCenter;
     398    case CSSValueLeft:
     399    case CSSValueWebkitLeft:
     400        return CSSValueLeft;
     401    case CSSValueRight:
     402    case CSSValueWebkitRight:
     403        return CSSValueRight;
     404    }
     405    return CSSValueInvalid;
     406}
     407
    391408RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
    392409{
     
    405422    if (getRGBAFontColor(result.get()) == getRGBAFontColor(baseStyle))
    406423        result->removeProperty(CSSPropertyColor);
     424
     425    if (getTextAlignment(result.get()) == getTextAlignment(baseStyle))
     426        result->removeProperty(CSSPropertyTextAlign);       
    407427
    408428    return result;
  • trunk/WebCore/editing/EditorCommand.cpp

    r68423 r68465  
    12981298{
    12991299    return frame->editor()->selectionUnorderedListState();
     1300}
     1301
     1302static TriState stateJustifyCenter(Frame* frame, Event*)
     1303{
     1304    return stateStyle(frame, CSSPropertyTextAlign, "center");
     1305}
     1306
     1307static TriState stateJustifyLeft(Frame* frame, Event*)
     1308{
     1309    return stateStyle(frame, CSSPropertyTextAlign, "left");
     1310}
     1311
     1312static TriState stateJustifyRight(Frame* frame, Event*)
     1313{
     1314    return stateStyle(frame, CSSPropertyTextAlign, "right");
    13001315}
    13011316
     
    13861401        { "InsertUnorderedList", { executeInsertUnorderedList, supported, enabledInRichlyEditableText, stateUnorderedList, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    13871402        { "Italic", { executeToggleItalic, supported, enabledInRichlyEditableText, stateItalic, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    1388         { "JustifyCenter", { executeJustifyCenter, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
     1403        { "JustifyCenter", { executeJustifyCenter, supported, enabledInRichlyEditableText, stateJustifyCenter, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    13891404        { "JustifyFull", { executeJustifyFull, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    1390         { "JustifyLeft", { executeJustifyLeft, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
     1405        { "JustifyLeft", { executeJustifyLeft, supported, enabledInRichlyEditableText, stateJustifyLeft, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    13911406        { "JustifyNone", { executeJustifyLeft, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    1392         { "JustifyRight", { executeJustifyRight, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
     1407        { "JustifyRight", { executeJustifyRight, supported, enabledInRichlyEditableText, stateJustifyRight, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    13931408        { "MakeTextWritingDirectionLeftToRight", { executeMakeTextWritingDirectionLeftToRight, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateTextWritingDirectionLeftToRight, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    13941409        { "MakeTextWritingDirectionNatural", { executeMakeTextWritingDirectionNatural, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateTextWritingDirectionNatural, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
Note: See TracChangeset for help on using the changeset viewer.