فهرست منبع

Share one selector engine, add ::before/::after and speed up page scripts

The cascade, querySelector(All) and matches now use one selector engine:
attribute values (= ~= |= ^= $= *=, i flag), the + and ~ combinators
with backtracking, the nth-* pseudo-classes, :empty, :checked,
:disabled/:enabled, :required/:optional, :not/:is/:where with selector
lists and :has.  User-state pseudo-classes never match and their rules
are dropped at parse time.  The rule index no longer files li:not(.x)
under class x.

::before/::after generated text (strings, attr(), quotes) is cascaded as
an anonymous inline box by br_pseudo() and emitted as literal runs, so
scripts never see it (tagesschau's "| mehr").

Text offsets in nodes and layout runs are 32-bit: the text arena is
512 KB, so pages with more than 64 KB of text drew the wrong strings.

QuickJS is built -O1: on the Cloudron store it is faster than -Os and
-O2.  The status bar shows a per-phase load breakdown, and the store
loads in 2572 ms under TCG (was 3414).  Scripts get a 20 s budget and
an interrupted script still reports its error.

e1000: pin the 82540EM to legacy RX descriptors.  QEMU stores RFCTL, so
EXTEN read back set and RX was dead.
Johannes Zellner 1 هفته پیش
والد
کامیت
22a97523c0
9فایلهای تغییر یافته به همراه1213 افزوده شده و 626 حذف شده
  1. 33 9
      AGENTS.md
  2. 1 1
      Makefile
  3. 100 20
      browser.c
  4. 1047 589
      browser_html.c
  5. 17 1
      browser_html.h
  6. 1 1
      docs/network.html
  7. 0 2
      docs/userland.html
  8. 6 1
      e1000e.c
  9. 8 2
      js_browser.c

+ 33 - 9
AGENTS.md

@@ -584,7 +584,9 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   no BAR sizing so the ME/AMT cannot leave the BAR undecoded; skips the
   no BAR sizing so the ME/AMT cannot leave the BAR undecoded; skips the
   global MAC reset while the link is up, because the PCH/ME wedges on the
   global MAC reset while the link is up, because the PCH/ME wedges on the
   CTRL_RST access; extended RX descriptors only when `RFCTL.EXTEN` reads
   CTRL_RST access; extended RX descriptors only when `RFCTL.EXTEN` reads
-  back set, legacy write-back on the 82540EM, which has no RFCTL),
+  back set; the 82540EM (`0x100E`) is pinned to the legacy write-back
+  layout, because it has no RFCTL but QEMU stores the register, so EXTEN
+  reads back set while the device still writes legacy descriptors),
   `r8168.c`
   `r8168.c`
   RTL8111/8168 (PCIe, polled, C+ mode, 64-entry RX ring), `ne2000.c`
   RTL8111/8168 (PCIe, polled, C+ mode, 64-entry RX ring), `ne2000.c`
   RTL8029 (QEMU/ISA), `asix.c` AX88772 USB Ethernet (bulk over the USB
   RTL8029 (QEMU/ISA), `asix.c` AX88772 USB Ethernet (bulk over the USB
@@ -978,7 +980,18 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   parsing/resolution, redirects, chunked decoding, timeouts and TLS; curl,
   parsing/resolution, redirects, chunked decoding, timeouts and TLS; curl,
   the browser and chat use it.  `browser_html.c/h` is a tolerant HTML tree + the
   the browser and chat use it.  `browser_html.c/h` is a tolerant HTML tree + the
   CSS subset: external `<link rel=stylesheet>` sheets (in document order,
   CSS subset: external `<link rel=stylesheet>` sheets (in document order,
-  inline `<style>` last), tag/class/id and descendant/child selectors,
+  inline `<style>` last), one selector engine shared by the cascade,
+  `querySelector(All)` and `matches` (type/class/id, attribute presence and
+  `= ~= |= ^= $= *=` values with the `i` flag, descendant/`>`/`+`/`~`
+  combinators with backtracking, `:root`, `:link`, the `first/last/only`
+  child and of-type classes, `:nth-child`/`:nth-last-child`/`:nth-of-type`/
+  `:nth-last-of-type` (`an+b`, `odd`, `even`), `:empty`, `:checked`,
+  `:disabled`/`:enabled`, `:required`/`:optional`, `:not`/`:is`/`:where`
+  with selector lists, and `:has` with relative combinators; user-state
+  pseudo-classes such as `:hover` never match and their rules are dropped
+  at parse time), `::before`/`::after` generated text (`content` strings,
+  `attr()`, quotes; cascaded as an anonymous inline box per element by
+  `br_pseudo()` and emitted as literal runs, so scripts never see it),
   colours/`rgba()`, legacy `bgcolor` attributes, solid backgrounds and
   colours/`rgba()`, legacy `bgcolor` attributes, solid backgrounds and
   `background-image` with
   `background-image` with
   `repeat`/`position`/`size` (`auto` keeps the legacy stretch, `cover` and
   `repeat`/`position`/`size` (`auto` keeps the legacy stretch, `cover` and
@@ -1064,8 +1077,12 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   focus, so raw commands can acquire the NIC.  A page fetch that fails with a
   focus, so raw commands can acquire the NIC.  A page fetch that fails with a
   DNS error is torn down and tried once more after half a second.  The helper
   DNS error is torn down and tried once more after half a second.  The helper
   sends `Accept-Encoding: gzip`; the browser inflates with a
   sends `Accept-Encoding: gzip`; the browser inflates with a
-  progress hook that pumps the UI.  The status bar reports the page fetch
-  (headers and first-byte milliseconds).  Page, CSS and
+  progress hook that pumps the UI.  While loading, the status bar reports
+  the page fetch (headers and first-byte milliseconds); when the load is
+  done it shows `Loaded in N ms: page P (headers H), parse, css, paint, js`
+  for 12 s, the phase breakdown to read before optimizing a page.  QuickJS
+  is compiled `-O1` (`QJS_CFLAGS`): faster than `-Os` and `-O2` on the
+  store's scripts and ~170 KB smaller than `-O2`.  Page, CSS and
   image buffers come from the ring-3 libc heap; the DOM uses fixed static
   image buffers come from the ring-3 libc heap; the DOM uses fixed static
   arenas (6144 nodes, 512 KB attributes, 4608 rules), and page bodies are
   arenas (6144 nodes, 512 KB attributes, 4608 rules), and page bodies are
   capped at 2 MB with CSS sheets up to 832 KB (six sheets).  Each image gets
   capped at 2 MB with CSS sheets up to 832 KB (six sheets).  Each image gets
@@ -1128,7 +1145,7 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   dispatches a bubbling, cancelable `click` before the default action.
   dispatches a bubbling, cancelable `click` before the default action.
   A state is created after `heap_start()`, shared by the page's scripts and
   A state is created after `heap_start()`, shared by the page's scripts and
   freed before `heap_reset()`.  `js_setlimit()` gives every script, timer
   freed before `heap_reset()`.  `js_setlimit()` gives every script, timer
-  and event a 10 s wall-clock budget (QuickJS's interrupt handler), so a
+  and event a 20 s wall-clock budget (QuickJS's interrupt handler), so a
   runaway loop raises `InternalError: interrupted` instead of freezing the
   runaway loop raises `InternalError: interrupted` instead of freezing the
   browser; errors are reported as `Name: message` plus the stack.  Math, Date and JSON come from the engine plus the
   browser; errors are reported as `Name: message` plus the stack.  Math, Date and JSON come from the engine plus the
   libc math/time layers.  The parsed page is painted before scripts are
   libc math/time layers.  The parsed page is painted before scripts are
@@ -1868,8 +1885,12 @@ and the WM falls back to polling (`io_keyboard_irq_masked()`).
     and `enctype=multipart/form-data` plus file inputs are unsupported.
     and `enctype=multipart/form-data` plus file inputs are unsupported.
     Also missing: `type="module"`,
     Also missing: `type="module"`,
     `defer`/`async`, `MutationObserver`/`IntersectionObserver`,
     `defer`/`async`, `MutationObserver`/`IntersectionObserver`,
-    `XMLHttpRequest`/`fetch`, `DOMParser`, canvas/2D contexts and
-    pseudo-class/element selectors.  `getComputedStyle` returns the engine's
+    `XMLHttpRequest`/`fetch`, `DOMParser`, canvas/2D contexts, user-state
+    pseudo-classes (`:hover`, `:focus`, ...), `:nth-child(... of S)` and
+    pseudo-elements other than `::before`/`::after`; generated content is
+    text only (no box, background, counters or `url()` images, and
+    pseudo-elements inside flex/grid containers are not emitted).
+    `getComputedStyle` returns the engine's
     known properties (display, box metrics, colours, fonts, borders,
     known properties (display, box metrics, colours, fonts, borders,
     background and transform state), `outerHTML` returns only the string last
     background and transform state), `outerHTML` returns only the string last
     assigned to `innerHTML`, and `style`/`dataset` cover inline state rather
     assigned to `innerHTML`, and `style`/`dataset` cover inline state rather
@@ -1906,8 +1927,11 @@ and the WM falls back to polling (`io_keyboard_irq_masked()`).
     text following a float wraps beside it, `clear` advances past the active
     text following a float wraps beside it, `clear` advances past the active
     float, and a float without a width uses a text-width estimate.  `@media` width
     float, and a float without a width uses a text-width estimate.  `@media` width
     blocks are evaluated against the canvas width at page-parse time, so a
     blocks are evaluated against the canvas width at page-parse time, so a
-    window resize does not re-evaluate them until the next load, and
-    pseudo-classes are never matched.  `font-size` maps to real pixel sizes
+    window resize does not re-evaluate them until the next load.  An
+    absolutely positioned box placed by `bottom` without an explicit
+    height, or by a percentage `left` inside a nested positioned box, can
+    land at the wrong place (the store's navbar search box).  `font-size`
+    maps to real pixel sizes
     (8..48), `font-weight` selects the bold face, `font-style: italic`
     (8..48), `font-weight` selects the bold face, `font-style: italic`
     selects the italic face, `font-family: monospace` selects Liberation
     selects the italic face, `font-family: monospace` selects Liberation
     Mono, and nested `em`/`%` font sizes, `em`/`rem` widths, and
     Mono, and nested `em`/`%` font sizes, `em`/`rem` widths, and

+ 1 - 1
Makefile

@@ -37,7 +37,7 @@ LIBC_OBJS = libc/malloc.o libc/string.o libc/strdup.o \
 # JavaScript engine.  -nostdinc keeps host headers from leaking into the
 # JavaScript engine.  -nostdinc keeps host headers from leaking into the
 # freestanding build; __nebos__ selects the local patches.
 # freestanding build; __nebos__ selects the local patches.
 QJS_DIR    = third_party/quickjs
 QJS_DIR    = third_party/quickjs
-QJS_CFLAGS = $(CFLAGS) -Os $(SECTION_CFLAGS) -nostdinc -Ilibc/include \
+QJS_CFLAGS = $(CFLAGS) -O1 $(SECTION_CFLAGS) -nostdinc -Ilibc/include \
              -I$(QJS_DIR) -fno-builtin -w -D__nebos__ -U__linux__ \
              -I$(QJS_DIR) -fno-builtin -w -D__nebos__ -U__linux__ \
              -U__gnu_linux__ -U__unix__ -U__GLIBC__ -DNDEBUG \
              -U__gnu_linux__ -U__unix__ -U__GLIBC__ -DNDEBUG \
              -DCONFIG_VERSION='"2026-06-04"'
              -DCONFIG_VERSION='"2026-06-04"'

+ 100 - 20
browser.c

@@ -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

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1047 - 589
browser_html.c


+ 17 - 1
browser_html.h

@@ -16,6 +16,7 @@
 #define BR_FACE_FAMILY   40
 #define BR_FACE_FAMILY   40
 #define BR_FACE_URL      192
 #define BR_FACE_URL      192
 #define BR_MAX_VARS      512
 #define BR_MAX_VARS      512
+#define BR_MAX_CONTENT   512
 #define BR_TAG_MAX       128
 #define BR_TAG_MAX       128
 #define BR_RULE_HASH     256
 #define BR_RULE_HASH     256
 #define BR_DECLS         48
 #define BR_DECLS         48
@@ -196,6 +197,7 @@ struct br_style {
 	unsigned short fill, stroke;
 	unsigned short fill, stroke;
 	unsigned short stroke_w;
 	unsigned short stroke_w;
 	unsigned char inline_flex;  /* display:inline-flex (not inherited) */
 	unsigned char inline_flex;  /* display:inline-flex (not inherited) */
+	unsigned short content;     /* ::before/::after content: index + 1 */
 };
 };
 
 
 #define BR_PAINT_UNSET   0    /* fill: black, stroke: none */
 #define BR_PAINT_UNSET   0    /* fill: black, stroke: none */
@@ -213,7 +215,7 @@ struct br_node {
 	unsigned short first;
 	unsigned short first;
 	unsigned short last;
 	unsigned short last;
 	unsigned short next;
 	unsigned short next;
-	unsigned short text_off;    /* text arena offset (text nodes) */
+	unsigned int text_off;      /* text arena offset (text nodes) */
 	unsigned short text_len;
 	unsigned short text_len;
 	unsigned int href_off;
 	unsigned int href_off;
 	unsigned int class_off;
 	unsigned int class_off;
@@ -238,6 +240,7 @@ struct br_node {
 	unsigned char svg_rx;       /* inline SVG rect corner radius */
 	unsigned char svg_rx;       /* inline SVG rect corner radius */
 	struct br_style style;      /* computed-style cache */
 	struct br_style style;      /* computed-style cache */
 	unsigned char style_valid;
 	unsigned char style_valid;
+	unsigned char pe_state;     /* br_pseudo() cache: 1/4 checked, 2/8 has */
 };
 };
 
 
 struct br_decl {
 struct br_decl {
@@ -252,6 +255,7 @@ struct br_rule {
 	unsigned short spec;        /* selector specificity */
 	unsigned short spec;        /* selector specificity */
 	unsigned char nd;
 	unsigned char nd;
 	unsigned char single;       /* one compound, no ancestor walk needed */
 	unsigned char single;       /* one compound, no ancestor walk needed */
+	unsigned char pe;           /* 0 element, 1 ::before, 2 ::after */
 	struct br_decl d[BR_DECLS];
 	struct br_decl d[BR_DECLS];
 };
 };
 
 
@@ -288,6 +292,11 @@ struct br_doc {
 	unsigned short rule_bucket[BR_RULE_HASH];
 	unsigned short rule_bucket[BR_RULE_HASH];
 	unsigned short rule_tag[BR_TAG_MAX];
 	unsigned short rule_tag[BR_TAG_MAX];
 	unsigned short rule_any;
 	unsigned short rule_any;
+	/* ::before/::after content strings (attr arena offsets); attr(x) is
+	 * stored as \001x\002 and expanded per element. */
+	unsigned int content_off[BR_MAX_CONTENT];
+	unsigned short ncontent;
+	unsigned short npe_rules;
 	int truncated;
 	int truncated;
 	int plain;                  /* text/plain: one preformatted text node */
 	int plain;                  /* text/plain: one preformatted text node */
 	const char *script_src;     /* buffer the script offsets point into */
 	const char *script_src;     /* buffer the script offsets point into */
@@ -297,6 +306,13 @@ struct br_doc {
 };
 };
 
 
 void br_doc_init(struct br_doc *d);
 void br_doc_init(struct br_doc *d);
+/* ::before (pe 1) or ::after (pe 2) of an element: the pseudo-element's
+ * style (inheriting from the element's style `elem`) and its generated
+ * text.  Returns the text length; 0 when there is no content, or when the
+ * pseudo-element is display:none or absolutely positioned. */
+unsigned int br_pseudo(struct br_doc *d, unsigned int node, int pe,
+		       const struct br_style *elem, struct br_style *out,
+		       char *buf, unsigned int cap);
 void br_set_rule_store(struct br_doc *d, struct br_rule *buf,
 void br_set_rule_store(struct br_doc *d, struct br_rule *buf,
 		       unsigned int cap);
 		       unsigned int cap);
 int  br_parse(struct br_doc *d, const char *html, unsigned int len);
 int  br_parse(struct br_doc *d, const char *html, unsigned int len);

+ 1 - 1
docs/network.html

@@ -209,7 +209,7 @@
 					<tr><th>Driver</th><th>Hardware</th><th>Transport</th><th>Notes</th></tr>
 					<tr><th>Driver</th><th>Hardware</th><th>Transport</th><th>Notes</th></tr>
 				</thead>
 				</thead>
 				<tbody>
 				<tbody>
-					<tr><td><span class="file">e1000e.c</span></td><td>Intel 82540EM, 82577LM, 82578, 82579</td><td>PCI MMIO</td><td>PCI INTx disabled before MMIO; PCH D0; skips the global MAC reset while the link is up; extended RX descriptors only when <code>RFCTL.EXTEN</code> reads back set (the 82540EM has no RFCTL and writes legacy descriptors).</td></tr>
+					<tr><td><span class="file">e1000e.c</span></td><td>Intel 82540EM, 82577LM, 82578, 82579</td><td>PCI MMIO</td><td>PCI INTx disabled before MMIO; PCH D0; skips the global MAC reset while the link is up; extended RX descriptors only when <code>RFCTL.EXTEN</code> reads back set; the 82540EM (<code>0x100E</code>) is pinned to legacy descriptors, because it has no RFCTL but QEMU stores the register, so EXTEN reads back set.</td></tr>
 					<tr><td><span class="file">r8168.c</span></td><td>RTL8111/8168</td><td>PCIe MMIO</td><td>C+ mode, 64-entry RX ring, polled.</td></tr>
 					<tr><td><span class="file">r8168.c</span></td><td>RTL8111/8168</td><td>PCIe MMIO</td><td>C+ mode, 64-entry RX ring, polled.</td></tr>
 					<tr><td><span class="file">ne2000.c</span></td><td>RTL8029</td><td>ISA / QEMU PCI</td><td>Simple DP8390 path used by <code>make run-net</code>.</td></tr>
 					<tr><td><span class="file">ne2000.c</span></td><td>RTL8029</td><td>ISA / QEMU PCI</td><td>Simple DP8390 path used by <code>make run-net</code>.</td></tr>
 					<tr><td><span class="file">asix.c</span></td><td>AX88772</td><td>USB bulk</td><td>Runs over the USB core; usable on EHCI/xHCI dongles.</td></tr>
 					<tr><td><span class="file">asix.c</span></td><td>AX88772</td><td>USB bulk</td><td>Runs over the USB core; usable on EHCI/xHCI dongles.</td></tr>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 2
docs/userland.html


+ 6 - 1
e1000e.c

@@ -226,7 +226,7 @@ static unsigned char *rx_bufs;
 static unsigned char *tx_bufs;
 static unsigned char *tx_bufs;
 static unsigned int rx_cur;
 static unsigned int rx_cur;
 /* 1 when RFCTL.EXTEN stuck (PCH parts): status/error at offset 8, length
 /* 1 when RFCTL.EXTEN stuck (PCH parts): status/error at offset 8, length
- * at 12.  0 for MACs without RFCTL (QEMU's 82540EM reads it as zero):
+ * at 12.  0 for MACs without RFCTL (the 82540EM, whatever RFCTL reads):
  * legacy write-back, length at 8, status at 12, errors at 13. */
  * legacy write-back, length at 8, status at 12, errors at 13. */
 static int rx_ext;
 static int rx_ext;
 static unsigned int tx_cur;
 static unsigned int tx_cur;
@@ -1499,6 +1499,11 @@ static void rx_desc_config(void)
 	 * extended layout reads the frame length as status, so DD looks clear
 	 * extended layout reads the frame length as status, so DD looks clear
 	 * for every even-length frame and the ring stalls full. */
 	 * for every even-length frame and the ring stalls full. */
 	rx_ext = (r32(REG_RFCTL) & RFCTL_EXTEN) ? 1 : 0;
 	rx_ext = (r32(REG_RFCTL) & RFCTL_EXTEN) ? 1 : 0;
+	/* QEMU's e1000 stores RFCTL like any register, so EXTEN reads back
+	 * set, yet the emulated 82540EM still writes legacy descriptors.
+	 * The 82540EM never has extended RX descriptors. */
+	if (device_id == 0x100E)
+		rx_ext = 0;
 
 
 	/* No checksum offload: the stack verifies checksums, and the driver
 	/* No checksum offload: the stack verifies checksums, and the driver
 	 * rejects any descriptor whose error byte is non-zero.  With RXCSUM
 	 * rejects any descriptor whose error byte is non-zero.  With RXCSUM

+ 8 - 2
js_browser.c

@@ -16,8 +16,10 @@
 
 
 /* Wall-clock budget per script/handler/timer entry, in milliseconds.  It is
 /* Wall-clock budget per script/handler/timer entry, in milliseconds.  It is
  * reset before every entry; a runaway loop becomes a catchable
  * reset before every entry; a runaway loop becomes a catchable
- * "interrupted" exception instead of a frozen browser. */
-#define JS_RUN_LIMIT 10000
+ * "interrupted" exception instead of a frozen browser.  A framework
+ * bootstrap (AngularJS rendering ~300 cards) needs several seconds on a
+ * slow CPU, so the budget is generous. */
+#define JS_RUN_LIMIT 20000
 #define JS_TIMERS 16
 #define JS_TIMERS 16
 
 
 struct js_timer {
 struct js_timer {
@@ -2956,6 +2958,10 @@ static void report_top(js_State *state)
 {
 {
 	const char *msg;
 	const char *msg;
 
 
+	/* An "interrupted" error leaves the deadline expired: formatting the
+	 * error runs JavaScript (toString), which would be interrupted too. */
+	js_setlimit(state, 0, 0);
+
 	js_getproperty(state, -1, "stack");
 	js_getproperty(state, -1, "stack");
 	if (js_isstring(state, -1)) {
 	if (js_isstring(state, -1)) {
 		/* QuickJS's stack is only the frames: lead with
 		/* QuickJS's stack is only the frames: lead with

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است