Changeset 77267 in webkit


Ignore:
Timestamp:
Feb 1, 2011 12:02:06 PM (13 years ago)
Author:
xji@chromium.org
Message:

2011-02-01 Xiaomei Ji <xji@chromium.org>

Reviewed by David Hyatt.

Fix a text rendering problem when enclosing block is RTL and text runs
are in different directionality.
https://bugs.webkit.org/show_bug.cgi?id=34176

The problem happens in the following example scenario (ABC represents
Hebrew characters):
<div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>

The line consists of 3 text runs -- TextRun1 TextRun2 TextRun3. In which
TextRun1 and TextRun2's bidi level are 2, and TextRun3's bidi level is 1.
TextRun2 and TextRun3's least common ancestor is not a sibling of TextRun1.

The visual bidi run order of the text runs is TextRun3 TextRun1 TextRun2.

Inside RenderBlock::constructLine(), when RenderBlock::createLineBoxes()
creates InlineFlowBox for TextRun2, it should check an InlineFlowBox for
the run's render object's ancestor (not only its parent) has already
been constructed or has something following it on the line, in which
case, create a new box for TextRun2 instead of sharing the same box with
TextRun3.

In other words, the following 2 div should render the same results
(ABC represents Hebrew characters).
<div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>
<div dir=rtl>this is a <span>Test <span>ABC</span></span></div>

Test: fast/dom/34176.html

  • rendering/RenderBlockLineLayout.cpp: (WebCore::parentIsConstructedOrHaveNext): (WebCore::RenderBlock::createLineBoxes):

2011-02-01 Xiaomei Ji <xji@chromium.org>

Reviewed by David Hyatt.

Fix a text rendering problem when enclosing block is RTL and text runs
are in different directionality.
https://bugs.webkit.org/show_bug.cgi?id=34176

The problem happens in the following example scenario (ABC represents
Hebrew characters):
<div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>

The line consists of 3 text runs -- TextRun1 TextRun2 TextRun3. In which
TextRun1 and TextRun2's bidi level are 2, and TextRun3's bidi level is 1.
TextRun2 and TextRun3's least common ancestor is not a sibling of TextRun1.

The visual bidi run order of the text runs is TextRun3 TextRun1 TextRun2.

Inside RenderBlock::constructLine(), when RenderBlock::createLineBoxes()
creates InlineFlowBox for TextRun2, it should check an InlineFlowBox for
the run's render object's ancestor (not only its parent) has already
been constructed or has something following it on the line, in which
case, create a new box for TextRun2 instead of sharing the same box with
TextRun3.

In other words, the following 2 div should render the same results
(ABC represents Hebrew characters).
<div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>
<div dir=rtl>this is a <span>Test <span>ABC</span></span></div>

  • fast/dom/34176.html: Added.
  • platform/mac/fast/dom/34176-expected.checksum: Added.
  • platform/mac/fast/dom/34176-expected.png: Added.
  • platform/mac/fast/dom/34176-expected.txt: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r77263 r77267  
     12011-02-01  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Fix a text rendering problem when enclosing block is RTL and text runs
     6        are in different directionality.
     7        https://bugs.webkit.org/show_bug.cgi?id=34176
     8
     9        The problem happens in the following example scenario (ABC represents
     10        Hebrew characters):
     11        <div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>
     12
     13        The line consists of 3 text runs -- TextRun1 TextRun2 TextRun3. In which
     14        TextRun1 and TextRun2's bidi level are 2, and TextRun3's bidi level is 1.
     15        TextRun2 and TextRun3's least common ancestor is not a sibling of TextRun1.
     16
     17        The visual bidi run order of the text runs is TextRun3 TextRun1 TextRun2.
     18
     19        Inside RenderBlock::constructLine(), when RenderBlock::createLineBoxes()
     20        creates InlineFlowBox for TextRun2, it should check an InlineFlowBox for
     21        the run's render object's ancestor (not only its parent) has already
     22        been constructed or has something following it on the line, in which
     23        case, create a new box for TextRun2 instead of sharing the same box with
     24        TextRun3.
     25
     26        In other words, the following 2 div should render the same results
     27        (ABC represents Hebrew characters).
     28        <div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>
     29        <div dir=rtl>this is a <span>Test <span>ABC</span></span></div>
     30
     31        * fast/dom/34176.html: Added.
     32        * platform/mac/fast/dom/34176-expected.checksum: Added.
     33        * platform/mac/fast/dom/34176-expected.png: Added.
     34        * platform/mac/fast/dom/34176-expected.txt: Added.
     35
    1362011-02-01  Mihai Parparita  <mihaip@chromium.org>
    237
  • trunk/Source/WebCore/ChangeLog

    r77262 r77267  
     12011-02-01  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Fix a text rendering problem when enclosing block is RTL and text runs
     6        are in different directionality.
     7        https://bugs.webkit.org/show_bug.cgi?id=34176
     8
     9        The problem happens in the following example scenario (ABC represents
     10        Hebrew characters):
     11        <div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>
     12
     13        The line consists of 3 text runs -- TextRun1 TextRun2 TextRun3. In which
     14        TextRun1 and TextRun2's bidi level are 2, and TextRun3's bidi level is 1.
     15        TextRun2 and TextRun3's least common ancestor is not a sibling of TextRun1.
     16
     17        The visual bidi run order of the text runs is TextRun3 TextRun1 TextRun2.
     18
     19        Inside RenderBlock::constructLine(), when RenderBlock::createLineBoxes()
     20        creates InlineFlowBox for TextRun2, it should check an InlineFlowBox for
     21        the run's render object's ancestor (not only its parent) has already
     22        been constructed or has something following it on the line, in which
     23        case, create a new box for TextRun2 instead of sharing the same box with
     24        TextRun3.
     25
     26        In other words, the following 2 div should render the same results
     27        (ABC represents Hebrew characters).
     28        <div dir=rtl>this is a <span><span>test <span>ABC</span></span></span></div>
     29        <div dir=rtl>this is a <span>Test <span>ABC</span></span></div>
     30
     31        Test: fast/dom/34176.html
     32
     33        * rendering/RenderBlockLineLayout.cpp:
     34        (WebCore::parentIsConstructedOrHaveNext):
     35        (WebCore::RenderBlock::createLineBoxes):
     36
    1372011-02-01  Abhishek Arya  <inferno@chromium.org>
    238
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r77153 r77267  
    185185}
    186186
     187static bool parentIsConstructedOrHaveNext(InlineFlowBox* parentBox)
     188{
     189    do {
     190        if (parentBox->isConstructed() || parentBox->nextOnLine())
     191            return true;
     192        parentBox = parentBox->parent();
     193    } while (parentBox);
     194    return false;
     195}
     196
    187197InlineFlowBox* RenderBlock::createLineBoxes(RenderObject* obj, bool firstLine)
    188198{
     
    199209        parentBox = obj->isRenderInline() ? toRenderInline(obj)->lastLineBox() : toRenderBlock(obj)->lastLineBox();
    200210
    201         // If this box is constructed then it is from a previous line, and we need
    202         // to make a new box for our line.  If this box is unconstructed but it has
     211        // If this box or its ancestor is constructed then it is from a previous line, and we need
     212        // to make a new box for our line.  If this box or its ancestor is unconstructed but it has
    203213        // something following it on the line, then we know we have to make a new box
    204214        // as well.  In this situation our inline has actually been split in two on
    205215        // the same line (this can happen with very fancy language mixtures).
    206216        bool constructedNewBox = false;
    207         if (!parentBox || parentBox->isConstructed() || parentBox->nextOnLine()) {
     217        if (!parentBox || parentIsConstructedOrHaveNext(parentBox)) {
    208218            // We need to make a new box for this render object.  Once
    209219            // made, we need to place it at the end of the current line.
Note: See TracChangeset for help on using the changeset viewer.