Commit bdfeec5e authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[cleanup] Simplify the -webkit-box overflow bias calculation.

This change simplifies how we determine the position of children
within a -webkit-box.

-webkit-box is special as any overflow always "hangs" to the line-right.

This patch adds any negative available-space instead of performing
a more complicated "flipped-offset" calculation.

There should be no behaviour change.

Change-Id: Ic204e2e2167b88a7fd1ab02c2ec5cff4d0355ac0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508029
Commit-Queue: David Grogan <dgrogan@chromium.org>
Reviewed-by: default avatarDavid Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822551}
parent 53715db6
...@@ -506,8 +506,6 @@ void FlexLine::ComputeLineItemsPosition(LayoutUnit main_axis_start_offset, ...@@ -506,8 +506,6 @@ void FlexLine::ComputeLineItemsPosition(LayoutUnit main_axis_start_offset,
sum_justify_adjustments_ += initial_position; sum_justify_adjustments_ += initial_position;
LayoutUnit main_axis_offset = initial_position + main_axis_start_offset; LayoutUnit main_axis_offset = initial_position + main_axis_start_offset;
LayoutUnit logical_width_when_flipped = container_logical_width_;
LayoutUnit flipped_offset;
bool should_flip_main_axis; bool should_flip_main_axis;
if (algorithm_->IsNGFlexBox()) { if (algorithm_->IsNGFlexBox()) {
should_flip_main_axis = style.ResolvedIsRowReverseFlexDirection(); should_flip_main_axis = style.ResolvedIsRowReverseFlexDirection();
...@@ -515,18 +513,12 @@ void FlexLine::ComputeLineItemsPosition(LayoutUnit main_axis_start_offset, ...@@ -515,18 +513,12 @@ void FlexLine::ComputeLineItemsPosition(LayoutUnit main_axis_start_offset,
should_flip_main_axis = !style.ResolvedIsColumnFlexDirection() && should_flip_main_axis = !style.ResolvedIsColumnFlexDirection() &&
!algorithm_->IsLeftToRightFlow(); !algorithm_->IsLeftToRightFlow();
// -webkit-box, always did layout starting at 0. ltr and reverse were // When a -webkit-box has negative available-space it always places that
// handled by reversing the order of iteration. OTOH, flex always iterates // overflow to the line-right. (Even if we have "direction: rtl" or
// in order and flips the main coordinate. The following gives the same // "-webkit-box-direction: reverse"). In the future it will hopefully be
// behavior for -webkit-box while using the same iteration order as flex // possible to remove this quirk.
// does by changing how the flipped coordinate is calculated. if (should_flip_main_axis && is_webkit_box && available_free_space < 0)
if (should_flip_main_axis && is_webkit_box) { main_axis_offset += available_free_space;
// -webkit-box only distributed space when > 0.
logical_width_when_flipped =
total_item_size + available_free_space.ClampNegativeToZero();
flipped_offset = main_axis_end_offset;
main_axis_offset -= main_axis_start_offset;
}
} }
LayoutUnit max_descent; // Used when align-items: baseline. LayoutUnit max_descent; // Used when align-items: baseline.
...@@ -562,9 +554,9 @@ void FlexLine::ComputeLineItemsPosition(LayoutUnit main_axis_start_offset, ...@@ -562,9 +554,9 @@ void FlexLine::ComputeLineItemsPosition(LayoutUnit main_axis_start_offset,
// on the left. This will be fixed later in // on the left. This will be fixed later in
// LayoutFlexibleBox::FlipForRightToLeftColumn. // LayoutFlexibleBox::FlipForRightToLeftColumn.
flex_item.desired_location_ = LayoutPoint( flex_item.desired_location_ = LayoutPoint(
should_flip_main_axis ? logical_width_when_flipped - main_axis_offset - should_flip_main_axis
child_main_extent + flipped_offset ? container_logical_width_ - main_axis_offset - child_main_extent
: main_axis_offset, : main_axis_offset,
cross_axis_offset + flex_item.FlowAwareMarginBefore()); cross_axis_offset + flex_item.FlowAwareMarginBefore());
main_axis_offset += child_main_extent + flex_item.FlowAwareMarginEnd(); main_axis_offset += child_main_extent + flex_item.FlowAwareMarginEnd();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment