Bug 86913

Summary: auto margins on flexbox should allocate space in the cross direction
Product: WebKit Reporter: Tony Chang <tony>
Component: Layout and RenderingAssignee: Tony Chang <tony>
Status: RESOLVED FIXED    
Severity: Normal CC: eric, hyatt, ojan, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 62048    
Attachments:
Description Flags
Patch
none
Patch none

Description Tony Chang 2012-05-18 15:46:43 PDT
See the section here:
http://dev.w3.org/csswg/css3-flexbox/#auto-margins

We're currently treating auto margins as 0.

See also 83086.
Comment 1 Tony Chang 2012-05-23 14:06:52 PDT
Created attachment 143647 [details]
Patch
Comment 2 Ojan Vafai 2012-05-23 14:20:28 PDT
Comment on attachment 143647 [details]
Patch

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

> Source/WebCore/rendering/RenderFlexibleBox.cpp:720
> +        child->setMarginTop(availableAlignmentSpace / 2);
> +        child->setMarginBottom(availableAlignmentSpace / 2);
> +        return true;
> +    }
> +    if (start.isAuto()) {
> +        adjustAlignmentForChild(child, availableAlignmentSpace);
> +        child->setMarginTop(availableAlignmentSpace);
> +        return true;
> +    }
> +    if (end.isAuto()) {
> +        child->setMarginBottom(availableAlignmentSpace);

If we're in a vertical flow, don't we want to be setting marginLeft/marginRight?
Comment 3 Tony Chang 2012-05-23 14:50:58 PDT
Created attachment 143658 [details]
Patch
Comment 4 Tony Chang 2012-05-23 14:51:25 PDT
(In reply to comment #2)
> (From update of attachment 143647 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=143647&action=review
> 
> > Source/WebCore/rendering/RenderFlexibleBox.cpp:720
> > +        child->setMarginTop(availableAlignmentSpace / 2);
> > +        child->setMarginBottom(availableAlignmentSpace / 2);
> > +        return true;
> > +    }
> > +    if (start.isAuto()) {
> > +        adjustAlignmentForChild(child, availableAlignmentSpace);
> > +        child->setMarginTop(availableAlignmentSpace);
> > +        return true;
> > +    }
> > +    if (end.isAuto()) {
> > +        child->setMarginBottom(availableAlignmentSpace);
> 
> If we're in a vertical flow, don't we want to be setting marginLeft/marginRight?

Yes, you're right.  Fixed and a test case added in auto-margins.html.
Comment 5 WebKit Review Bot 2012-05-23 17:19:01 PDT
Comment on attachment 143658 [details]
Patch

Clearing flags on attachment: 143658

Committed r118279: <http://trac.webkit.org/changeset/118279>
Comment 6 WebKit Review Bot 2012-05-23 17:19:05 PDT
All reviewed patches have been landed.  Closing bug.