|
|
@@ -236,6 +236,8 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
|
|
|
|
|
|
const ComputedValues& computed_flex = element_flex->GetComputedValues();
|
|
|
const Style::FlexDirection direction = computed_flex.flex_direction();
|
|
|
+ const Style::LengthPercentage row_gap = computed_flex.row_gap();
|
|
|
+ const Style::LengthPercentage column_gap = computed_flex.column_gap();
|
|
|
|
|
|
const bool main_axis_horizontal = (direction == Style::FlexDirection::Row || direction == Style::FlexDirection::RowReverse);
|
|
|
const bool direction_reverse = (direction == Style::FlexDirection::RowReverse || direction == Style::FlexDirection::ColumnReverse);
|
|
|
@@ -257,6 +259,9 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
|
|
|
const float main_size_base_value = (main_available_size < 0.0f ? 0.0f : main_available_size);
|
|
|
const float cross_size_base_value = (cross_available_size < 0.0f ? 0.0f : cross_available_size);
|
|
|
|
|
|
+ const float main_gap_size = ResolveValue(main_axis_horizontal ? column_gap : row_gap, main_size_base_value);
|
|
|
+ const float cross_gap_size = ResolveValue(main_axis_horizontal ? row_gap : column_gap, cross_size_base_value);
|
|
|
+
|
|
|
// -- Build a list of all flex items with base size information --
|
|
|
const int num_flex_children = element_flex->GetNumChildren();
|
|
|
Vector<FlexItem> items;
|
|
|
@@ -386,6 +391,8 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
|
|
|
// Add item to current line.
|
|
|
line_items.push_back(std::move(item));
|
|
|
}
|
|
|
+
|
|
|
+ cursor += main_gap_size;
|
|
|
}
|
|
|
|
|
|
if (!line_items.empty())
|
|
|
@@ -397,6 +404,18 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
|
|
|
|
|
|
for (FlexLine& line : container.lines)
|
|
|
{
|
|
|
+ // now that items are in lines, we can add the main gap size to all but the last item
|
|
|
+ if (main_gap_size > 0.f)
|
|
|
+ {
|
|
|
+ for (size_t i = 0; i < line.items.size() - 1; i++)
|
|
|
+ {
|
|
|
+ line.items[i].hypothetical_main_size += main_gap_size;
|
|
|
+ line.items[i].flex_base_size += main_gap_size;
|
|
|
+ line.items[i].main.margin_b += main_gap_size;
|
|
|
+ line.items[i].main.sum_edges += main_gap_size;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
line.accumulated_hypothetical_main_size = std::accumulate(line.items.begin(), line.items.end(), 0.0f,
|
|
|
[](float value, const FlexItem& item) { return value + item.hypothetical_main_size; });
|
|
|
}
|
|
|
@@ -624,6 +643,20 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Apply cross axis gaps to every item in every line except the last line.
|
|
|
+ if (cross_gap_size > 0.f)
|
|
|
+ {
|
|
|
+ for (size_t i = 0; i < container.lines.size() - 1; i++)
|
|
|
+ {
|
|
|
+ FlexLine& line = container.lines[i];
|
|
|
+ for (FlexItem& item : line.items)
|
|
|
+ {
|
|
|
+ item.cross.margin_b += cross_gap_size;
|
|
|
+ item.cross.sum_edges += cross_gap_size;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// -- Determine cross size (§9.4) --
|
|
|
// First, determine the cross size of each item, format it if necessary.
|
|
|
for (FlexLine& line : container.lines)
|