Skip to content

LibWeb: Only invalidate style for relevant links on navigation#9274

Open
tcl3 wants to merge 2 commits intoLadybirdBrowser:masterfrom
tcl3:libweb_href_invalidation
Open

LibWeb: Only invalidate style for relevant links on navigation#9274
tcl3 wants to merge 2 commits intoLadybirdBrowser:masterfrom
tcl3:libweb_href_invalidation

Conversation

@tcl3
Copy link
Copy Markdown
Member

@tcl3 tcl3 commented May 6, 2026

Previously, updating the document URL, by clicking a href, for example, would call respond_to_base_url_changes() which unconditionally invalidated style on the entire document, in order to update the style of any elements with pseudo classes that respond to changes in URL.

Currently, :link and :visited pseudo classes do not respond to URL changes, so I've added an early escape for now, so these do not invalidate style. We now also walk over all the links in the document and figure out which one's may have changed before invalidating their style. This will obviously need to be updated when we start tracking visited URLs.

This speedup can be seen on https://en.wikipedia.org/wiki/Holy_Roman_Empire, where the time taken to navigate to a given section after clicking on a table of contents link dropped from 1.05s to 750ms on average on my machine.

tcl3 added 2 commits May 6, 2026 13:55
Currently, this is the only pseudo class which is URL-sensitive. When
we implement proper tracking of visited URLs this will need to be
replaced with something more comprehensive.
@tcl3 tcl3 requested a review from AtkinsSJ as a code owner May 6, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant