Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/4c2c53487703fe212be466db128f3adb09acf0d4
...commit
http://git.netsurf-browser.org/netsurf.git/commit/4c2c53487703fe212be466db128f3adb09acf0d4
...tree
http://git.netsurf-browser.org/netsurf.git/tree/4c2c53487703fe212be466db128f3adb09acf0d4
The branch, tlsa/flex has been updated
via 4c2c53487703fe212be466db128f3adb09acf0d4 (commit)
from f33097278ec8eabd89c7e8768c77c81915021727 (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=4c2c53487703fe212be466db128f3adb09acf0d4
commit 4c2c53487703fe212be466db128f3adb09acf0d4
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
WIP: More flex (includes block min/max pass fix)
diff --git a/content/handlers/html/box_construct.c
b/content/handlers/html/box_construct.c
index 245aab4..648920d 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -437,6 +437,23 @@ box_construct_marker(struct box *box,
return true;
}
+static inline bool box__style_is_float(const struct box *box)
+{
+ return css_computed_float(box->style) == CSS_FLOAT_LEFT ||
+ css_computed_float(box->style) == CSS_FLOAT_RIGHT;
+}
+
+static inline bool box__is_flex(const struct box *box)
+{
+ return box->type == BOX_FLEX || box->type == BOX_INLINE_FLEX;
+}
+
+static inline bool box__containing_block_is_flex(
+ const struct box_construct_props *props)
+{
+ return props->containing_block != NULL &&
+ box__is_flex(props->containing_block);
+}
/**
* Construct the box tree for an XML element.
@@ -571,6 +588,21 @@ box_construct_element(struct box_construct_ctx *ctx, bool
*convert_children)
/* Normal mapping */
box->type = box_map[css_computed_display(box->style,
props.node_is_root)];
+
+ if (props.containing_block->type == BOX_FLEX ||
+ props.containing_block->type == BOX_INLINE_FLEX) {
+ /* Blockification */
+ switch (box->type) {
+ case BOX_INLINE_FLEX:
+ box->type = BOX_FLEX;
+ break;
+ case BOX_INLINE_BLOCK:
+ box->type = BOX_BLOCK;
+ break;
+ default:
+ break;
+ }
+ }
}
if (convert_special_elements(ctx->n,
@@ -624,8 +656,8 @@ box_construct_element(struct box_construct_ctx *ctx, bool
*convert_children)
box->type == BOX_BR ||
box->type == BOX_INLINE_BLOCK ||
box->type == BOX_INLINE_FLEX ||
- css_computed_float(box->style) == CSS_FLOAT_LEFT ||
- css_computed_float(box->style) == CSS_FLOAT_RIGHT) &&
+ (box__style_is_float(box) &&
+ !box__containing_block_is_flex(&props))) &&
props.node_is_root == false) {
/* Found an inline child of a block without a current container
* (i.e. this box is the first child of its parent, or was
@@ -690,6 +722,7 @@ box_construct_element(struct box_construct_ctx *ctx, bool
*convert_children)
}
if (props.node_is_root == false &&
+ box__containing_block_is_flex(&props) == false
&&
(css_computed_float(box->style) ==
CSS_FLOAT_LEFT ||
css_computed_float(box->style) ==
diff --git a/content/handlers/html/box_inspect.c
b/content/handlers/html/box_inspect.c
index 73b0981..181f58c 100644
--- a/content/handlers/html/box_inspect.c
+++ b/content/handlers/html/box_inspect.c
@@ -660,7 +660,7 @@ void box_dump(FILE *stream, struct box *box, unsigned int
depth, bool style)
if (box->max_width != UNKNOWN_MAX_WIDTH) {
fprintf(stream, "min%i max%i ", box->min_width, box->max_width);
}
- fprintf(stream, "(%i %i %i %i) ",
+ fprintf(stream, "desc(%i %i %i %i) ",
box->descendant_x0, box->descendant_y0,
box->descendant_x1, box->descendant_y1);
diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c
index 8a8096b..7e530c8 100644
--- a/content/handlers/html/layout.c
+++ b/content/handlers/html/layout.c
@@ -283,7 +283,7 @@ static void layout_minmax_table(struct box *table,
return;
if (table_calculate_column_types(&content->unit_len_ctx, table) ==
false) {
- NSLOG(netsurf, WARNING,
+ NSLOG(netsurf, ERROR,
"Could not establish table column types.");
return;
}
@@ -1049,21 +1049,6 @@ static void layout_minmax_block(
wtype == CSS_WIDTH_SET && wunit != CSS_UNIT_PCT) {
min = max = FIXTOINT(css_unit_len2device_px(block->style,
&content->unit_len_ctx, width, wunit));
- if (bs == CSS_BOX_SIZING_BORDER_BOX) {
- int border_box_fixed = 0;
- float border_box_frac = 0;
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, LEFT,
- false, true, true,
- &border_box_fixed, &border_box_frac);
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, RIGHT,
- false, true, true,
- &border_box_fixed, &border_box_frac);
- if (min < border_box_fixed) {
- min = max = border_box_fixed;
- }
- }
}
if (htype == CSS_HEIGHT_SET && hunit != CSS_UNIT_PCT &&
@@ -1075,22 +1060,13 @@ static void layout_minmax_block(
/* add margins, border, padding to min, max widths */
/* Note: we don't know available width here so percentage margin
* and paddings are wrong. */
- if (bs == CSS_BOX_SIZING_BORDER_BOX && wtype == CSS_WIDTH_SET) {
- /* Border and padding included in width, so just get margin */
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, LEFT, true, false, false,
- &extra_fixed, &extra_frac);
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, RIGHT, true, false, false,
- &extra_fixed, &extra_frac);
- } else {
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, LEFT, true, true, true,
- &extra_fixed, &extra_frac);
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, RIGHT, true, true, true,
- &extra_fixed, &extra_frac);
- }
+ calculate_mbp_width(&content->unit_len_ctx,
+ block->style, LEFT, true, true, true,
+ &extra_fixed, &extra_frac);
+ calculate_mbp_width(&content->unit_len_ctx,
+ block->style, RIGHT, true, true, true,
+ &extra_fixed, &extra_frac);
+
if (extra_fixed < 0)
extra_fixed = 0;
if (extra_frac < 0)
@@ -2271,7 +2247,9 @@ static bool layout_block_object(struct box *block)
{
assert(block);
assert(block->type == BOX_BLOCK ||
+ block->type == BOX_FLEX ||
block->type == BOX_INLINE_BLOCK ||
+ block->type == BOX_INLINE_FLEX ||
block->type == BOX_TABLE ||
block->type == BOX_TABLE_CELL);
assert(block->object);
@@ -3790,7 +3768,8 @@ bool layout_block_context(
goto advance_to_next_box;
}
- NSLOG(layout, DEBUG, "box %p, cx %i, cy %i", box, cx, cy);
+ NSLOG(layout, DEBUG, "box %p, cx %i, cy %i, width %i",
+ box, cx, cy, box->width);
/* Layout (except tables). */
if (box->object) {
@@ -5446,7 +5425,7 @@ bool layout_document(html_content *content, int width,
int height)
layout_position_absolute(doc, doc, 0, 0, content);
layout_position_relative(&content->unit_len_ctx, doc, doc, 0, 0);
- box_dump(stderr, doc, 0, false);
+// box_dump(stderr, doc, 0, false);
layout_calculate_descendant_bboxes(&content->unit_len_ctx, doc);
return ret;
diff --git a/content/handlers/html/layout_flex.c
b/content/handlers/html/layout_flex.c
index 8b789b8..9382569 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -226,16 +226,15 @@ static inline bool layout_flex__base_and_main_sizes(
if (ctx->horizontal == false) {
item->base_size = b->height;
} else {
- item->base_size = b->max_width;
+ item->base_size = b->max_width - delta_outer_main;
}
}
- item->base_size = min(item->base_size + delta_outer_main,
- available_width);
+ item->base_size += delta_outer_main;
if (ctx->horizontal) {
- item->base_size = max(item->base_size,
- b->min_width + delta_outer_main);
+ item->base_size = min(item->base_size, available_width);
+ item->base_size = max(item->base_size, b->min_width);
}
item->target_main_size = item->base_size;
@@ -338,8 +337,9 @@ static struct flex_line_data
*layout_flex__build_line(struct flex_ctx *ctx,
struct box *b = item->box;
int main;
- main = ctx->horizontal ? b->max_width : b->height;
- main += lh__delta_outer_main(ctx->flex, b);
+ main = ctx->horizontal ?
+ item->main_size :
+ b->height + lh__delta_outer_main(ctx->flex, b);
if (ctx->wrap == CSS_FLEX_WRAP_NOWRAP ||
main + used_main <= available_main ||
@@ -548,7 +548,7 @@ static bool layout_flex__resolve_line_horizontal(
int available_width)
{
size_t item_count = line->first + line->count;
- int x = 0;
+ int x = ctx->flex->padding[LEFT];
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
@@ -566,17 +566,15 @@ static bool layout_flex__resolve_line_horizontal(
height = b->height + lh__delta_outer_height(b);
- b->y = ctx->cross_size +
+ b->y = ctx->flex->padding[TOP] + ctx->cross_size +
lh__non_auto_margin(b, TOP) +
- b->border[TOP].width +
- b->padding[TOP];
+ b->border[TOP].width;
if (line->cross_size < height) {
line->cross_size = height;
}
b->x = x + lh__non_auto_margin(b, LEFT) +
- b->border[LEFT].width +
- b->padding[LEFT];
+ b->border[LEFT].width;
x += b->width + lh__delta_outer_width(b);
}
@@ -589,7 +587,7 @@ static bool layout_flex__resolve_line_vertical(
int available_width)
{
size_t item_count = line->first + line->count;
- int y = 0;
+ int y = ctx->flex->padding[TOP];
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
@@ -598,17 +596,15 @@ static bool layout_flex__resolve_line_vertical(
width = b->width + lh__delta_outer_width(b);
- b->x = ctx->cross_size +
+ b->x = ctx->flex->padding[LEFT] + ctx->cross_size +
lh__non_auto_margin(b, LEFT) +
- b->border[LEFT].width +
- b->padding[LEFT];
+ b->border[LEFT].width;
if (line->cross_size < width) {
line->cross_size = width;
}
b->y = y + lh__non_auto_margin(b, TOP) +
- b->border[TOP].width +
- b->padding[TOP];
+ b->border[TOP].width;
y += b->height + lh__delta_outer_height(b);
}
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/box_construct.c | 37 ++++++++++++++++++++++++--
content/handlers/html/box_inspect.c | 2 +-
content/handlers/html/layout.c | 47 +++++++++------------------------
content/handlers/html/layout_flex.c | 34 +++++++++++-------------
4 files changed, 64 insertions(+), 56 deletions(-)
diff --git a/content/handlers/html/box_construct.c
b/content/handlers/html/box_construct.c
index 245aab4..648920d 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -437,6 +437,23 @@ box_construct_marker(struct box *box,
return true;
}
+static inline bool box__style_is_float(const struct box *box)
+{
+ return css_computed_float(box->style) == CSS_FLOAT_LEFT ||
+ css_computed_float(box->style) == CSS_FLOAT_RIGHT;
+}
+
+static inline bool box__is_flex(const struct box *box)
+{
+ return box->type == BOX_FLEX || box->type == BOX_INLINE_FLEX;
+}
+
+static inline bool box__containing_block_is_flex(
+ const struct box_construct_props *props)
+{
+ return props->containing_block != NULL &&
+ box__is_flex(props->containing_block);
+}
/**
* Construct the box tree for an XML element.
@@ -571,6 +588,21 @@ box_construct_element(struct box_construct_ctx *ctx, bool
*convert_children)
/* Normal mapping */
box->type = box_map[css_computed_display(box->style,
props.node_is_root)];
+
+ if (props.containing_block->type == BOX_FLEX ||
+ props.containing_block->type == BOX_INLINE_FLEX) {
+ /* Blockification */
+ switch (box->type) {
+ case BOX_INLINE_FLEX:
+ box->type = BOX_FLEX;
+ break;
+ case BOX_INLINE_BLOCK:
+ box->type = BOX_BLOCK;
+ break;
+ default:
+ break;
+ }
+ }
}
if (convert_special_elements(ctx->n,
@@ -624,8 +656,8 @@ box_construct_element(struct box_construct_ctx *ctx, bool
*convert_children)
box->type == BOX_BR ||
box->type == BOX_INLINE_BLOCK ||
box->type == BOX_INLINE_FLEX ||
- css_computed_float(box->style) == CSS_FLOAT_LEFT ||
- css_computed_float(box->style) == CSS_FLOAT_RIGHT) &&
+ (box__style_is_float(box) &&
+ !box__containing_block_is_flex(&props))) &&
props.node_is_root == false) {
/* Found an inline child of a block without a current container
* (i.e. this box is the first child of its parent, or was
@@ -690,6 +722,7 @@ box_construct_element(struct box_construct_ctx *ctx, bool
*convert_children)
}
if (props.node_is_root == false &&
+ box__containing_block_is_flex(&props) == false
&&
(css_computed_float(box->style) ==
CSS_FLOAT_LEFT ||
css_computed_float(box->style) ==
diff --git a/content/handlers/html/box_inspect.c
b/content/handlers/html/box_inspect.c
index 73b0981..181f58c 100644
--- a/content/handlers/html/box_inspect.c
+++ b/content/handlers/html/box_inspect.c
@@ -660,7 +660,7 @@ void box_dump(FILE *stream, struct box *box, unsigned int
depth, bool style)
if (box->max_width != UNKNOWN_MAX_WIDTH) {
fprintf(stream, "min%i max%i ", box->min_width, box->max_width);
}
- fprintf(stream, "(%i %i %i %i) ",
+ fprintf(stream, "desc(%i %i %i %i) ",
box->descendant_x0, box->descendant_y0,
box->descendant_x1, box->descendant_y1);
diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c
index 8a8096b..7e530c8 100644
--- a/content/handlers/html/layout.c
+++ b/content/handlers/html/layout.c
@@ -283,7 +283,7 @@ static void layout_minmax_table(struct box *table,
return;
if (table_calculate_column_types(&content->unit_len_ctx, table) ==
false) {
- NSLOG(netsurf, WARNING,
+ NSLOG(netsurf, ERROR,
"Could not establish table column types.");
return;
}
@@ -1049,21 +1049,6 @@ static void layout_minmax_block(
wtype == CSS_WIDTH_SET && wunit != CSS_UNIT_PCT) {
min = max = FIXTOINT(css_unit_len2device_px(block->style,
&content->unit_len_ctx, width, wunit));
- if (bs == CSS_BOX_SIZING_BORDER_BOX) {
- int border_box_fixed = 0;
- float border_box_frac = 0;
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, LEFT,
- false, true, true,
- &border_box_fixed, &border_box_frac);
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, RIGHT,
- false, true, true,
- &border_box_fixed, &border_box_frac);
- if (min < border_box_fixed) {
- min = max = border_box_fixed;
- }
- }
}
if (htype == CSS_HEIGHT_SET && hunit != CSS_UNIT_PCT &&
@@ -1075,22 +1060,13 @@ static void layout_minmax_block(
/* add margins, border, padding to min, max widths */
/* Note: we don't know available width here so percentage margin
* and paddings are wrong. */
- if (bs == CSS_BOX_SIZING_BORDER_BOX && wtype == CSS_WIDTH_SET) {
- /* Border and padding included in width, so just get margin */
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, LEFT, true, false, false,
- &extra_fixed, &extra_frac);
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, RIGHT, true, false, false,
- &extra_fixed, &extra_frac);
- } else {
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, LEFT, true, true, true,
- &extra_fixed, &extra_frac);
- calculate_mbp_width(&content->unit_len_ctx,
- block->style, RIGHT, true, true, true,
- &extra_fixed, &extra_frac);
- }
+ calculate_mbp_width(&content->unit_len_ctx,
+ block->style, LEFT, true, true, true,
+ &extra_fixed, &extra_frac);
+ calculate_mbp_width(&content->unit_len_ctx,
+ block->style, RIGHT, true, true, true,
+ &extra_fixed, &extra_frac);
+
if (extra_fixed < 0)
extra_fixed = 0;
if (extra_frac < 0)
@@ -2271,7 +2247,9 @@ static bool layout_block_object(struct box *block)
{
assert(block);
assert(block->type == BOX_BLOCK ||
+ block->type == BOX_FLEX ||
block->type == BOX_INLINE_BLOCK ||
+ block->type == BOX_INLINE_FLEX ||
block->type == BOX_TABLE ||
block->type == BOX_TABLE_CELL);
assert(block->object);
@@ -3790,7 +3768,8 @@ bool layout_block_context(
goto advance_to_next_box;
}
- NSLOG(layout, DEBUG, "box %p, cx %i, cy %i", box, cx, cy);
+ NSLOG(layout, DEBUG, "box %p, cx %i, cy %i, width %i",
+ box, cx, cy, box->width);
/* Layout (except tables). */
if (box->object) {
@@ -5446,7 +5425,7 @@ bool layout_document(html_content *content, int width,
int height)
layout_position_absolute(doc, doc, 0, 0, content);
layout_position_relative(&content->unit_len_ctx, doc, doc, 0, 0);
- box_dump(stderr, doc, 0, false);
+// box_dump(stderr, doc, 0, false);
layout_calculate_descendant_bboxes(&content->unit_len_ctx, doc);
return ret;
diff --git a/content/handlers/html/layout_flex.c
b/content/handlers/html/layout_flex.c
index 8b789b8..9382569 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -226,16 +226,15 @@ static inline bool layout_flex__base_and_main_sizes(
if (ctx->horizontal == false) {
item->base_size = b->height;
} else {
- item->base_size = b->max_width;
+ item->base_size = b->max_width - delta_outer_main;
}
}
- item->base_size = min(item->base_size + delta_outer_main,
- available_width);
+ item->base_size += delta_outer_main;
if (ctx->horizontal) {
- item->base_size = max(item->base_size,
- b->min_width + delta_outer_main);
+ item->base_size = min(item->base_size, available_width);
+ item->base_size = max(item->base_size, b->min_width);
}
item->target_main_size = item->base_size;
@@ -338,8 +337,9 @@ static struct flex_line_data
*layout_flex__build_line(struct flex_ctx *ctx,
struct box *b = item->box;
int main;
- main = ctx->horizontal ? b->max_width : b->height;
- main += lh__delta_outer_main(ctx->flex, b);
+ main = ctx->horizontal ?
+ item->main_size :
+ b->height + lh__delta_outer_main(ctx->flex, b);
if (ctx->wrap == CSS_FLEX_WRAP_NOWRAP ||
main + used_main <= available_main ||
@@ -548,7 +548,7 @@ static bool layout_flex__resolve_line_horizontal(
int available_width)
{
size_t item_count = line->first + line->count;
- int x = 0;
+ int x = ctx->flex->padding[LEFT];
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
@@ -566,17 +566,15 @@ static bool layout_flex__resolve_line_horizontal(
height = b->height + lh__delta_outer_height(b);
- b->y = ctx->cross_size +
+ b->y = ctx->flex->padding[TOP] + ctx->cross_size +
lh__non_auto_margin(b, TOP) +
- b->border[TOP].width +
- b->padding[TOP];
+ b->border[TOP].width;
if (line->cross_size < height) {
line->cross_size = height;
}
b->x = x + lh__non_auto_margin(b, LEFT) +
- b->border[LEFT].width +
- b->padding[LEFT];
+ b->border[LEFT].width;
x += b->width + lh__delta_outer_width(b);
}
@@ -589,7 +587,7 @@ static bool layout_flex__resolve_line_vertical(
int available_width)
{
size_t item_count = line->first + line->count;
- int y = 0;
+ int y = ctx->flex->padding[TOP];
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
@@ -598,17 +596,15 @@ static bool layout_flex__resolve_line_vertical(
width = b->width + lh__delta_outer_width(b);
- b->x = ctx->cross_size +
+ b->x = ctx->flex->padding[LEFT] + ctx->cross_size +
lh__non_auto_margin(b, LEFT) +
- b->border[LEFT].width +
- b->padding[LEFT];
+ b->border[LEFT].width;
if (line->cross_size < width) {
line->cross_size = width;
}
b->y = y + lh__non_auto_margin(b, TOP) +
- b->border[TOP].width +
- b->padding[TOP];
+ b->border[TOP].width;
y += b->height + lh__delta_outer_height(b);
}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]