Commit graph

25 commits

Author SHA1 Message Date
Sam Atkins
ddb4bdadd7 LibDevTools: Populate DevTools Web Storage
Firefox exposes localStorage and sessionStorage through the same
storage actor protocol used by cookies. Add matching resources for the
current tab so the Storage panel can list key/value pairs.

Read the values through WebContent rather than directly from the
browser process. Session storage lives in LibWeb, and using the same
path for both stores keeps the actor independent of the backing store.
2026-06-11 16:08:33 +01:00
Sam Atkins
aa4139d002 LibDevTools: Allow adding and removing DevTools cookies
Firefox enables the Storage panel cookie toolbar from the storage traits
and calls addItem, removeItem, removeAll, or removeAllSessionCookies
for the selected host.

Advertise those operations and route them through the existing cookie
mutation delegate. Deletions reuse the visible storage host matching so
bulk actions stay scoped to the cookie tree item Firefox selected.
2026-06-11 15:03:47 +01:00
Sam Atkins
4113968e77 LibDevTools: Allow editing DevTools cookies
Firefox sends editItem when a cookie table cell is changed. Handle
that request by locating the original cookie, applying the edited
field, and forwarding the replacement through the delegate mutation
hook.

Return Firefox-style errorString values so invalid edits can be
rejected without changing the table contents.
2026-06-11 15:03:47 +01:00
Sam Atkins
47204bd3dd LibDevTools: Report cookie storage changes
Firefox keeps the Storage table current through storesUpdate messages
from the storage actor. Forward browser cookie change notifications to
the cookies actor and classify visible rows against a fresh cookie
snapshot.

The existing cookie-change notifications report cookies that are
relevant to a specific page, whereas DevTools wants all cookies
relevant for a host, so we end up having to provide two different sets
of cookies to `notify_cookies_changed()`.
2026-06-11 15:03:47 +01:00
Sam Atkins
20f922cbdb LibWebView+LibDevTools: Populate DevTools cookies
Firefox asks the cookies actor for rows after selecting a Storage host.
Read the browser cookie jar through the DevTools delegate and serialize
matching cookies with the fields Firefox expects.

This keeps mutation support disabled, but makes existing cookies visible
in the Storage panel.
2026-06-11 15:03:47 +01:00
Sam Atkins
deec1ec2c3 LibDevTools: Add cookie storage actor
Firefox discovers Storage panel data through watcher resources. This
adds a read-only cookies actor with the fields and empty store response
expected by the Storage panel.

Mutation traits are reported as unsupported for now.

DevTools storage resources all have a "host" key derived from the URL,
which we produce in `storage_host_for_url()`.
2026-06-11 15:03:47 +01:00
Sam Atkins
879fc69f89 LibWeb/CSS: Link DevTools rules to UA stylesheets
UA and user stylesheets do not have owner nodes or owner rules, so their
matched rules cannot be mapped through the generic stylesheet identifier
helper. Share the built-in UA stylesheet enumeration and map UA rules by
the matched CSSStyleSheet object, so that they stay in sync with any
future changes.
2026-06-04 20:54:33 +01:00
Sam Atkins
64e0aa8c26 LibWeb+LibDevTools: Link style rules to CSS sources
Resolve applied-rule stylesheet identities through StyleSheetsActor and
include Firefox parentStyleSheet, line, and column fields on rule forms.
Firefox can then show matched rules as stylesheet rules and open the
corresponding CSS source location from the Rules panel.
2026-06-04 20:54:33 +01:00
Sam Atkins
52e1d30404 LibWeb+LibDevTools: Report applied style rules to Firefox
Collect the style rules that apply to an inspected element and expose
them through the existing DOM node inspection path. This gives Firefox's
Rules panel real rule forms instead of the previous empty getApplied
response.
2026-06-04 20:54:33 +01:00
Sam Atkins
121105eb83 LibWebView+WebContent: Pass DOM inspection options
Extend the existing DOM node inspection request with an options payload
and carry it through the browser process, WebView, IPC, and WebContent.
This lets later DevTools requests forward Firefox's top-level flags
without changing any inspected-node behavior yet.
2026-06-04 20:54:33 +01:00
Sam Atkins
1b3296b574 LibDevTools: Avoid stale callbacks during server teardown
DevTools server callbacks can outlive the server when deferred work is
queued during connection shutdown. Capture weak pointers for those tasks
and clear socket callbacks while the server is being destroyed so later
actor cleanup cannot touch freed state.

Add protocol coverage that destroys a server with deferred actor cleanup
pending, before adding the style-rule actor path that depends on this.
2026-06-04 20:54:33 +01:00
Sam Atkins
cbbd2e173e LibDevTools+LibWebView: Support DevTools URL navigation
Firefox's remote toolbox exposes an editable URL field for tab
descriptors. Submitting that field sends navigateTo to the tab
descriptor rather than the frame target.

Handle the request in the tab actor, route it through the DevTools
delegate, and reuse WebView's URL sanitizing and load path. Add protocol
coverage so the toolbar navigation request stays wired up.
2026-06-01 15:09:25 +01:00
Sam Atkins
be3cc9ec39 LibDevTools+LibWebView: Support DevTools history navigation
Firefox's inspector toolbar sends goBack and goForward requests to the
tab descriptor when the descriptor advertises navigation support. Thread
those requests through the DevTools delegate and reuse the existing
WebView session-history traversal path.

Keep the legacy frame-target requests working too, matching Firefox's
window-global target compatibility surface. Add protocol coverage for
both entry points so the advertised trait and deltas stay locked down.
2026-06-01 15:09:25 +01:00
Sam Atkins
7c1e911fa9 LibDevTools+LibWebView: Support DevTools page reloads
Firefox reloads remote targets through the tab descriptor's
reloadDescriptor request. We advertised support for that request, but
left it unhandled, so Firefox could clear inspector state without
causing Ladybird to reload the page.

Route reloadDescriptor, and the legacy frame target reload request,
through the DevTools delegate to WebView's reload path. This lets the
existing navigation notifications publish the replacement inspector root
after the reload completes.
2026-06-01 15:09:25 +01:00
Sam Atkins
5283f669a1 LibDevTools: Reload inspector roots after navigation
Firefox keeps using the same walker after navigation and expects it to
publish the new document root.

Normal tab debugging also relies on target switching. Re-inspect the tab
when navigation finishes, replace the walker DOM data, and notify the
watcher that the previous top-level frame target was destroyed before a
fresh target becomes available.

Send target availability as a watcher event, not as the watchTargets
response, and give each navigation a new inner window id so Firefox can
associate the new target with the new document.
2026-06-01 15:09:25 +01:00
Sam Atkins
53cb67ca1a LibDevTools: Destroy inspector roots on navigation start
Firefox drops the inspector tree when a target starts navigating. Keep
navigation subscribed on the frame actor and forward the event to the
inspector so the walker can announce root-destroyed.

Clear walker DOM caches, pending mutations, picker state, and selected
node state at the same time so stale actors do not remain usable while
the new document is loading.
2026-06-01 15:09:25 +01:00
Sam Atkins
49776b2669 Tests: Add DevTools navigation reload fixtures
Split the test delegate navigation helpers so tests can simulate start
and finish independently.

Add a second DOM tree fixture for navigation reload coverage without
changing existing navigation tests.
2026-06-01 15:09:25 +01:00
Sam Atkins
97070f836c LibDevTools: Add walker node picker protocol support
Firefox starts element picking by sending pick to the walker actor. Add
matching protocol handling so Ladybird can enter picker mode, send
hover, preview, pick, and cancel events, and serialize picked nodes in
the shape Firefox expects.

Picker hit testing can return text nodes, but Firefox only selects
elements in this mode. Normalize picker events to the closest element
ancestor and include the parent chain so Firefox can materialize missing
tree nodes before selecting the target.
2026-05-29 17:01:34 +01:00
Sam Atkins
2000fd38c1 DevTools+WebContent: Support the flexbox highlighter 2026-05-28 12:58:46 +01:00
Sam Atkins
d465a5f32f DevTools: Implement Firefox flexbox layout actors 2026-05-28 12:58:46 +01:00
Sam Atkins
1caa3b9188 DevTools: Allocate fresh highlighter actors for each request
Firefox creates a new custom highlighter actor for each
getHighlighterByType request. Its frontend decides when to cache and
reuse those actors, while grid highlighting uses distinct actors so
multiple grids and subgrid parent overlays can remain visible at the
same time.

Match that allocation model by removing InspectorActor's server-side
highlighter cache. Also unregister highlighter actors after release or
finalize, and make each actor clear only the highlight state it owns.
2026-05-27 17:47:50 +01:00
Sam Atkins
fb96cdd7a1 DevTools: Include subframe grids in layout inspection
Firefox's grid inspector builds its subgrid tree from two protocol
signals: isSubgrid on each GridActor form, and
Walker.getParentGridNode() for each subgrid container. Teach the walker
to answer the parent grid lookup so Firefox can attach subgrids below
their parent grid in the Layout panel.
2026-05-27 17:47:50 +01:00
Sam Atkins
ad541dca7f DevTools: Support the CSS grid highlighter
Create typed highlighter actors for Firefox's highlighter requests.
The actor keeps the requested type so CssGridHighlighter can use grid
highlighting while the other highlighter types keep the existing box
model-compatible behavior.
2026-05-27 17:47:50 +01:00
Sam Atkins
5c551ac6aa DevTools: Implement Firefox grid layout actors
Teach the walker to vend a layout inspector actor and serialize node
display types.

The layout inspector now returns Firefox-compatible grid actor forms
for getGrids and getCurrentGrid. It also supports Firefox's fallback
walker.getNodeFromActor(grid, ["containerEl"]) path, which the grid
panel uses when a grid form does not already contain a container node
actor ID.
2026-05-27 17:47:50 +01:00
Sam Atkins
c985f9cad5 Tests: Add a LibDevTools test suite
Use a fake delegate to cover root, target, inspector, styles, network,
navigation, and accessibility behavior. This is not in-depth, but should
be enough to catch regressions.
2026-05-27 08:55:02 +01:00