dom: Stub out the IntersectionObserver interface (#33989)

This is the first step toward implementing the IntersectionObserver
interface. It adds stubs which are exposed when a preference is turned
on. This is enough to get some sites with `IntersectionObserver` to
start working.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-10-25 02:26:47 -07:00 committed by GitHub
parent 1624530ffe
commit 3b5dc069ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 354 additions and 0 deletions

View file

@ -190,6 +190,17 @@ impl<T: DomObject> DomRoot<T> {
pub fn from_ref(unrooted: &T) -> DomRoot<T> {
unsafe { DomRoot::new(Dom::from_ref(unrooted)) }
}
/// Create a traced version of this rooted object.
///
/// # Safety
///
/// This should never be used to create on-stack values. Instead these values should always
/// end up as members of other DOM objects.
#[allow(crown::unrooted_must_root)]
pub(crate) fn as_traced(&self) -> Dom<T> {
Dom::from_ref(self)
}
}
impl<T> MallocSizeOf for DomRoot<T>
@ -360,6 +371,11 @@ impl<T: DomObject> Dom<T> {
ptr: ptr::NonNull::from(obj),
}
}
/// Return a rooted version of this DOM object ([`DomRoot<T>`]) suitable for use on the stack.
pub(crate) fn as_rooted(&self) -> DomRoot<T> {
DomRoot::from_ref(self)
}
}
impl<T: DomObject> Deref for Dom<T> {