script: Make callbacks generic over DOM interfaces. (#35459)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-02-21 07:17:11 -05:00 committed by GitHub
parent 2b0d2ecc73
commit a433b20259
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 141 additions and 97 deletions

View file

@ -205,6 +205,7 @@ use crate::stylesheet_set::StylesheetSetRef;
use crate::task::TaskBox;
use crate::task_source::TaskSourceName;
use crate::timers::OneshotTimerCallback;
use crate::DomTypes;
/// The number of times we are allowed to see spurious `requestAnimationFrame()` calls before
/// falling back to fake ones.
@ -6214,3 +6215,13 @@ fn is_named_element_with_id_attribute(elem: &Element) -> bool {
// behaviour is actually implemented
elem.is::<HTMLImageElement>() && elem.get_name().is_some_and(|name| !name.is_empty())
}
pub(crate) trait DocumentHelpers<D: DomTypes> {
fn ensure_safe_to_run_script_or_layout(&self);
}
impl DocumentHelpers<crate::DomTypeHolder> for Document {
fn ensure_safe_to_run_script_or_layout(&self) {
Document::ensure_safe_to_run_script_or_layout(self)
}
}