html and body both took the document's extent, which now includes html's
declared height, so `html { height: 100% }` gave an empty body the
viewport's height. Chrome and Firefox give it 0. body now takes its
content or its own declared height, and html keeps the extent. A
document without a body yet also counts html's declared height.
html and body took their height from their content only, so a page with
`html, body { height: 100% }` and nothing but a canvas reported a 5px
body. Compose for Web sizes its canvas from the body, and drew into a
1920x5 bitmap.
The document's extent now grows to a declared root height: html's
percentage is of the viewport, body's of html's declared height. It
only grows, so boxes laid out past a shorter declared height still fit.
canvas and video without a size are 300x150, as iframe already was, and
read their width and height attributes like img and iframe.
CSS parser now flags selectors that can never match (because we don't support
them, e.g something with a :hover). These can now optionally be discarded at
parse time.
Rework Selector so that it goes from 32 -> 24, and Segment goes from 24 -> 16.
This is the same type of optimization we do else where: a slice converted to
an explicit length and ptr.
The goal here isn't memory savings. It's shrinking them so that we can add to
them without making it bigger (follow up PR).
StyleManager currently unwraps simple :where(X) selectors, keeping the zero
specificity but bucketing on X. Anything more complicated ended up in .other.
Any :where that isn't a list (:where(a, b)) can actually be keyed by its
right-most compound without being unwrapped. Moving things out of .other is
always a win.
A list can't because it can match either. I explored splitting the list, so that
:where(a, b) creates two separate selector: :where(a) and :where(b), which
is exactly how we treat non-:where lists. But across a bunch of site, this is
an uncommon pattern.
Each evaluate wrote its page's whole lp object back to the session
store, dropping every key the page didn't have. With evaluates in
flight on several pages, the last to finish undid what the others
stored, and a second evaluate on the same page reset what the first had
written but not yet synced.
The postlude now reports only what the page changed since its last
sync, and the prelude carries the page's unsynced changes over the
fresh copy of the store.
The overlap test counts evaluates in flight instead of timing them.
We create 3285 version of this function (and growing), and everything it needs
to be non-generic can easily be supplied by the callers.
Hard to measure accurately, but this saves ~1sec of debug build time.
On pages that return _a lot_ of zig instances to v8, the arena-backed identity
map 'leaks' roughly half of it's memory (previous allocations). While most pages
don't typically hold that many objects, we've seen cases where they do,
typically related to DOMRect / intersection / boundingRects.
In our own performance scenarios, the identity map peaks at ~14MB, with roughly
half of that wasted.
I think there are more specific solutions we can pick for DOMRect and a few
similar types, but this is a simpler, more general quick memory win.
When canonical names were added (#2901), they were stored on the frame and thus
a clone had to dupe those values (as the clone might be another frame). At some
point, they became owned by the page, so the cloning is no longer needed.
How much this saves depends on how much cloning a site does. Over all of our
performance scenarios, this was the single biggest memory allocation that we
easily control (because those tests clone a lot).
1. The node registry is deferred until we're sure the node will make it into
the output. Looking at the HTML5 one page layout, that cuts the number of nodes
from 672k to 314k. Cutting tens of MB from peak memory
2. Dumps which go through SemanticTree can now skip node registration
altogether. A node_id counter is used to keep things working.
Adds support for em and rem units. Adds limited support for calc(...). Because
we can't store 2 relative terms (e.g. 100% - 2rem) without needing more memory,
we convert one of those units (rem) to pixels on read based on the
DEFAULT_FONT_SIZE.
If we ever add better (i.e. not just inline) support for font-size, this might
need to be revisited.
The rules inside an `@supports` block never reached the cascade:
StyleManager.addStoredRules had arms for `@media` and `@layer`, and
`@supports` fell into the catch-all. The block is already parsed into child
rules and css/supports.zig already evaluates a <supports-condition> for
CSS.supports(), so evaluate the prelude and, when it holds, add the children
where the block is, through the helper the other grouping rules use.
A bare declaration is not a condition in an at-rule prelude, so the rule
path skips the retry CSS.supports() does for one.
Closes#4705
The clock's finalizer left the element pointing at a freed task: an element
that outlived its frame (held by a parent's script) wrote through it on the
next seek. The finalizer now stops the clock and clears the pointer, and the
element's tasks run on its own frame's scheduler, not the caller's.
A source whose duration isn't read no longer changes networkState, nor
resets the element when its src changes: only an element with a timeline is
reset. A data: URL is only decoded when its type is a WAV one.
An element playing out its timeline pauses when it leaves its document.
currentTime and playbackRate reject non-finite values with a TypeError
instead of taking the NaN the bridge coerces them to, which sought to the end.
duration was always NaN, currentTime never advanced, ended and seeking were
hardcoded to false, and no metadata, timeupdate, seeking or ended event was
ever fired. Nothing is decoded or played, but a media clock is enough for a
page that drives its own player from these.
Resource selection reads the duration of the src attribute, or of the first
<source> child it can read: a WAV file in a data: URL, for now. The element
then fires the metadata events, currentTime follows the scheduler's clock at
playbackRate while it plays, a task fires timeupdate and runs the end-of-media
steps (loop, or pause + ended), and assigning currentTime seeks. A source
whose duration can't be read keeps the faked playback it had.
Closes#4702
startGoto bypasses call, so a bad argument rejected with a bare
"navigation failed". It now goes through the same prepareArgs pass as
startEvaluate and rejects with the diagnostic, before the receiver's
page is replaced.
page.evaluate blocked the script until the page-side promise settled,
so several requests only overlapped when batched inside one evaluate.
It now returns a promise, like page.goto. A page promise that is still
pending is left to the driver loop, which ticks every waiting page
together, so Promise.all over several evaluates overlaps their fetches
and timers. The evaluate tool itself still waits, for MCP and the
agent.
Breaking: a script that uses the result without await now gets a
promise. The recorder and the script guide emit await page.evaluate.
Scripts had no way to see the cookie jar: document.cookie through
page.evaluate hides HttpOnly cookies, and the getCookies tool was kept
off the page object because script methods were exactly the recorded
tools.
Tool.isScriptable() now decides what a page carries: the recorded tools
plus getCookies, which stays out of recordings. Called from a script it
returns an array of cookie objects in the --cookie-jar shape; the MCP
and agent tool keep their text lines.
The option's type is a bit set, a packed struct whose one field is
`mask`, so completion offered that. An option can now name its
`choices`, and --tools gives the tool names.
The help leads with "Can be passed multiple times", like the other
list options, and keeps the comma-separated form.