Changeset 82105 in webkit


Ignore:
Timestamp:
Mar 28, 2011 5:04:56 AM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-03-27 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

WebKit's behavior for text-align inherit differs from other browsers
https://bugs.webkit.org/show_bug.cgi?id=56377

The bug was caused by WebKit's resolving text-align: start and text-align: end too early.
As discussed on the bug, when text-align: start and text-align: end are inherited by descendent nodes,
the alignment of the text in those nodes should be determined based on the directionality of the text,
not by the directionality of the ancestor node from which text-align property is inherited.

Fixed the bug by introducing new enum values to ETextAlign: TASTART and TAEND. These two values will
align text to the left in a LTR context and to the right in a RTL context respectively.

  • css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added the support for TASTART and TAEND. (WebCore::CSSPrimitiveValue::operator ETextAlign): Ditto.
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applyProperty): No longer processes CSSValueStart and CSSValueEnd.
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::localCaretRect): Added the support for TASTART and TAEND.
  • rendering/RenderBlockLineLayout.cpp: (WebCore::RenderBlock::computeInlineDirectionPositionsForLine): Added the support for TASTART and TAEND.
  • rendering/RenderText.cpp: (WebCore::RenderText::localCaretRect): Ditto.
  • rendering/style/RenderStyle.h: ETextAlign now has 10 values and requires 4 bits.
  • rendering/style/RenderStyleConstants.h: Added TASTART and TAEND to ETextAlign.

2011-03-27 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

WebKit's behavior for text-align inherit differs from other browsers
https://bugs.webkit.org/show_bug.cgi?id=56377

Added test more cases to text-align, which already has some tests for text-align: start and text-align: end.

  • fast/css/text-align-expected.txt:
  • fast/css/text-align.html:
  • platform/mac/fast/css/text-align-expected.checksum:
  • platform/mac/fast/css/text-align-expected.png:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r82100 r82105  
     12011-03-27  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        WebKit's behavior for text-align inherit differs from other browsers
     6        https://bugs.webkit.org/show_bug.cgi?id=56377
     7
     8        Added test more cases to text-align, which already has some tests for text-align: start and text-align: end.
     9
     10        * fast/css/text-align-expected.txt:
     11        * fast/css/text-align.html:
     12        * platform/mac/fast/css/text-align-expected.checksum:
     13        * platform/mac/fast/css/text-align-expected.png:
     14
    1152011-03-28  Yuta Kitamura  <yutak@chromium.org>
    216
  • trunk/LayoutTests/fast/css/text-align-expected.txt

    r63403 r82105  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x152
    4   RenderBlock {HTML} at (0,0) size 800x152
    5     RenderBody {BODY} at (8,16) size 784x120
    6       RenderBlock {P} at (0,0) size 784x18
     3layer at (0,0) size 800x520
     4  RenderBlock {HTML} at (0,0) size 800x520
     5    RenderBody {BODY} at (8,10) size 784x494
     6      RenderBlock {H1} at (0,0) size 784x18
     7        RenderText {#text} at (0,0) size 78x18
     8          text run at (0,0) width 78: "Simple case"
     9      RenderBlock {P} at (0,34) size 784x18
    710        RenderText {#text} at (0,0) size 64x18
    811          text run at (0,0) width 64: "LTR Start"
    9       RenderBlock {P} at (0,34) size 784x18
     12      RenderBlock {P} at (0,68) size 784x18
    1013        RenderText {#text} at (723,0) size 61x18
    1114          text run at (723,0) width 61: "LTR End"
    12       RenderBlock {P} at (0,68) size 784x18
     15      RenderBlock {P} at (0,102) size 784x18
    1316        RenderText {#text} at (720,0) size 64x18
    1417          text run at (720,0) width 64: "RTL Start"
    15       RenderBlock {P} at (0,102) size 784x18
     18      RenderBlock {P} at (0,136) size 784x18
    1619        RenderText {#text} at (0,0) size 61x18
    1720          text run at (0,0) width 61: "RTL End"
     21      RenderBlock {H1} at (0,170) size 784x18
     22        RenderText {#text} at (0,0) size 95x18
     23          text run at (0,0) width 95: "Inherited case"
     24      RenderBlock {DIV} at (0,204) size 784x18
     25        RenderBlock {P} at (0,0) size 784x18
     26          RenderText {#text} at (0,0) size 64x18
     27            text run at (0,0) width 64: "LTR Start"
     28      RenderBlock {DIV} at (0,238) size 784x18
     29        RenderBlock {P} at (0,0) size 784x18
     30          RenderText {#text} at (723,0) size 61x18
     31            text run at (723,0) width 61: "LTR End"
     32      RenderBlock {DIV} at (0,272) size 784x18
     33        RenderBlock {P} at (0,0) size 784x18
     34          RenderText {#text} at (720,0) size 64x18
     35            text run at (720,0) width 64: "RTL Start"
     36      RenderBlock {DIV} at (0,306) size 784x18
     37        RenderBlock {P} at (0,0) size 784x18
     38          RenderText {#text} at (0,0) size 61x18
     39            text run at (0,0) width 61: "RTL End"
     40      RenderBlock {H1} at (0,340) size 784x18
     41        RenderText {#text} at (0,0) size 415x18
     42          text run at (0,0) width 415: "Inherited case where parent block has opposite directionality."
     43      RenderBlock {DIV} at (0,374) size 784x18
     44        RenderBlock {P} at (0,0) size 784x18
     45          RenderText {#text} at (0,0) size 64x18
     46            text run at (0,0) width 64: "LTR Start"
     47      RenderBlock {DIV} at (0,408) size 784x18
     48        RenderBlock {P} at (0,0) size 784x18
     49          RenderText {#text} at (723,0) size 61x18
     50            text run at (723,0) width 61: "LTR End"
     51      RenderBlock {DIV} at (0,442) size 784x18
     52        RenderBlock {P} at (0,0) size 784x18
     53          RenderText {#text} at (720,0) size 64x18
     54            text run at (720,0) width 64: "RTL Start"
     55      RenderBlock {DIV} at (0,476) size 784x18
     56        RenderBlock {P} at (0,0) size 784x18
     57          RenderText {#text} at (0,0) size 61x18
     58            text run at (0,0) width 61: "RTL End"
  • trunk/LayoutTests/fast/css/text-align.html

    r26469 r82105  
    22<html lang="en">
    33    <title>Test Case for text-align: start/end</title>
     4    <h1 style="font-size: 1em;">Simple case</h1>
    45    <p dir="ltr" style="text-align:start">LTR Start
    56    <p dir="ltr" style="text-align:end">LTR End
    67    <p dir="rtl" style="text-align:start">RTL Start
    78    <p dir="rtl" style="text-align:end">RTL End
     9    <h1 style="font-size: 1em;">Inherited case</h1>
     10    <div style="text-align: start;"><p dir="ltr" style="text-align: inherit">LTR Start</div>
     11    <div style="text-align: end;"><p dir="ltr" style="text-align: inherit">LTR End</div>
     12    <div style="text-align: start;"><p dir="rtl" style="text-align: inherit">RTL Start</div>
     13    <div style="text-align: end;"><p dir="rtl" style="text-align: inherit">RTL End</div>
     14    <h1 style="font-size: 1em;">Inherited case where parent block has opposite directionality.</h1>
     15    <div dir="rtl" style="text-align: start;"><p dir="ltr" style="text-align: inherit">LTR Start</div>
     16    <div dir="rtl" style="text-align: end;"><p dir="ltr" style="text-align: inherit">LTR End</div>
     17    <div dir="ltr" style="text-align: start;"><p dir="rtl" style="text-align: inherit">RTL Start</div>
     18    <div dir="ltr" style="text-align: end;"><p dir="rtl" style="text-align: inherit">RTL End</div>
    819</html>
  • trunk/LayoutTests/platform/mac/fast/css/text-align-expected.checksum

    r71088 r82105  
    1 a0b9172d02f1de1895f983b9183c332f
     17326dc495a79d91ab1572f8493bf72f5
  • trunk/Source/WebCore/ChangeLog

    r82103 r82105  
     12011-03-27  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        WebKit's behavior for text-align inherit differs from other browsers
     6        https://bugs.webkit.org/show_bug.cgi?id=56377
     7
     8        The bug was caused by WebKit's resolving text-align: start and text-align: end too early.
     9        As discussed on the bug, when text-align: start and text-align: end are inherited by descendent nodes,
     10        the alignment of the text in those nodes should be determined based on the directionality of the text,
     11        not by the directionality of the ancestor node from which text-align property is inherited.
     12
     13        Fixed the bug by introducing new enum values to ETextAlign: TASTART and TAEND. These two values will
     14        align text to the left in a LTR context and to the right in a RTL context respectively.
     15
     16        * css/CSSPrimitiveValueMappings.h:
     17        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added the support for TASTART and TAEND.
     18        (WebCore::CSSPrimitiveValue::operator ETextAlign): Ditto.
     19        * css/CSSStyleSelector.cpp:
     20        (WebCore::CSSStyleSelector::applyProperty): No longer processes CSSValueStart and CSSValueEnd.
     21        * rendering/RenderBlock.cpp:
     22        (WebCore::RenderBlock::localCaretRect): Added the support for TASTART and TAEND.
     23        * rendering/RenderBlockLineLayout.cpp:
     24        (WebCore::RenderBlock::computeInlineDirectionPositionsForLine): Added the support for TASTART and TAEND.
     25        * rendering/RenderText.cpp:
     26        (WebCore::RenderText::localCaretRect): Ditto.
     27        * rendering/style/RenderStyle.h: ETextAlign now has 10 values and requires 4 bits.
     28        * rendering/style/RenderStyleConstants.h: Added TASTART and TAEND to ETextAlign.
     29
    1302011-03-28  Pavel Podivilov  <podivilov@chromium.org>
    231
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r80582 r82105  
    16181618{
    16191619    switch (e) {
    1620         case TAAUTO:
    1621             m_value.ident = CSSValueWebkitAuto;
    1622             break;
    1623         case LEFT:
    1624             m_value.ident = CSSValueLeft;
    1625             break;
    1626         case RIGHT:
    1627             m_value.ident = CSSValueRight;
    1628             break;
    1629         case CENTER:
    1630             m_value.ident = CSSValueCenter;
    1631             break;
    1632         case JUSTIFY:
    1633             m_value.ident = CSSValueJustify;
    1634             break;
    1635         case WEBKIT_LEFT:
    1636             m_value.ident = CSSValueWebkitLeft;
    1637             break;
    1638         case WEBKIT_RIGHT:
    1639             m_value.ident = CSSValueWebkitRight;
    1640             break;
    1641         case WEBKIT_CENTER:
    1642             m_value.ident = CSSValueWebkitCenter;
    1643             break;
     1620    case TAAUTO:
     1621        m_value.ident = CSSValueWebkitAuto;
     1622        break;
     1623    case TASTART:
     1624        m_value.ident = CSSValueStart;
     1625        break;
     1626    case TAEND:
     1627        m_value.ident = CSSValueEnd;
     1628        break;
     1629    case LEFT:
     1630        m_value.ident = CSSValueLeft;
     1631        break;
     1632    case RIGHT:
     1633        m_value.ident = CSSValueRight;
     1634        break;
     1635    case CENTER:
     1636        m_value.ident = CSSValueCenter;
     1637        break;
     1638    case JUSTIFY:
     1639        m_value.ident = CSSValueJustify;
     1640        break;
     1641    case WEBKIT_LEFT:
     1642        m_value.ident = CSSValueWebkitLeft;
     1643        break;
     1644    case WEBKIT_RIGHT:
     1645        m_value.ident = CSSValueWebkitRight;
     1646        break;
     1647    case WEBKIT_CENTER:
     1648        m_value.ident = CSSValueWebkitCenter;
     1649        break;
    16441650    }
    16451651}
     
    16491655    switch (m_value.ident) {
    16501656        case CSSValueStart:
     1657            return TASTART;
    16511658        case CSSValueEnd:
    1652             ASSERT_NOT_REACHED(); // Depends on direction, thus should be handled by the caller.
    1653             return LEFT;
     1659            return TAEND;
    16541660        default:
    16551661            return static_cast<ETextAlign>(m_value.ident - CSSValueWebkitAuto);
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r82053 r82105  
    46224622        if (!primitiveValue)
    46234623            return;
    4624         int id = primitiveValue->getIdent();
    4625         if (id == CSSValueStart)
    4626             m_style->setTextAlign(m_style->isLeftToRightDirection() ? LEFT : RIGHT);
    4627         else if (id == CSSValueEnd)
    4628             m_style->setTextAlign(m_style->isLeftToRightDirection() ? RIGHT : LEFT);
    4629         else
    4630             m_style->setTextAlign(*primitiveValue);
     4624        m_style->setTextAlign(*primitiveValue);
    46314625        return;
    46324626    }
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r81992 r82105  
    58185818            alignment = alignRight;
    58195819            break;
     5820        case TASTART:
     5821            if (!currentStyle->isLeftToRightDirection())
     5822                alignment = alignRight;
     5823            break;
     5824        case TAEND:
     5825            if (currentStyle->isLeftToRightDirection())
     5826                alignment = alignRight;
     5827            break;
    58205828    }
    58215829
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r82091 r82105  
    497497        case WEBKIT_CENTER:
    498498            updateLogicalWidthForCenterAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     499            break;
     500        case TASTART:
     501            if (style()->isLeftToRightDirection())
     502                updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     503            else
     504                updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     505            break;
     506        case TAEND:
     507            if (style()->isLeftToRightDirection())
     508                updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     509            else
     510                updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    499511            break;
    500512    }
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r81794 r82105  
    552552    case WEBKIT_CENTER:
    553553        break;
     554    case TASTART:
     555        rightAligned = !cbStyle->isLeftToRightDirection();
     556        break;
     557    case TAEND:
     558        rightAligned = cbStyle->isLeftToRightDirection();
     559        break;
    554560    }
    555561
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r81807 r82105  
    188188        unsigned _list_style_position : 1; // EListStylePosition
    189189        unsigned _visibility : 2; // EVisibility
    190         unsigned _text_align : 3; // ETextAlign
     190        unsigned _text_align : 4; // ETextAlign
    191191        unsigned _text_transform : 2; // ETextTransform
    192192        unsigned _text_decorations : 4;
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r81992 r82105  
    320320
    321321enum ETextAlign {
    322     TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, WEBKIT_LEFT, WEBKIT_RIGHT, WEBKIT_CENTER
     322    TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, WEBKIT_LEFT, WEBKIT_RIGHT, WEBKIT_CENTER, TASTART, TAEND,
    323323};
    324324
Note: See TracChangeset for help on using the changeset viewer.