|
|
@@ -170,6 +170,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 +185,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 +223,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;
|
|
|
@@ -1804,6 +1811,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++) {
|
|
|
@@ -5482,7 +5491,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);
|
|
|
|
|
|
@@ -7117,6 +7126,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;
|
|
|
@@ -7496,6 +7506,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 +7534,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 +7558,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 +7983,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 +8016,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 +8086,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 +8113,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 +8264,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;
|
|
|
@@ -9420,6 +9483,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 +9541,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 +9763,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 +10520,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;
|