Skip to content

Instantly share code, notes, and snippets.

Implement MutationObserver API

Background information: The DOM standard defines a MutationObserver API that allows web content to receive callbacks when the page contents are mutated. The goal of this work is to implement the fundamental pieces required to support this API.

Tracking issue: servo/servo#6633 (please ask questions here)

Initial steps:

create the MutationObserver and MutationRecord interfaces with stub method implementations (:warning: TODO: implement void disconnect();, sequence<MutationRecord> takeRecords();)

#[test]
fn sequence_rooter() {
let rt = Runtime_::new().unwrap();
let cx = rt.cx();
JS_SetGCZeal(rt, 2, 1);
unsafe {
rooted!(in(cx) let global =
JS_NewGlobalObject(cx, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(),
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![cfg(feature = "debugmozjs")]
#![allow(unused_imports)]
#[macro_use]
extern crate mozjs;
use mozjs::jsapi::CompartmentOptions;
unsafe extern fn readPixels(cx: *mut JSContext, _obj: HandleObject, this: *const WebGLRenderingContext, args: *const JSJitMethodCallArgs) -> bool {
return wrap_panic(panic::AssertUnwindSafe(|| {
let this = &*this;
let args = &*args;
let argc = args._base.argc_;
if argc < 7 {
throw_type_error(cx, "Not enough arguments to \"WebGLRenderingContext.readPixels\".");
return false;
}
{
"inputs": [
"/home/xanewok/.cargo/git/checkouts/cargo-e7ff1db891893a9e/af9e40c/Cargo.toml",
"/home/xanewok/.cargo/git/checkouts/cargo-e7ff1db891893a9e/af9e40c/src/crates-io/Cargo.toml",
"/home/xanewok/.cargo/git/checkouts/rust-clippy-96f6c8ce0bc85cf5/1f65617/clippy_lints/Cargo.toml",
"/home/xanewok/.cargo/git/checkouts/rustfmt-5390e0ead582d971/7e3dc8f/Cargo.toml",
"/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.6.6/Cargo.toml",
"/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/ansi_term-0.11.0/Cargo.toml",
"/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/arrayvec-0.4.7/Cargo.toml",
"/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/atty-0.2.11/Cargo.toml",
C:\Users\Xanewok\Documents\rust>python x.py build src/tools/rls --build=x86_64-pc-windows-msvc
Updating only changed submodules
Submodules updated in 0.13 seconds
Finished dev [unoptimized] target(s) in 0.36s
Building stage0 std artifacts (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc)
Finished release [optimized] target(s) in 0.56s
Copying stage0 std from stage0 (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc / x86_64-pc-windows-msvc)
Building stage0 test artifacts (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc)
Finished release [optimized] target(s) in 0.41s
Copying stage0 test from stage0 (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc / x86_64-pc-windows-msvc)
diff --git a/src/build/rustc.rs b/src/build/rustc.rs
index 4ea387f..a3effa7 100644
--- a/src/build/rustc.rs
+++ b/src/build/rustc.rs
@@ -161,9 +161,8 @@ fn clippy_after_parse_callback(state: &mut ::rustc_driver::driver::CompileState<
);
registry.args_hidden = Some(Vec::new());
- // TODO handle clippy toml config
- let empty_clippy_conf = clippy_lints::Conf::default();
@Xanewok
Xanewok / cargo_plan.diff
Created October 22, 2018 09:20
Diff of dry-run --build-plan and actual-run --build-plan on Cargo itself
diff --git a/cargo_plan_simple.pretty.json b/cargo_plan.pretty.json
index 479c2a8..7ff6bda 100644
--- a/cargo_plan_simple.pretty.json
+++ b/cargo_plan.pretty.json
@@ -992,7 +992,8 @@
11
],
"inputs": [
- "/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/libz-sys-1.0.23/build.rs"
+ "/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/libz-sys-1.0.23/build.rs",
@Xanewok
Xanewok / cargo_plan.diff
Created October 22, 2018 09:22
Diff of dry-run --build-plan and actual-run on Cargo itself
diff --git a/cargo_plan_simple.pretty.json b/cargo_plan.pretty.json
index 479c2a8..7ff6bda 100644
--- a/cargo_plan_simple.pretty.json
+++ b/cargo_plan.pretty.json
@@ -992,7 +992,8 @@
11
],
"inputs": [
- "/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/libz-sys-1.0.23/build.rs"
+ "/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/libz-sys-1.0.23/build.rs",
@Xanewok
Xanewok / cargo_plan.diff
Created October 23, 2018 21:44
Diff of dry-run --build-plan and actual-run on Cargo itself
diff --git a/home/xanewok/cargo.pretty.json b/home/xanewok/cargo_detailed.pretty.json
index 3f56bbc4..3c88eb11 100644
--- a/home/xanewok/cargo.pretty.json
+++ b/home/xanewok/cargo_detailed.pretty.json
@@ -8,6 +8,39 @@
],
"kind": "Host",
"deps": [],
+ "inputs": [
+ "/home/xanewok/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.43/src/cloudabi/mod.rs",