mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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:
parent
1624530ffe
commit
3b5dc069ae
8 changed files with 354 additions and 0 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue