Bug 70557

Summary: avoid unnecessary layouts of flex items during the flex pass
Product: WebKit Reporter: Tony Chang <tony>
Component: New BugsAssignee: Tony Chang <tony>
Status: RESOLVED FIXED    
Severity: Normal CC: hyatt, ojan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 62048    
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing none

Description Tony Chang 2011-10-20 15:44:01 PDT
avoid unnecessary layouts of flex items during the flex pass
Comment 1 Tony Chang 2011-10-20 15:49:14 PDT
Created attachment 111862 [details]
Patch
Comment 2 Ojan Vafai 2011-10-20 18:12:08 PDT
Comment on attachment 111862 [details]
Patch

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

Patch looks good to me.

> Source/WebCore/rendering/RenderFlexibleBox.cpp:496
> +    Length fixedWidth = isHorizontalFlow() ? child->style()->width() : child->style()->height();

Nit: I think the code would be simpler if you added flowAwareWidthStyleForChild instead of isFlowAwareLogicalWidthAutoForChild.
Comment 3 Dave Hyatt 2011-10-25 11:17:09 PDT
Comment on attachment 111862 [details]
Patch

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

> Source/WebCore/rendering/RenderFlexibleBox.cpp:224
> +    Length width = isHorizontalFlow() ? child->style()->width() : child->style()->height();
> +    return width.isAuto();

Please name the local variable logicalWidth and not just width.

> Source/WebCore/rendering/RenderFlexibleBox.cpp:497
> +    return fixedWidth.calcMinValue(flowAwareContentLogicalWidth());

Adding flowAwareLogicalWidthLengthForChild as Ojan suggests seems cleaner.
Comment 4 Tony Chang 2011-10-25 11:45:00 PDT
Created attachment 112368 [details]
Patch
Comment 5 Ojan Vafai 2011-10-25 12:11:03 PDT
Comment on attachment 112368 [details]
Patch

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

> Source/WebCore/rendering/RenderFlexibleBox.cpp:506
> +    if (flowAwareLogicalWidthLengthForChild(child).isAuto()) {
>          LayoutUnit logicalWidth = hasOrthogonalFlow(child) ? child->logicalHeight() : child->maxPreferredLogicalWidth();
>          return logicalWidth - logicalBorderAndPaddingWidthForChild(child) - logicalScrollbarHeightForChild(child);
>      }
> -    return isHorizontalFlow() ? child->contentWidth() : child->contentHeight();
> +    Length fixedWidth = isHorizontalFlow() ? child->style()->width() : child->style()->height();
> +    return fixedWidth.calcMinValue(flowAwareContentLogicalWidth());

nit: i would do this like so:
Length logicalWidthLength = flowAwareLogicalWidthLengthForChild(child);
if (logicalWidthLength.isAuto()) {
...
}
return logicalWidthLength.calcMinValue(...);
Comment 6 Tony Chang 2011-10-25 12:14:33 PDT
Created attachment 112372 [details]
Patch for landing
Comment 7 Tony Chang 2011-10-25 12:25:04 PDT
Committed r98373: <http://trac.webkit.org/changeset/98373>