Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/5ea392d58f94d6cb72a36050b627fc2dbfb77eb1
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/5ea392d58f94d6cb72a36050b627fc2dbfb77eb1
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/5ea392d58f94d6cb72a36050b627fc2dbfb77eb1

The branch, tlsa/flex has been updated
       via  5ea392d58f94d6cb72a36050b627fc2dbfb77eb1 (commit)
      from  d405207bde232b6e8d5f0ba2a7d7c7e4d5ffb4a3 (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=5ea392d58f94d6cb72a36050b627fc2dbfb77eb1
commit 5ea392d58f94d6cb72a36050b627fc2dbfb77eb1
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    html: layout: Add layout helper for dealing with auto margins

diff --git a/content/handlers/html/layout_flex.c 
b/content/handlers/html/layout_flex.c
index 8a53b98..8c43079 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -563,14 +563,14 @@ static bool layout_flex__resolve_line_horizontal(
                height = b->height + lh__delta_outer_height(b);
 
                b->y = ctx->cross_size +
-                               b->margin[TOP] +
+                               lh__non_auto_margin(b, TOP) +
                                b->border[TOP].width +
                                b->padding[TOP];
                if (line->cross_size < height) {
                        line->cross_size = height;
                }
 
-               b->x = x + b->margin[LEFT] +
+               b->x = x + lh__non_auto_margin(b, LEFT) +
                                b->border[LEFT].width +
                                b->padding[LEFT];
                x += b->width + lh__delta_outer_width(b);
@@ -595,14 +595,14 @@ static bool layout_flex__resolve_line_vertical(
                width = b->width + lh__delta_outer_width(b);
 
                b->x = ctx->cross_size +
-                               b->margin[LEFT] +
+                               lh__non_auto_margin(b, LEFT) +
                                b->border[LEFT].width +
                                b->padding[LEFT];
                if (line->cross_size < width) {
                        line->cross_size = width;
                }
 
-               b->y = y + b->margin[TOP] +
+               b->y = y + lh__non_auto_margin(b, TOP) +
                                b->border[TOP].width +
                                b->padding[TOP];
                y += b->height + lh__delta_outer_height(b);
diff --git a/content/handlers/html/layout_internal.h 
b/content/handlers/html/layout_internal.h
index 7934ddd..2cbd1ee 100644
--- a/content/handlers/html/layout_internal.h
+++ b/content/handlers/html/layout_internal.h
@@ -183,24 +183,29 @@ static inline bool layout_flex__main_is_horizontal(const 
struct box *flex)
        }
 }
 
+static inline int lh__non_auto_margin(const struct box *b, enum box_side side)
+{
+       return (b->margin[side] == AUTO) ? 0 : b->margin[side];
+}
+
 static inline int lh__delta_outer_height(const struct box *b)
 {
-       return b->margin[TOP] +
-              b->margin[BOTTOM] +
+       return b->padding[TOP] +
+              b->padding[BOTTOM] +
               b->border[TOP].width +
               b->border[BOTTOM].width +
-              b->padding[TOP] +
-              b->padding[BOTTOM];
+              lh__non_auto_margin(b, TOP) +
+              lh__non_auto_margin(b, BOTTOM);
 }
 
 static inline int lh__delta_outer_width(const struct box *b)
 {
-       return b->margin[LEFT] +
-              b->margin[RIGHT] +
+       return b->padding[LEFT] +
+              b->padding[RIGHT] +
               b->border[LEFT].width +
               b->border[RIGHT].width +
-              b->padding[LEFT] +
-              b->padding[RIGHT];
+              lh__non_auto_margin(b, LEFT) +
+              lh__non_auto_margin(b, RIGHT);
 }
 
 static inline int lh__delta_outer_main(const struct box *flex)


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

Summary of changes:
 content/handlers/html/layout_flex.c     |    8 ++++----
 content/handlers/html/layout_internal.h |   21 +++++++++++++--------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/content/handlers/html/layout_flex.c 
b/content/handlers/html/layout_flex.c
index 8a53b98..8c43079 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -563,14 +563,14 @@ static bool layout_flex__resolve_line_horizontal(
                height = b->height + lh__delta_outer_height(b);
 
                b->y = ctx->cross_size +
-                               b->margin[TOP] +
+                               lh__non_auto_margin(b, TOP) +
                                b->border[TOP].width +
                                b->padding[TOP];
                if (line->cross_size < height) {
                        line->cross_size = height;
                }
 
-               b->x = x + b->margin[LEFT] +
+               b->x = x + lh__non_auto_margin(b, LEFT) +
                                b->border[LEFT].width +
                                b->padding[LEFT];
                x += b->width + lh__delta_outer_width(b);
@@ -595,14 +595,14 @@ static bool layout_flex__resolve_line_vertical(
                width = b->width + lh__delta_outer_width(b);
 
                b->x = ctx->cross_size +
-                               b->margin[LEFT] +
+                               lh__non_auto_margin(b, LEFT) +
                                b->border[LEFT].width +
                                b->padding[LEFT];
                if (line->cross_size < width) {
                        line->cross_size = width;
                }
 
-               b->y = y + b->margin[TOP] +
+               b->y = y + lh__non_auto_margin(b, TOP) +
                                b->border[TOP].width +
                                b->padding[TOP];
                y += b->height + lh__delta_outer_height(b);
diff --git a/content/handlers/html/layout_internal.h 
b/content/handlers/html/layout_internal.h
index 7934ddd..2cbd1ee 100644
--- a/content/handlers/html/layout_internal.h
+++ b/content/handlers/html/layout_internal.h
@@ -183,24 +183,29 @@ static inline bool layout_flex__main_is_horizontal(const 
struct box *flex)
        }
 }
 
+static inline int lh__non_auto_margin(const struct box *b, enum box_side side)
+{
+       return (b->margin[side] == AUTO) ? 0 : b->margin[side];
+}
+
 static inline int lh__delta_outer_height(const struct box *b)
 {
-       return b->margin[TOP] +
-              b->margin[BOTTOM] +
+       return b->padding[TOP] +
+              b->padding[BOTTOM] +
               b->border[TOP].width +
               b->border[BOTTOM].width +
-              b->padding[TOP] +
-              b->padding[BOTTOM];
+              lh__non_auto_margin(b, TOP) +
+              lh__non_auto_margin(b, BOTTOM);
 }
 
 static inline int lh__delta_outer_width(const struct box *b)
 {
-       return b->margin[LEFT] +
-              b->margin[RIGHT] +
+       return b->padding[LEFT] +
+              b->padding[RIGHT] +
               b->border[LEFT].width +
               b->border[RIGHT].width +
-              b->padding[LEFT] +
-              b->padding[RIGHT];
+              lh__non_auto_margin(b, LEFT) +
+              lh__non_auto_margin(b, RIGHT);
 }
 
 static inline int lh__delta_outer_main(const struct box *flex)


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

Reply via email to