|
|
@@ -10186,6 +10186,20 @@ static void alpha_end(struct ngui_rect r, struct ngui_rect box, int a)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/* A table centred by legacy markup: a <center> parent or align="center".
|
|
|
+ * CSS text-align on the parent does not centre a block table, as in
|
|
|
+ * browsers. */
|
|
|
+static int table_centered(unsigned int node)
|
|
|
+{
|
|
|
+ const char *al = br_find_attr(&doc, node, "align");
|
|
|
+ unsigned int p = doc.nodes[node].parent;
|
|
|
+
|
|
|
+ if (al && (al[0] == 'c' || al[0] == 'C'))
|
|
|
+ return 1;
|
|
|
+ return p < doc.nnode && doc.nodes[p].type == BR_NODE_ELEM &&
|
|
|
+ doc.nodes[p].tag == BR_TAG_CENTER;
|
|
|
+}
|
|
|
+
|
|
|
static void layout_block(struct lay *l, unsigned int node,
|
|
|
const struct br_style *st, int depth,
|
|
|
unsigned short link)
|
|
|
@@ -10457,6 +10471,12 @@ static void layout_block(struct lay *l, unsigned int node,
|
|
|
ml = free_w;
|
|
|
} else if (st->mr_auto) {
|
|
|
mr = free_w;
|
|
|
+ } else if (doc.nodes[node].tag == BR_TAG_TABLE &&
|
|
|
+ table_centered(node)) {
|
|
|
+ /* <center><table width=85%> (Hacker News) and
|
|
|
+ * <table align=center> centre the table box. */
|
|
|
+ ml = free_w / 2;
|
|
|
+ mr = free_w - ml;
|
|
|
}
|
|
|
}
|
|
|
if (doc.nodes[node].tag == BR_TAG_IMG) {
|
|
|
@@ -14101,14 +14121,16 @@ static void draw_page(struct ngui_rect page)
|
|
|
* (Infima's light theme: `--ifm-background-color:
|
|
|
* transparent` on html, #1c1e21 text): the page expects the
|
|
|
* white canvas of a normal browser, and dark text on the
|
|
|
- * dark default canvas is unreadable. */
|
|
|
+ * dark default canvas is unreadable. Mid-grey counts too:
|
|
|
+ * Hacker News sets #828282 body text on a white page;
|
|
|
+ * text meant for a dark background is light (> ~200). */
|
|
|
if (!bg_found && (body || root) && bs.color != ui.theme.text) {
|
|
|
unsigned int c = bs.color;
|
|
|
unsigned int lum = ((c >> 11) & 31) * 8 * 299 +
|
|
|
((c >> 5) & 63) * 4 * 587 +
|
|
|
(c & 31) * 8 * 114;
|
|
|
|
|
|
- if (lum < 100 * 1000)
|
|
|
+ if (lum < 150 * 1000)
|
|
|
page_bg = 0xFFFF;
|
|
|
}
|
|
|
}
|