Changeset 132104 in webkit


Ignore:
Timestamp:
Oct 22, 2012 10:45:33 AM (12 years ago)
Author:
tony@chromium.org
Message:

Fix some baseline flexbox alignment
https://bugs.webkit.org/show_bug.cgi?id=99879

Reviewed by Ojan Vafai.

Source/WebCore:

Fix a bug where we weren't handling margin properly on inline-flexbox.
Fix a bug where we weren't getting the edge of the content box properly when synthesizing
a baseline.

Test: css3/flexbox/flexbox-baseline-margins.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::baselinePosition):
(WebCore::RenderBlock::inlineBlockBaseline): Add a new method that is used when calculating an inline-block's
baseline. Previously we would use lastLineBoxBaseline.
(WebCore::RenderBlock::lastLineBoxBaseline): Pass in direction and when searching children, use inlineBlockBaseline.

  • rendering/RenderBlock.h:

(RenderBlock): Make lastLineBoxBaseline non-virtual.

  • rendering/RenderBox.h:

(WebCore::RenderBox::inlineBlockBaseline): Replace lastLineBoxBaseline with inlineBlockBaseline.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::synthesizedBaselineFromContentBox): Helper method for getting the baseline from the content box.
(WebCore::RenderFlexibleBox::baselinePosition): Always include the margin. This fixes the inline-flexbox case.
(WebCore::RenderFlexibleBox::firstLineBoxBaseline): Fix a case where we didn't synthesize a baseline. Returning -1 means there is no baseline, but we can
synthesize a baseline if we have a flexitem without text.
(WebCore::RenderFlexibleBox::inlineBlockBaseline):

  • rendering/RenderFlexibleBox.h:
  • rendering/RenderTable.cpp: Replace lastLineBoxBaseline with inlineBlockBaseline.

(WebCore::RenderTable::inlineBlockBaseline): Try to make comment more direct.

  • rendering/RenderTable.h:

(RenderTable): Replace lastLineBoxBaseline with inlineBlockBaseline.

LayoutTests:

Additional test cases for baseline aligning flexbox.

  • css3/flexbox/flexbox-baseline-margins.html: Added.
  • css3/flexbox/resources/flexbox.css:

(.flex-one): New cross browser value.

  • platform/chromium-linux/css3/flexbox/flexbox-baseline-margins-expected.png: Added.
  • platform/chromium-linux/css3/flexbox/flexbox-baseline-margins-expected.txt: Added.
  • platform/chromium/TestExpectations:
  • platform/efl/TestExpectations:
  • platform/gtk/TestExpectations:
  • platform/mac/TestExpectations:
  • platform/qt/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r132103 r132104  
     12012-10-22  Tony Chang  <tony@chromium.org>
     2
     3        Fix some baseline flexbox alignment
     4        https://bugs.webkit.org/show_bug.cgi?id=99879
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Additional test cases for baseline aligning flexbox.
     9
     10        * css3/flexbox/flexbox-baseline-margins.html: Added.
     11        * css3/flexbox/resources/flexbox.css:
     12        (.flex-one): New cross browser value.
     13        * platform/chromium-linux/css3/flexbox/flexbox-baseline-margins-expected.png: Added.
     14        * platform/chromium-linux/css3/flexbox/flexbox-baseline-margins-expected.txt: Added.
     15        * platform/chromium/TestExpectations:
     16        * platform/efl/TestExpectations:
     17        * platform/gtk/TestExpectations:
     18        * platform/mac/TestExpectations:
     19        * platform/qt/TestExpectations:
     20        * platform/win/TestExpectations:
     21
    1222012-10-22  Tony Chang  <tony@chromium.org>
    223
  • trunk/LayoutTests/css3/flexbox/resources/flexbox.css

    r130457 r132104  
    1515    -webkit-flex: auto;
    1616    -moz-flex: auto;
     17}
     18.flex-one {
     19    -webkit-flex: 1;
     20    -moz-flex: 1;
    1721}
    1822
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r132043 r132104  
    40354035webkit.org/b/99421 platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-appearance.html [ Pass ImageOnlyFailure ]
    40364036
     4037webkit.org/b/99878 [ Mac Win ] css3/flexbox/flexbox-baseline-margins.html [ Missing ImageOnlyFailure ]
     4038
    40374039# Flaky crashing on debug
    40384040webkit.org/b/99604 [ Mac Win ] http/tests/workers/text-encoding.html [ Pass Crash ]
  • trunk/LayoutTests/platform/efl/TestExpectations

    r131984 r132104  
    19671967webkit.org/b/98587 fast/writing-mode/vertical-subst-font-vert-no-dflt.html [ ImageOnlyFailure ]
    19681968
     1969webkit.org/b/99878 css3/flexbox/flexbox-baseline-margins.html [ Missing ImageOnlyFailure ]
     1970
    19691971# Needs rebaseline eventually
    19701972webkit.org/b/97990 mathml/presentation/attributes.xhtml [ Failure ]
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r132082 r132104  
    13581358webkit.org/b/98587 fast/writing-mode/vertical-subst-font-vert-no-dflt.html [ ImageOnlyFailure ]
    13591359
     1360webkit.org/b/99878 css3/flexbox/flexbox-baseline-margins.html [ Missing ImageOnlyFailure ]
     1361
    13601362webkit.org/b/98612 [ Release ] fast/dom/gc-dom-tree-lifetime.html [ Failure ]
    13611363
  • trunk/LayoutTests/platform/mac/TestExpectations

    r132043 r132104  
    12991299webkit.org/b/86146 css3/supports.html
    13001300
     1301webkit.org/b/99878 css3/flexbox/flexbox-baseline-margins.html [ Missing ImageOnlyFailure ]
     1302
    13011303# Asserts in MessagePort::contextDestroyed, but the assert usually gets attributed to later tests.
    13021304webkit.org/b/94458 fast/events/message-port-constructor-for-deleted-document.html
  • trunk/LayoutTests/platform/qt/TestExpectations

    r132053 r132104  
    24152415webkit.org/b/90951 fast/text/shaping
    24162416
     2417webkit.org/b/99878 css3/flexbox/flexbox-baseline-margins.html [ Missing ImageOnlyFailure ]
     2418
    24172419# Flaky tests
    24182420webkit.org/b/91376 http/tests/security/sandboxed-iframe-modify-self.html [ Failure Pass ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r132103 r132104  
    23322332#https://bugs.webkit.org/show_bug.cgi?id=98306
    23332333css3/flexbox/flexbox-baseline.html
     2334#https://bugs.webkit.org/show_bug.cgi?id=99878
     2335css3/flexbox/flexbox-baseline-margins.html
    23342336
    23352337# css3-conditionals support is not yet enabled. http://webkit.org/b/86146
  • trunk/Source/WebCore/ChangeLog

    r132102 r132104  
     12012-10-22  Tony Chang  <tony@chromium.org>
     2
     3        Fix some baseline flexbox alignment
     4        https://bugs.webkit.org/show_bug.cgi?id=99879
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Fix a bug where we weren't handling margin properly on inline-flexbox.
     9        Fix a bug where we weren't getting the edge of the content box properly when synthesizing
     10        a baseline.
     11
     12        Test: css3/flexbox/flexbox-baseline-margins.html
     13
     14        * rendering/RenderBlock.cpp:
     15        (WebCore::RenderBlock::baselinePosition):
     16        (WebCore::RenderBlock::inlineBlockBaseline): Add a new method that is used when calculating an inline-block's
     17        baseline. Previously we would use lastLineBoxBaseline.
     18        (WebCore::RenderBlock::lastLineBoxBaseline): Pass in direction and when searching children, use inlineBlockBaseline.
     19        * rendering/RenderBlock.h:
     20        (RenderBlock): Make lastLineBoxBaseline non-virtual.
     21        * rendering/RenderBox.h:
     22        (WebCore::RenderBox::inlineBlockBaseline): Replace lastLineBoxBaseline with inlineBlockBaseline.
     23        * rendering/RenderFlexibleBox.cpp:
     24        (WebCore::synthesizedBaselineFromContentBox): Helper method for getting the baseline from the content box.
     25        (WebCore::RenderFlexibleBox::baselinePosition): Always include the margin. This fixes the inline-flexbox case.
     26        (WebCore::RenderFlexibleBox::firstLineBoxBaseline): Fix a case where we didn't synthesize a baseline.  Returning -1 means there is no baseline, but we can
     27        synthesize a baseline if we have a flexitem without text.
     28        (WebCore::RenderFlexibleBox::inlineBlockBaseline):
     29        * rendering/RenderFlexibleBox.h:
     30        * rendering/RenderTable.cpp: Replace lastLineBoxBaseline with inlineBlockBaseline.
     31        (WebCore::RenderTable::inlineBlockBaseline): Try to make comment more direct.
     32        * rendering/RenderTable.h:
     33        (RenderTable): Replace lastLineBoxBaseline with inlineBlockBaseline.
     34
    1352012-10-22  Levi Weintraub  <leviw@chromium.org>
    236
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r131971 r132104  
    62066206            : (layer()->horizontalScrollbar() || layer()->scrollXOffset() != 0)))) || (isWritingModeRoot() && !isRubyRun());
    62076207       
    6208         LayoutUnit baselinePos = ignoreBaseline ? static_cast<LayoutUnit>(-1) : lastLineBoxBaseline();
     6208        LayoutUnit baselinePos = ignoreBaseline ? static_cast<LayoutUnit>(-1) : inlineBlockBaseline(direction);
    62096209       
    62106210        LayoutUnit bottomOfContent = direction == HorizontalLine ? borderTop() + paddingTop() + contentHeight() : borderRight() + paddingRight() + contentWidth();
     
    62436243}
    62446244
    6245 LayoutUnit RenderBlock::lastLineBoxBaseline() const
     6245LayoutUnit RenderBlock::inlineBlockBaseline(LineDirectionMode direction) const
     6246{
     6247    return lastLineBoxBaseline(direction);
     6248}
     6249
     6250LayoutUnit RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const
    62466251{
    62476252    if (!isBlockFlow() || (isWritingModeRoot() && !isRubyRun()))
    62486253        return -1;
    6249 
    6250     LineDirectionMode lineDirection = isHorizontalWritingMode() ? HorizontalLine : VerticalLine;
    62516254
    62526255    if (childrenInline()) {
     
    62656268            if (!curr->isFloatingOrOutOfFlowPositioned()) {
    62666269                haveNormalFlowChild = true;
    6267                 LayoutUnit result = curr->lastLineBoxBaseline();
     6270                LayoutUnit result = curr->inlineBlockBaseline(lineDirection);
    62686271                if (result != -1)
    62696272                    return curr->logicalTop() + result; // Translate to our coordinate space.
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r131526 r132104  
    465465
    466466    virtual LayoutUnit firstLineBoxBaseline() const;
    467     virtual LayoutUnit lastLineBoxBaseline() const;
     467    virtual LayoutUnit inlineBlockBaseline(LineDirectionMode) const OVERRIDE;
     468    LayoutUnit lastLineBoxBaseline(LineDirectionMode) const;
    468469
    469470    virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
  • trunk/Source/WebCore/rendering/RenderBox.h

    r131348 r132104  
    474474   
    475475    virtual LayoutUnit firstLineBoxBaseline() const { return -1; }
    476     virtual LayoutUnit lastLineBoxBaseline() const { return -1; }
     476    virtual LayoutUnit inlineBlockBaseline(LineDirectionMode) const { return -1; } // Returns -1 if we should skip this box when computing the baseline of an inline-block.
    477477
    478478    bool shrinkToAvoidFloats() const;
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r131972 r132104  
    236236}
    237237
    238 LayoutUnit RenderFlexibleBox::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
     238static LayoutUnit synthesizedBaselineFromContentBox(const RenderBox* box, LineDirectionMode direction)
     239{
     240    return direction == HorizontalLine ? box->borderTop() + box->paddingTop() + box->contentHeight() : box->borderRight() + box->paddingRight() + box->contentWidth();
     241}
     242
     243LayoutUnit RenderFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode direction, LinePositionMode) const
    239244{
    240245    LayoutUnit baseline = firstLineBoxBaseline();
    241     if (baseline != -1) {
    242         LayoutUnit marginAscent = direction == HorizontalLine ? marginTop() : marginRight();
    243         return baseline + marginAscent;
    244     }
    245 
    246     return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
     246    if (baseline == -1)
     247        baseline = synthesizedBaselineFromContentBox(this, direction);
     248
     249    LayoutUnit marginAscent = direction == HorizontalLine ? marginTop() : marginRight();
     250    return baseline + marginAscent;
    247251}
    248252
     
    275279
    276280    LayoutUnit baseline = baselineChild->firstLineBoxBaseline();
    277     if (baseline == -1)
    278         return -1;
     281    if (baseline == -1) {
     282        // FIXME: We should pass |direction| into firstLineBoxBaseline and stop bailing out if we're a writing mode root.
     283        // This would also fix some cases where the flexbox is orthogonal to its container.
     284        LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine : VerticalLine;
     285        return synthesizedBaselineFromContentBox(baselineChild, direction) + baselineChild->logicalTop();
     286    }
    279287
    280288    return baseline + baselineChild->logicalTop();
     289}
     290
     291LayoutUnit RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const
     292{
     293    LayoutUnit baseline = firstLineBoxBaseline();
     294    if (baseline != -1)
     295        return baseline;
     296
     297    LayoutUnit marginAscent = direction == HorizontalLine ? marginTop() : marginRight();
     298    return synthesizedBaselineFromContentBox(this, direction) + marginAscent;
    281299}
    282300
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r130714 r132104  
    5252    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
    5353    virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE;
     54    virtual LayoutUnit inlineBlockBaseline(LineDirectionMode) const OVERRIDE;
    5455
    5556    virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect) OVERRIDE;
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r131938 r132104  
    12301230}
    12311231
    1232 LayoutUnit RenderTable::lastLineBoxBaseline() const
    1233 {
    1234     // Tables don't contribute their baseline towards the computation of an inline-block's baseline.
     1232LayoutUnit RenderTable::inlineBlockBaseline(LineDirectionMode) const
     1233{
     1234    // Tables are skipped when computing an inline-block's baseline.
    12351235    return -1;
    12361236}
  • trunk/Source/WebCore/rendering/RenderTable.h

    r131465 r132104  
    280280    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
    281281    virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE;
    282     virtual LayoutUnit lastLineBoxBaseline() const OVERRIDE;
     282    virtual LayoutUnit inlineBlockBaseline(LineDirectionMode) const OVERRIDE;
    283283
    284284    RenderTableCol* slowColElement(unsigned col, bool* startEdge, bool* endEdge) const;
Note: See TracChangeset for help on using the changeset viewer.