Changeset 128155 in webkit


Ignore:
Timestamp:
Sep 11, 2012 1:07:36 AM (12 years ago)
Author:
mihnea@adobe.com
Message:

[CSS Regions] Auto width is not working for Regions
https://bugs.webkit.org/show_bug.cgi?id=74135

Reviewed by Julien Chaffraix.

Source/WebCore:

It was not possible to flow content into a region having { width: auto; } since in such case, the region width was computed to 0.
Now, a region having auto width, will have its width computed following the rules for calculation of widths and margins
(http://www.w3.org/TR/CSS2/visudet.html#Computing_widths_and_margins).
For those cases in which resolving the width requires measuring of content's min/max-content values, we use the associated named flow min/max-content
values (the same for all regions with width auto in a region chain).
When a region has width:auto, the computation of width should be done using normal block/box sizing code, instead of replaced element code.
Contains code contributed by Alexandru Chiculita(Alexandru Chiculita).

Tests: fast/regions/autowidth-abspos-regionchain.html

fast/regions/autowidth-abspos.html
fast/regions/autowidth-attachedinvalidregion.html
fast/regions/autowidth-float.html
fast/regions/autowidth-inlineblock.html
fast/regions/autowidth-nonreplaced-abspos.html
fast/regions/autowidth-nonreplacedblock-normalflow.html
fast/regions/autowidth-normalflow-maxwidth.html
fast/regions/autowidth-normalflow-minmaxwidth.html
fast/regions/autowidth-normalflow-minwidth.html
fast/regions/autowidth-normalflow-vertrl.html
fast/regions/autowidth-normalflow.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::computePositionedLogicalWidth): For positioned auto-width regions, skip the code path for replaced elements.

  • rendering/RenderRegion.cpp:

(WebCore): Override min/maxPreferredLogicalWidth as they are used in the process of computing width for regions with auto width.
As this moment, a region is still a RenderReplaced element, so this code needs to be revisited when the region will become a RenderBlock.
Also, for min/max-width, we support only <length> values. We will extend support for other values in a following patch.
We only attempt to use the flowThread min/maxPreferredLogicalWidth if the region is valid (there are no circular dependencies).
(WebCore::RenderRegion::minPreferredLogicalWidth):
(WebCore::RenderRegion::maxPreferredLogicalWidth):

  • rendering/RenderRegion.h:

(RenderRegion): Override isInlineBlockOrInlineTable() and shouldComputeSizeAsReplaced() to ensure that computation for width auto follows the normal
block/box sizing code.
(WebCore::RenderRegion::expandToEncompassFlowThreadContentsIfNeeded):

LayoutTests:

Add tests for width: auto and modify the existing region tests that were having width: auto so that they do not fail after the changes.

  • fast/regions/autowidth-abspos-expected.html: Added.
  • fast/regions/autowidth-abspos-regionchain-expected.html: Added.
  • fast/regions/autowidth-abspos-regionchain.html: Added.
  • fast/regions/autowidth-abspos.html: Added.
  • fast/regions/autowidth-attachedinvalidregion-expected.txt: Added.
  • fast/regions/autowidth-attachedinvalidregion.html: Added.
  • fast/regions/autowidth-float-expected.html: Added.
  • fast/regions/autowidth-float.html: Added.
  • fast/regions/autowidth-inlineblock-expected.html: Added.
  • fast/regions/autowidth-inlineblock.html: Added.
  • fast/regions/autowidth-nonreplaced-abspos-expected.html: Added.
  • fast/regions/autowidth-nonreplaced-abspos.html: Added.
  • fast/regions/autowidth-nonreplacedblock-normalflow-expected.html: Added.
  • fast/regions/autowidth-nonreplacedblock-normalflow.html: Added.
  • fast/regions/autowidth-normalflow-expected.html: Added.
  • fast/regions/autowidth-normalflow-maxwidth-expected.html: Added.
  • fast/regions/autowidth-normalflow-maxwidth.html: Added.
  • fast/regions/autowidth-normalflow-minmaxwidth-expected.html: Added.
  • fast/regions/autowidth-normalflow-minmaxwidth.html: Added.
  • fast/regions/autowidth-normalflow-minwidth-expected.html: Added.
  • fast/regions/autowidth-normalflow-minwidth.html: Added.
  • fast/regions/autowidth-normalflow-vertrl-expected.html: Added.
  • fast/regions/autowidth-normalflow-vertrl.html: Added.
  • fast/regions/autowidth-normalflow.html: Added.
  • fast/regions/bottom-overflow-out-of-first-region.html:
  • fast/regions/flows-dependency-dynamic-remove.html:
  • fast/regions/flows-dependency-same-flow.html:
  • fast/regions/render-region-renderer-expected.html:
  • fast/regions/top-overflow-out-of-second-region.html:
Location:
trunk
Files:
24 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r128152 r128155  
     12012-09-11  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSS Regions] Auto width is not working for Regions
     4        https://bugs.webkit.org/show_bug.cgi?id=74135
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Add tests for width: auto and modify the existing region tests that were having width: auto so that they do not fail after the changes.
     9
     10        * fast/regions/autowidth-abspos-expected.html: Added.
     11        * fast/regions/autowidth-abspos-regionchain-expected.html: Added.
     12        * fast/regions/autowidth-abspos-regionchain.html: Added.
     13        * fast/regions/autowidth-abspos.html: Added.
     14        * fast/regions/autowidth-attachedinvalidregion-expected.txt: Added.
     15        * fast/regions/autowidth-attachedinvalidregion.html: Added.
     16        * fast/regions/autowidth-float-expected.html: Added.
     17        * fast/regions/autowidth-float.html: Added.
     18        * fast/regions/autowidth-inlineblock-expected.html: Added.
     19        * fast/regions/autowidth-inlineblock.html: Added.
     20        * fast/regions/autowidth-nonreplaced-abspos-expected.html: Added.
     21        * fast/regions/autowidth-nonreplaced-abspos.html: Added.
     22        * fast/regions/autowidth-nonreplacedblock-normalflow-expected.html: Added.
     23        * fast/regions/autowidth-nonreplacedblock-normalflow.html: Added.
     24        * fast/regions/autowidth-normalflow-expected.html: Added.
     25        * fast/regions/autowidth-normalflow-maxwidth-expected.html: Added.
     26        * fast/regions/autowidth-normalflow-maxwidth.html: Added.
     27        * fast/regions/autowidth-normalflow-minmaxwidth-expected.html: Added.
     28        * fast/regions/autowidth-normalflow-minmaxwidth.html: Added.
     29        * fast/regions/autowidth-normalflow-minwidth-expected.html: Added.
     30        * fast/regions/autowidth-normalflow-minwidth.html: Added.
     31        * fast/regions/autowidth-normalflow-vertrl-expected.html: Added.
     32        * fast/regions/autowidth-normalflow-vertrl.html: Added.
     33        * fast/regions/autowidth-normalflow.html: Added.
     34        * fast/regions/bottom-overflow-out-of-first-region.html:
     35        * fast/regions/flows-dependency-dynamic-remove.html:
     36        * fast/regions/flows-dependency-same-flow.html:
     37        * fast/regions/render-region-renderer-expected.html:
     38        * fast/regions/top-overflow-out-of-second-region.html:
     39
    1402012-09-11  Zan Dobersek  <zandobersek@gmail.com>
    241
  • trunk/LayoutTests/fast/regions/bottom-overflow-out-of-first-region.html

    r127684 r128155  
    3434    }
    3535
     36    #region3 {
     37        width: 0px;
     38        height: 0px;
     39    }
    3640</style>
    3741
  • trunk/LayoutTests/fast/regions/flows-dependency-dynamic-remove.html

    r127684 r128155  
    99.regionFlowB { -webkit-flow-from: flowB; }
    1010.regionFlowC { -webkit-flow-from: flowC; }
     11
     12.regionFlowA, .regionFlowB, .regionFlowC { width: 0px; height: 0px; }
    1113</style>
    1214
  • trunk/LayoutTests/fast/regions/flows-dependency-same-flow.html

    r127684 r128155  
    99.regionFlowB { -webkit-flow-from: flowB; }
    1010.regionFlowC { -webkit-flow-from: flowC; }
     11
     12.regionFlowA, .regionFlowB, .regionFlowC { width: 0px; height: 0px; }
    1113</style>
    1214
  • trunk/LayoutTests/fast/regions/render-region-renderer-expected.html

    r127684 r128155  
    1515    .size1
    1616    {
    17         width:0.5px;
    1817        height:0.5px;
    1918    }
  • trunk/LayoutTests/fast/regions/top-overflow-out-of-second-region.html

    r127684 r128155  
    3434    }
    3535
     36    #region3 {
     37        width: 0px;
     38        height: 0px;
     39    }
    3640</style>
    3741
  • trunk/Source/WebCore/ChangeLog

    r128153 r128155  
     12012-09-11  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSS Regions] Auto width is not working for Regions
     4        https://bugs.webkit.org/show_bug.cgi?id=74135
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        It was not possible to flow content into a region having { width: auto; } since in such case, the region width was computed to 0.
     9        Now, a region having auto width, will have its width computed following the rules for calculation of widths and margins
     10        (http://www.w3.org/TR/CSS2/visudet.html#Computing_widths_and_margins).
     11        For those cases in which resolving the width requires measuring of content's min/max-content values, we use the associated named flow min/max-content
     12        values (the same for all regions with width auto in a region chain).
     13        When a region has width:auto, the computation of width should be done using normal block/box sizing code, instead of replaced element code.
     14        Contains code contributed by Alexandru Chiculita(achicu@adobe.com).
     15
     16        Tests: fast/regions/autowidth-abspos-regionchain.html
     17               fast/regions/autowidth-abspos.html
     18               fast/regions/autowidth-attachedinvalidregion.html
     19               fast/regions/autowidth-float.html
     20               fast/regions/autowidth-inlineblock.html
     21               fast/regions/autowidth-nonreplaced-abspos.html
     22               fast/regions/autowidth-nonreplacedblock-normalflow.html
     23               fast/regions/autowidth-normalflow-maxwidth.html
     24               fast/regions/autowidth-normalflow-minmaxwidth.html
     25               fast/regions/autowidth-normalflow-minwidth.html
     26               fast/regions/autowidth-normalflow-vertrl.html
     27               fast/regions/autowidth-normalflow.html
     28
     29        * rendering/RenderBox.cpp:
     30        (WebCore::RenderBox::computePositionedLogicalWidth): For positioned auto-width regions, skip the code path for replaced elements.
     31        * rendering/RenderRegion.cpp:
     32        (WebCore): Override min/maxPreferredLogicalWidth as they are used in the process of computing width for regions with auto width.
     33        As this moment, a region is still a RenderReplaced element, so this code needs to be revisited when the region will become a RenderBlock.
     34        Also, for min/max-width, we support only <length> values. We will extend support for other values in a following patch.
     35        We only attempt to use the flowThread min/maxPreferredLogicalWidth if the region is valid (there are no circular dependencies).
     36        (WebCore::RenderRegion::minPreferredLogicalWidth):
     37        (WebCore::RenderRegion::maxPreferredLogicalWidth):
     38        * rendering/RenderRegion.h:
     39        (RenderRegion): Override isInlineBlockOrInlineTable() and shouldComputeSizeAsReplaced() to ensure that computation for width auto follows the normal
     40        block/box sizing code.
     41        (WebCore::RenderRegion::expandToEncompassFlowThreadContentsIfNeeded):
     42
    1432012-09-10  Ilya Tikhonovsky  <loislo@chromium.org>
    244
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r128130 r128155  
    25362536{
    25372537    if (isReplaced()) {
    2538         computePositionedLogicalWidthReplaced(computedValues); // FIXME: Patch for regions when we add replaced element support.
    2539         return;
     2538        // FIXME: For regions with width auto, we want to compute width using the normal block sizing code.
     2539        // For now, regions are replaced elements and this code can be removed once the RenderRegion
     2540        // will inherit from RenderBlock instead of RenderReplaced.
     2541        // (see https://bugs.webkit.org/show_bug.cgi?id=74132 )
     2542        if (!isRenderRegion() || (isRenderRegion() && shouldComputeSizeAsReplaced())) {
     2543            computePositionedLogicalWidthReplaced(computedValues); // FIXME: Patch for regions when we add replaced element support.
     2544            return;
     2545        }
    25402546    }
    25412547
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r127684 r128155  
    497497}
    498498
     499// FIXME: when RenderRegion will inherit from RenderBlock instead of RenderReplaced,
     500// we should overwrite computePreferredLogicalWidths ( see https://bugs.webkit.org/show_bug.cgi?id=74132 )
     501LayoutUnit RenderRegion::minPreferredLogicalWidth() const
     502{
     503    if (!m_flowThread || !m_isValid)
     504        return RenderReplaced::minPreferredLogicalWidth();
     505
     506    // FIXME: Currently, the code handles only the <length> case for min-width. It should also support other values, like percentage, calc
     507    // or viewport relative.
     508    RenderStyle* styleToUse = style();
     509    LayoutUnit minPreferredLogicalWidth = m_flowThread->minPreferredLogicalWidth();
     510
     511    if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0)
     512        minPreferredLogicalWidth = std::max(minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
     513
     514    if (styleToUse->logicalMaxWidth().isFixed())
     515        minPreferredLogicalWidth = std::min(minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
     516
     517    return minPreferredLogicalWidth + borderAndPaddingLogicalWidth();
     518}
     519
     520LayoutUnit RenderRegion::maxPreferredLogicalWidth() const
     521{
     522    if (!m_flowThread || !m_isValid)
     523        return RenderReplaced::maxPreferredLogicalWidth();
     524
     525    // FIXME: Currently, the code handles only the <length> case for max-width. It should also support other values, like percentage, calc
     526    // or viewport relative.
     527    RenderStyle* styleToUse = style();
     528    LayoutUnit maxPreferredLogicalWidth = m_flowThread->maxPreferredLogicalWidth();
     529
     530    if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0)
     531        maxPreferredLogicalWidth = std::max(maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
     532
     533    if (styleToUse->logicalMaxWidth().isFixed())
     534        maxPreferredLogicalWidth = std::min(maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
     535
     536    return maxPreferredLogicalWidth + borderAndPaddingLogicalWidth();
     537}
     538
    499539} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderRegion.h

    r127684 r128155  
    101101    virtual LayoutUnit pageLogicalWidth() const;
    102102    virtual LayoutUnit pageLogicalHeight() const;
     103
     104    virtual LayoutUnit minPreferredLogicalWidth() const OVERRIDE;
     105    virtual LayoutUnit maxPreferredLogicalWidth() const OVERRIDE;
    103106   
    104107    // This method represents the logical height of the entire flow thread portion used by the region or set.
     
    112115    virtual LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const;
    113116   
    114     virtual void expandToEncompassFlowThreadContentsIfNeeded() {};
     117    virtual void expandToEncompassFlowThreadContentsIfNeeded() { };
    115118
    116119    // Whether or not this region is a set.
     
    129132private:
    130133    virtual const char* renderName() const { return "RenderRegion"; }
     134
     135    // FIXME: these functions should be revisited once RenderRegion inherits from RenderBlock
     136    // instead of RenderReplaced (see https://bugs.webkit.org/show_bug.cgi?id=74132 )
     137    // When width is auto, use normal block/box sizing code except when inline.
     138    virtual bool isInlineBlockOrInlineTable() const OVERRIDE { return isInline() && style()->logicalWidth().isAuto(); }
     139    virtual bool shouldComputeSizeAsReplaced() const OVERRIDE { return !style()->logicalWidth().isAuto(); }
    131140
    132141    virtual void insertedIntoTree() OVERRIDE;
Note: See TracChangeset for help on using the changeset viewer.