diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-12-15 20:54:02 +0000 |
---|---|---|
committer | Michael Drake <mdrake.unique@gmail.com> | 2022-12-15 21:57:15 +0000 |
commit | 88e6fc918aee40dc4223732650378e50d3b82326 (patch) | |
tree | 0d4c8a6630ac8fc3cc604a3240e4e847226c6dd8 /content/handlers/html | |
parent | cab66fb1ac15700392a26fdef8207db87144aac0 (diff) | |
download | netsurf-88e6fc918aee40dc4223732650378e50d3b82326.tar.gz netsurf-88e6fc918aee40dc4223732650378e50d3b82326.tar.bz2 |
html: layout: flex: Track used size and count auto margins for main
Diffstat (limited to 'content/handlers/html')
-rw-r--r-- | content/handlers/html/layout_flex.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c index a12becf3a..de3120740 100644 --- a/content/handlers/html/layout_flex.c +++ b/content/handlers/html/layout_flex.c @@ -76,6 +76,9 @@ struct flex_line_data { int main_size; int cross_size; + int used_main_size; + int main_auto_margin_count; + int pos; size_t first; @@ -410,6 +413,8 @@ static bool layout_flex_ctx__ensure_line(struct flex_ctx *ctx) static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx, size_t item_index) { + enum box_side start_side = layout_flex__main_start_side(ctx); + enum box_side end_side = layout_flex__main_end_side(ctx); struct flex_line_data *line; int used_main = 0; @@ -441,6 +446,13 @@ static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx, if (lh__box_is_absolute(item->box) == false) { line->main_size += item->main_size; used_main += pos_main; + + if (b->margin[start_side] == AUTO) { + line->main_auto_margin_count++; + } + if (b->margin[end_side] == AUTO) { + line->main_auto_margin_count++; + } } item->line = ctx->line.count; line->count++; @@ -472,6 +484,10 @@ static inline void layout_flex__item_freeze( item->freeze = true; line->frozen++; + if (!lh__box_is_absolute(item->box)){ + line->used_main_size += item->target_main_size; + } + NSLOG(flex, DEEPDEBUG, "flex-item box: %p: " "Frozen at target_main_size: %i", item->box, item->target_main_size); |