Changeset 125229 in webkit


Ignore:
Timestamp:
Aug 9, 2012 6:05:56 PM (12 years ago)
Author:
jchaffraix@webkit.org
Message:

REGRESSION(r117339): cell in block-level table in inline-block are aligned with their last line box
https://bugs.webkit.org/show_bug.cgi?id=91137

Reviewed by Tony Chang.

Source/WebCore:

Fixed the code to properly ignore any inline-table's baseline for the purpose of 'inline-block' baseline computation.
See http://lists.w3.org/Archives/Public/www-style/2012Jul/0721.html about the discussion.

While touching the code, properly fixed the table baseline logic that was wrong because it wrongly piggy-backed
on the inline-block baseline logic.

Tests: fast/table/anonymous-table-no-baseline-align.html

fast/table/inline-table-in-inline-block-last-baseline-align.html

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::baselinePosition):
Overrode this function: this is needed as RenderBlock assumes that isReplaced() == true
means it is handling an inline-block, not a table.

(WebCore::RenderTable::lastLineBoxBaseline):
Table are ignored for the purpose of inline-block baseline determination.

(WebCore::RenderTable::firstLineBoxBaseline):
Inlined the code from getLineBoxBaseline. Added some comments to explain
why this code works as expected in the 'table' case.

  • rendering/RenderTable.h:

Added baselinePosition.

LayoutTests:

  • fast/table/anonymous-table-no-baseline-align-expected.html: Added.
  • fast/table/anonymous-table-no-baseline-align.html: Added.
  • fast/table/inline-table-in-inline-block-last-baseline-align-expected.html: Added.
  • fast/table/inline-table-in-inline-block-last-baseline-align.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125215 r125229  
     12012-08-09  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        REGRESSION(r117339): cell in block-level table in inline-block are aligned with their last line box
     4        https://bugs.webkit.org/show_bug.cgi?id=91137
     5
     6        Reviewed by Tony Chang.
     7
     8        * fast/table/anonymous-table-no-baseline-align-expected.html: Added.
     9        * fast/table/anonymous-table-no-baseline-align.html: Added.
     10        * fast/table/inline-table-in-inline-block-last-baseline-align-expected.html: Added.
     11        * fast/table/inline-table-in-inline-block-last-baseline-align.html: Added.
     12
    1132012-08-09  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r125222 r125229  
     12012-08-09  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        REGRESSION(r117339): cell in block-level table in inline-block are aligned with their last line box
     4        https://bugs.webkit.org/show_bug.cgi?id=91137
     5
     6        Reviewed by Tony Chang.
     7
     8        Fixed the code to properly ignore any inline-table's baseline for the purpose of 'inline-block' baseline computation.
     9        See http://lists.w3.org/Archives/Public/www-style/2012Jul/0721.html about the discussion.
     10
     11        While touching the code, properly fixed the table baseline logic that was wrong because it wrongly piggy-backed
     12        on the inline-block baseline logic.
     13
     14        Tests: fast/table/anonymous-table-no-baseline-align.html
     15               fast/table/inline-table-in-inline-block-last-baseline-align.html
     16
     17        * rendering/RenderTable.cpp:
     18        (WebCore::RenderTable::baselinePosition):
     19        Overrode this function: this is needed as RenderBlock assumes that isReplaced() == true
     20        means it is handling an inline-block, not a table.
     21
     22        (WebCore::RenderTable::lastLineBoxBaseline):
     23        Table are ignored for the purpose of inline-block baseline determination.
     24
     25        (WebCore::RenderTable::firstLineBoxBaseline):
     26        Inlined the code from getLineBoxBaseline. Added some comments to explain
     27        why this code works as expected in the 'table' case.
     28
     29        * rendering/RenderTable.h:
     30        Added baselinePosition.
     31
    1322012-08-09  Adam Barth  <abarth@webkit.org>
    233
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r123779 r125229  
    12071207}
    12081208
    1209 enum LineBox { FirstLineBox, LastLineBox };
    1210 
    1211 static LayoutUnit getLineBoxBaseline(const RenderTable* table, LineBox lineBox)
    1212 {
    1213     if (table->isWritingModeRoot())
     1209LayoutUnit RenderTable::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
     1210{
     1211    LayoutUnit baseline = firstLineBoxBaseline();
     1212    if (baseline != -1)
     1213        return baseline;
     1214
     1215    return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
     1216}
     1217
     1218LayoutUnit RenderTable::lastLineBoxBaseline() const
     1219{
     1220    // Tables don't contribute their baseline towards the computation of an inline-block's baseline.
     1221    return -1;
     1222}
     1223
     1224LayoutUnit RenderTable::firstLineBoxBaseline() const
     1225{
     1226    // The baseline of a 'table' is the same as the 'inline-table' baseline per CSS 3 Flexbox (CSS 2.1
     1227    // doesn't define the baseline of a 'table' only an 'inline-table').
     1228    // This is also needed to properly determine the baseline of a cell if it has a table child.
     1229
     1230    if (isWritingModeRoot())
    12141231        return -1;
    12151232
    1216     table->recalcSectionsIfNeeded();
    1217 
    1218     const RenderTableSection* topNonEmptySection = table->topNonEmptySection();
     1233    recalcSectionsIfNeeded();
     1234
     1235    const RenderTableSection* topNonEmptySection = this->topNonEmptySection();
    12191236    if (!topNonEmptySection)
    12201237        return -1;
     
    12241241        return topNonEmptySection->logicalTop() + baseline;
    12251242
    1226     // The 'first' linebox baseline in a table in the absence of any text in the first section
    1227     // is the top of the table.
    1228     if (lineBox == FirstLineBox)
    1229         return topNonEmptySection->logicalTop();
    1230 
    1231     // The 'last' linebox baseline in a table is the baseline of text in the first
    1232     // cell in the first row/section, so if there is no text do not return a baseline.
     1243    // FIXME: A table row always has a baseline per CSS 2.1. Will this return the right value?
    12331244    return -1;
    1234 }
    1235 
    1236 LayoutUnit RenderTable::lastLineBoxBaseline() const
    1237 {
    1238     return getLineBoxBaseline(this, LastLineBox);
    1239 }
    1240 
    1241 LayoutUnit RenderTable::firstLineBoxBaseline() const
    1242 {
    1243     return getLineBoxBaseline(this, FirstLineBox);
    12441245}
    12451246
  • trunk/Source/WebCore/rendering/RenderTable.h

    r123062 r125229  
    252252    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
    253253
     254    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
    254255    virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE;
    255256    virtual LayoutUnit lastLineBoxBaseline() const OVERRIDE;
Note: See TracChangeset for help on using the changeset viewer.