Skip to content
  • mihnea@adobe.com's avatar
    [CSS Regions] Auto width is not working for Regions · 2ccb17c0
    mihnea@adobe.com authored
    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(achicu@adobe.com).
    
    Tests: fast/regions/autowidth-abspos-regionchain.html
           fast/regions/autowidth-abspos.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.
    (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.
    
    LayoutTests:
    
    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).
    
    Besides adding new tests, i have modified existing tests that were having regions with width:auto as they were failing after this patch.
    
    * 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-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:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127596 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    2ccb17c0