LibWeb: Avoid unnecessary style invalidation in Document::set_url()

If we set the same URL that we already had, there's no need to
invalidate style for the base URL changing.

This avoids some style recomputation while loading pages.
This commit is contained in:
Andreas Kling 2025-08-18 23:21:52 +02:00 committed by Jelle Raaijmakers
parent ec2b568919
commit 775d15c115
Notes: github-actions[bot] 2025-08-20 07:16:44 +00:00

View file

@ -1178,6 +1178,10 @@ void Document::respond_to_base_url_changes()
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#set-the-url
void Document::set_url(URL::URL const& url)
{
// OPTIMIZATION: Avoid unnecessary work if the URL is already set.
if (m_url == url)
return;
// To set the URL for a Document document to a URL record url:
// 1. Set document's URL to url.