|
|
@@ -95,6 +95,7 @@ struct br_image {
|
|
|
int state; /* 0 empty, 1 ready */
|
|
|
struct img_image img; /* scaled bitmap at <= BR_IMG_LAYOUT_W */
|
|
|
int native_w, native_h;
|
|
|
+ unsigned int url_hash; /* <img> source, 0 = not shareable */
|
|
|
char err[32];
|
|
|
};
|
|
|
|
|
|
@@ -170,6 +171,9 @@ static unsigned int pending_post_len;
|
|
|
/* The pending navigation is a POST even when its body is empty (a form
|
|
|
* without fields, e.g. the OIDC consent auto-submit). */
|
|
|
static int pending_post_is;
|
|
|
+/* window "resize" bookkeeping: the page width the last event was for. */
|
|
|
+static int resize_sent_w = -1;
|
|
|
+static int resize_pending;
|
|
|
static unsigned int pending_action;
|
|
|
static int cancel_fetch;
|
|
|
static int quit;
|
|
|
@@ -182,6 +186,8 @@ static int page_cache_scroll;
|
|
|
static unsigned int page_cache_nnode;
|
|
|
static int page_cache_x, page_cache_y, page_cache_w, page_cache_h;
|
|
|
static int layout_valid, layout_left, layout_right;
|
|
|
+/* Height of the page viewport: what html/body height:100% resolves to. */
|
|
|
+static int layout_view_h;
|
|
|
static unsigned int layout_nnode;
|
|
|
static int layout_content_h;
|
|
|
|
|
|
@@ -218,6 +224,8 @@ struct lay {
|
|
|
int line_left, line_right;
|
|
|
int parent_top;
|
|
|
int cb_left, cb_right, cb_top; /* containing block for absolute boxes */
|
|
|
+ int cb_h; /* definite content height of the containing block for
|
|
|
+ * percentage heights; 0 = indefinite (auto) */
|
|
|
int run_x;
|
|
|
int align;
|
|
|
int depth;
|
|
|
@@ -401,6 +409,22 @@ static void form_reset_state(void)
|
|
|
form_focus = 0;
|
|
|
}
|
|
|
|
|
|
+/* A <button> with element content (an icon <svg>/<img>, a <span> label)
|
|
|
+ * is laid out like a normal element so that content shows; only a text or
|
|
|
+ * empty button is drawn as a native control. Clicks still reach it
|
|
|
+ * through the box hit test. */
|
|
|
+static int button_has_elements(unsigned int node)
|
|
|
+{
|
|
|
+ unsigned int c;
|
|
|
+
|
|
|
+ if (node >= doc.nnode || doc.nodes[node].tag != BR_TAG_BUTTON)
|
|
|
+ return 0;
|
|
|
+ for (c = doc.nodes[node].first; c; c = doc.nodes[c].next)
|
|
|
+ if (doc.nodes[c].type == BR_NODE_ELEM)
|
|
|
+ return 1;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static int form_is_control(unsigned int node)
|
|
|
{
|
|
|
unsigned int tag;
|
|
|
@@ -409,7 +433,8 @@ static int form_is_control(unsigned int node)
|
|
|
return 0;
|
|
|
tag = doc.nodes[node].tag;
|
|
|
return tag == BR_TAG_INPUT || tag == BR_TAG_TEXTAREA ||
|
|
|
- tag == BR_TAG_SELECT || tag == BR_TAG_BUTTON;
|
|
|
+ tag == BR_TAG_SELECT ||
|
|
|
+ (tag == BR_TAG_BUTTON && !button_has_elements(node));
|
|
|
}
|
|
|
|
|
|
#define HIT_MAX 96
|
|
|
@@ -1804,6 +1829,8 @@ static void run_page_scripts(void)
|
|
|
js_host_status("JavaScript: out of memory", 1);
|
|
|
return;
|
|
|
}
|
|
|
+ resize_sent_w = -1;
|
|
|
+ resize_pending = 0;
|
|
|
prefetch_module_preloads();
|
|
|
|
|
|
for (i = 0; i < doc.nscripts; i++) {
|
|
|
@@ -2033,6 +2060,10 @@ static void decode_arena_put(void)
|
|
|
/* box_w/box_h: the laid-out box a background image paints, or 0. The
|
|
|
* bitmap then only needs to cover that box (an app-store icon is 48 px), not
|
|
|
* BR_IMG_LAYOUT_W, which keeps hundreds of small images inside the budget. */
|
|
|
+static int svg_text_sniff(const unsigned char *d, unsigned int len);
|
|
|
+static int svg_decode_image(const unsigned char *data, unsigned int len,
|
|
|
+ struct br_image *bi, int box_w, int box_h);
|
|
|
+
|
|
|
static int decode_image_data(const unsigned char *data, unsigned int len,
|
|
|
struct br_image *bi, int box_w, int box_h)
|
|
|
{
|
|
|
@@ -2046,7 +2077,10 @@ static int decode_image_data(const unsigned char *data, unsigned int len,
|
|
|
unsigned char *alpha = 0;
|
|
|
int dw, dh, r;
|
|
|
|
|
|
+ bi->url_hash = 0;
|
|
|
if (img_sniff(data, len, &info) != 0) {
|
|
|
+ if (svg_text_sniff(data, len))
|
|
|
+ return svg_decode_image(data, len, bi, box_w, box_h);
|
|
|
s_copy(bi->err, "unknown image format", sizeof(bi->err));
|
|
|
return -1;
|
|
|
}
|
|
|
@@ -4019,7 +4053,8 @@ static void preload_job_error(struct fetch_worker *w)
|
|
|
}
|
|
|
|
|
|
static void preload_decode(unsigned int node, int bg,
|
|
|
- const unsigned char *data, unsigned int len)
|
|
|
+ const unsigned char *data, unsigned int len,
|
|
|
+ const char *url)
|
|
|
{
|
|
|
if (image_count >= BR_MAX_IMAGES) {
|
|
|
if (bg)
|
|
|
@@ -4033,6 +4068,12 @@ static void preload_decode(unsigned int node, int bg,
|
|
|
layout_boxes[node].valid ? layout_boxes[node].w : 0,
|
|
|
bg && node < BR_MAX_NODES &&
|
|
|
layout_boxes[node].valid ? layout_boxes[node].h : 0) == 0) {
|
|
|
+ /* An <img> bitmap only depends on its URL, so the next
|
|
|
+ * <img> with the same source reuses it (heise repeats one
|
|
|
+ * comment icon 85 times). Backgrounds are scaled to their
|
|
|
+ * box and are not shared. */
|
|
|
+ images[image_count].url_hash =
|
|
|
+ !bg && url ? script_cache_hash(url) | 1u : 0;
|
|
|
if (bg)
|
|
|
doc.nodes[node].bg_img_index = (short)image_count;
|
|
|
else
|
|
|
@@ -4069,7 +4110,7 @@ static int preload_finish_worker(struct fetch_worker *w)
|
|
|
&tr, err, sizeof(err));
|
|
|
if (rv >= 0)
|
|
|
preload_decode(w->node, w->bg, image_file_buf,
|
|
|
- (unsigned int)rv);
|
|
|
+ (unsigned int)rv, w->url);
|
|
|
else
|
|
|
preload_job_error(w);
|
|
|
fetch_worker_release(w);
|
|
|
@@ -4121,7 +4162,6 @@ static int preload_fill_jobs(void)
|
|
|
continue;
|
|
|
}
|
|
|
if (bsrc[0] &&
|
|
|
- !contains_ci(bsrc, ".svg") &&
|
|
|
!starts_with(bsrc, "data:") &&
|
|
|
resolve_link(page_url, bsrc, url,
|
|
|
sizeof(url)) == 0) {
|
|
|
@@ -4141,7 +4181,7 @@ static int preload_fill_jobs(void)
|
|
|
&data, &len,
|
|
|
err,
|
|
|
sizeof(err)) == 0)
|
|
|
- preload_decode(i, 1, data, len);
|
|
|
+ preload_decode(i, 1, data, len, 0);
|
|
|
else
|
|
|
nd->bg_img_index = -2;
|
|
|
continue;
|
|
|
@@ -4183,8 +4223,7 @@ static int preload_fill_jobs(void)
|
|
|
continue;
|
|
|
}
|
|
|
src = br_src(&doc, i);
|
|
|
- if (!src[0] || contains_ci(src, ".svg") ||
|
|
|
- starts_with(src, "data:")) {
|
|
|
+ if (!src[0] || starts_with(src, "data:")) {
|
|
|
preload_node++;
|
|
|
continue;
|
|
|
}
|
|
|
@@ -4206,6 +4245,22 @@ static int preload_fill_jobs(void)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ {
|
|
|
+ unsigned int uh = script_cache_hash(url) | 1u;
|
|
|
+ int k;
|
|
|
+
|
|
|
+ for (k = 0; k < image_count; k++)
|
|
|
+ if (images[k].state == 1 &&
|
|
|
+ images[k].url_hash == uh)
|
|
|
+ break;
|
|
|
+ if (k < image_count) {
|
|
|
+ nd->img_index = (short)k;
|
|
|
+ layout_valid = 0;
|
|
|
+ preload_node = i + 1;
|
|
|
+ ngui_invalidate(&ui);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (url[0] == '/') {
|
|
|
unsigned char *data = 0;
|
|
|
unsigned int len = 0;
|
|
|
@@ -4213,7 +4268,7 @@ static int preload_fill_jobs(void)
|
|
|
preload_node = i + 1;
|
|
|
if (fetch_image(url, BR_IMG_FILE_MAX, &data, &len,
|
|
|
err, sizeof(err)) == 0)
|
|
|
- preload_decode(i, 0, data, len);
|
|
|
+ preload_decode(i, 0, data, len, url);
|
|
|
else
|
|
|
nd->img_index = -2;
|
|
|
continue;
|
|
|
@@ -5482,7 +5537,7 @@ static void flush_line(struct lay *l)
|
|
|
l->ui->theme.border);
|
|
|
/* A value wider than the field shows its
|
|
|
* tail (where typing happens). */
|
|
|
- if (editable && w > 12) {
|
|
|
+ if (editable && fs && fs->len && w > 12) {
|
|
|
int tw = (int)run_text_width(l->ui,
|
|
|
r, txt, tl);
|
|
|
|
|
|
@@ -6950,6 +7005,165 @@ static struct svg_cache_ent *svg_layer(unsigned int node, int w, int h,
|
|
|
return e;
|
|
|
}
|
|
|
|
|
|
+/* ---- SVG files as images (<img src="logo.svg">, CSS backgrounds) ----
|
|
|
+ *
|
|
|
+ * The markup is parsed into a detached subtree of the page document and
|
|
|
+ * drawn with the inline-SVG renderer above into a fresh RGB565 + alpha
|
|
|
+ * bitmap, which then behaves like any decoded image. currentColor is
|
|
|
+ * black (an image has no inherited text colour); <text> is not drawn. */
|
|
|
+static int svg_text_sniff(const unsigned char *d, unsigned int len)
|
|
|
+{
|
|
|
+ unsigned int i = 0;
|
|
|
+
|
|
|
+ if (len >= 3 && d[0] == 0xEF && d[1] == 0xBB && d[2] == 0xBF)
|
|
|
+ i = 3;
|
|
|
+ while (i < len) {
|
|
|
+ while (i < len && (d[i] == ' ' || d[i] == '\t' ||
|
|
|
+ d[i] == '\r' || d[i] == '\n'))
|
|
|
+ i++;
|
|
|
+ if (i + 4 <= len && !memcmp(d + i, "<svg", 4))
|
|
|
+ return 1;
|
|
|
+ if (i + 4 <= len && !memcmp(d + i, "<!--", 4)) {
|
|
|
+ i += 4;
|
|
|
+ while (i + 3 <= len && memcmp(d + i, "-->", 3))
|
|
|
+ i++;
|
|
|
+ i += 3;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (i + 1 < len && d[i] == '<' && (d[i + 1] == '?' || d[i + 1] == '!')) {
|
|
|
+ while (i < len && d[i] != '>')
|
|
|
+ i++;
|
|
|
+ i++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int svg_len_attr(unsigned int node, const char *name)
|
|
|
+{
|
|
|
+ const char *v = br_find_attr(&doc, node, name);
|
|
|
+ int n = 0, any = 0;
|
|
|
+
|
|
|
+ if (!v)
|
|
|
+ return 0;
|
|
|
+ while (*v == ' ')
|
|
|
+ v++;
|
|
|
+ while (*v >= '0' && *v <= '9') {
|
|
|
+ n = n * 10 + (*v++ - '0');
|
|
|
+ any = 1;
|
|
|
+ }
|
|
|
+ if (*v == '.')
|
|
|
+ while (*++v >= '0' && *v <= '9')
|
|
|
+ ;
|
|
|
+ if (!any || *v == '%')
|
|
|
+ return 0;
|
|
|
+ return n;
|
|
|
+}
|
|
|
+
|
|
|
+static int svg_decode_image(const unsigned char *data, unsigned int len,
|
|
|
+ struct br_image *bi, int box_w, int box_h)
|
|
|
+{
|
|
|
+ unsigned int holder, svg = 0, c, need, i;
|
|
|
+ struct br_style base = base_style(), st;
|
|
|
+ struct svgr_layer L;
|
|
|
+ double vb[4], m[6];
|
|
|
+ int w, h, have_vb, nat_w, nat_h;
|
|
|
+
|
|
|
+ holder = br_create_element(&doc, "div", 3);
|
|
|
+ if (!holder) {
|
|
|
+ s_copy(bi->err, "page is full", sizeof(bi->err));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ holder--;
|
|
|
+ br_set_inner_html(&doc, holder, (const char *)data, len);
|
|
|
+ for (c = doc.nodes[holder].first; c; c = doc.nodes[c].next)
|
|
|
+ if (doc.nodes[c].type == BR_NODE_ELEM &&
|
|
|
+ doc.nodes[c].tag == BR_TAG_SVG) {
|
|
|
+ svg = c;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!svg) {
|
|
|
+ s_copy(bi->err, "bad SVG", sizeof(bi->err));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ have_vb = svg_viewbox4(svg, vb) && vb[2] > 0 && vb[3] > 0;
|
|
|
+ w = svg_len_attr(svg, "width");
|
|
|
+ h = svg_len_attr(svg, "height");
|
|
|
+ if (box_w > 0 && box_h > 0) {
|
|
|
+ w = box_w;
|
|
|
+ h = box_h;
|
|
|
+ } else if (!w && !h) {
|
|
|
+ w = have_vb ? (int)(vb[2] + 0.5) : 150;
|
|
|
+ h = have_vb ? (int)(vb[3] + 0.5) : 150;
|
|
|
+ } else if (!w) {
|
|
|
+ w = have_vb ? (int)(h * vb[2] / vb[3] + 0.5) : h;
|
|
|
+ } else if (!h) {
|
|
|
+ h = have_vb ? (int)(w * vb[3] / vb[2] + 0.5) : w;
|
|
|
+ }
|
|
|
+ /* Layout uses the intrinsic size; small icons are drawn at up to 4x
|
|
|
+ * so CSS scaling stays crisp. */
|
|
|
+ nat_w = w;
|
|
|
+ nat_h = h;
|
|
|
+ while (w < 96 && h < 96 && w * h > 0 && w * 2 <= 384) {
|
|
|
+ w *= 2;
|
|
|
+ h *= 2;
|
|
|
+ }
|
|
|
+ if (w > BR_IMG_LAYOUT_W) {
|
|
|
+ h = (int)((long)h * BR_IMG_LAYOUT_W / w);
|
|
|
+ w = BR_IMG_LAYOUT_W;
|
|
|
+ }
|
|
|
+ if (h > 2048)
|
|
|
+ h = 2048;
|
|
|
+ if (w < 1)
|
|
|
+ w = 1;
|
|
|
+ if (h < 1)
|
|
|
+ h = 1;
|
|
|
+ need = (unsigned int)w * (unsigned int)h;
|
|
|
+ if (image_pixels + need > BR_IMG_PIXEL_BUDGET) {
|
|
|
+ s_copy(bi->err, "image budget exhausted", sizeof(bi->err));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if (!svg_geom_buf) {
|
|
|
+ svg_geom_buf = malloc(SVG_MAX_POINTS * (2 * sizeof(float) + 1));
|
|
|
+ if (!svg_geom_buf) {
|
|
|
+ s_copy(bi->err, "out of memory", sizeof(bi->err));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ svgr_init(&svg_geom, svg_geom_buf, SVG_MAX_POINTS);
|
|
|
+ L.px = (unsigned short *)malloc(need * sizeof(unsigned short));
|
|
|
+ L.a = (unsigned char *)calloc(need, 1);
|
|
|
+ if (!L.px || !L.a) {
|
|
|
+ free(L.px);
|
|
|
+ free(L.a);
|
|
|
+ s_copy(bi->err, "out of memory", sizeof(bi->err));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ for (i = 0; i < need; i++)
|
|
|
+ L.px[i] = 0xFFFF;
|
|
|
+ L.w = w;
|
|
|
+ L.h = h;
|
|
|
+ base.color = 0x0000;
|
|
|
+ br_style_for(&doc, svg, &base, &st);
|
|
|
+ svg_root_matrix(svg, w, h, m);
|
|
|
+ svg_vp_w = have_vb ? vb[2] : w;
|
|
|
+ svg_vp_h = have_vb ? vb[3] : h;
|
|
|
+ svg_draw_children(&L, svg, m, &st, 255, 0);
|
|
|
+ bi->native_w = nat_w;
|
|
|
+ bi->native_h = nat_h;
|
|
|
+ bi->img.format = 0;
|
|
|
+ bi->img.w = (unsigned int)w;
|
|
|
+ bi->img.h = (unsigned int)h;
|
|
|
+ bi->img.px = L.px;
|
|
|
+ bi->img.alpha = L.a;
|
|
|
+ bi->img.flags = 0;
|
|
|
+ bi->state = 1;
|
|
|
+ image_pixels += need;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
/* Intrinsic size of an inline <svg> in a w-wide containing box. */
|
|
|
static void svg_size(unsigned int node, const struct br_style *st, int cw,
|
|
|
int *out_w, int *out_h)
|
|
|
@@ -7117,6 +7331,7 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
unsigned short link)
|
|
|
{
|
|
|
int old_left = l->left, old_right = l->right, old_align = l->align;
|
|
|
+ int parent_cb_h = l->cb_h;
|
|
|
int saved_parent_top = l->parent_top;
|
|
|
int saved_cb_left = l->cb_left, saved_cb_right = l->cb_right;
|
|
|
int saved_cb_top = l->cb_top;
|
|
|
@@ -7192,10 +7407,11 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
rel_dx += st->tx;
|
|
|
rel_dy += st->ty;
|
|
|
}
|
|
|
- if (doc.nodes[node].tag == BR_TAG_INPUT ||
|
|
|
- doc.nodes[node].tag == BR_TAG_TEXTAREA ||
|
|
|
- doc.nodes[node].tag == BR_TAG_SELECT ||
|
|
|
- doc.nodes[node].tag == BR_TAG_BUTTON) {
|
|
|
+ if ((doc.nodes[node].tag == BR_TAG_INPUT ||
|
|
|
+ doc.nodes[node].tag == BR_TAG_TEXTAREA ||
|
|
|
+ doc.nodes[node].tag == BR_TAG_SELECT ||
|
|
|
+ doc.nodes[node].tag == BR_TAG_BUTTON) &&
|
|
|
+ !button_has_elements(node)) {
|
|
|
if (doc.nodes[node].tag == BR_TAG_INPUT &&
|
|
|
s_eq(br_type(&doc, node), "hidden"))
|
|
|
return;
|
|
|
@@ -7496,6 +7712,21 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
st->color);
|
|
|
}
|
|
|
}
|
|
|
+ /* This box's definite content height, for its children's
|
|
|
+ * percentage heights. */
|
|
|
+ if (doc.nodes[node].tag == BR_TAG_HTML ||
|
|
|
+ doc.nodes[node].tag == BR_TAG_BODY)
|
|
|
+ l->cb_h = layout_view_h;
|
|
|
+ else if (st->height_kind == 1)
|
|
|
+ l->cb_h = (int)st->height -
|
|
|
+ (st->box_sizing ? deco_h : 0);
|
|
|
+ else if (st->height_kind == 2 && parent_cb_h > 0)
|
|
|
+ l->cb_h = parent_cb_h * (int)st->height / 100 -
|
|
|
+ (st->box_sizing ? deco_h : 0);
|
|
|
+ else
|
|
|
+ l->cb_h = 0;
|
|
|
+ if (l->cb_h < 0)
|
|
|
+ l->cb_h = 0;
|
|
|
if (doc.nodes[node].tag == BR_TAG_TR)
|
|
|
layout_table_row(l, node, st, depth + 1, link);
|
|
|
else if (doc.nodes[node].tag == BR_TAG_TABLE &&
|
|
|
@@ -7509,8 +7740,19 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
else if (st->display == BR_DISPLAY_FLEX && !st->flex_col &&
|
|
|
flex_wants_row(node, st))
|
|
|
layout_flex_children(l, node, st, depth + 1, link);
|
|
|
- else
|
|
|
+ else if (st->display == BR_DISPLAY_FLEX && st->flex_col &&
|
|
|
+ st->align_items == 1) {
|
|
|
+ /* align-items: center in a column: the items' lines
|
|
|
+ * (an app card's icon and label) are centred; a child
|
|
|
+ * with its own text-align keeps it. */
|
|
|
+ struct br_style cst = *st;
|
|
|
+
|
|
|
+ cst.align = BR_ALIGN_CENTER;
|
|
|
+ l->align = BR_ALIGN_CENTER;
|
|
|
+ layout_children(l, node, &cst, depth + 1, link);
|
|
|
+ } else
|
|
|
layout_children(l, node, st, depth + 1, link);
|
|
|
+ l->cb_h = parent_cb_h;
|
|
|
}
|
|
|
flush_line(l);
|
|
|
if (clip_pushed)
|
|
|
@@ -7522,6 +7764,21 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
}
|
|
|
if (doc.nodes[node].tag == BR_TAG_IMG) {
|
|
|
content_h = img_dh;
|
|
|
+ } else if (st->height_kind == 2 &&
|
|
|
+ doc.nodes[node].tag != BR_TAG_HTML &&
|
|
|
+ doc.nodes[node].tag != BR_TAG_BODY) {
|
|
|
+ /* A percentage of the containing block's definite height, or
|
|
|
+ * auto when it has none (it used to resolve against the
|
|
|
+ * width). The result is a minimum: without scrollable inner
|
|
|
+ * boxes, an app shell's height:100%; overflow:hidden column
|
|
|
+ * would otherwise clip everything past the first screen. */
|
|
|
+ int auto_h = l->y - (top + bt + pt);
|
|
|
+
|
|
|
+ content_h = parent_cb_h > 0 ?
|
|
|
+ parent_cb_h * (int)st->height / 100 -
|
|
|
+ (st->box_sizing ? deco_h : 0) : 0;
|
|
|
+ if (content_h < auto_h)
|
|
|
+ content_h = auto_h;
|
|
|
} else if (st->height_kind &&
|
|
|
!((doc.nodes[node].tag == BR_TAG_HTML ||
|
|
|
doc.nodes[node].tag == BR_TAG_BODY) &&
|
|
|
@@ -7932,6 +8189,11 @@ static int flex_item_width(struct lay *l, unsigned int n,
|
|
|
w = (int)nd->width_attr;
|
|
|
else
|
|
|
w = 64;
|
|
|
+ } else if (nd->tag == BR_TAG_INPUT || nd->tag == BR_TAG_SELECT ||
|
|
|
+ nd->tag == BR_TAG_TEXTAREA) {
|
|
|
+ /* A control has no content to measure: its default size
|
|
|
+ * (a search field in a filter bar). */
|
|
|
+ w = nd->tag == BR_TAG_TEXTAREA ? 180 : 150;
|
|
|
} else {
|
|
|
w = intrinsic_width(l->ui, n, cs, 0, avail);
|
|
|
}
|
|
|
@@ -7960,6 +8222,10 @@ static unsigned int layout_inline_blocks(struct lay *l, unsigned int first,
|
|
|
int row_left = l->left, row_right = l->right;
|
|
|
int avail = row_right - row_left;
|
|
|
int x = row_left, y = l->y, row_h = 0, any = 0;
|
|
|
+ /* Each box sets l->align from its own style; the text after the row
|
|
|
+ * must keep the container's (a centred .fa-fw icon centred the menu
|
|
|
+ * label that followed it). */
|
|
|
+ unsigned char row_align = l->align;
|
|
|
|
|
|
flush_line(l);
|
|
|
y = l->y;
|
|
|
@@ -8026,6 +8292,7 @@ static unsigned int layout_inline_blocks(struct lay *l, unsigned int first,
|
|
|
y += row_h;
|
|
|
l->left = row_left;
|
|
|
l->right = row_right;
|
|
|
+ l->align = row_align;
|
|
|
l->y = y;
|
|
|
l->line_x = l->left;
|
|
|
l->run_x = l->left;
|
|
|
@@ -8052,6 +8319,7 @@ static void layout_flex_children(struct lay *l, unsigned int parent,
|
|
|
int row_left = l->left, row_right = l->right;
|
|
|
int avail = row_right - row_left;
|
|
|
int idx, row_top;
|
|
|
+ unsigned char row_align = l->align;
|
|
|
|
|
|
if (avail < 160 || depth > 48) {
|
|
|
layout_children(l, parent, pst, depth, link);
|
|
|
@@ -8202,6 +8470,7 @@ static void layout_flex_children(struct lay *l, unsigned int parent,
|
|
|
}
|
|
|
l->left = row_left;
|
|
|
l->right = row_right;
|
|
|
+ l->align = row_align;
|
|
|
l->y = row_top;
|
|
|
l->line_x = l->left;
|
|
|
l->run_x = l->left;
|
|
|
@@ -9334,8 +9603,9 @@ static void layout_children(struct lay *l, unsigned int parent,
|
|
|
n = nd->next;
|
|
|
continue;
|
|
|
}
|
|
|
- if (nd->tag == BR_TAG_INPUT || nd->tag == BR_TAG_TEXTAREA ||
|
|
|
- nd->tag == BR_TAG_SELECT || nd->tag == BR_TAG_BUTTON) {
|
|
|
+ if ((nd->tag == BR_TAG_INPUT || nd->tag == BR_TAG_TEXTAREA ||
|
|
|
+ nd->tag == BR_TAG_SELECT || nd->tag == BR_TAG_BUTTON) &&
|
|
|
+ !button_has_elements(n)) {
|
|
|
if (!(nd->tag == BR_TAG_INPUT &&
|
|
|
s_eq(br_type(&doc, n), "hidden"))) {
|
|
|
form_fill_line = pst->display ==
|
|
|
@@ -9420,6 +9690,7 @@ static int measure_page(int left, int right)
|
|
|
l->line_y = 0;
|
|
|
l->line_h = 0;
|
|
|
l->align = BR_ALIGN_LEFT;
|
|
|
+ l->cb_h = layout_view_h;
|
|
|
l->float_active = 0;
|
|
|
l->parent_top = 0;
|
|
|
l->cb_left = left;
|
|
|
@@ -9477,6 +9748,7 @@ static void render_page(int left, int right, int y0)
|
|
|
l->line_y = y0;
|
|
|
l->line_h = 0;
|
|
|
l->align = BR_ALIGN_LEFT;
|
|
|
+ l->cb_h = layout_view_h;
|
|
|
l->float_active = 0;
|
|
|
l->parent_top = 0;
|
|
|
l->cb_left = left;
|
|
|
@@ -9698,11 +9970,17 @@ static void draw_page(struct ngui_rect page)
|
|
|
right = page.x + page.w - 16;
|
|
|
if (!layout_valid || left != layout_left || right != layout_right ||
|
|
|
layout_nnode != doc.nnode) {
|
|
|
+ layout_view_h = page.h - 8;
|
|
|
layout_content_h = measure_page(left, right);
|
|
|
layout_valid = 1;
|
|
|
layout_left = left;
|
|
|
layout_right = right;
|
|
|
layout_nnode = doc.nnode;
|
|
|
+ /* Scripts that measured before any layout (offsetWidth on
|
|
|
+ * mount) get a resize event once real boxes exist, and again
|
|
|
+ * whenever the page width changes. */
|
|
|
+ if (js_browser_active() && right - left != resize_sent_w)
|
|
|
+ resize_pending = 1;
|
|
|
}
|
|
|
ch = layout_content_h;
|
|
|
page_scroll.content_h = ch;
|
|
|
@@ -10449,6 +10727,11 @@ void _start(const char *arg)
|
|
|
preload_active = 1;
|
|
|
}
|
|
|
js_browser_tick();
|
|
|
+ if (resize_pending && !pending_action) {
|
|
|
+ resize_pending = 0;
|
|
|
+ resize_sent_w = layout_right - layout_left;
|
|
|
+ js_browser_window_event("resize");
|
|
|
+ }
|
|
|
persist_tick();
|
|
|
if (pending_action)
|
|
|
continue;
|