RESOLVED FIXED 80552
implement flexbox wrap-reverse
https://bugs.webkit.org/show_bug.cgi?id=80552
Summary implement flexbox wrap-reverse
Tony Chang
Reported 2012-03-07 16:55:16 PST
implement wrap-reverse
Attachments
Patch (143.84 KB, patch)
2012-03-07 16:59 PST, Tony Chang
no flags
Patch for landing (143.82 KB, patch)
2012-03-08 11:12 PST, Tony Chang
no flags
Tony Chang
Comment 1 2012-03-07 16:59:51 PST
Ojan Vafai
Comment 2 2012-03-07 19:10:58 PST
Comment on attachment 130728 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130728&action=review > Source/WebCore/rendering/RenderFlexibleBox.cpp:130 > + return (crossAxisContentExtent - startOffset - lineHeight) - startOffset; Nit: I'd rather this be: return crossAxisContentExtent - lineHeight - (2 * startOffset); > Source/WebCore/rendering/RenderFlexibleBox.cpp:598 > + wrapReverseContext.addNumberOfChildrenOnLine(orderedChildren.size()); > + wrapReverseContext.addCrossAxisOffset(crossAxisOffset); Nit: I'd rather this be something like: wrapReverseContext.add(crossAxisOffset, orderedChildren); void WrapReverseContext::add(LayoutUnit crossAxisOffset, OrderedFlexItemList childrenOnLine) { if (!isWrapReverse) return; crossAxisOffsets.append(crossAxisOffset); childrenPerLine.append(childrenOnLine.size()); } > Source/WebCore/rendering/RenderFlexibleBox.cpp:953 > + if (style()->flexWrap() == FlexWrapReverse) > + adjustAlignmentForChild(child, availableAlignmentSpaceForChild(lineCrossAxisExtent, child)); This could use a comment (e.g. FlexWrapReverse means that stretched children should align to the cross-end edge) > Source/WebCore/rendering/RenderFlexibleBox.cpp:991 > + switch (flexAlignForChild(child)) { > + case AlignBaseline: > + adjustAlignmentForChild(child, minMarginAfterBaseline); > + break; > + case AlignAuto: > + case AlignStretch: > + case AlignStart: > + case AlignEnd: > + case AlignCenter: > + break; > + } Don't need the switch. Just make it an if statement. > Source/WebCore/rendering/RenderFlexibleBox.cpp:1021 > + LayoutRect oldRect = child->frameRect(); Can you inline this to line 1024? > Source/WebCore/rendering/RenderFlexibleBox.cpp:1026 > + ++currentChild; Nit: I'd just put this in the if-statement below. I've certainly seen other WebKit code that does.
Tony Chang
Comment 3 2012-03-08 11:12:24 PST
Created attachment 130858 [details] Patch for landing
Tony Chang
Comment 4 2012-03-08 11:14:19 PST
Comment on attachment 130728 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130728&action=review >> Source/WebCore/rendering/RenderFlexibleBox.cpp:130 >> + return (crossAxisContentExtent - startOffset - lineHeight) - startOffset; > > Nit: I'd rather this be: > return crossAxisContentExtent - lineHeight - (2 * startOffset); I split it into two lines to make it clear what crossAxisContentExtent - startOffset - lineHeight is. >> Source/WebCore/rendering/RenderFlexibleBox.cpp:598 >> + wrapReverseContext.addCrossAxisOffset(crossAxisOffset); > > Nit: I'd rather this be something like: > wrapReverseContext.add(crossAxisOffset, orderedChildren); > > void WrapReverseContext::add(LayoutUnit crossAxisOffset, OrderedFlexItemList childrenOnLine) > { > if (!isWrapReverse) > return; > crossAxisOffsets.append(crossAxisOffset); > childrenPerLine.append(childrenOnLine.size()); > } I didn't change this because I use addCrossAxisOffset below. >> Source/WebCore/rendering/RenderFlexibleBox.cpp:953 >> + adjustAlignmentForChild(child, availableAlignmentSpaceForChild(lineCrossAxisExtent, child)); > > This could use a comment (e.g. FlexWrapReverse means that stretched children should align to the cross-end edge) Done. >> Source/WebCore/rendering/RenderFlexibleBox.cpp:991 >> + } > > Don't need the switch. Just make it an if statement. Done. >> Source/WebCore/rendering/RenderFlexibleBox.cpp:1021 >> + LayoutRect oldRect = child->frameRect(); > > Can you inline this to line 1024? setFlowAwareLocationForChild changes the frameRect. >> Source/WebCore/rendering/RenderFlexibleBox.cpp:1026 >> + ++currentChild; > > Nit: I'd just put this in the if-statement below. I've certainly seen other WebKit code that does. Done.
Ojan Vafai
Comment 5 2012-03-08 11:24:13 PST
Comment on attachment 130728 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130728&action=review >>> Source/WebCore/rendering/RenderFlexibleBox.cpp:598 >>> + wrapReverseContext.addCrossAxisOffset(crossAxisOffset); >> >> Nit: I'd rather this be something like: >> wrapReverseContext.add(crossAxisOffset, orderedChildren); >> >> void WrapReverseContext::add(LayoutUnit crossAxisOffset, OrderedFlexItemList childrenOnLine) >> { >> if (!isWrapReverse) >> return; >> crossAxisOffsets.append(crossAxisOffset); >> childrenPerLine.append(childrenOnLine.size()); >> } > > I didn't change this because I use addCrossAxisOffset below. Right, but you can just passed in orderedChildren there as well without it causing problems, no? Not a big deal I guess.
Tony Chang
Comment 6 2012-03-08 11:28:00 PST
Comment on attachment 130728 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130728&action=review >>>> Source/WebCore/rendering/RenderFlexibleBox.cpp:598 >>>> + wrapReverseContext.addCrossAxisOffset(crossAxisOffset); >>> >>> Nit: I'd rather this be something like: >>> wrapReverseContext.add(crossAxisOffset, orderedChildren); >>> >>> void WrapReverseContext::add(LayoutUnit crossAxisOffset, OrderedFlexItemList childrenOnLine) >>> { >>> if (!isWrapReverse) >>> return; >>> crossAxisOffsets.append(crossAxisOffset); >>> childrenPerLine.append(childrenOnLine.size()); >>> } >> >> I didn't change this because I use addCrossAxisOffset below. > > Right, but you can just passed in orderedChildren there as well without it causing problems, no? > > Not a big deal I guess. It would add an extra entry to childrenPerLine making us think we had an additional line. Maybe we could pass in a vector of size 0 and special case that since it's not possible to have 0 children in a line. It would be more code.
Tony Chang
Comment 7 2012-03-08 14:56:00 PST
Note You need to log in before you can comment on or make changes to this bug.