LibWeb: Cache the first <base href> (in tree order) in Document

When parsing relative URLs, we have to check the first <base href> in
tree order (if one is available). This was getting *very* costly on
large DOMs with many relative urls.

This patch avoids all that repeated traversal by letting Document cache
the first <base href> and invalidating the cache whenever a <base>
element is added/removed/edited in the DOM.

The browser was stuck doing this for a *very* long time when loading
the ECMA-262 spec, and this removes that problem entirely.
This commit is contained in:
Andreas Kling 2022-11-04 20:56:30 +01:00
commit b400a34984
Notes: sideshowbarker 2024-07-17 04:47:17 +09:00
4 changed files with 23 additions and 3 deletions

View file

@ -22,6 +22,7 @@ public:
AK::URL const& frozen_base_url() const { return m_frozen_base_url; }
virtual void inserted() override;
virtual void removed_from(Node*) override;
virtual void parse_attribute(FlyString const& name, String const& value) override;
private: