From cab66fb1ac15700392a26fdef8207db87144aac0 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 15 Dec 2022 20:52:51 +0000 Subject: html: layout: flex: Helper to get main margin end size --- content/handlers/html/layout_flex.c | 48 ++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c index cea7964d7..a12becf3a 100644 --- a/content/handlers/html/layout_flex.c +++ b/content/handlers/html/layout_flex.c @@ -171,6 +171,38 @@ static struct flex_ctx *layout_flex_ctx__create( return ctx; } +/** + * Find box side representing the start of flex container in main direction. + * + * \param[in] ctx Flex layout context. + * \return the start side. + */ +static enum box_side layout_flex__main_start_side( + const struct flex_ctx *ctx) +{ + if (ctx->horizontal) { + return (ctx->main_reversed) ? RIGHT : LEFT; + } else { + return (ctx->main_reversed) ? BOTTOM : TOP; + } +} + +/** + * Find box side representing the end of flex container in main direction. + * + * \param[in] ctx Flex layout context. + * \return the end side. + */ +static enum box_side layout_flex__main_end_side( + const struct flex_ctx *ctx) +{ + if (ctx->horizontal) { + return (ctx->main_reversed) ? LEFT : RIGHT; + } else { + return (ctx->main_reversed) ? TOP : BOTTOM; + } +} + /** * Perform layout on a flex item * @@ -737,22 +769,6 @@ static bool layout_flex__resolve_line( return true; } -/** - * Find box side representing the start of flex container in main direction. - * - * \param[in] ctx Flex layout context. - * \return the start side. - */ -static enum box_side layout_flex__main_start_side( - const struct flex_ctx *ctx) -{ - if (ctx->horizontal) { - return (ctx->main_reversed) ? RIGHT : LEFT; - } else { - return (ctx->main_reversed) ? BOTTOM : TOP; - } -} - /** * Position items along a line * -- cgit v1.2.1