From 85af2ac45012a5b5d959d7705600ae581d8875d7 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Tue, 14 Sep 2021 22:36:10 +0200 Subject: [PATCH] LibWeb: Flexbox: Change the name of a variable to correspond to spec The spec used two different names for the same thing, and it was confusing to read the spec on the one side and have the other name in the code. --- .../LibWeb/Layout/FlexFormattingContext.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 6ad7918488..52ec8af999 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -400,7 +400,7 @@ void FlexFormattingContext::run(Box& box, LayoutMode) flex_lines.append(line); } - // 6. Resolve the flexible lengths + // 6. Resolve the flexible lengths https://www.w3.org/TR/css-flexbox-1/#resolve-flexible-lengths enum FlexFactor { FlexGrowFactor, FlexShrinkFactor @@ -514,9 +514,8 @@ void FlexFormattingContext::run(Box& box, LayoutMode) flex_item->target_main_size = flex_item->flex_base_size; }); } - // d Fix min/max violations. - float adjustments = 0; + float adjustments = 0.0f; for_each_unfrozen_item([&](FlexItem* item) { auto min_main = has_main_min_size(item->box) ? specified_main_min_size(item->box) @@ -537,23 +536,23 @@ void FlexFormattingContext::run(Box& box, LayoutMode) item->is_max_violation = true; } float delta = item->target_main_size - original_target_size; - adjustments += delta; }); // e Freeze over-flexed items - if (adjustments == 0) { + float total_violation = adjustments; + if (total_violation == 0) { for_each_unfrozen_item([&](FlexItem* item) { --number_of_unfrozen_items_on_line; item->frozen = true; }); - } else if (adjustments > 0) { + } else if (total_violation > 0) { for_each_unfrozen_item([&](FlexItem* item) { if (item->is_min_violation) { --number_of_unfrozen_items_on_line; item->frozen = true; } }); - } else if (adjustments < 0) { + } else if (total_violation < 0) { for_each_unfrozen_item([&](FlexItem* item) { if (item->is_max_violation) { --number_of_unfrozen_items_on_line;