summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTobias Christiansen <tobyase@serenityos.org>2021-09-14 22:36:10 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-14 22:52:48 +0200
commit85af2ac45012a5b5d959d7705600ae581d8875d7 (patch)
tree55480b3854f9c275f507fe71293231eb0c7877a2 /Userland
parent15b61ce14383a774cb363e35353855b67dcadd50 (diff)
downloadserenity-85af2ac45012a5b5d959d7705600ae581d8875d7.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp13
1 files 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;