Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/71765dd1e8dc968f15ce359f7e604585aa428f90
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/71765dd1e8dc968f15ce359f7e604585aa428f90
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/71765dd1e8dc968f15ce359f7e604585aa428f90

The branch, master has been updated
       via  71765dd1e8dc968f15ce359f7e604585aa428f90 (commit)
       via  88e6fc918aee40dc4223732650378e50d3b82326 (commit)
       via  cab66fb1ac15700392a26fdef8207db87144aac0 (commit)
      from  651deffcf73f4760f32934dc2045e314998f5338 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=71765dd1e8dc968f15ce359f7e604585aa428f90
commit 71765dd1e8dc968f15ce359f7e604585aa428f90
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    html: layout: flex: Handle auto margins in main direction

diff --git a/content/handlers/html/layout_flex.c 
b/content/handlers/html/layout_flex.c
index de31207..ac0b888 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -800,16 +800,33 @@ static bool layout_flex__place_line_items_main(
        int post_multiplier = ctx->main_reversed ? 0 : 1;
        int pre_multiplier = ctx->main_reversed ? -1 : 0;
        size_t item_count = line->first + line->count;
+       int extra_remainder = 0;
+       int extra = 0;
 
        if (ctx->main_reversed) {
                main_pos = lh__box_size_main(ctx->horizontal, ctx->flex) -
                                main_pos;
        }
 
+       if (ctx->available_main != AUTO &&
+           ctx->available_main != UNKNOWN_WIDTH &&
+           ctx->available_main > line->used_main_size) {
+               if (line->main_auto_margin_count > 0) {
+                       extra = ctx->available_main - line->used_main_size;
+
+                       extra_remainder = extra % line->main_auto_margin_count;
+                       extra /= line->main_auto_margin_count;
+               }
+       }
+
        for (size_t i = line->first; i < item_count; i++) {
+               enum box_side main_end = ctx->horizontal ? RIGHT : BOTTOM;
                enum box_side main_start = ctx->horizontal ? LEFT : TOP;
                struct flex_item_data *item = &ctx->item.data[i];
                struct box *b = item->box;
+               int extra_total = 0;
+               int extra_post = 0;
+               int extra_pre = 0;
                int box_size_main;
                int *box_pos_main;
 
@@ -826,20 +843,30 @@ static bool layout_flex__place_line_items_main(
                box_pos_main = ctx->horizontal ? &b->x : &b->y;
 
                if (!lh__box_is_absolute(b)) {
-                       main_pos += pre_multiplier * (box_size_main +
-                                       lh__delta_outer_main(ctx->flex, b));
+                       if (b->margin[main_start] == AUTO) {
+                               extra_pre = extra + extra_remainder;
+                       }
+                       if (b->margin[main_end] == AUTO) {
+                               extra_post = extra + extra_remainder;
+                       }
+                       extra_total = extra_pre + extra_post;
+
+                       main_pos += pre_multiplier *
+                                       (extra_total + box_size_main +
+                                        lh__delta_outer_main(ctx->flex, b));
                }
 
                *box_pos_main = main_pos + lh__non_auto_margin(b, main_start) +
-                               b->border[main_start].width;
+                               extra_pre + b->border[main_start].width;
 
                if (!lh__box_is_absolute(b)) {
                        int cross_size;
                        int box_size_cross = lh__box_size_cross(
                                        ctx->horizontal, b);
 
-                       main_pos += post_multiplier * (box_size_main +
-                                       lh__delta_outer_main(ctx->flex, b));
+                       main_pos += post_multiplier *
+                                       (extra_total + box_size_main +
+                                        lh__delta_outer_main(ctx->flex, b));
 
                        cross_size = box_size_cross + lh__delta_outer_cross(
                                        ctx->flex, b);


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=88e6fc918aee40dc4223732650378e50d3b82326
commit 88e6fc918aee40dc4223732650378e50d3b82326
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    html: layout: flex: Track used size and count auto margins for main

diff --git a/content/handlers/html/layout_flex.c 
b/content/handlers/html/layout_flex.c
index a12becf..de31207 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);


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=cab66fb1ac15700392a26fdef8207db87144aac0
commit cab66fb1ac15700392a26fdef8207db87144aac0
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    html: layout: flex: Helper to get main margin end size

diff --git a/content/handlers/html/layout_flex.c 
b/content/handlers/html/layout_flex.c
index cea7964..a12becf 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -172,6 +172,38 @@ static struct flex_ctx *layout_flex_ctx__create(
 }
 
 /**
+ * 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
  *
  * \param[in] ctx              Flex layout context
@@ -738,22 +770,6 @@ static bool layout_flex__resolve_line(
 }
 
 /**
- * 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
  *
  * \param[in] ctx   Flex layout context


-----------------------------------------------------------------------

Summary of changes:
 content/handlers/html/layout_flex.c |  101 +++++++++++++++++++++++++++--------
 1 file changed, 80 insertions(+), 21 deletions(-)

diff --git a/content/handlers/html/layout_flex.c 
b/content/handlers/html/layout_flex.c
index cea7964..ac0b888 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;
@@ -172,6 +175,38 @@ static struct flex_ctx *layout_flex_ctx__create(
 }
 
 /**
+ * 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
  *
  * \param[in] ctx              Flex layout context
@@ -378,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;
 
@@ -409,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++;
@@ -440,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);
@@ -738,22 +786,6 @@ static bool layout_flex__resolve_line(
 }
 
 /**
- * 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
  *
  * \param[in] ctx   Flex layout context
@@ -768,16 +800,33 @@ static bool layout_flex__place_line_items_main(
        int post_multiplier = ctx->main_reversed ? 0 : 1;
        int pre_multiplier = ctx->main_reversed ? -1 : 0;
        size_t item_count = line->first + line->count;
+       int extra_remainder = 0;
+       int extra = 0;
 
        if (ctx->main_reversed) {
                main_pos = lh__box_size_main(ctx->horizontal, ctx->flex) -
                                main_pos;
        }
 
+       if (ctx->available_main != AUTO &&
+           ctx->available_main != UNKNOWN_WIDTH &&
+           ctx->available_main > line->used_main_size) {
+               if (line->main_auto_margin_count > 0) {
+                       extra = ctx->available_main - line->used_main_size;
+
+                       extra_remainder = extra % line->main_auto_margin_count;
+                       extra /= line->main_auto_margin_count;
+               }
+       }
+
        for (size_t i = line->first; i < item_count; i++) {
+               enum box_side main_end = ctx->horizontal ? RIGHT : BOTTOM;
                enum box_side main_start = ctx->horizontal ? LEFT : TOP;
                struct flex_item_data *item = &ctx->item.data[i];
                struct box *b = item->box;
+               int extra_total = 0;
+               int extra_post = 0;
+               int extra_pre = 0;
                int box_size_main;
                int *box_pos_main;
 
@@ -794,20 +843,30 @@ static bool layout_flex__place_line_items_main(
                box_pos_main = ctx->horizontal ? &b->x : &b->y;
 
                if (!lh__box_is_absolute(b)) {
-                       main_pos += pre_multiplier * (box_size_main +
-                                       lh__delta_outer_main(ctx->flex, b));
+                       if (b->margin[main_start] == AUTO) {
+                               extra_pre = extra + extra_remainder;
+                       }
+                       if (b->margin[main_end] == AUTO) {
+                               extra_post = extra + extra_remainder;
+                       }
+                       extra_total = extra_pre + extra_post;
+
+                       main_pos += pre_multiplier *
+                                       (extra_total + box_size_main +
+                                        lh__delta_outer_main(ctx->flex, b));
                }
 
                *box_pos_main = main_pos + lh__non_auto_margin(b, main_start) +
-                               b->border[main_start].width;
+                               extra_pre + b->border[main_start].width;
 
                if (!lh__box_is_absolute(b)) {
                        int cross_size;
                        int box_size_cross = lh__box_size_cross(
                                        ctx->horizontal, b);
 
-                       main_pos += post_multiplier * (box_size_main +
-                                       lh__delta_outer_main(ctx->flex, b));
+                       main_pos += post_multiplier *
+                                       (extra_total + box_size_main +
+                                        lh__delta_outer_main(ctx->flex, b));
 
                        cross_size = box_size_cross + lh__delta_outer_cross(
                                        ctx->flex, b);


-- 
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to