libnsgif: branch tlsa/ci-sanitize created. release/0.2.1-213-g622cf7e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libnsgif.git/shortlog/622cf7e422a8ef0acaba...
...commit http://git.netsurf-browser.org/libnsgif.git/commit/622cf7e422a8ef0acabad1...
...tree http://git.netsurf-browser.org/libnsgif.git/tree/622cf7e422a8ef0acabad1bc...
The branch, tlsa/ci-sanitize has been created
at 622cf7e422a8ef0acabad1bc8a98731cb1a7f5a9 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=622cf7e422a8ef0aca...
commit 622cf7e422a8ef0acabad1bc8a98731cb1a7f5a9
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
CI: Add sanitizer jobs
diff --git a/.github/workflows/sanitize.yaml b/.github/workflows/sanitize.yaml
new file mode 100644
index 0000000..70a2f3c
--- /dev/null
+++ b/.github/workflows/sanitize.yaml
@@ -0,0 +1,65 @@
+name: "Linux Sanitize"
+
+on: [push]
+
+jobs:
+ linux:
+ name: '${{ matrix.os }}: ${{ matrix.compiler.vendor }}'
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - ubuntu-22.04
+ compiler:
+ # The NetSurf build system can't find LLVM AR (it looks for it
+ # in /usr/lib instead of /usr/bin:
+ # `make: /usr/lib/llvm-ar: No such file or directory`).
+ # So we need to make it explicit for llvm.
+ - { vendor: gnu, CC: gcc, AR: ar }
+ - { vendor: llvm, CC: clang, AR: llvm-ar }
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 1
+
+ - name: apt-get install packages
+ run: sudo apt-get update -qq &&
+ sudo apt-get install --no-install-recommends -y
+ bison
+ build-essential
+ check
+ clang
+ flex
+ git
+ gperf
+ llvm
+ pkg-config
+
+ - name: Get env.sh
+ run: |
+ mkdir projects
+ wget -O projects/env.sh https://git.netsurf-browser.org/netsurf.git/plain/docs/env.sh
+
+ - name: Build and install project deps
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ AR: ${{ matrix.compiler.AR }}
+ TARGET: ${{ github.event.repository.name }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source projects/env.sh
+ ns-clone -d -s
+ ns-make-libs install
+
+ - name: Build and Sanitize
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ AR: ${{ matrix.compiler.AR }}
+ TARGET: ${{ github.event.repository.name }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source projects/env.sh
+ make sanitize
-----------------------------------------------------------------------
--
NetSurf GIF Decoder
5 months, 3 weeks
libnsgif: branch master updated. release/0.2.1-212-gca8b9c3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libnsgif.git/shortlog/ca8b9c3784f1f0f074cf...
...commit http://git.netsurf-browser.org/libnsgif.git/commit/ca8b9c3784f1f0f074cff1...
...tree http://git.netsurf-browser.org/libnsgif.git/tree/ca8b9c3784f1f0f074cff1e5...
The branch, master has been updated
via ca8b9c3784f1f0f074cff1e5474d4a16b80885c6 (commit)
via ccec86deb2d8063aa60b72cf0cc099c9990b6c24 (commit)
via 1f39b5d057f614a46c99534f8fb4d64846fdbbee (commit)
from fa1f47e6bec71ed970a02a517056fac677256c9d (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/libnsgif.git/commit/?id=ca8b9c3784f1f0f074...
commit ca8b9c3784f1f0f074cff1e5474d4a16b80885c6
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
gif: Remove unnecessary cast
diff --git a/src/gif.c b/src/gif.c
index 5f7e599..688fe12 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -1343,7 +1343,7 @@ static nsgif_error nsgif__process_frame(
return NSGIF_OK;
}
} else {
- pos = (uint8_t *)(gif->buf + gif->buf_pos);
+ pos = gif->buf + gif->buf_pos;
/* Check if we've finished */
if (pos < end && pos[0] == NSGIF_TRAILER) {
commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=ccec86deb2d8063aa6...
commit ccec86deb2d8063aa60b72cf0cc099c9990b6c24
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
gif: Store buffer length/position as size_t
This makes the internal behaviour match the public API.
diff --git a/src/gif.c b/src/gif.c
index fb4b03e..5f7e599 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -32,7 +32,7 @@ typedef struct nsgif_frame {
struct nsgif_frame_info info;
/** offset (in bytes) to the GIF frame data */
- uint32_t frame_offset;
+ size_t frame_offset;
/** whether the frame has previously been decoded. */
bool decoded;
/** whether the frame is totally opaque */
@@ -102,9 +102,9 @@ struct nsgif {
/** pointer to GIF data */
const uint8_t *buf;
/** current index into GIF data */
- uint32_t buf_pos;
+ size_t buf_pos;
/** total number of bytes of GIF data available */
- uint32_t buf_len;
+ size_t buf_len;
/** current number of frame holders */
uint32_t frame_holders;
commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=1f39b5d057f614a46c...
commit 1f39b5d057f614a46c99534f8fb4d64846fdbbee
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
lzw: Use size_t for buffer length/position
diff --git a/src/lzw.c b/src/lzw.c
index 6f85caa..3098ef5 100644
--- a/src/lzw.c
+++ b/src/lzw.c
@@ -36,9 +36,9 @@
* Note that an individual LZW code can be split over up to three sub-blocks.
*/
struct lzw_read_ctx {
- const uint8_t *restrict data; /**< Pointer to start of input data */
- uint32_t data_len; /**< Input data length */
- uint32_t data_sb_next; /**< Offset to sub-block size */
+ const uint8_t *restrict data; /**< Pointer to start of input data */
+ size_t data_len; /**< Input data length */
+ size_t data_sb_next; /**< Offset to sub-block size */
const uint8_t *sb_data; /**< Pointer to current sub-block in data */
size_t sb_bit; /**< Current bit offset in sub-block */
@@ -122,8 +122,8 @@ void lzw_context_destroy(struct lzw_ctx *ctx)
*/
static lzw_result lzw__block_advance(struct lzw_read_ctx *restrict ctx)
{
- uint32_t block_size;
- uint32_t next_block_pos = ctx->data_sb_next;
+ size_t block_size;
+ size_t next_block_pos = ctx->data_sb_next;
const uint8_t *data_next = ctx->data + next_block_pos;
if (next_block_pos >= ctx->data_len) {
@@ -260,8 +260,8 @@ lzw_result lzw_decode_init(
struct lzw_ctx *ctx,
uint8_t minimum_code_size,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos)
+ size_t input_length,
+ size_t input_pos)
{
struct lzw_table_entry *table = ctx->table;
lzw_result res;
@@ -322,8 +322,8 @@ lzw_result lzw_decode_init_map(
uint32_t transparency_idx,
const uint32_t *colour_table,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos)
+ size_t input_length,
+ size_t input_pos)
{
lzw_result res;
diff --git a/src/lzw.h b/src/lzw.h
index c68753a..f19432f 100644
--- a/src/lzw.h
+++ b/src/lzw.h
@@ -69,8 +69,8 @@ lzw_result lzw_decode_init(
struct lzw_ctx *ctx,
uint8_t minimum_code_size,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos);
+ size_t input_length,
+ size_t input_pos);
/**
* Read input codes until end of LZW context owned output buffer.
@@ -110,8 +110,8 @@ lzw_result lzw_decode_init_map(
uint32_t transparency_idx,
const uint32_t *colour_table,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos);
+ size_t input_length,
+ size_t input_pos);
/**
* Read LZW codes into client buffer, mapping output to colours.
-----------------------------------------------------------------------
Summary of changes:
src/gif.c | 8 ++++----
src/lzw.c | 18 +++++++++---------
src/lzw.h | 8 ++++----
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/gif.c b/src/gif.c
index fb4b03e..688fe12 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -32,7 +32,7 @@ typedef struct nsgif_frame {
struct nsgif_frame_info info;
/** offset (in bytes) to the GIF frame data */
- uint32_t frame_offset;
+ size_t frame_offset;
/** whether the frame has previously been decoded. */
bool decoded;
/** whether the frame is totally opaque */
@@ -102,9 +102,9 @@ struct nsgif {
/** pointer to GIF data */
const uint8_t *buf;
/** current index into GIF data */
- uint32_t buf_pos;
+ size_t buf_pos;
/** total number of bytes of GIF data available */
- uint32_t buf_len;
+ size_t buf_len;
/** current number of frame holders */
uint32_t frame_holders;
@@ -1343,7 +1343,7 @@ static nsgif_error nsgif__process_frame(
return NSGIF_OK;
}
} else {
- pos = (uint8_t *)(gif->buf + gif->buf_pos);
+ pos = gif->buf + gif->buf_pos;
/* Check if we've finished */
if (pos < end && pos[0] == NSGIF_TRAILER) {
diff --git a/src/lzw.c b/src/lzw.c
index 6f85caa..3098ef5 100644
--- a/src/lzw.c
+++ b/src/lzw.c
@@ -36,9 +36,9 @@
* Note that an individual LZW code can be split over up to three sub-blocks.
*/
struct lzw_read_ctx {
- const uint8_t *restrict data; /**< Pointer to start of input data */
- uint32_t data_len; /**< Input data length */
- uint32_t data_sb_next; /**< Offset to sub-block size */
+ const uint8_t *restrict data; /**< Pointer to start of input data */
+ size_t data_len; /**< Input data length */
+ size_t data_sb_next; /**< Offset to sub-block size */
const uint8_t *sb_data; /**< Pointer to current sub-block in data */
size_t sb_bit; /**< Current bit offset in sub-block */
@@ -122,8 +122,8 @@ void lzw_context_destroy(struct lzw_ctx *ctx)
*/
static lzw_result lzw__block_advance(struct lzw_read_ctx *restrict ctx)
{
- uint32_t block_size;
- uint32_t next_block_pos = ctx->data_sb_next;
+ size_t block_size;
+ size_t next_block_pos = ctx->data_sb_next;
const uint8_t *data_next = ctx->data + next_block_pos;
if (next_block_pos >= ctx->data_len) {
@@ -260,8 +260,8 @@ lzw_result lzw_decode_init(
struct lzw_ctx *ctx,
uint8_t minimum_code_size,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos)
+ size_t input_length,
+ size_t input_pos)
{
struct lzw_table_entry *table = ctx->table;
lzw_result res;
@@ -322,8 +322,8 @@ lzw_result lzw_decode_init_map(
uint32_t transparency_idx,
const uint32_t *colour_table,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos)
+ size_t input_length,
+ size_t input_pos)
{
lzw_result res;
diff --git a/src/lzw.h b/src/lzw.h
index c68753a..f19432f 100644
--- a/src/lzw.h
+++ b/src/lzw.h
@@ -69,8 +69,8 @@ lzw_result lzw_decode_init(
struct lzw_ctx *ctx,
uint8_t minimum_code_size,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos);
+ size_t input_length,
+ size_t input_pos);
/**
* Read input codes until end of LZW context owned output buffer.
@@ -110,8 +110,8 @@ lzw_result lzw_decode_init_map(
uint32_t transparency_idx,
const uint32_t *colour_table,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos);
+ size_t input_length,
+ size_t input_pos);
/**
* Read LZW codes into client buffer, mapping output to colours.
--
NetSurf GIF Decoder
5 months, 3 weeks
libnsgif: branch tlsa/buffer-lengths created. release/0.2.1-212-gc7c807a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libnsgif.git/shortlog/c7c807ad44462583bd3a...
...commit http://git.netsurf-browser.org/libnsgif.git/commit/c7c807ad44462583bd3a13...
...tree http://git.netsurf-browser.org/libnsgif.git/tree/c7c807ad44462583bd3a136e...
The branch, tlsa/buffer-lengths has been created
at c7c807ad44462583bd3a136e4a575418ab29e9de (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=c7c807ad44462583bd...
commit c7c807ad44462583bd3a136e4a575418ab29e9de
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
gif: Remove unnecessary cast
diff --git a/src/gif.c b/src/gif.c
index 5f7e599..688fe12 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -1343,7 +1343,7 @@ static nsgif_error nsgif__process_frame(
return NSGIF_OK;
}
} else {
- pos = (uint8_t *)(gif->buf + gif->buf_pos);
+ pos = gif->buf + gif->buf_pos;
/* Check if we've finished */
if (pos < end && pos[0] == NSGIF_TRAILER) {
commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=5368f2f0e929f83a09...
commit 5368f2f0e929f83a090e68171c33aad6d9b3b3b2
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
gif: Store buffer length/position as size_t
This makes the internal behaviour match the public API.
diff --git a/src/gif.c b/src/gif.c
index fb4b03e..5f7e599 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -32,7 +32,7 @@ typedef struct nsgif_frame {
struct nsgif_frame_info info;
/** offset (in bytes) to the GIF frame data */
- uint32_t frame_offset;
+ size_t frame_offset;
/** whether the frame has previously been decoded. */
bool decoded;
/** whether the frame is totally opaque */
@@ -102,9 +102,9 @@ struct nsgif {
/** pointer to GIF data */
const uint8_t *buf;
/** current index into GIF data */
- uint32_t buf_pos;
+ size_t buf_pos;
/** total number of bytes of GIF data available */
- uint32_t buf_len;
+ size_t buf_len;
/** current number of frame holders */
uint32_t frame_holders;
commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=80c9c8d8e065a34662...
commit 80c9c8d8e065a34662979ee002bd760df0b831a1
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
lzw: Use size_t for buffer length/position
diff --git a/src/lzw.c b/src/lzw.c
index 6f85caa..3098ef5 100644
--- a/src/lzw.c
+++ b/src/lzw.c
@@ -36,9 +36,9 @@
* Note that an individual LZW code can be split over up to three sub-blocks.
*/
struct lzw_read_ctx {
- const uint8_t *restrict data; /**< Pointer to start of input data */
- uint32_t data_len; /**< Input data length */
- uint32_t data_sb_next; /**< Offset to sub-block size */
+ const uint8_t *restrict data; /**< Pointer to start of input data */
+ size_t data_len; /**< Input data length */
+ size_t data_sb_next; /**< Offset to sub-block size */
const uint8_t *sb_data; /**< Pointer to current sub-block in data */
size_t sb_bit; /**< Current bit offset in sub-block */
@@ -122,8 +122,8 @@ void lzw_context_destroy(struct lzw_ctx *ctx)
*/
static lzw_result lzw__block_advance(struct lzw_read_ctx *restrict ctx)
{
- uint32_t block_size;
- uint32_t next_block_pos = ctx->data_sb_next;
+ size_t block_size;
+ size_t next_block_pos = ctx->data_sb_next;
const uint8_t *data_next = ctx->data + next_block_pos;
if (next_block_pos >= ctx->data_len) {
@@ -260,8 +260,8 @@ lzw_result lzw_decode_init(
struct lzw_ctx *ctx,
uint8_t minimum_code_size,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos)
+ size_t input_length,
+ size_t input_pos)
{
struct lzw_table_entry *table = ctx->table;
lzw_result res;
@@ -322,8 +322,8 @@ lzw_result lzw_decode_init_map(
uint32_t transparency_idx,
const uint32_t *colour_table,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos)
+ size_t input_length,
+ size_t input_pos)
{
lzw_result res;
diff --git a/src/lzw.h b/src/lzw.h
index c68753a..f19432f 100644
--- a/src/lzw.h
+++ b/src/lzw.h
@@ -69,8 +69,8 @@ lzw_result lzw_decode_init(
struct lzw_ctx *ctx,
uint8_t minimum_code_size,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos);
+ size_t input_length,
+ size_t input_pos);
/**
* Read input codes until end of LZW context owned output buffer.
@@ -110,8 +110,8 @@ lzw_result lzw_decode_init_map(
uint32_t transparency_idx,
const uint32_t *colour_table,
const uint8_t *input_data,
- uint32_t input_length,
- uint32_t input_pos);
+ size_t input_length,
+ size_t input_pos);
/**
* Read LZW codes into client buffer, mapping output to colours.
-----------------------------------------------------------------------
--
NetSurf GIF Decoder
5 months, 3 weeks
netsurf: branch master updated. release/3.10-351-gf7a0135
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f7a0135300ead08731fe1...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f7a0135300ead08731fe10a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f7a0135300ead08731fe10a63...
The branch, master has been updated
via f7a0135300ead08731fe10a63891a12cc2dbe067 (commit)
via 73dab84ef8de2f419349aa4c8872704c7ca9122c (commit)
via dbd7f5bcd8a6500c7236bbe67e4a38c48a613b20 (commit)
from 71765dd1e8dc968f15ce359f7e604585aa428f90 (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=f7a0135300ead08731f...
commit f7a0135300ead08731fe10a63891a12cc2dbe067
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Don't freeze already-frozen items
This fixes an error in the used main size tracking.
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index 7c295f1..61adcaa 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -780,6 +780,10 @@ static bool layout_flex__resolve_line(
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
+ if (item->freeze) {
+ continue;
+ }
+
if (total_violation == 0 ||
(total_violation > 0 && item->min_violation) ||
(total_violation < 0 && item->max_violation)) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=73dab84ef8de2f41934...
commit 73dab84ef8de2f419349aa4c8872704c7ca9122c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: shrink: Avoid rounding error accumulation
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index 3a0fa4a..7c295f1 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -649,6 +649,7 @@ static inline void layout_flex__distribute_free_main(
}
} else {
css_fixed scaled_shrink_factor_sum = 0;
+ css_fixed remainder = 0;
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
@@ -667,6 +668,7 @@ static inline void layout_flex__distribute_free_main(
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
css_fixed scaled_shrink_factor;
+ css_fixed result;
css_fixed ratio;
if (item->freeze) {
@@ -681,12 +683,13 @@ static inline void layout_flex__distribute_free_main(
item->shrink,
INTTOFIX(item->base_size));
ratio = FDIV(scaled_shrink_factor,
- scaled_shrink_factor_sum);
+ scaled_shrink_factor_sum);
+ result = FMUL(INTTOFIX(abs(remaining_free_main)),
+ ratio) + remainder;
item->target_main_size = item->base_size -
- FIXTOINT(FMUL(
- INTTOFIX(abs(remaining_free_main)),
- ratio));
+ FIXTOINT(result);
+ remainder = FIXFRAC(result);
}
}
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=dbd7f5bcd8a6500c723...
commit dbd7f5bcd8a6500c7236bbe67e4a38c48a613b20
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: grow: Avoid rounding error accumulation
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index ac0b888..3a0fa4a 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -629,8 +629,10 @@ static inline void layout_flex__distribute_free_main(
size_t item_count = line->first + line->count;
if (grow) {
+ css_fixed remainder = 0;
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
+ css_fixed result;
css_fixed ratio;
if (item->freeze) {
@@ -638,11 +640,12 @@ static inline void layout_flex__distribute_free_main(
}
ratio = FDIV(item->grow, unfrozen_factor_sum);
+ result = FMUL(INTTOFIX(remaining_free_main), ratio) +
+ remainder;
item->target_main_size = item->base_size +
- FIXTOINT(FMUL(
- INTTOFIX(remaining_free_main),
- ratio));
+ FIXTOINT(result);
+ remainder = FIXFRAC(result);
}
} else {
css_fixed scaled_shrink_factor_sum = 0;
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/layout_flex.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index ac0b888..61adcaa 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -629,8 +629,10 @@ static inline void layout_flex__distribute_free_main(
size_t item_count = line->first + line->count;
if (grow) {
+ css_fixed remainder = 0;
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
+ css_fixed result;
css_fixed ratio;
if (item->freeze) {
@@ -638,14 +640,16 @@ static inline void layout_flex__distribute_free_main(
}
ratio = FDIV(item->grow, unfrozen_factor_sum);
+ result = FMUL(INTTOFIX(remaining_free_main), ratio) +
+ remainder;
item->target_main_size = item->base_size +
- FIXTOINT(FMUL(
- INTTOFIX(remaining_free_main),
- ratio));
+ FIXTOINT(result);
+ remainder = FIXFRAC(result);
}
} else {
css_fixed scaled_shrink_factor_sum = 0;
+ css_fixed remainder = 0;
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
@@ -664,6 +668,7 @@ static inline void layout_flex__distribute_free_main(
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
css_fixed scaled_shrink_factor;
+ css_fixed result;
css_fixed ratio;
if (item->freeze) {
@@ -678,12 +683,13 @@ static inline void layout_flex__distribute_free_main(
item->shrink,
INTTOFIX(item->base_size));
ratio = FDIV(scaled_shrink_factor,
- scaled_shrink_factor_sum);
+ scaled_shrink_factor_sum);
+ result = FMUL(INTTOFIX(abs(remaining_free_main)),
+ ratio) + remainder;
item->target_main_size = item->base_size -
- FIXTOINT(FMUL(
- INTTOFIX(abs(remaining_free_main)),
- ratio));
+ FIXTOINT(result);
+ remainder = FIXFRAC(result);
}
}
}
@@ -774,6 +780,10 @@ static bool layout_flex__resolve_line(
for (size_t i = line->first; i < item_count; i++) {
struct flex_item_data *item = &ctx->item.data[i];
+ if (item->freeze) {
+ continue;
+ }
+
if (total_violation == 0 ||
(total_violation > 0 && item->min_violation) ||
(total_violation < 0 && item->max_violation)) {
--
NetSurf Browser
5 months, 3 weeks
libcss: branch master updated. release/0.9.1-85-g58f1673
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/58f1673186a41b396d4ca4...
...commit http://git.netsurf-browser.org/libcss.git/commit/58f1673186a41b396d4ca4e1...
...tree http://git.netsurf-browser.org/libcss.git/tree/58f1673186a41b396d4ca4e13f...
The branch, master has been updated
via 58f1673186a41b396d4ca4e13f43b502a305bf01 (commit)
from f5842253bdb62fef9543e58ae38c232f5b4f982a (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/libcss.git/commit/?id=58f1673186a41b396d4c...
commit 58f1673186a41b396d4ca4e13f43b502a305bf01
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
api: fpmath: Add macro to get fractional part
diff --git a/include/libcss/fpmath.h b/include/libcss/fpmath.h
index d7cac4d..eec40b3 100644
--- a/include/libcss/fpmath.h
+++ b/include/libcss/fpmath.h
@@ -130,6 +130,8 @@ css_float_to_fixed(const float a) {
/* truncate a fixed point value */
#define TRUNCATEFIX(a) (a & ~((1 << CSS_RADIX_POINT)- 1 ))
+/* get fractional component of a fixed point value */
+#define FIXFRAC(a) (a & ((1 << CSS_RADIX_POINT)- 1 ))
/* Useful values */
#define F_PI_2 0x00000648 /* 1.5708 (PI/2) */
-----------------------------------------------------------------------
Summary of changes:
include/libcss/fpmath.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/libcss/fpmath.h b/include/libcss/fpmath.h
index d7cac4d..eec40b3 100644
--- a/include/libcss/fpmath.h
+++ b/include/libcss/fpmath.h
@@ -130,6 +130,8 @@ css_float_to_fixed(const float a) {
/* truncate a fixed point value */
#define TRUNCATEFIX(a) (a & ~((1 << CSS_RADIX_POINT)- 1 ))
+/* get fractional component of a fixed point value */
+#define FIXFRAC(a) (a & ((1 << CSS_RADIX_POINT)- 1 ))
/* Useful values */
#define F_PI_2 0x00000648 /* 1.5708 (PI/2) */
--
Cascading Style Sheets library
5 months, 3 weeks
netsurf: branch master updated. release/3.10-348-g71765dd
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/71765dd1e8dc968f15ce3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/71765dd1e8dc968f15ce359...
...tree http://git.netsurf-browser.org/netsurf.git/tree/71765dd1e8dc968f15ce359f7...
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=71765dd1e8dc968f15c...
commit 71765dd1e8dc968f15ce359f7e604585aa428f90
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
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=88e6fc918aee40dc422...
commit 88e6fc918aee40dc4223732650378e50d3b82326
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
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=cab66fb1ac15700392a...
commit cab66fb1ac15700392a26fdef8207db87144aac0
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
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
5 months, 3 weeks
netsurf: branch master updated. release/3.10-345-g651deff
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/651deffcf73f4760f3293...
...commit http://git.netsurf-browser.org/netsurf.git/commit/651deffcf73f4760f32934d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/651deffcf73f4760f32934dc2...
The branch, master has been updated
via 651deffcf73f4760f32934dc2045e314998f5338 (commit)
from e754f31cb7aa4293ebe1a28fbca695d26def627c (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=651deffcf73f4760f32...
commit 651deffcf73f4760f32934dc2045e314998f5338
Author: Daniel Silverstone <daniel.silverstone(a)codethink.co.uk>
Commit: Daniel Silverstone <daniel.silverstone(a)codethink.co.uk>
(curl): Add extra logging to fetcher initialisation
Signed-off-by: Daniel Silverstone <daniel.silverstone(a)codethink.co.uk>
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 5368983..a0c26ae 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -1713,8 +1713,10 @@ nserror fetch_curl_register(void)
#undef SETOPT
#define SETOPT(option, value) \
mcode = curl_multi_setopt(fetch_curl_multi, option, value); \
- if (mcode != CURLM_OK) \
- goto curl_multi_setopt_failed;
+ if (mcode != CURLM_OK) { \
+ NSLOG(netsurf, ERROR, "attempting curl_multi_setopt(%s, ...)", #option); \
+ goto curl_multi_setopt_failed; \
+ }
SETOPT(CURLMOPT_MAXCONNECTS, maxconnects);
SETOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, maxconnects);
@@ -1734,8 +1736,10 @@ nserror fetch_curl_register(void)
#undef SETOPT
#define SETOPT(option, value) \
code = curl_easy_setopt(fetch_blank_curl, option, value); \
- if (code != CURLE_OK) \
- goto curl_easy_setopt_failed;
+ if (code != CURLE_OK) { \
+ NSLOG(netsurf, ERROR, "attempting curl_easy_setopt(%s, ...)", #option); \
+ goto curl_easy_setopt_failed; \
+ }
SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer);
SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_debug);
-----------------------------------------------------------------------
Summary of changes:
content/fetchers/curl.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 5368983..a0c26ae 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -1713,8 +1713,10 @@ nserror fetch_curl_register(void)
#undef SETOPT
#define SETOPT(option, value) \
mcode = curl_multi_setopt(fetch_curl_multi, option, value); \
- if (mcode != CURLM_OK) \
- goto curl_multi_setopt_failed;
+ if (mcode != CURLM_OK) { \
+ NSLOG(netsurf, ERROR, "attempting curl_multi_setopt(%s, ...)", #option); \
+ goto curl_multi_setopt_failed; \
+ }
SETOPT(CURLMOPT_MAXCONNECTS, maxconnects);
SETOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, maxconnects);
@@ -1734,8 +1736,10 @@ nserror fetch_curl_register(void)
#undef SETOPT
#define SETOPT(option, value) \
code = curl_easy_setopt(fetch_blank_curl, option, value); \
- if (code != CURLE_OK) \
- goto curl_easy_setopt_failed;
+ if (code != CURLE_OK) { \
+ NSLOG(netsurf, ERROR, "attempting curl_easy_setopt(%s, ...)", #option); \
+ goto curl_easy_setopt_failed; \
+ }
SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer);
SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_debug);
--
NetSurf Browser
5 months, 3 weeks
netsurf: branch master updated. release/3.10-344-ge754f31
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e754f31cb7aa4293ebe1a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e754f31cb7aa4293ebe1a28...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e754f31cb7aa4293ebe1a28fb...
The branch, master has been updated
via e754f31cb7aa4293ebe1a28fbca695d26def627c (commit)
via fbc4f141f7957cf03ccd4e6de1ee44b869956611 (commit)
via 25acf1a5dd778aa82a828a2138bf33af20fb81dc (commit)
via 73ce30325f60310b2bce69b181a1d4f61399a33c (commit)
via 3760bbcd2a0b6ce25ab2b38d9f7ac2c79d8713f9 (commit)
via b07bda787c02210d018c39d917b02ca0bee87de7 (commit)
via 43d5ce44acdef1686edc0f7cd8579cf4f9f9adfb (commit)
via 8d4176e4d46cc4e37d2f9ee02e9508aa4a641b54 (commit)
via 6da16e564820e2a958a7266f05fb98b4f252dc49 (commit)
via fbb39f0d49f2606400dcf6bb2fb1d5c56903ddf9 (commit)
from f30f869ea40ad7633ec34903d0f1594c860a32ae (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=e754f31cb7aa4293ebe...
commit e754f31cb7aa4293ebe1a28fbca695d26def627c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Support reversed main direction
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index 65f770f..cea7964 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -98,6 +98,7 @@ struct flex_ctx {
int available_cross;
bool horizontal;
+ bool main_reversed;
enum css_flex_wrap_e wrap;
struct flex_items {
@@ -165,6 +166,7 @@ static struct flex_ctx *layout_flex_ctx__create(
ctx->wrap = css_computed_flex_wrap(flex->style);
ctx->horizontal = lh__flex_main_is_horizontal(flex);
+ ctx->main_reversed = lh__flex_direction_reversed(flex);
return ctx;
}
@@ -736,6 +738,22 @@ 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
@@ -746,13 +764,21 @@ static bool layout_flex__place_line_items_main(
struct flex_ctx *ctx,
struct flex_line_data *line)
{
+ int main_pos = ctx->flex->padding[layout_flex__main_start_side(ctx)];
+ int post_multiplier = ctx->main_reversed ? 0 : 1;
+ int pre_multiplier = ctx->main_reversed ? -1 : 0;
size_t item_count = line->first + line->count;
+ if (ctx->main_reversed) {
+ main_pos = lh__box_size_main(ctx->horizontal, ctx->flex) -
+ main_pos;
+ }
+
for (size_t i = line->first; i < item_count; i++) {
enum box_side main_start = ctx->horizontal ? LEFT : TOP;
struct flex_item_data *item = &ctx->item.data[i];
- int main_pos = ctx->flex->padding[main_start];
struct box *b = item->box;
+ int box_size_main;
int *box_pos_main;
if (ctx->horizontal) {
@@ -764,24 +790,26 @@ static bool layout_flex__place_line_items_main(
}
}
+ box_size_main = lh__box_size_main(ctx->horizontal, b);
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));
+ }
+
*box_pos_main = main_pos + lh__non_auto_margin(b, main_start) +
b->border[main_start].width;
if (!lh__box_is_absolute(b)) {
int cross_size;
- int *box_size_main;
- int *box_size_cross;
-
- box_size_main = lh__box_size_main_ptr(
- ctx->horizontal, b);
- box_size_cross = lh__box_size_cross_ptr(
+ int box_size_cross = lh__box_size_cross(
ctx->horizontal, b);
- main_pos += *box_size_main + lh__delta_outer_main(
- ctx->flex, b);
+ main_pos += post_multiplier * (box_size_main +
+ lh__delta_outer_main(ctx->flex, b));
- cross_size = *box_size_cross + lh__delta_outer_cross(
+ cross_size = box_size_cross + lh__delta_outer_cross(
ctx->flex, b);
if (line->cross_size < cross_size) {
line->cross_size = cross_size;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=fbc4f141f7957cf03cc...
commit fbc4f141f7957cf03ccd4e6de1ee44b869956611
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: Helpers to get cross/main box size
diff --git a/content/handlers/html/layout_internal.h b/content/handlers/html/layout_internal.h
index 7367789..d094462 100644
--- a/content/handlers/html/layout_internal.h
+++ b/content/handlers/html/layout_internal.h
@@ -258,6 +258,20 @@ static inline int *lh__box_size_cross_ptr(
return horizontal ? &b->height : &b->width;
}
+static inline int lh__box_size_main(
+ bool horizontal,
+ const struct box *b)
+{
+ return horizontal ? b->width : b->height;
+}
+
+static inline int lh__box_size_cross(
+ bool horizontal,
+ const struct box *b)
+{
+ return horizontal ? b->height : b->width;
+}
+
static inline bool lh__box_size_cross_is_auto(
bool horizontal,
struct box *b)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=25acf1a5dd778aa82a8...
commit 25acf1a5dd778aa82a828a2138bf33af20fb81dc
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Rename indirected box w/h functions
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index 40e1063..65f770f 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -773,8 +773,10 @@ static bool layout_flex__place_line_items_main(
int *box_size_main;
int *box_size_cross;
- box_size_main = lh__box_size_main(ctx->horizontal, b);
- box_size_cross = lh__box_size_cross(ctx->horizontal, b);
+ box_size_main = lh__box_size_main_ptr(
+ ctx->horizontal, b);
+ box_size_cross = lh__box_size_cross_ptr(
+ ctx->horizontal, b);
main_pos += *box_size_main + lh__delta_outer_main(
ctx->flex, b);
@@ -854,7 +856,7 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
int *box_pos_cross;
box_pos_cross = ctx->horizontal ? &b->y : &b->x;
- box_size_cross = lh__box_size_cross(ctx->horizontal, b);
+ box_size_cross = lh__box_size_cross_ptr(ctx->horizontal, b);
cross_free_space = line->cross_size + extra - *box_size_cross -
lh__delta_outer_cross(ctx->flex, b);
diff --git a/content/handlers/html/layout_internal.h b/content/handlers/html/layout_internal.h
index c6eb56d..7367789 100644
--- a/content/handlers/html/layout_internal.h
+++ b/content/handlers/html/layout_internal.h
@@ -244,14 +244,14 @@ static inline int lh__delta_outer_cross(
}
}
-static inline int *lh__box_size_main(
+static inline int *lh__box_size_main_ptr(
bool horizontal,
struct box *b)
{
return horizontal ? &b->width : &b->height;
}
-static inline int *lh__box_size_cross(
+static inline int *lh__box_size_cross_ptr(
bool horizontal,
struct box *b)
{
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=73ce30325f60310b2bc...
commit 73ce30325f60310b2bce69b181a1d4f61399a33c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Scope reduce variables
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index b57f3e3..40e1063 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -746,12 +746,12 @@ static bool layout_flex__place_line_items_main(
struct flex_ctx *ctx,
struct flex_line_data *line)
{
- enum box_side main_start = ctx->horizontal ? LEFT : TOP;
size_t item_count = line->first + line->count;
- int main_pos = ctx->flex->padding[main_start];
for (size_t i = line->first; i < item_count; i++) {
+ enum box_side main_start = ctx->horizontal ? LEFT : TOP;
struct flex_item_data *item = &ctx->item.data[i];
+ int main_pos = ctx->flex->padding[main_start];
struct box *b = item->box;
int *box_pos_main;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3760bbcd2a0b6ce25ab...
commit 3760bbcd2a0b6ce25ab2b38d9f7ac2c79d8713f9
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Only distribute positive remaining cross space
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index c9e02a6..b57f3e3 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -913,7 +913,7 @@ static void layout_flex__place_lines(struct flex_ctx *ctx)
int extra = 0;
if (ctx->available_cross != AUTO &&
- ctx->available_cross != ctx->cross_size &&
+ ctx->available_cross > ctx->cross_size &&
ctx->line.count > 0) {
extra = ctx->available_cross - ctx->cross_size;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b07bda787c02210d018...
commit b07bda787c02210d018c39d917b02ca0bee87de7
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Minor code style change
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index b63cb5d..c9e02a6 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -187,19 +187,16 @@ static bool layout_flex_item(
switch (b->type) {
case BOX_BLOCK:
- success = layout_block_context(b, -1,
- ctx->content);
+ success = layout_block_context(b, -1, ctx->content);
break;
case BOX_TABLE:
b->float_container = b->parent;
- success = layout_table(b, available_width,
- ctx->content);
+ success = layout_table(b, available_width, ctx->content);
b->float_container = NULL;
break;
case BOX_FLEX:
b->float_container = b->parent;
- success = layout_flex(b, available_width,
- ctx->content);
+ success = layout_flex(b, available_width, ctx->content);
b->float_container = NULL;
break;
default:
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=43d5ce44acdef1686ed...
commit 43d5ce44acdef1686edc0f7cd8579cf4f9f9adfb
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Add code documentation
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index 355ae93..b63cb5d 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -42,6 +42,9 @@
#include "html/box_inspect.h"
#include "html/layout_internal.h"
+/**
+ * Flex item data
+ */
struct flex_item_data {
enum css_flex_basis_e basis;
css_fixed basis_length;
@@ -66,6 +69,9 @@ struct flex_item_data {
bool max_violation;
};
+/**
+ * Flex line data
+ */
struct flex_line_data {
int main_size;
int cross_size;
@@ -77,6 +83,9 @@ struct flex_line_data {
size_t frozen;
};
+/**
+ * Flex layout context
+ */
struct flex_ctx {
html_content *content;
const struct box *flex;
@@ -103,6 +112,11 @@ struct flex_ctx {
} line;
};
+/**
+ * Destroy a flex layout context
+ *
+ * \param[in] ctx Flex layout context
+ */
static void layout_flex_ctx__destroy(struct flex_ctx *ctx)
{
if (ctx != NULL) {
@@ -112,6 +126,13 @@ static void layout_flex_ctx__destroy(struct flex_ctx *ctx)
}
}
+/**
+ * Create a flex layout context
+ *
+ * \param[in] content HTML content containing flex box
+ * \param[in] flex Box to create layout context for
+ * \return flex layout context or NULL on error
+ */
static struct flex_ctx *layout_flex_ctx__create(
html_content *content,
const struct box *flex)
@@ -148,6 +169,14 @@ static struct flex_ctx *layout_flex_ctx__create(
return ctx;
}
+/**
+ * Perform layout on a flex item
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] item Item to lay out
+ * \param[in] available_width Available width for item in pixels
+ * \return true on success false on failure
+ */
static bool layout_flex_item(
const struct flex_ctx *ctx,
const struct flex_item_data *item,
@@ -186,6 +215,14 @@ static bool layout_flex_item(
return success;
}
+/**
+ * Calculate an item's base and target main sizes.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] item Item to get sizes of
+ * \param[in] available_width Available width in pixels
+ * \return true on success false on failure
+ */
static inline bool layout_flex__base_and_main_sizes(
const struct flex_ctx *ctx,
struct flex_item_data *item,
@@ -262,6 +299,13 @@ static inline bool layout_flex__base_and_main_sizes(
return true;
}
+/**
+ * Fill out all item's data in a flex container.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] flex Flex box
+ * \param[in] available_width Available width in pixels
+ */
static void layout_flex_ctx__populate_item_data(
const struct flex_ctx *ctx,
const struct box *flex,
@@ -297,6 +341,12 @@ static void layout_flex_ctx__populate_item_data(
}
}
+/**
+ * Ensure context's lines array has a free space
+ *
+ * \param[in] ctx Flex layout context
+ * \return true on success false on out of memory
+ */
static bool layout_flex_ctx__ensure_line(struct flex_ctx *ctx)
{
struct flex_line_data *temp;
@@ -319,6 +369,13 @@ static bool layout_flex_ctx__ensure_line(struct flex_ctx *ctx)
return true;
}
+/**
+ * Assigns flex items to the line and returns the line
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] item_index Index to first item to assign to this line
+ * \return Pointer to the new line, or NULL on error.
+ */
static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx,
size_t item_index)
{
@@ -371,6 +428,12 @@ static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx,
return line;
}
+/**
+ * Freeze an item on a line
+ *
+ * \param[in] line Line to containing item
+ * \param[in] item Item to freeze
+ */
static inline void layout_flex__item_freeze(
struct flex_line_data *line,
struct flex_item_data *item)
@@ -383,6 +446,17 @@ static inline void layout_flex__item_freeze(
item->box, item->target_main_size);
}
+/**
+ * Calculate remaining free space and unfrozen item factor sum
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to calculate free space on
+ * \param[out] unfrozen_factor_sum Returns sum of unfrozen item's flex factors
+ * \param[in] initial_free_main Initial free space in main direction
+ * \param[in] available_main Available space in main direction
+ * \param[in] grow Whether to grow or shrink
+ * return remaining free space on line
+ */
static inline int layout_flex__remaining_free_main(
struct flex_ctx *ctx,
struct flex_line_data *line,
@@ -424,6 +498,13 @@ static inline int layout_flex__remaining_free_main(
return remaining_free_main;
}
+/**
+ * Clamp flex item target main size and get min/max violations
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to align items on
+ * return total violation in pixels
+ */
static inline int layout_flex__get_min_max_violations(
struct flex_ctx *ctx,
struct flex_line_data *line)
@@ -480,6 +561,17 @@ static inline int layout_flex__get_min_max_violations(
return total_violation;
}
+/**
+ * Distribute remaining free space proportional to the flex factors.
+ *
+ * Remaining free space may be negative.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to distribute free space on
+ * \param[in] unfrozen_factor_sum Sum of unfrozen item's flex factors
+ * \param[in] remaining_free_main Remaining free space in main direction
+ * \param[in] grow Whether to grow or shrink
+ */
static inline void layout_flex__distribute_free_main(
struct flex_ctx *ctx,
struct flex_line_data *line,
@@ -549,7 +641,15 @@ static inline void layout_flex__distribute_free_main(
}
}
-/** 9.7. Resolving Flexible Lengths */
+/**
+ * Resolve flexible item lengths along a line.
+ *
+ * See 9.7 of Tests CSS Flexible Box Layout Module Level 1.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to resolve
+ * \return true on success, false on failure.
+ */
static bool layout_flex__resolve_line(
struct flex_ctx *ctx,
struct flex_line_data *line)
@@ -638,6 +738,13 @@ static bool layout_flex__resolve_line(
return true;
}
+/**
+ * Position items along a line
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to resolve
+ * \return true on success, false on failure.
+ */
static bool layout_flex__place_line_items_main(
struct flex_ctx *ctx,
struct flex_line_data *line)
@@ -686,6 +793,12 @@ static bool layout_flex__place_line_items_main(
return true;
}
+/**
+ * Collect items onto lines and place items along the lines
+ *
+ * \param[in] ctx Flex layout context
+ * \return true on success, false on failure.
+ */
static bool layout_flex__collect_items_into_lines(
struct flex_ctx *ctx)
{
@@ -723,6 +836,13 @@ static bool layout_flex__collect_items_into_lines(
return true;
}
+/**
+ * Align items on a line.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to align items on
+ * \param[in] extra Extra line width in pixels
+ */
static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
struct flex_line_data *line, int extra)
{
@@ -781,6 +901,11 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
}
}
+/**
+ * Place the lines and align the items on the line.
+ *
+ * \param[in] ctx Flex layout context
+ */
static void layout_flex__place_lines(struct flex_ctx *ctx)
{
bool reversed = ctx->wrap == CSS_FLEX_WRAP_WRAP_REVERSE;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8d4176e4d46cc4e37d2...
commit 8d4176e4d46cc4e37d2f9ee02e9508aa4a641b54
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Hoist item placement out of line resolver
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index a149528..355ae93 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -549,54 +549,6 @@ static inline void layout_flex__distribute_free_main(
}
}
-static bool layout_flex__place_line_items_main(
- struct flex_ctx *ctx,
- struct flex_line_data *line)
-{
- enum box_side main_start = ctx->horizontal ? LEFT : TOP;
- size_t item_count = line->first + line->count;
- int main_pos = ctx->flex->padding[main_start];
-
- for (size_t i = line->first; i < item_count; i++) {
- struct flex_item_data *item = &ctx->item.data[i];
- struct box *b = item->box;
- int *box_pos_main;
-
- if (ctx->horizontal) {
- b->width = item->target_main_size -
- lh__delta_outer_width(b);
-
- if (!layout_flex_item(ctx, item, b->width)) {
- return false;
- }
- }
-
- box_pos_main = ctx->horizontal ? &b->x : &b->y;
- *box_pos_main = main_pos + lh__non_auto_margin(b, main_start) +
- b->border[main_start].width;
-
- if (!lh__box_is_absolute(b)) {
- int cross_size;
- int *box_size_main;
- int *box_size_cross;
-
- box_size_main = lh__box_size_main(ctx->horizontal, b);
- box_size_cross = lh__box_size_cross(ctx->horizontal, b);
-
- main_pos += *box_size_main + lh__delta_outer_main(
- ctx->flex, b);
-
- cross_size = *box_size_cross + lh__delta_outer_cross(
- ctx->flex, b);
- if (line->cross_size < cross_size) {
- line->cross_size = cross_size;
- }
- }
- }
-
- return true;
-}
-
/** 9.7. Resolving Flexible Lengths */
static bool layout_flex__resolve_line(
struct flex_ctx *ctx,
@@ -683,8 +635,52 @@ static bool layout_flex__resolve_line(
}
}
- if (!layout_flex__place_line_items_main(ctx, line)) {
- return false;
+ return true;
+}
+
+static bool layout_flex__place_line_items_main(
+ struct flex_ctx *ctx,
+ struct flex_line_data *line)
+{
+ enum box_side main_start = ctx->horizontal ? LEFT : TOP;
+ size_t item_count = line->first + line->count;
+ int main_pos = ctx->flex->padding[main_start];
+
+ for (size_t i = line->first; i < item_count; i++) {
+ struct flex_item_data *item = &ctx->item.data[i];
+ struct box *b = item->box;
+ int *box_pos_main;
+
+ if (ctx->horizontal) {
+ b->width = item->target_main_size -
+ lh__delta_outer_width(b);
+
+ if (!layout_flex_item(ctx, item, b->width)) {
+ return false;
+ }
+ }
+
+ box_pos_main = ctx->horizontal ? &b->x : &b->y;
+ *box_pos_main = main_pos + lh__non_auto_margin(b, main_start) +
+ b->border[main_start].width;
+
+ if (!lh__box_is_absolute(b)) {
+ int cross_size;
+ int *box_size_main;
+ int *box_size_cross;
+
+ box_size_main = lh__box_size_main(ctx->horizontal, b);
+ box_size_cross = lh__box_size_cross(ctx->horizontal, b);
+
+ main_pos += *box_size_main + lh__delta_outer_main(
+ ctx->flex, b);
+
+ cross_size = *box_size_cross + lh__delta_outer_cross(
+ ctx->flex, b);
+ if (line->cross_size < cross_size) {
+ line->cross_size = cross_size;
+ }
+ }
}
return true;
@@ -714,6 +710,10 @@ static bool layout_flex__collect_items_into_lines(
return false;
}
+ if (!layout_flex__place_line_items_main(ctx, line)) {
+ return false;
+ }
+
ctx->cross_size += line->cross_size;
if (ctx->main_size < line->main_size) {
ctx->main_size = line->main_size;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6da16e564820e2a958a...
commit 6da16e564820e2a958a7266f05fb98b4f252dc49
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: flex: Return NULL for pointer
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index feaa4b3..a149528 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -326,7 +326,7 @@ static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx,
int used_main = 0;
if (!layout_flex_ctx__ensure_line(ctx)) {
- return 0;
+ return NULL;
}
line = &ctx->line.data[ctx->line.count];
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=fbb39f0d49f2606400d...
commit fbb39f0d49f2606400dcf6bb2fb1d5c56903ddf9
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: layout: Helper for whether flex direction is reversed
diff --git a/content/handlers/html/layout_internal.h b/content/handlers/html/layout_internal.h
index 974f493..c6eb56d 100644
--- a/content/handlers/html/layout_internal.h
+++ b/content/handlers/html/layout_internal.h
@@ -184,6 +184,19 @@ static inline bool lh__flex_main_is_horizontal(const struct box *flex)
}
}
+static inline bool lh__flex_direction_reversed(const struct box *flex)
+{
+ switch (css_computed_flex_direction(flex->style)) {
+ default: /* Fallthrough. */
+ case CSS_FLEX_DIRECTION_ROW_REVERSE: /* Fallthrough. */
+ case CSS_FLEX_DIRECTION_COLUMN_REVERSE:
+ return true;
+ case CSS_FLEX_DIRECTION_ROW: /* Fallthrough. */
+ case CSS_FLEX_DIRECTION_COLUMN:
+ return false;
+ }
+}
+
static inline int lh__non_auto_margin(const struct box *b, enum box_side side)
{
return (b->margin[side] == AUTO) ? 0 : b->margin[side];
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/layout_flex.c | 272 ++++++++++++++++++++++++-------
content/handlers/html/layout_internal.h | 31 +++-
2 files changed, 241 insertions(+), 62 deletions(-)
diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c
index feaa4b3..cea7964 100644
--- a/content/handlers/html/layout_flex.c
+++ b/content/handlers/html/layout_flex.c
@@ -42,6 +42,9 @@
#include "html/box_inspect.h"
#include "html/layout_internal.h"
+/**
+ * Flex item data
+ */
struct flex_item_data {
enum css_flex_basis_e basis;
css_fixed basis_length;
@@ -66,6 +69,9 @@ struct flex_item_data {
bool max_violation;
};
+/**
+ * Flex line data
+ */
struct flex_line_data {
int main_size;
int cross_size;
@@ -77,6 +83,9 @@ struct flex_line_data {
size_t frozen;
};
+/**
+ * Flex layout context
+ */
struct flex_ctx {
html_content *content;
const struct box *flex;
@@ -89,6 +98,7 @@ struct flex_ctx {
int available_cross;
bool horizontal;
+ bool main_reversed;
enum css_flex_wrap_e wrap;
struct flex_items {
@@ -103,6 +113,11 @@ struct flex_ctx {
} line;
};
+/**
+ * Destroy a flex layout context
+ *
+ * \param[in] ctx Flex layout context
+ */
static void layout_flex_ctx__destroy(struct flex_ctx *ctx)
{
if (ctx != NULL) {
@@ -112,6 +127,13 @@ static void layout_flex_ctx__destroy(struct flex_ctx *ctx)
}
}
+/**
+ * Create a flex layout context
+ *
+ * \param[in] content HTML content containing flex box
+ * \param[in] flex Box to create layout context for
+ * \return flex layout context or NULL on error
+ */
static struct flex_ctx *layout_flex_ctx__create(
html_content *content,
const struct box *flex)
@@ -144,10 +166,19 @@ static struct flex_ctx *layout_flex_ctx__create(
ctx->wrap = css_computed_flex_wrap(flex->style);
ctx->horizontal = lh__flex_main_is_horizontal(flex);
+ ctx->main_reversed = lh__flex_direction_reversed(flex);
return ctx;
}
+/**
+ * Perform layout on a flex item
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] item Item to lay out
+ * \param[in] available_width Available width for item in pixels
+ * \return true on success false on failure
+ */
static bool layout_flex_item(
const struct flex_ctx *ctx,
const struct flex_item_data *item,
@@ -158,19 +189,16 @@ static bool layout_flex_item(
switch (b->type) {
case BOX_BLOCK:
- success = layout_block_context(b, -1,
- ctx->content);
+ success = layout_block_context(b, -1, ctx->content);
break;
case BOX_TABLE:
b->float_container = b->parent;
- success = layout_table(b, available_width,
- ctx->content);
+ success = layout_table(b, available_width, ctx->content);
b->float_container = NULL;
break;
case BOX_FLEX:
b->float_container = b->parent;
- success = layout_flex(b, available_width,
- ctx->content);
+ success = layout_flex(b, available_width, ctx->content);
b->float_container = NULL;
break;
default:
@@ -186,6 +214,14 @@ static bool layout_flex_item(
return success;
}
+/**
+ * Calculate an item's base and target main sizes.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] item Item to get sizes of
+ * \param[in] available_width Available width in pixels
+ * \return true on success false on failure
+ */
static inline bool layout_flex__base_and_main_sizes(
const struct flex_ctx *ctx,
struct flex_item_data *item,
@@ -262,6 +298,13 @@ static inline bool layout_flex__base_and_main_sizes(
return true;
}
+/**
+ * Fill out all item's data in a flex container.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] flex Flex box
+ * \param[in] available_width Available width in pixels
+ */
static void layout_flex_ctx__populate_item_data(
const struct flex_ctx *ctx,
const struct box *flex,
@@ -297,6 +340,12 @@ static void layout_flex_ctx__populate_item_data(
}
}
+/**
+ * Ensure context's lines array has a free space
+ *
+ * \param[in] ctx Flex layout context
+ * \return true on success false on out of memory
+ */
static bool layout_flex_ctx__ensure_line(struct flex_ctx *ctx)
{
struct flex_line_data *temp;
@@ -319,6 +368,13 @@ static bool layout_flex_ctx__ensure_line(struct flex_ctx *ctx)
return true;
}
+/**
+ * Assigns flex items to the line and returns the line
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] item_index Index to first item to assign to this line
+ * \return Pointer to the new line, or NULL on error.
+ */
static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx,
size_t item_index)
{
@@ -326,7 +382,7 @@ static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx,
int used_main = 0;
if (!layout_flex_ctx__ensure_line(ctx)) {
- return 0;
+ return NULL;
}
line = &ctx->line.data[ctx->line.count];
@@ -371,6 +427,12 @@ static struct flex_line_data *layout_flex__build_line(struct flex_ctx *ctx,
return line;
}
+/**
+ * Freeze an item on a line
+ *
+ * \param[in] line Line to containing item
+ * \param[in] item Item to freeze
+ */
static inline void layout_flex__item_freeze(
struct flex_line_data *line,
struct flex_item_data *item)
@@ -383,6 +445,17 @@ static inline void layout_flex__item_freeze(
item->box, item->target_main_size);
}
+/**
+ * Calculate remaining free space and unfrozen item factor sum
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to calculate free space on
+ * \param[out] unfrozen_factor_sum Returns sum of unfrozen item's flex factors
+ * \param[in] initial_free_main Initial free space in main direction
+ * \param[in] available_main Available space in main direction
+ * \param[in] grow Whether to grow or shrink
+ * return remaining free space on line
+ */
static inline int layout_flex__remaining_free_main(
struct flex_ctx *ctx,
struct flex_line_data *line,
@@ -424,6 +497,13 @@ static inline int layout_flex__remaining_free_main(
return remaining_free_main;
}
+/**
+ * Clamp flex item target main size and get min/max violations
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to align items on
+ * return total violation in pixels
+ */
static inline int layout_flex__get_min_max_violations(
struct flex_ctx *ctx,
struct flex_line_data *line)
@@ -480,6 +560,17 @@ static inline int layout_flex__get_min_max_violations(
return total_violation;
}
+/**
+ * Distribute remaining free space proportional to the flex factors.
+ *
+ * Remaining free space may be negative.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to distribute free space on
+ * \param[in] unfrozen_factor_sum Sum of unfrozen item's flex factors
+ * \param[in] remaining_free_main Remaining free space in main direction
+ * \param[in] grow Whether to grow or shrink
+ */
static inline void layout_flex__distribute_free_main(
struct flex_ctx *ctx,
struct flex_line_data *line,
@@ -549,55 +640,15 @@ static inline void layout_flex__distribute_free_main(
}
}
-static bool layout_flex__place_line_items_main(
- struct flex_ctx *ctx,
- struct flex_line_data *line)
-{
- enum box_side main_start = ctx->horizontal ? LEFT : TOP;
- size_t item_count = line->first + line->count;
- int main_pos = ctx->flex->padding[main_start];
-
- for (size_t i = line->first; i < item_count; i++) {
- struct flex_item_data *item = &ctx->item.data[i];
- struct box *b = item->box;
- int *box_pos_main;
-
- if (ctx->horizontal) {
- b->width = item->target_main_size -
- lh__delta_outer_width(b);
-
- if (!layout_flex_item(ctx, item, b->width)) {
- return false;
- }
- }
-
- box_pos_main = ctx->horizontal ? &b->x : &b->y;
- *box_pos_main = main_pos + lh__non_auto_margin(b, main_start) +
- b->border[main_start].width;
-
- if (!lh__box_is_absolute(b)) {
- int cross_size;
- int *box_size_main;
- int *box_size_cross;
-
- box_size_main = lh__box_size_main(ctx->horizontal, b);
- box_size_cross = lh__box_size_cross(ctx->horizontal, b);
-
- main_pos += *box_size_main + lh__delta_outer_main(
- ctx->flex, b);
-
- cross_size = *box_size_cross + lh__delta_outer_cross(
- ctx->flex, b);
- if (line->cross_size < cross_size) {
- line->cross_size = cross_size;
- }
- }
- }
-
- return true;
-}
-
-/** 9.7. Resolving Flexible Lengths */
+/**
+ * Resolve flexible item lengths along a line.
+ *
+ * See 9.7 of Tests CSS Flexible Box Layout Module Level 1.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to resolve
+ * \return true on success, false on failure.
+ */
static bool layout_flex__resolve_line(
struct flex_ctx *ctx,
struct flex_line_data *line)
@@ -683,13 +734,98 @@ static bool layout_flex__resolve_line(
}
}
- if (!layout_flex__place_line_items_main(ctx, line)) {
- return false;
+ 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
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to resolve
+ * \return true on success, false on failure.
+ */
+static bool layout_flex__place_line_items_main(
+ struct flex_ctx *ctx,
+ struct flex_line_data *line)
+{
+ int main_pos = ctx->flex->padding[layout_flex__main_start_side(ctx)];
+ int post_multiplier = ctx->main_reversed ? 0 : 1;
+ int pre_multiplier = ctx->main_reversed ? -1 : 0;
+ size_t item_count = line->first + line->count;
+
+ if (ctx->main_reversed) {
+ main_pos = lh__box_size_main(ctx->horizontal, ctx->flex) -
+ main_pos;
+ }
+
+ for (size_t i = line->first; i < item_count; i++) {
+ enum box_side main_start = ctx->horizontal ? LEFT : TOP;
+ struct flex_item_data *item = &ctx->item.data[i];
+ struct box *b = item->box;
+ int box_size_main;
+ int *box_pos_main;
+
+ if (ctx->horizontal) {
+ b->width = item->target_main_size -
+ lh__delta_outer_width(b);
+
+ if (!layout_flex_item(ctx, item, b->width)) {
+ return false;
+ }
+ }
+
+ box_size_main = lh__box_size_main(ctx->horizontal, b);
+ 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));
+ }
+
+ *box_pos_main = main_pos + lh__non_auto_margin(b, main_start) +
+ 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));
+
+ cross_size = box_size_cross + lh__delta_outer_cross(
+ ctx->flex, b);
+ if (line->cross_size < cross_size) {
+ line->cross_size = cross_size;
+ }
+ }
}
return true;
}
+/**
+ * Collect items onto lines and place items along the lines
+ *
+ * \param[in] ctx Flex layout context
+ * \return true on success, false on failure.
+ */
static bool layout_flex__collect_items_into_lines(
struct flex_ctx *ctx)
{
@@ -714,6 +850,10 @@ static bool layout_flex__collect_items_into_lines(
return false;
}
+ if (!layout_flex__place_line_items_main(ctx, line)) {
+ return false;
+ }
+
ctx->cross_size += line->cross_size;
if (ctx->main_size < line->main_size) {
ctx->main_size = line->main_size;
@@ -723,6 +863,13 @@ static bool layout_flex__collect_items_into_lines(
return true;
}
+/**
+ * Align items on a line.
+ *
+ * \param[in] ctx Flex layout context
+ * \param[in] line Line to align items on
+ * \param[in] extra Extra line width in pixels
+ */
static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
struct flex_line_data *line, int extra)
{
@@ -737,7 +884,7 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
int *box_pos_cross;
box_pos_cross = ctx->horizontal ? &b->y : &b->x;
- box_size_cross = lh__box_size_cross(ctx->horizontal, b);
+ box_size_cross = lh__box_size_cross_ptr(ctx->horizontal, b);
cross_free_space = line->cross_size + extra - *box_size_cross -
lh__delta_outer_cross(ctx->flex, b);
@@ -781,6 +928,11 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
}
}
+/**
+ * Place the lines and align the items on the line.
+ *
+ * \param[in] ctx Flex layout context
+ */
static void layout_flex__place_lines(struct flex_ctx *ctx)
{
bool reversed = ctx->wrap == CSS_FLEX_WRAP_WRAP_REVERSE;
@@ -791,7 +943,7 @@ static void layout_flex__place_lines(struct flex_ctx *ctx)
int extra = 0;
if (ctx->available_cross != AUTO &&
- ctx->available_cross != ctx->cross_size &&
+ ctx->available_cross > ctx->cross_size &&
ctx->line.count > 0) {
extra = ctx->available_cross - ctx->cross_size;
diff --git a/content/handlers/html/layout_internal.h b/content/handlers/html/layout_internal.h
index 974f493..d094462 100644
--- a/content/handlers/html/layout_internal.h
+++ b/content/handlers/html/layout_internal.h
@@ -184,6 +184,19 @@ static inline bool lh__flex_main_is_horizontal(const struct box *flex)
}
}
+static inline bool lh__flex_direction_reversed(const struct box *flex)
+{
+ switch (css_computed_flex_direction(flex->style)) {
+ default: /* Fallthrough. */
+ case CSS_FLEX_DIRECTION_ROW_REVERSE: /* Fallthrough. */
+ case CSS_FLEX_DIRECTION_COLUMN_REVERSE:
+ return true;
+ case CSS_FLEX_DIRECTION_ROW: /* Fallthrough. */
+ case CSS_FLEX_DIRECTION_COLUMN:
+ return false;
+ }
+}
+
static inline int lh__non_auto_margin(const struct box *b, enum box_side side)
{
return (b->margin[side] == AUTO) ? 0 : b->margin[side];
@@ -231,20 +244,34 @@ static inline int lh__delta_outer_cross(
}
}
-static inline int *lh__box_size_main(
+static inline int *lh__box_size_main_ptr(
bool horizontal,
struct box *b)
{
return horizontal ? &b->width : &b->height;
}
-static inline int *lh__box_size_cross(
+static inline int *lh__box_size_cross_ptr(
bool horizontal,
struct box *b)
{
return horizontal ? &b->height : &b->width;
}
+static inline int lh__box_size_main(
+ bool horizontal,
+ const struct box *b)
+{
+ return horizontal ? b->width : b->height;
+}
+
+static inline int lh__box_size_cross(
+ bool horizontal,
+ const struct box *b)
+{
+ return horizontal ? b->height : b->width;
+}
+
static inline bool lh__box_size_cross_is_auto(
bool horizontal,
struct box *b)
--
NetSurf Browser
5 months, 3 weeks
netsurf: branch master updated. release/3.10-334-gf30f869
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f30f869ea40ad7633ec34...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f30f869ea40ad7633ec3490...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f30f869ea40ad7633ec34903d...
The branch, master has been updated
via f30f869ea40ad7633ec34903d0f1594c860a32ae (commit)
via 68a4cd39cdb7e57ff45aea6ad892b727851603e6 (commit)
from 9b57f64c55d244d59ac0c00988ee60c514405d6d (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=f30f869ea40ad7633ec...
commit f30f869ea40ad7633ec34903d0f1594c860a32ae
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
rsvg246: Fix build against librsvg 2.48
The version of librsvg is used on Ubuntu 20.04TLS.
diff --git a/content/handlers/image/rsvg246.c b/content/handlers/image/rsvg246.c
index 5c61c86..0e33713 100644
--- a/content/handlers/image/rsvg246.c
+++ b/content/handlers/image/rsvg246.c
@@ -147,6 +147,7 @@ rsvg_cache_convert(struct content *c)
static void rsvg__get_demensions(const rsvg_content *svgc,
int *width, int *height)
{
+#if LIBRSVG_MAJOR_VERSION >= 2 && LIBRSVG_MINOR_VERSION >= 52
gdouble rwidth;
gdouble rheight;
gboolean gotsize;
@@ -168,7 +169,13 @@ static void rsvg__get_demensions(const rsvg_content *svgc,
*width = ink_rect.width;
*height = ink_rect.height;
}
+#else
+ RsvgDimensionData rsvgsize;
+ rsvg_handle_get_dimensions(svgc->rsvgh, &rsvgsize);
+ *width = rsvgsize.width;
+ *height = rsvgsize.height;
+#endif
NSLOG(netsurf, DEBUG, "rsvg width:%d height:%d.", *width, *height);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=68a4cd39cdb7e57ff45...
commit 68a4cd39cdb7e57ff45aea6ad892b727851603e6
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
rsvg246: Split out width/height acquisition
diff --git a/content/handlers/image/rsvg246.c b/content/handlers/image/rsvg246.c
index 1769c50..5c61c86 100644
--- a/content/handlers/image/rsvg246.c
+++ b/content/handlers/image/rsvg246.c
@@ -144,6 +144,33 @@ rsvg_cache_convert(struct content *c)
return bitmap;
}
+static void rsvg__get_demensions(const rsvg_content *svgc,
+ int *width, int *height)
+{
+ gdouble rwidth;
+ gdouble rheight;
+ gboolean gotsize;
+
+ gotsize = rsvg_handle_get_intrinsic_size_in_pixels(svgc->rsvgh,
+ &rwidth,
+ &rheight);
+ if (gotsize == TRUE) {
+ *width = rwidth;
+ *height = rheight;
+ } else {
+ RsvgRectangle ink_rect;
+ RsvgRectangle logical_rect;
+ rsvg_handle_get_geometry_for_element(svgc->rsvgh,
+ NULL,
+ &ink_rect,
+ &logical_rect,
+ NULL);
+ *width = ink_rect.width;
+ *height = ink_rect.height;
+ }
+
+ NSLOG(netsurf, DEBUG, "rsvg width:%d height:%d.", *width, *height);
+}
static bool rsvg_convert(struct content *c)
{
@@ -152,8 +179,7 @@ static bool rsvg_convert(struct content *c)
size_t size; /* content data size */
GInputStream * istream;
GError *gerror = NULL;
- gdouble rwidth, rheight;
- gboolean gotsize;
+
/* check image header is valid and get width/height */
data = content__get_source_data(c, &size);
@@ -170,25 +196,7 @@ static bool rsvg_convert(struct content *c)
return false;
}
- gotsize = rsvg_handle_get_intrinsic_size_in_pixels(svgc->rsvgh,
- &rwidth,
- &rheight);
- if (gotsize == TRUE) {
- c->width = rwidth;
- c->height = rheight;
- } else {
- RsvgRectangle ink_rect;
- RsvgRectangle logical_rect;
- rsvg_handle_get_geometry_for_element(svgc->rsvgh,
- NULL,
- &ink_rect,
- &logical_rect,
- NULL);
- c->width = ink_rect.width;
- c->height = ink_rect.height;
- }
-
- NSLOG(netsurf, DEBUG, "rsvg width:%d height:%d.",c->width, c->height);
+ rsvg__get_demensions(svgc, &c->width, &c->height);
c->size = c->width * c->height * 4;
-----------------------------------------------------------------------
Summary of changes:
content/handlers/image/rsvg246.c | 57 ++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 21 deletions(-)
diff --git a/content/handlers/image/rsvg246.c b/content/handlers/image/rsvg246.c
index 1769c50..0e33713 100644
--- a/content/handlers/image/rsvg246.c
+++ b/content/handlers/image/rsvg246.c
@@ -144,6 +144,40 @@ rsvg_cache_convert(struct content *c)
return bitmap;
}
+static void rsvg__get_demensions(const rsvg_content *svgc,
+ int *width, int *height)
+{
+#if LIBRSVG_MAJOR_VERSION >= 2 && LIBRSVG_MINOR_VERSION >= 52
+ gdouble rwidth;
+ gdouble rheight;
+ gboolean gotsize;
+
+ gotsize = rsvg_handle_get_intrinsic_size_in_pixels(svgc->rsvgh,
+ &rwidth,
+ &rheight);
+ if (gotsize == TRUE) {
+ *width = rwidth;
+ *height = rheight;
+ } else {
+ RsvgRectangle ink_rect;
+ RsvgRectangle logical_rect;
+ rsvg_handle_get_geometry_for_element(svgc->rsvgh,
+ NULL,
+ &ink_rect,
+ &logical_rect,
+ NULL);
+ *width = ink_rect.width;
+ *height = ink_rect.height;
+ }
+#else
+ RsvgDimensionData rsvgsize;
+
+ rsvg_handle_get_dimensions(svgc->rsvgh, &rsvgsize);
+ *width = rsvgsize.width;
+ *height = rsvgsize.height;
+#endif
+ NSLOG(netsurf, DEBUG, "rsvg width:%d height:%d.", *width, *height);
+}
static bool rsvg_convert(struct content *c)
{
@@ -152,8 +186,7 @@ static bool rsvg_convert(struct content *c)
size_t size; /* content data size */
GInputStream * istream;
GError *gerror = NULL;
- gdouble rwidth, rheight;
- gboolean gotsize;
+
/* check image header is valid and get width/height */
data = content__get_source_data(c, &size);
@@ -170,25 +203,7 @@ static bool rsvg_convert(struct content *c)
return false;
}
- gotsize = rsvg_handle_get_intrinsic_size_in_pixels(svgc->rsvgh,
- &rwidth,
- &rheight);
- if (gotsize == TRUE) {
- c->width = rwidth;
- c->height = rheight;
- } else {
- RsvgRectangle ink_rect;
- RsvgRectangle logical_rect;
- rsvg_handle_get_geometry_for_element(svgc->rsvgh,
- NULL,
- &ink_rect,
- &logical_rect,
- NULL);
- c->width = ink_rect.width;
- c->height = ink_rect.height;
- }
-
- NSLOG(netsurf, DEBUG, "rsvg width:%d height:%d.",c->width, c->height);
+ rsvg__get_demensions(svgc, &c->width, &c->height);
c->size = c->width * c->height * 4;
--
NetSurf Browser
5 months, 3 weeks