summaryrefslogtreecommitdiff
path: root/content/handlers
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2023-11-25 21:09:01 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2023-11-25 21:09:01 +0000
commit3f764b04597e0587fa7bb034c16c9a38401b8002 (patch)
treefcb02a96a1c7069c76304d09f7ea231b13414ea2 /content/handlers
parent4cb38c4704e4ed11cf10fc046b32ef6ef5afa78f (diff)
downloadnetsurf-3f764b04597e0587fa7bb034c16c9a38401b8002.tar.gz
netsurf-3f764b04597e0587fa7bb034c16c9a38401b8002.tar.bz2
html: layout: Ensure all object types are reflowed if appropriate
The SVGTiny content handler uses the reflow method to set the content width/height. The when the content first broadcasts "done", the HTML handler checks if there had already been a layout. If there has, it calls the SVG's content reflow method with the box dimensions. If not, it calls the reflow method with width/height zero. Since the layout code was only reflowing objects if they were HTML, these SVG contents were never getting their actual dimensions. The result of this was that when we came to plot these SVGs we were dividing by zero in the building of the transformation matrix: transform[0] = (float) width / (float) c->width; ... transform[3] = (float) height / (float) c->height; These divided the plot size by the content size. The result of this on the GTK front end was infinities in the transformation matrix passed to Cairo, and the turning of the whole nsgtk window into a glitchy ruin while the SVG was on screen. It may have affected other front ends too; these divide by zeros were happening in the core, and passed to the front ends' plotters. This issue only affected SVGs on HTML pages, and not when viewed directly. Also the SVGs had to be completely fetched and converted before the document had undergone layout. This was the case with SVGs at the top of both Wikipedia and The Register. In both cases the glitching window would be fixed by scrolling down the page past the SVG.
Diffstat (limited to 'content/handlers')
-rw-r--r--content/handlers/html/layout.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c
index 827180cce..76ce24df5 100644
--- a/content/handlers/html/layout.c
+++ b/content/handlers/html/layout.c
@@ -2305,7 +2305,7 @@ static bool layout_block_object(struct box *block)
NSLOG(layout, DEBUG, "block %p, object %p, width %i", block,
hlcache_handle_get_url(block->object), block->width);
- if (content_get_type(block->object) == CONTENT_HTML) {
+ if (content_can_reformat(block->object)) {
content_reformat(block->object, false, block->width, 1);
} else {
/* Non-HTML objects */
@@ -2984,7 +2984,7 @@ layout_line(struct box *first,
}
/* Reformat object to new box size */
- if (b->object && content_get_type(b->object) == CONTENT_HTML &&
+ if (b->object && content_can_reformat(b->object) &&
b->width !=
content_get_available_width(b->object)) {
css_fixed value = 0;