|
@@ -4208,6 +4208,13 @@ static void emit_word(struct lay *l, const char *s, unsigned int start,
|
|
|
(unsigned short)n, st, href, 0);
|
|
(unsigned short)n, st, href, 0);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ /* A padded/bordered one-word button can be a few pixels wider than
|
|
|
|
|
+ * the content box; keep it on one line instead of splitting it. */
|
|
|
|
|
+ if (l->nruns == 0 && st->has_bg && w > avail && w <= avail + 8) {
|
|
|
|
|
+ add_run(l, (unsigned short)(base + start),
|
|
|
|
|
+ (unsigned short)n, st, href, 0);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (l->line_x + w > l->line_right &&
|
|
if (l->line_x + 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);
|
|
@@ -5185,7 +5192,7 @@ static int intrinsic_width(struct ngui *ui, unsigned int node,
|
|
|
const struct br_style *pst, int depth, int base)
|
|
const struct br_style *pst, int depth, int base)
|
|
|
{
|
|
{
|
|
|
unsigned int c;
|
|
unsigned int c;
|
|
|
- int w = 0;
|
|
|
|
|
|
|
+ int line_w = 0, max_w = 0;
|
|
|
|
|
|
|
|
if (depth > 12)
|
|
if (depth > 12)
|
|
|
return 0;
|
|
return 0;
|
|
@@ -5198,11 +5205,11 @@ static int intrinsic_width(struct ngui *ui, unsigned int node,
|
|
|
unsigned int tn = nd->text_len;
|
|
unsigned int tn = nd->text_len;
|
|
|
|
|
|
|
|
if (doc.nodes[node].tag == BR_TAG_PRE) {
|
|
if (doc.nodes[node].tag == BR_TAG_PRE) {
|
|
|
- w += (int)face_text_width(ui, pst, t, tn);
|
|
|
|
|
|
|
+ line_w += (int)face_text_width(ui, pst, t, tn);
|
|
|
} else {
|
|
} else {
|
|
|
unsigned int ti = 0;
|
|
unsigned int ti = 0;
|
|
|
int first = 1;
|
|
int first = 1;
|
|
|
- int lead = w > 0 && tn > 0 && text_space(t[0]);
|
|
|
|
|
|
|
+ int lead = line_w > 0 && tn > 0 && text_space(t[0]);
|
|
|
int sp = (int)face_text_width(ui, pst, " ", 1);
|
|
int sp = (int)face_text_width(ui, pst, " ", 1);
|
|
|
|
|
|
|
|
while (ti < tn) {
|
|
while (ti < tn) {
|
|
@@ -5216,9 +5223,9 @@ static int intrinsic_width(struct ngui *ui, unsigned int node,
|
|
|
if (ti == ts)
|
|
if (ti == ts)
|
|
|
break;
|
|
break;
|
|
|
if (!first || lead)
|
|
if (!first || lead)
|
|
|
- w += sp;
|
|
|
|
|
|
|
+ line_w += sp;
|
|
|
lead = 0;
|
|
lead = 0;
|
|
|
- w += (int)face_text_width(ui, pst,
|
|
|
|
|
|
|
+ line_w += (int)face_text_width(ui, pst,
|
|
|
t + ts, ti - ts);
|
|
t + ts, ti - ts);
|
|
|
first = 0;
|
|
first = 0;
|
|
|
}
|
|
}
|
|
@@ -5229,7 +5236,9 @@ static int intrinsic_width(struct ngui *ui, unsigned int node,
|
|
|
if (cs.display == BR_DISPLAY_NONE)
|
|
if (cs.display == BR_DISPLAY_NONE)
|
|
|
continue;
|
|
continue;
|
|
|
if (nd->tag == BR_TAG_BR) {
|
|
if (nd->tag == BR_TAG_BR) {
|
|
|
- w += 8;
|
|
|
|
|
|
|
+ if (line_w > max_w)
|
|
|
|
|
+ max_w = line_w;
|
|
|
|
|
+ line_w = 0;
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
if (nd->tag == BR_TAG_IMG) {
|
|
if (nd->tag == BR_TAG_IMG) {
|
|
@@ -5252,31 +5261,45 @@ static int intrinsic_width(struct ngui *ui, unsigned int node,
|
|
|
if (cs.width_kind) {
|
|
if (cs.width_kind) {
|
|
|
int ww = style_width_px(&cs, base);
|
|
int ww = style_width_px(&cs, base);
|
|
|
|
|
|
|
|
- w += ww > 0 ? ww : 64;
|
|
|
|
|
|
|
+ line_w += ww > 0 ? ww : 64;
|
|
|
} else if (nd->width_attr) {
|
|
} else if (nd->width_attr) {
|
|
|
- w += nd->width_attr;
|
|
|
|
|
|
|
+ line_w += nd->width_attr;
|
|
|
} else if (nd->height_attr && iw && ih) {
|
|
} else if (nd->height_attr && iw && ih) {
|
|
|
- w += iw * (int)nd->height_attr / ih;
|
|
|
|
|
|
|
+ line_w += iw * (int)nd->height_attr / ih;
|
|
|
} else if (cs.height_kind && iw && ih) {
|
|
} else if (cs.height_kind && iw && ih) {
|
|
|
int hh = style_height_px(&cs, base);
|
|
int hh = style_height_px(&cs, base);
|
|
|
|
|
|
|
|
- w += hh > 0 ? iw * hh / ih : iw;
|
|
|
|
|
|
|
+ line_w += hh > 0 ? iw * hh / ih : iw;
|
|
|
} else if (iw) {
|
|
} else if (iw) {
|
|
|
- w += iw;
|
|
|
|
|
|
|
+ line_w += iw;
|
|
|
} else {
|
|
} else {
|
|
|
- w += 64;
|
|
|
|
|
|
|
+ line_w += 64;
|
|
|
}
|
|
}
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- w += mp_px(&cs, 7, base) +
|
|
|
|
|
- mp_px(&cs, 5, base) +
|
|
|
|
|
- mp_px(&cs, 3, base) +
|
|
|
|
|
- mp_px(&cs, 1, base);
|
|
|
|
|
- w += intrinsic_width(ui, c, &cs, depth + 1, base);
|
|
|
|
|
- if (w > 4096)
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ int cw = mp_px(&cs, 7, base) +
|
|
|
|
|
+ mp_px(&cs, 5, base) +
|
|
|
|
|
+ mp_px(&cs, 3, base) +
|
|
|
|
|
+ mp_px(&cs, 1, base) +
|
|
|
|
|
+ cs.border_w[1] + cs.border_w[3] +
|
|
|
|
|
+ intrinsic_width(ui, c, &cs, depth + 1, base);
|
|
|
|
|
+
|
|
|
|
|
+ if (cs.float_left || cs.display == BR_DISPLAY_INLINE ||
|
|
|
|
|
+ cs.display == BR_DISPLAY_INLINE_BLOCK) {
|
|
|
|
|
+ line_w += cw;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (line_w > max_w)
|
|
|
|
|
+ max_w = line_w;
|
|
|
|
|
+ line_w = 0;
|
|
|
|
|
+ if (cw > max_w)
|
|
|
|
|
+ max_w = cw;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (line_w > 4096 || max_w > 4096)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- return w;
|
|
|
|
|
|
|
+ return line_w > max_w ? line_w : max_w;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Lay consecutive floated block children side by side. Bootstrap's grid is
|
|
/* Lay consecutive floated block children side by side. Bootstrap's grid is
|
|
@@ -5672,6 +5695,9 @@ static void layout_flex_children(struct lay *l, unsigned int parent,
|
|
|
} else if (pst->justify == 4) {
|
|
} else if (pst->justify == 4) {
|
|
|
extra = count ? free_w / count : 0;
|
|
extra = count ? free_w / count : 0;
|
|
|
x += extra / 2;
|
|
x += extra / 2;
|
|
|
|
|
+ } else if (pst->justify == 5) {
|
|
|
|
|
+ extra = count ? free_w / (count + 1) : 0;
|
|
|
|
|
+ x += extra;
|
|
|
}
|
|
}
|
|
|
for (k = 0; k < count; k++) {
|
|
for (k = 0; k < count; k++) {
|
|
|
int node = (int)it[start + k].node;
|
|
int node = (int)it[start + k].node;
|
|
@@ -6828,7 +6854,7 @@ static int measure_page(int left, int right)
|
|
|
layout_boxes[i].valid = 0;
|
|
layout_boxes[i].valid = 0;
|
|
|
}
|
|
}
|
|
|
l->draw = 0;
|
|
l->draw = 0;
|
|
|
- l->ui = 0;
|
|
|
|
|
|
|
+ l->ui = &ui;
|
|
|
l->left = left;
|
|
l->left = left;
|
|
|
l->right = right;
|
|
l->right = right;
|
|
|
l->y = 0;
|
|
l->y = 0;
|
|
@@ -7046,9 +7072,28 @@ static void draw_page(struct ngui_rect page)
|
|
|
int left, right, ch;
|
|
int left, right, ch;
|
|
|
int old_panel, old_dim;
|
|
int old_panel, old_dim;
|
|
|
unsigned short *saved_px;
|
|
unsigned short *saved_px;
|
|
|
|
|
+ unsigned short page_bg = ui.theme.bg;
|
|
|
int saved_w, saved_h, use_buf;
|
|
int saved_w, saved_h, use_buf;
|
|
|
|
|
|
|
|
page_rect = page;
|
|
page_rect = page;
|
|
|
|
|
+ {
|
|
|
|
|
+ unsigned int root = doc.nnode > 1 ?
|
|
|
|
|
+ br_find_tag(&doc, BR_TAG_HTML) : 0;
|
|
|
|
|
+ unsigned int body = doc.nnode > 1 ?
|
|
|
|
|
+ br_find_tag(&doc, BR_TAG_BODY) : 0;
|
|
|
|
|
+ struct br_style bs;
|
|
|
|
|
+
|
|
|
|
|
+ if (root) {
|
|
|
|
|
+ style_for_node(root - 1, &bs);
|
|
|
|
|
+ if (bs.has_bg)
|
|
|
|
|
+ page_bg = bs.bg;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (body) {
|
|
|
|
|
+ style_for_node(body - 1, &bs);
|
|
|
|
|
+ if (bs.has_bg)
|
|
|
|
|
+ page_bg = bs.bg;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (page_backbuf && pagebuf_w == ui.w && pagebuf_h == ui.h &&
|
|
if (page_backbuf && pagebuf_w == ui.w && pagebuf_h == ui.h &&
|
|
|
page_cache_valid && layout_valid &&
|
|
page_cache_valid && layout_valid &&
|
|
|
!ui.pressed && !(ui.buttons & 1) && !ui.released &&
|
|
!ui.pressed && !(ui.buttons & 1) && !ui.released &&
|
|
@@ -7059,7 +7104,7 @@ static void draw_page(struct ngui_rect page)
|
|
|
blit_page(page, page_backbuf, pagebuf_w);
|
|
blit_page(page, page_backbuf, pagebuf_w);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- ngui_fill_rect(&ui, page, ui.theme.bg);
|
|
|
|
|
|
|
+ ngui_fill_rect(&ui, page, page_bg);
|
|
|
if (!doc.nnode || (page_loading && doc.nnode <= 1)) {
|
|
if (!doc.nnode || (page_loading && doc.nnode <= 1)) {
|
|
|
const char *s = page_loading ? "Loading..." : "No page";
|
|
const char *s = page_loading ? "Loading..." : "No page";
|
|
|
int w = (int)ngui_text_width_ui(&ui, s);
|
|
int w = (int)ngui_text_width_ui(&ui, s);
|
|
@@ -7083,7 +7128,7 @@ static void draw_page(struct ngui_rect page)
|
|
|
ui.px = page_backbuf;
|
|
ui.px = page_backbuf;
|
|
|
ui.w = pagebuf_w;
|
|
ui.w = pagebuf_w;
|
|
|
ui.h = pagebuf_h;
|
|
ui.h = pagebuf_h;
|
|
|
- ngui_fill_rect(&ui, page, ui.theme.bg);
|
|
|
|
|
|
|
+ ngui_fill_rect(&ui, page, page_bg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
left = page.x + 8;
|
|
left = page.x + 8;
|