Skip to content

OS-DEV v1931 — stylesheets can lay out a page, virtual desktops, and the intermittent hang fixed

Latest

Choose a tag to compare

@milescoviello milescoviello released this 11 Sep 02:41
· 659 commits to main since this release

Three strands since v1916: the browser can finally be laid out by a stylesheet,
the desktop got virtual desktops and the keyboard chords people actually press,
and a code review of that work found ten defects worth fixing.

The browser can be laid out by a stylesheet (M1928-M1931)

Found by pointing the browser at real sites and looking at the result rather
than guessing which CSS feature to add next. One screenshot of example.com
exposed three separate gaps:

  • The CSS cascade carried no box geometry at all. The rule table stored
    colour, background, align, border and the rest — but no width, margins,
    padding or height, and all of those came only from an inline style=
    attribute. So a stylesheet could not lay out a page, which is how essentially
    every real page is built.
  • No viewport units. vw/vh were unparsed, so width:60vw was discarded.
  • <body> can never own a box. It is consumed by a terminal branch in the
    tag parser. It does not need one — body's box is the page's content column.

example.com now renders as the centred column its stylesheet asks for.

Also float and clear (M1928). browser.c's own comment listed float with
position and z-index as needing out-of-flow boxes; that was wrong for float.
A floated image is just an obstacle: record the vertical band it occupies and
have every line box consult it for a left/right inset — that inset is text wrap.
And a display:flex <li> no longer draws a bullet (M1931), because
display is one property and flex replaces list-item — danluu.com relies on it.

Verified by screenshot: danluu.com (22 KB of real HTML) and a full article render
close to a real browser, and text.npr.org shows live headlines as working links.

Desktop (M1920-M1925)

The features mostly already existed but were bound to keys nobody presses —
Alt+Tab, Alt+F4, Super and Super+Arrow all did nothing. They work now, including
on a USB keyboard, where none of them worked at all (the raw scancode queue
was fed only by the PS/2 handler — invisible under QEMU, and only ever visible on
real hardware). Plus 4 virtual desktops with Ctrl+Alt+Arrow and Super+1..4,
and the desktop finally has automated tests.

Ten defects from reviewing that work (M1926)

Including a type-confused write (a stale window pointer after a chord
reordered the window array handed a browser_t* to a raw-keyboard app) and a
use-after-free (the switcher's index was never clamped when a background app
exited). Also: every new chord fired twice, and kvprintf held interrupts off
for ~7 ms per line on real hardware.

Earlier in this line

v1916's scheduler fix (sub-millisecond yields charged zero vruntime, starving
lock holders) remains the single most important change — it was the root cause of
years of "intermittent" hangs.

make check is green: 131 suites.

Try it

Download os-dev-tryit.zip, unzip, and see RUN_ME.md — one QEMU command.