|
@@ -74,7 +74,7 @@ static unsigned int decode_arena_size;
|
|
|
#define SCRIPT_CACHE_PREFIX "bjs-"
|
|
#define SCRIPT_CACHE_PREFIX "bjs-"
|
|
|
#define BR_MAX_SHEETS 6
|
|
#define BR_MAX_SHEETS 6
|
|
|
#define BR_HISTORY 16
|
|
#define BR_HISTORY 16
|
|
|
-#define BR_URL_MAX 512
|
|
|
|
|
|
|
+#define BR_URL_MAX 4096 /* = UHTTP_PATH_MAX: google.com's JS URL is ~3.7 KB */
|
|
|
#define BR_STATUS_MAX 200
|
|
#define BR_STATUS_MAX 200
|
|
|
|
|
|
|
|
#define BR_IMG_RGB565(r, g, b) \
|
|
#define BR_IMG_RGB565(r, g, b) \
|
|
@@ -308,6 +308,10 @@ static int s_eq(const char *a, const char *b);
|
|
|
static void form_key(int k);
|
|
static void form_key(int k);
|
|
|
static void form_click(unsigned int node);
|
|
static void form_click(unsigned int node);
|
|
|
static void style_for_node(unsigned int node, struct br_style *out);
|
|
static void style_for_node(unsigned int node, struct br_style *out);
|
|
|
|
|
+static int form_author_styled(const struct br_style *st);
|
|
|
|
|
+static int css_radius(const struct br_style *st, int corner, int w, int h);
|
|
|
|
|
+static void form_paint_author(struct ngui *ui, struct ngui_rect box,
|
|
|
|
|
+ const struct br_style *st, int focused);
|
|
|
|
|
|
|
|
static int form_disabled(unsigned int node)
|
|
static int form_disabled(unsigned int node)
|
|
|
{
|
|
{
|
|
@@ -2708,7 +2712,7 @@ static int path_dir(const char *path, char *out, unsigned int cap)
|
|
|
static int resolve_link(const char *base, const char *href, char *out,
|
|
static int resolve_link(const char *base, const char *href, char *out,
|
|
|
unsigned int cap)
|
|
unsigned int cap)
|
|
|
{
|
|
{
|
|
|
- char joined[BR_URL_MAX];
|
|
|
|
|
|
|
+ static char joined[BR_URL_MAX]; /* leaf: off the stack */
|
|
|
|
|
|
|
|
if (!href || !href[0] || href[0] == '#')
|
|
if (!href || !href[0] || href[0] == '#')
|
|
|
return -1;
|
|
return -1;
|
|
@@ -2743,7 +2747,7 @@ static int resolve_link(const char *base, const char *href, char *out,
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- char dir[BR_URL_MAX];
|
|
|
|
|
|
|
+ static char dir[BR_URL_MAX];
|
|
|
unsigned int n = 0;
|
|
unsigned int n = 0;
|
|
|
|
|
|
|
|
if (s_eq(base, "about:home"))
|
|
if (s_eq(base, "about:home"))
|
|
@@ -3195,7 +3199,7 @@ static int fetch_worker_submit_req(struct fetch_worker *w, const char *url,
|
|
|
unsigned int dec_h, char *err,
|
|
unsigned int dec_h, char *err,
|
|
|
unsigned int errcap)
|
|
unsigned int errcap)
|
|
|
{
|
|
{
|
|
|
- static char req[1024];
|
|
|
|
|
|
|
+ static char req[BR_URL_MAX + 256];
|
|
|
unsigned int n = 0;
|
|
unsigned int n = 0;
|
|
|
|
|
|
|
|
fetch_seq++;
|
|
fetch_seq++;
|
|
@@ -3270,7 +3274,7 @@ static int fetch_worker_submit_req(struct fetch_worker *w, const char *url,
|
|
|
static int fetch_worker_read_meta(struct fetch_worker *w, char *err,
|
|
static int fetch_worker_read_meta(struct fetch_worker *w, char *err,
|
|
|
unsigned int errcap)
|
|
unsigned int errcap)
|
|
|
{
|
|
{
|
|
|
- static char meta[1024];
|
|
|
|
|
|
|
+ static char meta[BR_URL_MAX + 1024];
|
|
|
char *p;
|
|
char *p;
|
|
|
int rn, mseq;
|
|
int rn, mseq;
|
|
|
|
|
|
|
@@ -6274,6 +6278,35 @@ static void flush_line(struct lay *l)
|
|
|
}
|
|
}
|
|
|
tl = fs->len;
|
|
tl = fs->len;
|
|
|
}
|
|
}
|
|
|
|
|
+ struct br_style fst;
|
|
|
|
|
+ int author, tx = x + 6, pr = 6;
|
|
|
|
|
+
|
|
|
|
|
+ style_for_node(node, &fst);
|
|
|
|
|
+ author = form_author_styled(&fst);
|
|
|
|
|
+ if (author) {
|
|
|
|
|
+ /* The page styled the control:
|
|
|
|
|
+ * its background, border, radius
|
|
|
|
|
+ * and text colour. */
|
|
|
|
|
+ form_paint_author(l->ui, box, &fst,
|
|
|
|
|
+ focused);
|
|
|
|
|
+ tx = x + fst.border_w[3] +
|
|
|
|
|
+ mp_px(&fst, 7, w);
|
|
|
|
|
+ pr = fst.border_w[1] +
|
|
|
|
|
+ mp_px(&fst, 5, w);
|
|
|
|
|
+ if (tx < x + 2 && !editable)
|
|
|
|
|
+ tx = x + 2;
|
|
|
|
|
+ if (!disabled)
|
|
|
|
|
+ fg = editable && fs &&
|
|
|
|
|
+ !fs->len ?
|
|
|
|
|
+ 0x8410 : fst.color;
|
|
|
|
|
+ if (!editable) {
|
|
|
|
|
+ int tw0 = (int)
|
|
|
|
|
+ run_text_width(l->ui,
|
|
|
|
|
+ r, txt, tl);
|
|
|
|
|
+
|
|
|
|
|
+ tx = x + (w - tw0) / 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
/* The box is drawn in theme colours, so
|
|
/* The box is drawn in theme colours, so
|
|
|
* the text is too: the page's CSS colour
|
|
* the text is too: the page's CSS colour
|
|
|
* (dark on a light page) would vanish on
|
|
* (dark on a light page) would vanish on
|
|
@@ -6286,21 +6319,24 @@ static void flush_line(struct lay *l)
|
|
|
ngui_frame(l->ui, box,
|
|
ngui_frame(l->ui, box,
|
|
|
focused ? l->ui->theme.accent :
|
|
focused ? l->ui->theme.accent :
|
|
|
l->ui->theme.border);
|
|
l->ui->theme.border);
|
|
|
|
|
+ }
|
|
|
/* A value wider than the field shows its
|
|
/* A value wider than the field shows its
|
|
|
* tail (where typing happens). */
|
|
* tail (where typing happens). */
|
|
|
- if (editable && fs && fs->len && w > 12) {
|
|
|
|
|
|
|
+ if (editable && fs && fs->len &&
|
|
|
|
|
+ w > (tx - x) + pr) {
|
|
|
int tw = (int)run_text_width(l->ui,
|
|
int tw = (int)run_text_width(l->ui,
|
|
|
r, txt, tl);
|
|
r, txt, tl);
|
|
|
|
|
+ int room = w - (tx - x) - pr;
|
|
|
|
|
|
|
|
- if (tw > w - 12)
|
|
|
|
|
- scroll = tw - (w - 12);
|
|
|
|
|
|
|
+ if (tw > room)
|
|
|
|
|
+ scroll = tw - room;
|
|
|
}
|
|
}
|
|
|
ngui_push_clip(l->ui, (struct ngui_rect){
|
|
ngui_push_clip(l->ui, (struct ngui_rect){
|
|
|
x + 1, ry + 1,
|
|
x + 1, ry + 1,
|
|
|
w > 2 ? w - 2 : 1,
|
|
w > 2 ? w - 2 : 1,
|
|
|
hh > 2 ? hh - 2 : 1 });
|
|
hh > 2 ? hh - 2 : 1 });
|
|
|
ngui_text_px_face(l->ui, run_face(r),
|
|
ngui_text_px_face(l->ui, run_face(r),
|
|
|
- x + 6 - scroll,
|
|
|
|
|
|
|
+ tx - scroll,
|
|
|
ry + (hh - r->font_px) / 2 - 1,
|
|
ry + (hh - r->font_px) / 2 - 1,
|
|
|
txt, tl, fg, r->font_px,
|
|
txt, tl, fg, r->font_px,
|
|
|
r->bold, r->italic, r->mono);
|
|
r->bold, r->italic, r->mono);
|
|
@@ -6314,7 +6350,7 @@ static void flush_line(struct lay *l)
|
|
|
fs->caret : fs->len);
|
|
fs->caret : fs->len);
|
|
|
ngui_fill_rect(l->ui,
|
|
ngui_fill_rect(l->ui,
|
|
|
(struct ngui_rect){
|
|
(struct ngui_rect){
|
|
|
- x + 6 + cw - scroll,
|
|
|
|
|
|
|
+ tx + cw - scroll,
|
|
|
ry + 4, 1,
|
|
ry + 4, 1,
|
|
|
hh > 8 ? hh - 8 : 1
|
|
hh > 8 ? hh - 8 : 1
|
|
|
},
|
|
},
|
|
@@ -6994,6 +7030,22 @@ static void list_marker_text(char *m, unsigned int cap, int style, int idx)
|
|
|
m[n] = '\0';
|
|
m[n] = '\0';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* A control the page styled itself (background, border or radius in author
|
|
|
|
|
+ * CSS -- `background:transparent;border:none` counts) is painted with that
|
|
|
|
|
+ * style, sized from its padding/height and keeps the page's text colour.
|
|
|
|
|
+ * Unstyled controls keep the ngui theme look. */
|
|
|
|
|
+static int form_author_styled(const struct br_style *st)
|
|
|
|
|
+{
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (st->bg_set)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ for (i = 0; i < 4; i++)
|
|
|
|
|
+ if (st->border_w[i] || st->radius[i])
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/* Set by the layout when the control is stretched to its line: a flex item
|
|
/* Set by the layout when the control is stretched to its line: a flex item
|
|
|
* (its box width was assigned by the flex row) or a child of a flex column,
|
|
* (its box width was assigned by the flex row) or a child of a flex column,
|
|
|
* whose default align-items: stretch makes inputs full width. */
|
|
* whose default align-items: stretch makes inputs full width. */
|
|
@@ -7009,7 +7061,9 @@ static void add_form_run(struct lay *l, unsigned int node,
|
|
|
struct lay_run *r;
|
|
struct lay_run *r;
|
|
|
int kind = form_kind_of(node);
|
|
int kind = form_kind_of(node);
|
|
|
int disabled = form_disabled(node);
|
|
int disabled = form_disabled(node);
|
|
|
- int tw, w = 120, h = 20, i;
|
|
|
|
|
|
|
+ int author = form_author_styled(st);
|
|
|
|
|
+ int tw, w = 120, h = 20, i, line_w, pad_x, pad_y;
|
|
|
|
|
+ int ml = 0, mr = 0, mt = 0, mb = 0;
|
|
|
|
|
|
|
|
if (!fs)
|
|
if (!fs)
|
|
|
return;
|
|
return;
|
|
@@ -7047,34 +7101,87 @@ static void add_form_run(struct lay *l, unsigned int node,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
tw = (int)face_text_width(l->ui, st, text, s_len(text));
|
|
tw = (int)face_text_width(l->ui, st, text, s_len(text));
|
|
|
|
|
+ line_w = l->line_right - l->line_left;
|
|
|
|
|
+ pad_x = mp_px(st, 7, line_w) + mp_px(st, 5, line_w) +
|
|
|
|
|
+ st->border_w[1] + st->border_w[3];
|
|
|
|
|
+ pad_y = mp_px(st, 4, line_w) + mp_px(st, 6, line_w) +
|
|
|
|
|
+ st->border_w[0] + st->border_w[2];
|
|
|
if (kind == FORM_BUTTON || kind == FORM_SUBMIT || kind == FORM_RESET) {
|
|
if (kind == FORM_BUTTON || kind == FORM_SUBMIT || kind == FORM_RESET) {
|
|
|
- w = tw + 18;
|
|
|
|
|
- if (w < 64)
|
|
|
|
|
- w = 64;
|
|
|
|
|
- h = 22;
|
|
|
|
|
- } else if (kind == FORM_TEXT || kind == FORM_PASSWORD) {
|
|
|
|
|
- int line_w = l->line_right - l->line_left;
|
|
|
|
|
-
|
|
|
|
|
- if (st->width_kind == 1)
|
|
|
|
|
- w = st->width;
|
|
|
|
|
- else if (st->width_kind == 2)
|
|
|
|
|
- w = css_size(st->width_kind, st->width, line_w);
|
|
|
|
|
- else if (form_fill_line || st->display == BR_DISPLAY_BLOCK)
|
|
|
|
|
|
|
+ /* Buttons are border-box in every UA stylesheet: an
|
|
|
|
|
+ * explicit width/height is the whole box. */
|
|
|
|
|
+ if (author || pad_x) {
|
|
|
|
|
+ w = tw + pad_x;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ w = tw + 18;
|
|
|
|
|
+ if (w < 64)
|
|
|
|
|
+ w = 64;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (st->width_kind)
|
|
|
|
|
+ w = style_width_px(st, line_w);
|
|
|
|
|
+ if (st->min_width_kind == 1 && w < (int)st->min_width)
|
|
|
|
|
+ w = st->min_width;
|
|
|
|
|
+ if (st->height_kind == 1)
|
|
|
|
|
+ h = st->height;
|
|
|
|
|
+ else if (author)
|
|
|
|
|
+ h = st->font_px + 6 + pad_y;
|
|
|
|
|
+ else
|
|
|
|
|
+ h = 22;
|
|
|
|
|
+ } else if (kind == FORM_TEXT || kind == FORM_PASSWORD ||
|
|
|
|
|
+ kind == FORM_TEXTAREA) {
|
|
|
|
|
+ int fill = form_fill_line || st->display == BR_DISPLAY_BLOCK ||
|
|
|
|
|
+ st->display == BR_DISPLAY_FLEX;
|
|
|
|
|
+ int boxed = st->box_sizing ? 0 : pad_x;
|
|
|
|
|
+
|
|
|
|
|
+ if (st->width_kind)
|
|
|
|
|
+ w = style_width_px(st, line_w) + boxed;
|
|
|
|
|
+ else if (fill)
|
|
|
w = line_w - (l->line_x - l->line_left);
|
|
w = line_w - (l->line_x - l->line_left);
|
|
|
else
|
|
else
|
|
|
- w = 120;
|
|
|
|
|
- /* Taller fields for large text (min-height/padding on login
|
|
|
|
|
- * pages): keep the box around the glyphs. */
|
|
|
|
|
- if (st->font_px + 8 > h)
|
|
|
|
|
|
|
+ w = kind == FORM_TEXTAREA ? 180 : 120;
|
|
|
|
|
+ if (kind == FORM_TEXTAREA) {
|
|
|
|
|
+ const char *ra = br_find_attr(&doc, node, "rows");
|
|
|
|
|
+ int rows = 0;
|
|
|
|
|
+ int lh = st->line_h_px ? st->line_h_px :
|
|
|
|
|
+ st->font_px * 5 / 4;
|
|
|
|
|
+
|
|
|
|
|
+ while (ra && *ra >= '0' && *ra <= '9')
|
|
|
|
|
+ rows = rows * 10 + (*ra++ - '0');
|
|
|
|
|
+ if (rows < 1 || rows > 40)
|
|
|
|
|
+ rows = 2;
|
|
|
|
|
+ h = author ? rows * lh + pad_y : 40;
|
|
|
|
|
+ } else if (author) {
|
|
|
|
|
+ h = st->font_px + 8 + pad_y;
|
|
|
|
|
+ } else if (st->font_px + 8 > h) {
|
|
|
|
|
+ /* Taller fields for large text (min-height/padding
|
|
|
|
|
+ * on login pages): keep the box around the glyphs. */
|
|
|
h = st->font_px + 8;
|
|
h = st->font_px + 8;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (st->height_kind == 1)
|
|
|
|
|
+ h = st->height + (st->box_sizing ? 0 : pad_y);
|
|
|
|
|
+ if (st->min_height_kind == 1 && h < (int)st->min_height)
|
|
|
|
|
+ h = st->min_height;
|
|
|
} else if (kind == FORM_SELECT) {
|
|
} else if (kind == FORM_SELECT) {
|
|
|
w = st->width_kind == 1 ? st->width : 120;
|
|
w = st->width_kind == 1 ? st->width : 120;
|
|
|
}
|
|
}
|
|
|
- if (w > l->line_right - l->line_left)
|
|
|
|
|
- w = l->line_right - l->line_left;
|
|
|
|
|
|
|
+ if (author) {
|
|
|
|
|
+ /* Inline margins (Google's `margin:11px 4px` between its
|
|
|
|
|
+ * two submit buttons). */
|
|
|
|
|
+ ml = mp_px(st, 3, line_w);
|
|
|
|
|
+ mr = mp_px(st, 1, line_w);
|
|
|
|
|
+ mt = mp_px(st, 0, line_w);
|
|
|
|
|
+ mb = mp_px(st, 2, line_w);
|
|
|
|
|
+ if (ml < 0 || ml > 64) ml = 0;
|
|
|
|
|
+ if (mr < 0 || mr > 64) mr = 0;
|
|
|
|
|
+ if (mt < 0 || mt > 64) mt = 0;
|
|
|
|
|
+ if (mb < 0 || mb > 64) mb = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (w > line_w - ml - mr)
|
|
|
|
|
+ w = line_w - ml - mr;
|
|
|
if (w < 8)
|
|
if (w < 8)
|
|
|
w = 8;
|
|
w = 8;
|
|
|
- if (l->line_x + w > l->line_right &&
|
|
|
|
|
|
|
+ if (h > 400)
|
|
|
|
|
+ h = 400;
|
|
|
|
|
+ if (l->line_x + ml + w > l->line_right &&
|
|
|
(l->nruns > 0 || l->line_x > l->line_left))
|
|
(l->nruns > 0 || l->line_x > l->line_left))
|
|
|
flush_line(l);
|
|
flush_line(l);
|
|
|
if (l->nruns >= 96)
|
|
if (l->nruns >= 96)
|
|
@@ -7084,12 +7191,13 @@ static void add_form_run(struct lay *l, unsigned int node,
|
|
|
l->line_h = 0;
|
|
l->line_h = 0;
|
|
|
start_line(l, st);
|
|
start_line(l, st);
|
|
|
}
|
|
}
|
|
|
|
|
+ l->line_x += ml;
|
|
|
r = &l->runs[l->nruns++];
|
|
r = &l->runs[l->nruns++];
|
|
|
r->gap = (unsigned short)(l->line_x - l->run_x);
|
|
r->gap = (unsigned short)(l->line_x - l->run_x);
|
|
|
r->off = r->len = 0;
|
|
r->off = r->len = 0;
|
|
|
r->color = st->color;
|
|
r->color = st->color;
|
|
|
r->href = href;
|
|
r->href = href;
|
|
|
- r->dy = 0;
|
|
|
|
|
|
|
+ r->dy = (signed short)mt;
|
|
|
r->has_lit = 1;
|
|
r->has_lit = 1;
|
|
|
for (i = 0; i + 1 < (int)sizeof(r->lit) && text[i]; i++)
|
|
for (i = 0; i + 1 < (int)sizeof(r->lit) && text[i]; i++)
|
|
|
r->lit[i] = text[i];
|
|
r->lit[i] = text[i];
|
|
@@ -7109,15 +7217,60 @@ static void add_form_run(struct lay *l, unsigned int node,
|
|
|
r->form_disabled = (unsigned char)disabled;
|
|
r->form_disabled = (unsigned char)disabled;
|
|
|
if (node < BR_MAX_NODES) {
|
|
if (node < BR_MAX_NODES) {
|
|
|
layout_boxes[node].x = l->line_x;
|
|
layout_boxes[node].x = l->line_x;
|
|
|
- layout_boxes[node].y = l->line_y;
|
|
|
|
|
|
|
+ layout_boxes[node].y = l->line_y + mt;
|
|
|
layout_boxes[node].w = w;
|
|
layout_boxes[node].w = w;
|
|
|
layout_boxes[node].h = h;
|
|
layout_boxes[node].h = h;
|
|
|
layout_boxes[node].valid = 1;
|
|
layout_boxes[node].valid = 1;
|
|
|
}
|
|
}
|
|
|
l->line_x += w;
|
|
l->line_x += w;
|
|
|
l->run_x = l->line_x;
|
|
l->run_x = l->line_x;
|
|
|
- if (l->line_h < h)
|
|
|
|
|
- l->line_h = h;
|
|
|
|
|
|
|
+ l->line_x += mr;
|
|
|
|
|
+ if (l->line_h < h + mt + mb)
|
|
|
|
|
+ l->line_h = h + mt + mb;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Background, border and corner radius of an author-styled control, the
|
|
|
|
|
+ * same decoration rules as a block box. */
|
|
|
|
|
+static void form_paint_author(struct ngui *ui, struct ngui_rect box,
|
|
|
|
|
+ const struct br_style *st, int focused)
|
|
|
|
|
+{
|
|
|
|
|
+ int rtl = css_radius(st, 0, box.w, box.h);
|
|
|
|
|
+ int rtr = css_radius(st, 1, box.w, box.h);
|
|
|
|
|
+ int rbr = css_radius(st, 2, box.w, box.h);
|
|
|
|
|
+ int rbl = css_radius(st, 3, box.w, box.h);
|
|
|
|
|
+ int bw = st->border_t[0] ? 0 : st->border_w[0];
|
|
|
|
|
+
|
|
|
|
|
+ (void)focused;
|
|
|
|
|
+ if (box.w <= 0 || box.h <= 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ if (rtl || rtr || rbr || rbl) {
|
|
|
|
|
+ if (bw > 0 && st->has_bg && st->border_c[0] != st->bg &&
|
|
|
|
|
+ box.w > bw * 2 && box.h > bw * 2) {
|
|
|
|
|
+ struct ngui_rect in = { box.x + bw, box.y + bw,
|
|
|
|
|
+ box.w - bw * 2,
|
|
|
|
|
+ box.h - bw * 2 };
|
|
|
|
|
+
|
|
|
|
|
+ ngui_fill_round_rect(ui, box, rtl, rtr, rbr, rbl,
|
|
|
|
|
+ st->border_c[0]);
|
|
|
|
|
+ ngui_fill_round_rect(ui, in,
|
|
|
|
|
+ rtl > bw ? rtl - bw : 0,
|
|
|
|
|
+ rtr > bw ? rtr - bw : 0,
|
|
|
|
|
+ rbr > bw ? rbr - bw : 0,
|
|
|
|
|
+ rbl > bw ? rbl - bw : 0, st->bg);
|
|
|
|
|
+ } else if (st->has_bg) {
|
|
|
|
|
+ ngui_fill_round_rect(ui, box, rtl, rtr, rbr, rbl,
|
|
|
|
|
+ st->bg);
|
|
|
|
|
+ } else if (bw > 0) {
|
|
|
|
|
+ ngui_frame_round(ui, box, rtl, rtr, rbr, rbl, bw,
|
|
|
|
|
+ st->border_c[0]);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (st->has_bg)
|
|
|
|
|
+ ngui_fill_rect(ui, box, st->bg);
|
|
|
|
|
+ if (st->border_w[0] || st->border_w[1] || st->border_w[2] ||
|
|
|
|
|
+ st->border_w[3])
|
|
|
|
|
+ draw_border_box(ui, box, st);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* A poster wrapper is absolutely positioned over the media slot; the
|
|
/* A poster wrapper is absolutely positioned over the media slot; the
|
|
@@ -8342,8 +8495,12 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
css_size(st->max_width_kind, st->max_width, cbw);
|
|
css_size(st->max_width_kind, st->max_width, cbw);
|
|
|
int max_box = st->box_sizing ? mw : mw + deco_w;
|
|
int max_box = st->box_sizing ? mw : mw + deco_w;
|
|
|
|
|
|
|
|
- if (content_w + deco_w > max_box)
|
|
|
|
|
|
|
+ /* A clamped auto width is used as the width, so auto
|
|
|
|
|
+ * margins share the rest (Google's 688 px search box). */
|
|
|
|
|
+ if (content_w + deco_w > max_box) {
|
|
|
content_w = max_box - deco_w;
|
|
content_w = max_box - deco_w;
|
|
|
|
|
+ definite_w = 1;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (st->min_width_kind) {
|
|
if (st->min_width_kind) {
|
|
|
int mw = st->min_width_kind == 3 ?
|
|
int mw = st->min_width_kind == 3 ?
|
|
@@ -8963,11 +9120,14 @@ static unsigned int layout_float_group(struct lay *l, unsigned int first,
|
|
|
} else {
|
|
} else {
|
|
|
int base = row_right - row_left;
|
|
int base = row_right - row_left;
|
|
|
|
|
|
|
|
|
|
+ /* Shrink-to-fit outer width: borders too (Google's
|
|
|
|
|
+ * 1px-bordered "Anmelden" pill wrapped otherwise). */
|
|
|
colw = intrinsic_width(l->ui, n, &cs, 0, base) +
|
|
colw = intrinsic_width(l->ui, n, &cs, 0, base) +
|
|
|
mp_px(&cs, 7, base) +
|
|
mp_px(&cs, 7, base) +
|
|
|
mp_px(&cs, 5, base) +
|
|
mp_px(&cs, 5, base) +
|
|
|
mp_px(&cs, 3, base) +
|
|
mp_px(&cs, 3, base) +
|
|
|
- mp_px(&cs, 1, base);
|
|
|
|
|
|
|
+ mp_px(&cs, 1, base) +
|
|
|
|
|
+ cs.border_w[1] + cs.border_w[3];
|
|
|
if (colw < 8)
|
|
if (colw < 8)
|
|
|
colw = 8;
|
|
colw = 8;
|
|
|
}
|
|
}
|
|
@@ -9301,7 +9461,7 @@ static void layout_flex_children(struct lay *l, unsigned int parent,
|
|
|
int idx, row_top;
|
|
int idx, row_top;
|
|
|
unsigned char row_align = l->align;
|
|
unsigned char row_align = l->align;
|
|
|
|
|
|
|
|
- if (avail < 160 || depth > 48) {
|
|
|
|
|
|
|
+ if (avail < 8 || depth > 48) {
|
|
|
layout_children(l, parent, pst, depth, link);
|
|
layout_children(l, parent, pst, depth, link);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -9338,6 +9498,14 @@ static void layout_flex_children(struct lay *l, unsigned int parent,
|
|
|
fixed += flex_item_width(l, c, &cs, avail);
|
|
fixed += flex_item_width(l, c, &cs, avail);
|
|
|
nitem++;
|
|
nitem++;
|
|
|
}
|
|
}
|
|
|
|
|
+ /* A narrow container (an icon row sized to its content, Google's
|
|
|
|
|
+ * mic + lens buttons) is still a row when its items fit; only a
|
|
|
|
|
+ * narrow one that would overflow or squeeze growing items falls
|
|
|
|
|
+ * back to block flow. */
|
|
|
|
|
+ if (avail < 160 && (grow_count || fixed > avail)) {
|
|
|
|
|
+ layout_children(l, parent, pst, depth, link);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
grow_w = grow_count ? (avail - fixed) / grow_count : 0;
|
|
grow_w = grow_count ? (avail - fixed) / grow_count : 0;
|
|
|
if (grow_w < 96)
|
|
if (grow_w < 96)
|
|
|
grow_w = 96;
|
|
grow_w = 96;
|
|
@@ -9416,12 +9584,17 @@ static void layout_flex_children(struct lay *l, unsigned int parent,
|
|
|
br_style_for(&doc, node, pst, &cs);
|
|
br_style_for(&doc, node, pst, &cs);
|
|
|
cs.width_kind = 0;
|
|
cs.width_kind = 0;
|
|
|
cs.max_width_kind = 0;
|
|
cs.max_width_kind = 0;
|
|
|
- if (l->draw && pst->align_items &&
|
|
|
|
|
- row_h > block_h[node]) {
|
|
|
|
|
- if (pst->align_items == 1)
|
|
|
|
|
- yoff = (row_h - block_h[node]) / 2;
|
|
|
|
|
- else if (pst->align_items == 2)
|
|
|
|
|
- yoff = row_h - block_h[node];
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ int ai = cs.align_self ? cs.align_self - 1 :
|
|
|
|
|
+ pst->align_items;
|
|
|
|
|
+
|
|
|
|
|
+ if (l->draw && ai && row_h > block_h[node]) {
|
|
|
|
|
+ if (ai == 1)
|
|
|
|
|
+ yoff = (row_h -
|
|
|
|
|
+ block_h[node]) / 2;
|
|
|
|
|
+ else if (ai == 2)
|
|
|
|
|
+ yoff = row_h - block_h[node];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
l->left = x;
|
|
l->left = x;
|
|
|
l->right = x + it[start + k].w;
|
|
l->right = x + it[start + k].w;
|
|
@@ -11031,7 +11204,7 @@ static void draw_page(struct ngui_rect page)
|
|
|
|
|
|
|
|
static void draw_status(struct ngui_rect r)
|
|
static void draw_status(struct ngui_rect r)
|
|
|
{
|
|
{
|
|
|
- char msg[BR_URL_MAX + 32];
|
|
|
|
|
|
|
+ static char msg[BR_URL_MAX + 32]; /* leaf: off the 128 KB stack */
|
|
|
unsigned int n = 0;
|
|
unsigned int n = 0;
|
|
|
int hover = page_hover_node();
|
|
int hover = page_hover_node();
|
|
|
unsigned short color;
|
|
unsigned short color;
|