Changeset 164867 in webkit


Ignore:
Timestamp:
Feb 28, 2014 10:12:52 AM (10 years ago)
Author:
mario.prada@samsung.com
Message:

paragraphs with different directionality in textarea with unicode-bidi: plaintext are aligned the same
https://bugs.webkit.org/show_bug.cgi?id=71194

Reviewed by David Hyatt.

Merged from Blink r157263 by <igor.o@sisa.samsung.com>
<https://src.chromium.org/viewvc/blink?revision=157263&view=revision>

Source/WebCore:

In the css3-text spec (http://www.w3.org/TR/css3-text/#bidi-linebox):

The start and end edges of a line box are determined by the inline
base direction of the line box. In most cases, this is given by
its containing block's computed ‘direction’. However if its
containing block has ‘unicode-bidi: plaintext’, the inline base
direction the line box must be determined by the base direction of
the bidi paragraph to which it belongs: that is, the bidi
paragraph for which the line box holds content.

This patch just implements the behavior described above modifying
updateLogicalWidthForAlignment and setting the bidi level of the
RootInlineBox.

  • rendering/RenderBlockFlow.h:
  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlockFlow::updateLogicalWidthForAlignment):
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
(WebCore::RenderBlockFlow::createLineBoxesFromBidiRuns):
(WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
(WebCore::RenderBlockFlow::deleteEllipsisLineBoxes):
(WebCore::RenderBlockFlow::checkLinesForTextOverflow):
(WebCore::RenderBlockFlow::startAlignedOffsetForLine):

LayoutTests:

Modified expectations for two layout tests to make them conforming to the spec.

  • fast/text/international/unicode-bidi-plaintext-expected.html:
  • platform/gtk/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt:
  • platform/mac-mountainlion/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164866 r164867  
     12014-02-28  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        paragraphs with different directionality in textarea with unicode-bidi: plaintext are aligned the same
     4        https://bugs.webkit.org/show_bug.cgi?id=71194
     5
     6        Reviewed by David Hyatt.
     7
     8        Merged from Blink r157263 by <igor.o@sisa.samsung.com>
     9        <https://src.chromium.org/viewvc/blink?revision=157263&view=revision>
     10
     11        Modified expectations for two layout tests to make them conforming to the spec.
     12
     13        * fast/text/international/unicode-bidi-plaintext-expected.html:
     14        * platform/gtk/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt:
     15        * platform/mac-mountainlion/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt:
     16
    1172014-02-28  Jochen Eisinger  <jochen@chromium.org>
    218
  • trunk/LayoutTests/fast/text/international/unicode-bidi-plaintext-expected.html

    r101949 r164867  
    33<head>
    44<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     5<style>
     6.rightAligned {
     7  display: block;
     8  text-align: right;
     9}
     10</style>
    511</head>
    612<body>
     
    915<div dir=ltr>
    1016!hello.<br>
    11 <span dir=rtl>
     17<span class="rightAligned" dir=rtl>
    1218!שלום.
    13 </span><br>
     19</span>
    1420<span dir=ltr>
    1521hello, לוי!
    1622</span><br>
    17 <span dir=rtl>
    18 שלום, WebKit!</span><br>
    19 <pre>
     23<span class="rightAligned" dir=rtl>
     24שלום, WebKit!</span>
     25<pre style="margin-bottom: 0px">
    2026a
    2127(
    22 !WebKit ,שלום
     28</pre>
     29<pre dir="rtl" style="margin: 0px">
     30שלום, WebKit!
     31</pre>
     32<pre style="margin-top: 0px">
    2333hello, לוי!
    2434)
  • trunk/LayoutTests/platform/gtk/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt

    r148815 r164867  
    1717  RenderTextControl {TEXTAREA} at (2,2) size 471x74 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    1818    RenderBlock {DIV} at (3,3) size 465x51
    19       RenderText {#text} at (424,0) size 41x34
     19      RenderText {#text} at (424,0) size 465x34
    2020        text run at (424,0) width 0 RTL: " "
    2121        text run at (424,0) width 41 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    22         text run at (426,17) width 39: "hello!"
    23         text run at (465,17) width 0: " "
     22        text run at (0,17) width 39: "hello!"
     23        text run at (39,17) width 0: " "
    2424      RenderBR {BR} at (465,34) size 0x17
    2525layer at (10,125) size 471x74 clip at (11,126) size 469x72
    2626  RenderTextControl {TEXTAREA} at (2,83) size 471x74 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    2727    RenderBlock {DIV} at (3,3) size 465x51
    28       RenderText {#text} at (0,0) size 41x34
    29         text run at (0,0) width 0 RTL: " "
    30         text run at (0,0) width 41 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
     28      RenderText {#text} at (424,0) size 465x34
     29        text run at (424,0) width 0 RTL: " "
     30        text run at (424,0) width 41 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    3131        text run at (0,17) width 39: "hello!"
    3232        text run at (39,17) width 0: " "
     
    3535  RenderTextControl {TEXTAREA} at (2,164) size 471x74 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    3636    RenderBlock {DIV} at (3,3) size 465x51
    37       RenderText {#text} at (0,0) size 41x34
    38         text run at (0,0) width 0 RTL: " "
    39         text run at (0,0) width 41 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
     37      RenderText {#text} at (424,0) size 465x34
     38        text run at (424,0) width 0 RTL: " "
     39        text run at (424,0) width 41 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    4040        text run at (0,17) width 39: "hello!"
    4141        text run at (39,17) width 0: " "
     
    4444  RenderTextControl {TEXTAREA} at (2,245) size 471x74 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    4545    RenderBlock {DIV} at (3,3) size 465x51
    46       RenderText {#text} at (424,0) size 41x34
     46      RenderText {#text} at (424,0) size 465x34
    4747        text run at (424,0) width 0 RTL: " "
    4848        text run at (424,0) width 41 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    49         text run at (426,17) width 39: "hello!"
    50         text run at (465,17) width 0: " "
     49        text run at (0,17) width 39: "hello!"
     50        text run at (39,17) width 0: " "
    5151      RenderBR {BR} at (465,34) size 0x17
  • trunk/LayoutTests/platform/mac-mountainlion/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt

    r158041 r164867  
    1717  RenderTextControl {TEXTAREA} at (2,2) size 371x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    1818    RenderBlock {DIV} at (3,3) size 365x39
    19       RenderText {#text} at (336,0) size 30x26
     19      RenderText {#text} at (336,0) size 365x26
    2020        text run at (336,0) width 1 RTL: " "
    2121        text run at (336,0) width 29 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    22         text run at (335,13) width 30: "hello!"
    23         text run at (365,13) width 0: " "
     22        text run at (0,13) width 30: "hello!"
     23        text run at (29,13) width 1: " "
    2424      RenderBR {BR} at (365,26) size 0x13
    2525layer at (10,112) size 371x58 clip at (11,113) size 369x56
    2626  RenderTextControl {TEXTAREA} at (2,68) size 371x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    2727    RenderBlock {DIV} at (3,3) size 365x39
    28       RenderText {#text} at (0,0) size 30x26
    29         text run at (0,0) width 0 RTL: " "
    30         text run at (0,0) width 29 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
     28      RenderText {#text} at (336,0) size 365x26
     29        text run at (336,0) width 1 RTL: " "
     30        text run at (336,0) width 29 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    3131        text run at (0,13) width 30: "hello!"
    3232        text run at (29,13) width 1: " "
     
    3535  RenderTextControl {TEXTAREA} at (2,134) size 371x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    3636    RenderBlock {DIV} at (3,3) size 365x39
    37       RenderText {#text} at (0,0) size 30x26
    38         text run at (0,0) width 0 RTL: " "
    39         text run at (0,0) width 29 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
     37      RenderText {#text} at (336,0) size 365x26
     38        text run at (336,0) width 1 RTL: " "
     39        text run at (336,0) width 29 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    4040        text run at (0,13) width 30: "hello!"
    4141        text run at (29,13) width 1: " "
     
    4444  RenderTextControl {TEXTAREA} at (2,200) size 371x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    4545    RenderBlock {DIV} at (3,3) size 365x39
    46       RenderText {#text} at (336,0) size 30x26
     46      RenderText {#text} at (336,0) size 365x26
    4747        text run at (336,0) width 1 RTL: " "
    4848        text run at (336,0) width 29 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}!"
    49         text run at (335,13) width 30: "hello!"
    50         text run at (365,13) width 0: " "
     49        text run at (0,13) width 30: "hello!"
     50        text run at (29,13) width 1: " "
    5151      RenderBR {BR} at (365,26) size 0x13
  • trunk/Source/WebCore/ChangeLog

    r164866 r164867  
     12014-02-28  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        paragraphs with different directionality in textarea with unicode-bidi: plaintext are aligned the same
     4        https://bugs.webkit.org/show_bug.cgi?id=71194
     5
     6        Reviewed by David Hyatt.
     7
     8        Merged from Blink r157263 by <igor.o@sisa.samsung.com>
     9        <https://src.chromium.org/viewvc/blink?revision=157263&view=revision>
     10
     11        In the css3-text spec (http://www.w3.org/TR/css3-text/#bidi-linebox):
     12
     13        The start and end edges of a line box are determined by the inline
     14        base direction of the line box. In most cases, this is given by
     15        its containing block's computed ‘direction’. However if its
     16        containing block has ‘unicode-bidi: plaintext’, the inline base
     17        direction the line box must be determined by the base direction of
     18        the bidi paragraph to which it belongs: that is, the bidi
     19        paragraph for which the line box holds content.
     20
     21        This patch just implements the behavior described above modifying
     22        updateLogicalWidthForAlignment and setting the bidi level of the
     23        RootInlineBox.
     24
     25        * rendering/RenderBlockFlow.h:
     26        * rendering/RenderBlockLineLayout.cpp:
     27        (WebCore::RenderBlockFlow::updateLogicalWidthForAlignment):
     28        (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
     29        (WebCore::RenderBlockFlow::createLineBoxesFromBidiRuns):
     30        (WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
     31        (WebCore::RenderBlockFlow::deleteEllipsisLineBoxes):
     32        (WebCore::RenderBlockFlow::checkLinesForTextOverflow):
     33        (WebCore::RenderBlockFlow::startAlignedOffsetForLine):
     34
    1352014-02-28  Jochen Eisinger  <jochen@chromium.org>
    236
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r164440 r164867  
    536536    void appendFloatingObjectToLastLine(FloatingObject*);
    537537    // Helper function for layoutInlineChildren()
    538     RootInlineBox* createLineBoxesFromBidiRuns(BidiRunList<BidiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun, WordMeasurements&);
     538    RootInlineBox* createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun, WordMeasurements&);
    539539    void layoutRunsAndFloats(LineLayoutState&, bool hasInlineChild);
    540540    const InlineIterator& restartLayoutRunsAndFloatsInRange(LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight,  FloatingObject* lastFloatFromPreviousLine, InlineBidiResolver&,  const InlineIterator&);
     
    561561    // line, i.e., that it can't be re-used.
    562562    bool lineWidthForPaginatedLineChanged(RootInlineBox*, LayoutUnit lineDelta, RenderFlowThread*) const;
    563     void updateLogicalWidthForAlignment(const ETextAlign&, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount);
     563    void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount);
    564564
    565565// END METHODS DEFINED IN RenderBlockLineLayout
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r164441 r164867  
    572572}
    573573
    574 void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount)
    575 {
     574void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign, const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount)
     575{
     576    TextDirection direction;
     577    if (rootInlineBox && style().unicodeBidi() == Plaintext)
     578        direction = rootInlineBox->direction();
     579    else
     580        direction = style().direction();
     581
    576582    // Armed with the total width of the line (without justification),
    577583    // we now examine our text-align property in order to determine where to position the
     
    602608        FALLTHROUGH;
    603609    case TASTART:
    604         if (style().isLeftToRightDirection())
     610        if (direction == LTR)
    605611            updateLogicalWidthForLeftAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    606612        else
     
    608614        break;
    609615    case TAEND:
    610         if (style().isLeftToRightDirection())
     616        if (direction == LTR)
    611617            updateLogicalWidthForRightAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    612618        else
     
    748754    }
    749755
    750     updateLogicalWidthForAlignment(textAlign, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount);
     756    updateLogicalWidthForAlignment(textAlign, lineBox, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount);
    751757
    752758    computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth);
     
    979985
    980986// This function constructs line boxes for all of the text runs in the resolver and computes their position.
    981 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, VerticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeasurements& wordMeasurements)
     987RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, VerticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeasurements& wordMeasurements)
    982988{
    983989    if (!bidiRuns.runCount())
     
    991997        return 0;
    992998
     999    lineBox->setBidiLevel(bidiLevel);
    9931000    lineBox->setEndsWithBreak(lineInfo.previousLineBrokeCleanly());
    9941001   
     
    13821389
    13831390            LayoutUnit oldLogicalHeight = logicalHeight();
    1384             RootInlineBox* lineBox = createLineBoxesFromBidiRuns(bidiRuns, end, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun, wordMeasurements);
     1391            RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status().context->level(), bidiRuns, end, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun, wordMeasurements);
    13851392
    13861393            bidiRuns.deleteRuns();
     
    20372044            float availableLogicalWidth = logicalRightOffsetForLine(curr->lineTop(), false) - logicalLeft;
    20382045            float totalLogicalWidth = curr->logicalWidth();
    2039             updateLogicalWidthForAlignment(textAlign, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
     2046            updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
    20402047
    20412048            if (ltr)
     
    20842091                float logicalLeft = 0; // We are only interested in the delta from the base position.
    20852092                float truncatedWidth = pixelSnappedLogicalRightOffsetForLine(curr->lineTop(), firstLine);
    2086                 updateLogicalWidthForAlignment(textAlign, 0, logicalLeft, totalLogicalWidth, truncatedWidth, 0);
     2093                updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, truncatedWidth, 0);
    20872094                if (ltr)
    20882095                    curr->adjustLogicalPosition(logicalLeft, 0);
     
    21662173    float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
    21672174    float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) - logicalLeft;
    2168     updateLogicalWidthForAlignment(textAlign, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
     2175
     2176    // FIXME: Bug 129311: We need to pass a valid RootInlineBox here, considering the bidi level used to construct the line.
     2177    updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
    21692178
    21702179    if (!style().isLeftToRightDirection())
Note: See TracChangeset for help on using the changeset viewer.