LibWeb: Replace cached navigable with Navigable-maintained back-pointer

Now that Navigable directly owns its active document (m_active_document)
we can have Navigable maintain a back-pointer on Document instead of
using the old cache-with-validation pattern that fell back to a linear
scan of all navigables via navigable_with_active_document().
This commit is contained in:
Aliaksandr Kalenik
2026-04-01 10:18:55 +02:00
committed by Alexander Kalenik
parent 2645695fdd
commit 4985dabf3d
Notes: github-actions[bot] 2026-04-01 09:52:45 +00:00
8 changed files with 36 additions and 34 deletions

View File

@@ -398,17 +398,9 @@ WebIDL::ExceptionOr<void> Node::set_node_value(Optional<String> const& maybe_val
// https://html.spec.whatwg.org/multipage/document-sequences.html#node-navigable
GC::Ptr<HTML::Navigable> Node::navigable() const
{
auto& document = const_cast<Document&>(this->document());
if (auto cached_navigable = document.cached_navigable()) {
if (cached_navigable->active_document() == &document)
return cached_navigable;
}
// To get the node navigable of a node node, return the navigable whose active document is node's node document,
// or null if there is no such navigable.
auto navigable = HTML::Navigable::navigable_with_active_document(document);
document.set_cached_navigable(navigable);
return navigable;
return document().navigable();
}
[[maybe_unused]] static StringView to_string(StyleInvalidationReason reason)