|
@@ -815,7 +815,8 @@ static void css_rgb(unsigned short c, char *buf, int cap)
|
|
|
snprintf(buf, cap, "rgb(%d, %d, %d)", r, g, b);
|
|
snprintf(buf, cap, "rgb(%d, %d, %d)", r, g, b);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void css_mp_value(char *buf, int cap, int raw, int unit, int px)
|
|
|
|
|
|
|
+static void css_mp_value(char *buf, int cap, int raw, int unit, int px,
|
|
|
|
|
+ int font_px)
|
|
|
{
|
|
{
|
|
|
if (unit == 4) {
|
|
if (unit == 4) {
|
|
|
snprintf(buf, cap, "auto");
|
|
snprintf(buf, cap, "auto");
|
|
@@ -824,9 +825,11 @@ static void css_mp_value(char *buf, int cap, int raw, int unit, int px)
|
|
|
} else if (unit == 1) {
|
|
} else if (unit == 1) {
|
|
|
snprintf(buf, cap, "%d.%02d%%", raw / 100, raw % 100);
|
|
snprintf(buf, cap, "%d.%02d%%", raw / 100, raw % 100);
|
|
|
} else if (unit == 2) {
|
|
} else if (unit == 2) {
|
|
|
- snprintf(buf, cap, "%d.%02dem", raw / 100, raw % 100);
|
|
|
|
|
|
|
+ /* Chrome's getComputedStyle() reports used pixel values. */
|
|
|
|
|
+ snprintf(buf, cap, "%dpx", font_px * raw / 100);
|
|
|
} else if (unit == 3) {
|
|
} else if (unit == 3) {
|
|
|
- snprintf(buf, cap, "%d.%02drem", raw / 100, raw % 100);
|
|
|
|
|
|
|
+ snprintf(buf, cap, "%dpx",
|
|
|
|
|
+ (int)br_root_font_px() * raw / 100);
|
|
|
} else {
|
|
} else {
|
|
|
snprintf(buf, cap, "calc(%d.%02d%% + %dpx)",
|
|
snprintf(buf, cap, "calc(%d.%02d%% + %dpx)",
|
|
|
raw / 100, raw % 100, px);
|
|
raw / 100, raw % 100, px);
|
|
@@ -985,7 +988,8 @@ static int js_host_computed(unsigned int node, const char *property,
|
|
|
side == 2 ? st.mb : side == 3 ? st.ml :
|
|
side == 2 ? st.mb : side == 3 ? st.ml :
|
|
|
side == 4 ? st.pt : side == 5 ? st.pr :
|
|
side == 4 ? st.pt : side == 5 ? st.pr :
|
|
|
side == 6 ? st.pb : st.pl,
|
|
side == 6 ? st.pb : st.pl,
|
|
|
- st.mp_unit[side], st.mp_calc_px[side]);
|
|
|
|
|
|
|
+ st.mp_unit[side], st.mp_calc_px[side],
|
|
|
|
|
+ st.font_px);
|
|
|
} else if (!strcmp(name, "border-top-width") ||
|
|
} else if (!strcmp(name, "border-top-width") ||
|
|
|
!strcmp(name, "border-right-width") ||
|
|
!strcmp(name, "border-right-width") ||
|
|
|
!strcmp(name, "border-bottom-width") ||
|
|
!strcmp(name, "border-bottom-width") ||
|
|
@@ -999,7 +1003,7 @@ static int js_host_computed(unsigned int node, const char *property,
|
|
|
!strcmp(name, "border-left-color")) {
|
|
!strcmp(name, "border-left-color")) {
|
|
|
int side = name[7] == 't' ? 0 : name[7] == 'r' ? 1 :
|
|
int side = name[7] == 't' ? 0 : name[7] == 'r' ? 1 :
|
|
|
name[7] == 'b' ? 2 : 3;
|
|
name[7] == 'b' ? 2 : 3;
|
|
|
- if (st.border_w[side])
|
|
|
|
|
|
|
+ if (st.border_w[side] && !st.border_t[side])
|
|
|
css_rgb(st.border_c[side], buf, cap);
|
|
css_rgb(st.border_c[side], buf, cap);
|
|
|
else
|
|
else
|
|
|
snprintf(buf, cap, "rgba(0, 0, 0, 0)");
|
|
snprintf(buf, cap, "rgba(0, 0, 0, 0)");
|
|
@@ -4125,22 +4129,22 @@ static void draw_border_box(struct ngui *ui, struct ngui_rect r,
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
for (i = 0; i < 4; i++)
|
|
|
- if (st->border_w[i]) {
|
|
|
|
|
|
|
+ if (st->border_w[i] && !st->border_t[i]) {
|
|
|
ngui_fill_rect(ui, r, st->border_c[i]);
|
|
ngui_fill_rect(ui, r, st->border_c[i]);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (top)
|
|
|
|
|
|
|
+ if (top && !st->border_t[0])
|
|
|
draw_border_side(ui, r.x, r.y, r.w, top, 1,
|
|
draw_border_side(ui, r.x, r.y, r.w, top, 1,
|
|
|
st->border_c[0], st->border_s[0]);
|
|
st->border_c[0], st->border_s[0]);
|
|
|
- if (bottom)
|
|
|
|
|
|
|
+ if (bottom && !st->border_t[2])
|
|
|
draw_border_side(ui, r.x, r.y + r.h - bottom, r.w, bottom, 1,
|
|
draw_border_side(ui, r.x, r.y + r.h - bottom, r.w, bottom, 1,
|
|
|
st->border_c[2], st->border_s[2]);
|
|
st->border_c[2], st->border_s[2]);
|
|
|
- if (left)
|
|
|
|
|
|
|
+ if (left && !st->border_t[3])
|
|
|
draw_border_side(ui, r.x, r.y + top, r.h - top - bottom,
|
|
draw_border_side(ui, r.x, r.y + top, r.h - top - bottom,
|
|
|
left, 0, st->border_c[3], st->border_s[3]);
|
|
left, 0, st->border_c[3], st->border_s[3]);
|
|
|
- if (right)
|
|
|
|
|
|
|
+ if (right && !st->border_t[1])
|
|
|
draw_border_side(ui, r.x + r.w - right, r.y + top,
|
|
draw_border_side(ui, r.x + r.w - right, r.y + top,
|
|
|
r.h - top - bottom, right, 0,
|
|
r.h - top - bottom, right, 0,
|
|
|
st->border_c[1], st->border_s[1]);
|
|
st->border_c[1], st->border_s[1]);
|
|
@@ -5672,7 +5676,10 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
int clip_pushed = 0;
|
|
int clip_pushed = 0;
|
|
|
struct ngui_rect clip_rect;
|
|
struct ngui_rect clip_rect;
|
|
|
|
|
|
|
|
- if (depth > 24 || st->display == BR_DISPLAY_NONE)
|
|
|
|
|
|
|
+ /* A DOM level costs about two depth units (layout_block ->
|
|
|
|
|
+ * layout_children), so 48 covers a ~24-level page. Real news pages
|
|
|
|
|
+ * nest a teaser 12+ levels deep; the old 24 skipped its text. */
|
|
|
|
|
+ if (depth > 48 || st->display == BR_DISPLAY_NONE)
|
|
|
return;
|
|
return;
|
|
|
flow_y = l->y;
|
|
flow_y = l->y;
|
|
|
flow_left = l->left;
|
|
flow_left = l->left;
|
|
@@ -5900,7 +5907,8 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
if (st->has_bg) {
|
|
if (st->has_bg) {
|
|
|
int bw = st->border_w[0];
|
|
int bw = st->border_w[0];
|
|
|
|
|
|
|
|
- if (bw > 0 && st->border_c[0] != st->bg &&
|
|
|
|
|
|
|
+ if (bw > 0 && !st->border_t[0] &&
|
|
|
|
|
+ st->border_c[0] != st->bg &&
|
|
|
box.w > bw * 2 && box.h > bw * 2) {
|
|
box.w > bw * 2 && box.h > bw * 2) {
|
|
|
struct ngui_rect inner = {
|
|
struct ngui_rect inner = {
|
|
|
box.x + bw, box.y + bw,
|
|
box.x + bw, box.y + bw,
|
|
@@ -5922,7 +5930,7 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
rtr, rbr, rbl,
|
|
rtr, rbr, rbl,
|
|
|
st->bg);
|
|
st->bg);
|
|
|
}
|
|
}
|
|
|
- } else if (st->border_w[0]) {
|
|
|
|
|
|
|
+ } else if (st->border_w[0] && !st->border_t[0]) {
|
|
|
ngui_frame_round(l->ui, box, rtl, rtr, rbr,
|
|
ngui_frame_round(l->ui, box, rtl, rtr, rbr,
|
|
|
rbl, st->border_w[0],
|
|
rbl, st->border_w[0],
|
|
|
st->border_c[0]);
|
|
st->border_c[0]);
|
|
@@ -6162,7 +6170,7 @@ static int intrinsic_width(struct ngui *ui, unsigned int node,
|
|
|
int line_w = 0, max_w = 0;
|
|
int line_w = 0, max_w = 0;
|
|
|
int flex_row = pst->display == BR_DISPLAY_FLEX && !pst->flex_col;
|
|
int flex_row = pst->display == BR_DISPLAY_FLEX && !pst->flex_col;
|
|
|
|
|
|
|
|
- if (depth > 12)
|
|
|
|
|
|
|
+ if (depth > 32)
|
|
|
return 0;
|
|
return 0;
|
|
|
for (c = doc.nodes[node].first; c; c = doc.nodes[c].next) {
|
|
for (c = doc.nodes[node].first; c; c = doc.nodes[c].next) {
|
|
|
struct br_node *nd = &doc.nodes[c];
|
|
struct br_node *nd = &doc.nodes[c];
|
|
@@ -6252,10 +6260,14 @@ static int intrinsic_width(struct ngui *ui, unsigned int node,
|
|
|
mp_px(&cs, 1, base) +
|
|
mp_px(&cs, 1, base) +
|
|
|
cs.border_w[1] + cs.border_w[3];
|
|
cs.border_w[1] + cs.border_w[3];
|
|
|
|
|
|
|
|
- if (cs.width_kind == 1)
|
|
|
|
|
- cw += cs.width;
|
|
|
|
|
- else if (cs.width_kind == 2 || cs.width_kind == 3)
|
|
|
|
|
- cw += style_width_px(&cs, base);
|
|
|
|
|
|
|
+ /* width/height do not apply to non-replaced inline
|
|
|
|
|
+ * boxes. The tagesschau home label is an inline span
|
|
|
|
|
+ * with width:1px for the mobile icon-only header; using
|
|
|
|
|
+ * that width made the whole subnav collapse to a
|
|
|
|
|
+ * one-character column. */
|
|
|
|
|
+ if (cs.width_kind && cs.display != BR_DISPLAY_INLINE)
|
|
|
|
|
+ cw += cs.width_kind == 1 ? cs.width :
|
|
|
|
|
+ style_width_px(&cs, base);
|
|
|
else
|
|
else
|
|
|
cw += intrinsic_width(ui, c, &cs, depth + 1,
|
|
cw += intrinsic_width(ui, c, &cs, depth + 1,
|
|
|
base);
|
|
base);
|
|
@@ -6586,7 +6598,7 @@ static void layout_flex_children(struct lay *l, unsigned int parent,
|
|
|
int avail = row_right - row_left;
|
|
int avail = row_right - row_left;
|
|
|
int idx, row_top;
|
|
int idx, row_top;
|
|
|
|
|
|
|
|
- if (avail < 160 || depth > 24) {
|
|
|
|
|
|
|
+ if (avail < 160 || depth > 48) {
|
|
|
layout_children(l, parent, pst, depth, link);
|
|
layout_children(l, parent, pst, depth, link);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -6771,7 +6783,7 @@ static void layout_grid_children(struct lay *l, unsigned int parent,
|
|
|
int row_y, row_bottom, have_left = 0, have_right = 0;
|
|
int row_y, row_bottom, have_left = 0, have_right = 0;
|
|
|
unsigned int c;
|
|
unsigned int c;
|
|
|
|
|
|
|
|
- if (avail < 32 || depth > 24)
|
|
|
|
|
|
|
+ if (avail < 32 || depth > 48)
|
|
|
return;
|
|
return;
|
|
|
if (track_total < 16)
|
|
if (track_total < 16)
|
|
|
track_total = 16;
|
|
track_total = 16;
|
|
@@ -6912,7 +6924,7 @@ static void layout_grid_auto(struct lay *l, unsigned int parent,
|
|
|
int minw = pst->width_kind == 1 ? pst->width : 200;
|
|
int minw = pst->width_kind == 1 ? pst->width : 200;
|
|
|
int ncols, colw, x, y = l->y, start_y = l->y, row_h = 0, col = 0;
|
|
int ncols, colw, x, y = l->y, start_y = l->y, row_h = 0, col = 0;
|
|
|
|
|
|
|
|
- if (avail < 32 || depth > 24) {
|
|
|
|
|
|
|
+ if (avail < 32 || depth > 48) {
|
|
|
layout_children(l, parent, pst, depth, link);
|
|
layout_children(l, parent, pst, depth, link);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -7361,7 +7373,7 @@ static void layout_table(struct lay *l, unsigned int table,
|
|
|
unsigned int r, c;
|
|
unsigned int r, c;
|
|
|
int i, rr, cc;
|
|
int i, rr, cc;
|
|
|
|
|
|
|
|
- if (depth > 24 || table_active) {
|
|
|
|
|
|
|
+ if (depth > 48 || table_active) {
|
|
|
layout_children(l, table, st, depth, link);
|
|
layout_children(l, table, st, depth, link);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -7695,7 +7707,7 @@ static void layout_children(struct lay *l, unsigned int parent,
|
|
|
{
|
|
{
|
|
|
unsigned int n;
|
|
unsigned int n;
|
|
|
|
|
|
|
|
- if (depth > 24)
|
|
|
|
|
|
|
+ if (depth > 48)
|
|
|
return;
|
|
return;
|
|
|
n = doc.nodes[parent].first;
|
|
n = doc.nodes[parent].first;
|
|
|
while (n) {
|
|
while (n) {
|
|
@@ -7821,7 +7833,14 @@ static void layout_children(struct lay *l, unsigned int parent,
|
|
|
n = layout_inline_blocks(l, n, pst, depth, link);
|
|
n = layout_inline_blocks(l, n, pst, depth, link);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if (cs.display == BR_DISPLAY_BLOCK || br_tag_is_block(nd->tag))
|
|
|
|
|
|
|
+ /* A flex container is block-level like any block box even when
|
|
|
|
|
+ * the element is an inline tag such as <a> (a link card with
|
|
|
|
|
+ * display:flex is common on news sites). Without the block box
|
|
|
|
|
+ * its children were laid out in the parent flow with a 0x0 box
|
|
|
|
|
+ * of their own. */
|
|
|
|
|
+ if (cs.display == BR_DISPLAY_BLOCK ||
|
|
|
|
|
+ cs.display == BR_DISPLAY_FLEX ||
|
|
|
|
|
+ br_tag_is_block(nd->tag))
|
|
|
layout_block(l, n, &cs, depth + 1, lk);
|
|
layout_block(l, n, &cs, depth + 1, lk);
|
|
|
else {
|
|
else {
|
|
|
layout_children(l, n, &cs, depth + 1, lk);
|
|
layout_children(l, n, &cs, depth + 1, lk);
|