<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>87905</bug_id>
          
          <creation_ts>2012-05-30 15:57:38 -0700</creation_ts>
          <short_desc>Can avoid a second layout of flex-items in some cases</short_desc>
          <delta_ts>2024-07-22 09:30:33 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>62048</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Ojan Vafai">ojan</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>cgarcia</cc>
    
    <cc>eric</cc>
    
    <cc>hyatt</cc>
    
    <cc>jchaffraix</cc>
    
    <cc>sgill26</cc>
    
    <cc>tony</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>637776</commentid>
    <comment_count>0</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2012-05-30 15:57:38 -0700</bug_when>
    <thetext>Whenever we&apos;re extending the logicalHeight of a flex-item that we&apos;ve already laid out (e.g. due to flexing or flex-align:stretch), we only need to layout after modifying the height if the contents of the item depend on it&apos;s height (e.g. contains % height elements and is a containing block, has a background-color, etc) because we already.

The tricky bit here is maintaining the function of when we need to do a relayout.

In theory, in some of these cases we could take this a step further and avoid doing a full relayout, e.g. we don&apos;t actually need to relayout just to extend the background color further up/down; for percentage height decendants, we already keep a list of them and only need to relayout those items, etc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>766542</commentid>
    <comment_count>1</comment_count>
      <attachid>174091</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2012-11-14 00:13:38 -0800</bug_when>
    <thetext>Created attachment 174091
Patch

I&apos;m getting a failure in 3 tests that I&apos;m not sure why.

css3/flexbox/inline-flex-crash.html
css3/flexbox/inline-flex-crash2.html

The output is different in both cases, but it doesn&apos;t crash.

css3/flexbox/auto-margins.html

The output is correct, but the first time it&apos;s called it fails to get the margin values, although the inspector shows the right ones and simply reloading the page fixes the test. 

All other css3 flexbox tests pass.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>767065</commentid>
    <comment_count>2</comment_count>
      <attachid>174091</attachid>
    <who name="Tony Chang">tony</who>
    <bug_when>2012-11-14 11:01:48 -0800</bug_when>
    <thetext>Comment on attachment 174091
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=174091&amp;action=review

&gt; Source/WebCore/rendering/RenderFlexibleBox.cpp:1090
&gt; +        LayoutUnit childCurrentSize = isColumnFlow() ? child-&gt;logicalHeight() : child-&gt;logicalWidth();

You want mainAxisExtentForChild().  You don&apos;t want the child&apos;s logical height since it can have an orthogonal writing mode to the flexbox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>767162</commentid>
    <comment_count>3</comment_count>
      <attachid>174091</attachid>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2012-11-14 12:14:54 -0800</bug_when>
    <thetext>Comment on attachment 174091
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=174091&amp;action=review

This is actually a separate optimization than bug 87905. That bug is about when we *do* change the height, there are many cases where we don&apos;t need to do a layout (i.e. if there are no descendants or css properties that depend on the height).

This is still a good optimization though. It just needs it&apos;s own bug.

&gt; Source/WebCore/rendering/RenderFlexibleBox.cpp:1094
&gt; +        if (child-&gt;size().isZero() || childPreferredSize != childCurrentSize) {
&gt; +            child-&gt;setChildNeedsLayout(true, MarkOnlyThis);
&gt; +            child-&gt;layoutIfNeeded();
&gt; +        }

I don&apos;t think we need the isZero check. Instead, we should always call child-&gt;layoutIfNeeded() here (i.e. move it out of the if-statement), but only setChildNeedsLayout if childPreferredSize != childCurrentSize.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>767823</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2012-11-15 01:49:35 -0800</bug_when>
    <thetext>Thank you guys for the review! I&apos;ve just opened a new bug with a patch addressing your comments, see: 

https://bugs.webkit.org/show_bug.cgi?id=102352

css3/flexbox/inline-flex-crash.html and css3/flexbox/inline-flex-crash2.html don&apos;t fail anymore with the new patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2047350</commentid>
    <comment_count>5</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-07-20 09:41:24 -0700</bug_when>
    <thetext>@Sammy - is it still applicable?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2047510</commentid>
    <comment_count>6</comment_count>
    <who name="Sammy Gill">sgill26</who>
    <bug_when>2024-07-22 09:30:33 -0700</bug_when>
    <thetext>I think so since there is still a FIXME that references this bugzilla in RenderFlexibleBox::applyStretchAlignmentToFlexItem</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>174091</attachid>
            <date>2012-11-14 00:13:38 -0800</date>
            <delta_ts>2012-11-14 12:14:54 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>css3-flexbox-layout.diff</filename>
            <type>text/plain</type>
            <size>1968</size>
            <attacher name="Carlos Garcia Campos">cgarcia</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0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6ZSA9IGlzQ29sdW1u
RmxvdygpID8gY2hpbGQtPmxvZ2ljYWxIZWlnaHQoKSA6IGNoaWxkLT5sb2dpY2FsV2lkdGgoKTsK
KyAgICAgICAgaWYgKGNoaWxkLT5zaXplKCkuaXNaZXJvKCkgfHwgY2hpbGRQcmVmZXJyZWRTaXpl
ICE9IGNoaWxkQ3VycmVudFNpemUpIHsKKyAgICAgICAgICAgIGNoaWxkLT5zZXRDaGlsZE5lZWRz
TGF5b3V0KHRydWUsIE1hcmtPbmx5VGhpcyk7CisgICAgICAgICAgICBjaGlsZC0+bGF5b3V0SWZO
ZWVkZWQoKTsKKyAgICAgICAgfQogCiAgICAgICAgIHVwZGF0ZUF1dG9NYXJnaW5zSW5NYWluQXhp
cyhjaGlsZCwgYXV0b01hcmdpbk9mZnNldCk7CiAK
</data>
<flag name="review"
          id="189012"
          type_id="1"
          status="-"
          setter="tony"
    />
          </attachment>
      

    </bug>

</bugzilla>