|
@@ -181,7 +181,8 @@ static int layout_content_h;
|
|
|
|
|
|
|
|
/* layout output */
|
|
/* layout output */
|
|
|
struct lay_run {
|
|
struct lay_run {
|
|
|
- unsigned short off, len;
|
|
|
|
|
|
|
+ unsigned int off;
|
|
|
|
|
+ unsigned short len;
|
|
|
unsigned short gap;
|
|
unsigned short gap;
|
|
|
unsigned short color;
|
|
unsigned short color;
|
|
|
unsigned short href;
|
|
unsigned short href;
|
|
@@ -3649,6 +3650,9 @@ static void load_page(const char *url, int local, int push)
|
|
|
const char *post = pending_post_len ? pending_post : 0;
|
|
const char *post = pending_post_len ? pending_post : 0;
|
|
|
unsigned int post_len = pending_post_len;
|
|
unsigned int post_len = pending_post_len;
|
|
|
unsigned int page_open_ms = 0, page_first_ms = 0, page_total_ms = 0;
|
|
unsigned int page_open_ms = 0, page_first_ms = 0, page_total_ms = 0;
|
|
|
|
|
+ /* Phase timings for the status line: where a slow load spends it. */
|
|
|
|
|
+ unsigned int t_start = u_ticks_ms(), t_fetch = 0, t_parse = 0;
|
|
|
|
|
+ unsigned int t_css = 0, t_paint = 0, t_js = 0, t_mark;
|
|
|
int upgraded = nav_https_upgraded;
|
|
int upgraded = nav_https_upgraded;
|
|
|
int retried = 0;
|
|
int retried = 0;
|
|
|
int rv;
|
|
int rv;
|
|
@@ -3712,6 +3716,7 @@ static void load_page(const char *url, int local, int push)
|
|
|
}
|
|
}
|
|
|
if (rv == FETCH_ABORT)
|
|
if (rv == FETCH_ABORT)
|
|
|
return;
|
|
return;
|
|
|
|
|
+ t_fetch = u_ticks_ms() - t_start;
|
|
|
/* Capture the page timing before CSS/script/image fetches overwrite the
|
|
/* Capture the page timing before CSS/script/image fetches overwrite the
|
|
|
* shared fetch_meta block. */
|
|
* shared fetch_meta block. */
|
|
|
if (rv == 0 && !local) {
|
|
if (rv == 0 && !local) {
|
|
@@ -3765,11 +3770,15 @@ static void load_page(const char *url, int local, int push)
|
|
|
s_copy(page_title, "Image", sizeof(page_title));
|
|
s_copy(page_title, "Image", sizeof(page_title));
|
|
|
} else {
|
|
} else {
|
|
|
br_set_viewport(ui.w);
|
|
br_set_viewport(ui.w);
|
|
|
|
|
+ t_mark = u_ticks_ms();
|
|
|
br_parse(&doc, (const char *)body, len);
|
|
br_parse(&doc, (const char *)body, len);
|
|
|
|
|
+ t_parse = u_ticks_ms() - t_mark;
|
|
|
s_copy(page_title, doc.title[0] ? doc.title : page_url,
|
|
s_copy(page_title, doc.title[0] ? doc.title : page_url,
|
|
|
sizeof(page_title));
|
|
sizeof(page_title));
|
|
|
|
|
+ t_mark = u_ticks_ms();
|
|
|
if (load_stylesheets() == FETCH_ABORT)
|
|
if (load_stylesheets() == FETCH_ABORT)
|
|
|
return;
|
|
return;
|
|
|
|
|
+ t_css = u_ticks_ms() - t_mark;
|
|
|
if (pending_action)
|
|
if (pending_action)
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -3785,14 +3794,18 @@ static void load_page(const char *url, int local, int push)
|
|
|
* remote <script src> then does not hide the page behind the loading
|
|
* remote <script src> then does not hide the page behind the loading
|
|
|
* screen; the fetch helper pumps this UI while it waits. */
|
|
* screen; the fetch helper pumps this UI while it waits. */
|
|
|
set_status("Loading scripts...", 0, 0);
|
|
set_status("Loading scripts...", 0, 0);
|
|
|
|
|
+ t_mark = u_ticks_ms();
|
|
|
redraw_now();
|
|
redraw_now();
|
|
|
|
|
+ t_paint = u_ticks_ms() - t_mark;
|
|
|
/* Start one image download before the scripts. The other workers
|
|
/* Start one image download before the scripts. The other workers
|
|
|
* fetch the external script bodies in parallel, and the remaining
|
|
* fetch the external script bodies in parallel, and the remaining
|
|
|
* images start as soon as the script phase ends. */
|
|
* images start as soon as the script phase ends. */
|
|
|
preload_max_jobs = 1;
|
|
preload_max_jobs = 1;
|
|
|
preload_fill_jobs();
|
|
preload_fill_jobs();
|
|
|
preload_wait = 0;
|
|
preload_wait = 0;
|
|
|
|
|
+ t_mark = u_ticks_ms();
|
|
|
run_page_scripts();
|
|
run_page_scripts();
|
|
|
|
|
+ t_js = u_ticks_ms() - t_mark;
|
|
|
preload_max_jobs = FETCH_WORKERS;
|
|
preload_max_jobs = FETCH_WORKERS;
|
|
|
if (pending_action)
|
|
if (pending_action)
|
|
|
return;
|
|
return;
|
|
@@ -3814,32 +3827,44 @@ static void load_page(const char *url, int local, int push)
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
|
post_status_ttl = 6000;
|
|
post_status_ttl = 6000;
|
|
|
} else if (page_total_ms) {
|
|
} else if (page_total_ms) {
|
|
|
|
|
+ /* "Loaded in 2410 ms: page 84 (headers 69), parse 40, css 310,
|
|
|
|
|
+ * paint 220, js 1750" -- the phases of this load. */
|
|
|
unsigned int n = 0;
|
|
unsigned int n = 0;
|
|
|
-
|
|
|
|
|
|
|
+ static const char *const names[] = {
|
|
|
|
|
+ ", parse ", ", css ", ", paint ", ", js "
|
|
|
|
|
+ };
|
|
|
|
|
+ unsigned int vals[4];
|
|
|
|
|
+ int k;
|
|
|
|
|
+
|
|
|
|
|
+ vals[0] = t_parse;
|
|
|
|
|
+ vals[1] = t_css;
|
|
|
|
|
+ vals[2] = t_paint;
|
|
|
|
|
+ vals[3] = t_js;
|
|
|
|
|
+ (void)page_first_ms;
|
|
|
if (starts_with(page_url, "https://"))
|
|
if (starts_with(page_url, "https://"))
|
|
|
s_append(post_status_text, &n,
|
|
s_append(post_status_text, &n,
|
|
|
"HTTPS (not verified), ",
|
|
"HTTPS (not verified), ",
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
|
- else
|
|
|
|
|
- s_append(post_status_text, &n, "Loaded in ",
|
|
|
|
|
- sizeof(post_status_text));
|
|
|
|
|
- s_append_dec(post_status_text, &n, page_total_ms,
|
|
|
|
|
|
|
+ s_append(post_status_text, &n, "Loaded in ",
|
|
|
|
|
+ sizeof(post_status_text));
|
|
|
|
|
+ s_append_dec(post_status_text, &n, u_ticks_ms() - t_start,
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
|
- s_append(post_status_text, &n, " ms (headers ",
|
|
|
|
|
|
|
+ s_append(post_status_text, &n, " ms: page ",
|
|
|
|
|
+ sizeof(post_status_text));
|
|
|
|
|
+ s_append_dec(post_status_text, &n, t_fetch,
|
|
|
|
|
+ sizeof(post_status_text));
|
|
|
|
|
+ s_append(post_status_text, &n, " (headers ",
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
|
s_append_dec(post_status_text, &n, page_open_ms,
|
|
s_append_dec(post_status_text, &n, page_open_ms,
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
|
- s_append(post_status_text, &n, " ms", sizeof(post_status_text));
|
|
|
|
|
- if (page_first_ms) {
|
|
|
|
|
- s_append(post_status_text, &n, ", first byte ",
|
|
|
|
|
|
|
+ s_append(post_status_text, &n, ")", sizeof(post_status_text));
|
|
|
|
|
+ for (k = 0; k < 4; k++) {
|
|
|
|
|
+ s_append(post_status_text, &n, names[k],
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
|
- s_append_dec(post_status_text, &n, page_first_ms,
|
|
|
|
|
|
|
+ s_append_dec(post_status_text, &n, vals[k],
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
|
- s_append(post_status_text, &n, " ms",
|
|
|
|
|
- sizeof(post_status_text));
|
|
|
|
|
}
|
|
}
|
|
|
- s_append(post_status_text, &n, ")", sizeof(post_status_text));
|
|
|
|
|
- post_status_ttl = 6000;
|
|
|
|
|
|
|
+ post_status_ttl = 12000;
|
|
|
} else if (starts_with(page_url, "https://")) {
|
|
} else if (starts_with(page_url, "https://")) {
|
|
|
s_copy(post_status_text, "HTTPS: certificate NOT verified",
|
|
s_copy(post_status_text, "HTTPS: certificate NOT verified",
|
|
|
sizeof(post_status_text));
|
|
sizeof(post_status_text));
|
|
@@ -4873,7 +4898,7 @@ static void flush_line(struct lay *l)
|
|
|
l->space_pending = 0;
|
|
l->space_pending = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void add_run(struct lay *l, unsigned short off, unsigned short len,
|
|
|
|
|
|
|
+static void add_run(struct lay *l, unsigned int off, unsigned short len,
|
|
|
const struct br_style *st, unsigned short href,
|
|
const struct br_style *st, unsigned short href,
|
|
|
const char *lit)
|
|
const char *lit)
|
|
|
{
|
|
{
|
|
@@ -5182,14 +5207,14 @@ static void emit_word(struct lay *l, const char *s, unsigned int start,
|
|
|
avail = l->line_right - l->line_left;
|
|
avail = l->line_right - l->line_left;
|
|
|
if (st->nowrap) {
|
|
if (st->nowrap) {
|
|
|
if (n)
|
|
if (n)
|
|
|
- add_run(l, (unsigned short)(base + start),
|
|
|
|
|
|
|
+ add_run(l, base + 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
|
|
/* 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. */
|
|
* the content box; keep it on one line instead of splitting it. */
|
|
|
if (l->nruns == 0 && st->has_bg && w > avail && w <= avail + 8) {
|
|
if (l->nruns == 0 && st->has_bg && w > avail && w <= avail + 8) {
|
|
|
- add_run(l, (unsigned short)(base + start),
|
|
|
|
|
|
|
+ add_run(l, base + start,
|
|
|
(unsigned short)n, st, href, 0);
|
|
(unsigned short)n, st, href, 0);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -5201,14 +5226,14 @@ static void emit_word(struct lay *l, const char *s, unsigned int start,
|
|
|
}
|
|
}
|
|
|
if (w <= avail) {
|
|
if (w <= avail) {
|
|
|
if (n)
|
|
if (n)
|
|
|
- add_run(l, (unsigned short)(base + start),
|
|
|
|
|
|
|
+ add_run(l, base + start,
|
|
|
(unsigned short)n, st, href, 0);
|
|
(unsigned short)n, st, href, 0);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
while (n > 0) {
|
|
while (n > 0) {
|
|
|
unsigned int take = fit_prefix(l, s + off, n, st, avail);
|
|
unsigned int take = fit_prefix(l, s + off, n, st, avail);
|
|
|
|
|
|
|
|
- add_run(l, (unsigned short)(base + off),
|
|
|
|
|
|
|
+ add_run(l, base + off,
|
|
|
(unsigned short)take, st, href, 0);
|
|
(unsigned short)take, st, href, 0);
|
|
|
off += take;
|
|
off += take;
|
|
|
n -= take;
|
|
n -= take;
|
|
@@ -8380,6 +8405,59 @@ struct br_deferred {
|
|
|
static struct br_deferred deferred[BR_MAX_DEFERRED];
|
|
static struct br_deferred deferred[BR_MAX_DEFERRED];
|
|
|
static int ndeferred;
|
|
static int ndeferred;
|
|
|
|
|
|
|
|
|
|
+/* ::before/::after generated text (br_pseudo()) as literal runs in the
|
|
|
|
|
+ * element's line. A block-level pseudo-element gets its own line; its box
|
|
|
|
|
+ * (margins, padding, background) is not drawn. */
|
|
|
|
|
+static void emit_pseudo(struct lay *l, unsigned int node,
|
|
|
|
|
+ const struct br_style *st, int pe, unsigned short link)
|
|
|
|
|
+{
|
|
|
|
|
+ char buf[160];
|
|
|
|
|
+ struct br_style ps;
|
|
|
|
|
+ unsigned int n = br_pseudo(&doc, node, pe, st, &ps, buf, sizeof(buf));
|
|
|
|
|
+ unsigned int i = 0;
|
|
|
|
|
+ int block, space_w;
|
|
|
|
|
+
|
|
|
|
|
+ if (!n)
|
|
|
|
|
+ return;
|
|
|
|
|
+ block = ps.display == BR_DISPLAY_BLOCK || ps.display == BR_DISPLAY_FLEX;
|
|
|
|
|
+ if (block)
|
|
|
|
|
+ flush_line(l);
|
|
|
|
|
+ if (ps.uppercase)
|
|
|
|
|
+ for (i = 0; i < n; i++)
|
|
|
|
|
+ if (buf[i] >= 'a' && buf[i] <= 'z')
|
|
|
|
|
+ buf[i] = (char)(buf[i] - 'a' + 'A');
|
|
|
|
|
+ space_w = (int)face_text_width(l->ui, &ps, " ", 1);
|
|
|
|
|
+ if (space_w <= 0)
|
|
|
|
|
+ space_w = 8;
|
|
|
|
|
+ i = 0;
|
|
|
|
|
+ while (i < n) {
|
|
|
|
|
+ char word[28];
|
|
|
|
|
+ unsigned int k = 0;
|
|
|
|
|
+ int w;
|
|
|
|
|
+
|
|
|
|
|
+ if (buf[i] == ' ') {
|
|
|
|
|
+ l->space_pending = 1;
|
|
|
|
|
+ i++;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ while (i < n && buf[i] != ' ' && k + 1 < sizeof(word))
|
|
|
|
|
+ word[k++] = buf[i++];
|
|
|
|
|
+ word[k] = '\0';
|
|
|
|
|
+ if (l->space_pending &&
|
|
|
|
|
+ (l->nruns > 0 || l->line_x > l->line_left) &&
|
|
|
|
|
+ l->line_x + space_w <= l->line_right)
|
|
|
|
|
+ l->line_x += space_w;
|
|
|
|
|
+ l->space_pending = 0;
|
|
|
|
|
+ w = (int)face_text_width(l->ui, &ps, word, k);
|
|
|
|
|
+ if (l->line_x + w > l->line_right &&
|
|
|
|
|
+ (l->nruns > 0 || l->line_x > l->line_left))
|
|
|
|
|
+ flush_line(l);
|
|
|
|
|
+ add_run(l, 0, 0, &ps, link, word);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (block)
|
|
|
|
|
+ flush_line(l);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void layout_children(struct lay *l, unsigned int parent,
|
|
static void layout_children(struct lay *l, unsigned int parent,
|
|
|
const struct br_style *pst, int depth,
|
|
const struct br_style *pst, int depth,
|
|
|
unsigned short link)
|
|
unsigned short link)
|
|
@@ -8388,6 +8466,7 @@ static void layout_children(struct lay *l, unsigned int parent,
|
|
|
|
|
|
|
|
if (depth > 48)
|
|
if (depth > 48)
|
|
|
return;
|
|
return;
|
|
|
|
|
+ emit_pseudo(l, parent, pst, 1, link);
|
|
|
n = doc.nodes[parent].first;
|
|
n = doc.nodes[parent].first;
|
|
|
while (n) {
|
|
while (n) {
|
|
|
struct br_node *nd = &doc.nodes[n];
|
|
struct br_node *nd = &doc.nodes[n];
|
|
@@ -8547,6 +8626,7 @@ static void layout_children(struct lay *l, unsigned int parent,
|
|
|
}
|
|
}
|
|
|
n = nd->next;
|
|
n = nd->next;
|
|
|
}
|
|
}
|
|
|
|
|
+ emit_pseudo(l, parent, pst, 2, link);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* One layout state, kept out of the 8 KB user stack: it holds 96 line
|
|
/* One layout state, kept out of the 8 KB user stack: it holds 96 line
|