script: Cache the <iframe> list per-Document (#34702)

This change creates a new struct `IFrameCollection` that is used to
cache the list of `<iframe>`s in a `Document` as long as the
`Document`'s DOM has not changed. This prevent constantly iterating the
entire DOM during *update the rendering*, which runs up to 60 times per
second as well as for other operations.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-12-20 12:46:46 +01:00 committed by GitHub
parent adfee3daa5
commit a5c461146f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 225 additions and 107 deletions

View file

@ -2988,15 +2988,15 @@ impl ScriptThread {
browsing_context_id: BrowsingContextId,
can_gc: CanGc,
) {
let doc = self
let document = self
.documents
.borrow()
.find_document(parent_pipeline_id)
.unwrap();
let frame_element = doc.find_iframe(browsing_context_id);
if let Some(ref frame_element) = frame_element {
doc.request_focus(Some(frame_element.upcast()), FocusType::Parent, can_gc);
let iframes = document.iframes();
if let Some(iframe) = iframes.get(browsing_context_id) {
document.request_focus(Some(iframe.element.upcast()), FocusType::Parent, can_gc);
}
}