HTML: Before building the box tree, get viewport dimensions.

This commit is contained in:
Michael Drake 2019-05-06 15:37:44 +01:00
parent 0f3b279167
commit 0db71994ea

View File

@ -570,6 +570,25 @@ static bool html_process_img(html_content *c, dom_node *node)
return success;
}
static void html_get_dimensions(html_content *htmlc)
{
unsigned w;
unsigned h;
union content_msg_data msg_data = {
.getdims = {
.viewport_width = &w,
.viewport_height = &h,
},
};
content_broadcast(&htmlc->base, CONTENT_MSG_GETDIMS, &msg_data);
htmlc->media.width.value = INTTOFIX(w);
htmlc->media.width.unit = CSS_UNIT_PX;
htmlc->media.height.value = INTTOFIX(h);
htmlc->media.height.unit = CSS_UNIT_PX;
}
/* exported function documented in html/html_internal.h */
void html_finish_conversion(html_content *htmlc)
{
@ -632,6 +651,8 @@ void html_finish_conversion(html_content *htmlc)
return;
}
html_get_dimensions(htmlc);
error = dom_to_box(html, htmlc, html_box_convert_done);
if (error != NSERROR_OK) {
NSLOG(netsurf, INFO, "box conversion failed");