mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Implement basic interface for MutationObserver and MutationRecord.
This commit is contained in:
parent
5421d833de
commit
107ac9ab56
8 changed files with 145 additions and 0 deletions
|
@ -46,6 +46,7 @@ use dom::event::{Event, EventBubbles, EventCancelable};
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::htmlanchorelement::HTMLAnchorElement;
|
||||
use dom::htmliframeelement::HTMLIFrameElement;
|
||||
use dom::mutationobserver::MutationObserver;
|
||||
use dom::node::{Node, NodeDamage, window_from_node};
|
||||
use dom::serviceworker::TrustedServiceWorkerAddress;
|
||||
use dom::serviceworkerregistration::ServiceWorkerRegistration;
|
||||
|
@ -480,6 +481,9 @@ pub struct ScriptThread {
|
|||
|
||||
microtask_queue: MicrotaskQueue,
|
||||
|
||||
/// The unit of related similar-origin browsing contexts' list of MutationObserver objects
|
||||
mutation_observers: DOMRefCell<Vec<JS<MutationObserver>>>,
|
||||
|
||||
/// A handle to the webvr thread, if available
|
||||
webvr_thread: Option<IpcSender<WebVRMsg>>,
|
||||
|
||||
|
@ -570,6 +574,15 @@ impl ScriptThreadFactory for ScriptThread {
|
|||
}
|
||||
|
||||
impl ScriptThread {
|
||||
pub fn add_mutation_observer(observer: &MutationObserver) {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
script_thread.mutation_observers
|
||||
.borrow_mut()
|
||||
.push(JS::from_ref(observer));
|
||||
})
|
||||
}
|
||||
|
||||
pub fn mark_document_with_no_blocked_loads(doc: &Document) {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
|
@ -722,6 +735,8 @@ impl ScriptThread {
|
|||
|
||||
microtask_queue: MicrotaskQueue::default(),
|
||||
|
||||
mutation_observers: Default::default(),
|
||||
|
||||
layout_to_constellation_chan: state.layout_to_constellation_chan,
|
||||
|
||||
webvr_thread: state.webvr_thread,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue