Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutation observer API #16190

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
73f2c6e
Initial Files for MutationObserverAPI
srivassumit Mar 16, 2017
bee1340
add a vector of MutationObserver objects as a member of ScriptThread
srivassumit Mar 16, 2017
a5af9a2
Merge branch 'master' of https://github.com/servo/servo into Mutation…
srivassumit Mar 16, 2017
4ec5d92
Merge branch 'master' of https://github.com/servo/servo into Mutation…
srivassumit Mar 17, 2017
16c09d4
incomplete code for mutationobserver and mutationrecord
srivassumit Mar 20, 2017
e162f8a
fixed build errors, Constructor is pending
srivassumit Mar 21, 2017
b0af820
Resolving merge conflicts
krishnakarthick1993 Mar 23, 2017
8e6d4e9
added Mutation Observer Constructor
srivassumit Mar 29, 2017
4797cc3
Merge branch 'MutationObserver-dev' of https://github.com/srivassumit…
srivassumit Mar 29, 2017
dd9ea19
Merge branch 'master' of https://github.com/servo/servo into Mutation…
srivassumit Mar 29, 2017
4db8c26
changes for constructor
srivassumit Mar 30, 2017
1a7e2d4
Merge branch 'master' of https://github.com/servo/servo into Mutation…
srivassumit Mar 30, 2017
ef51869
Update mutationrecord.rs
srivassumit Mar 31, 2017
2d10eb7
Update script_thread.rs
srivassumit Mar 31, 2017
3dd78ed
more changes as per review comments
srivassumit Apr 1, 2017
0160982
fixed test test-tidy issues, accessed ScriptThread from mutationobserver
srivassumit Apr 1, 2017
eefb95b
Merge branch 'master' of https://github.com/servo/servo into Mutation…
srivassumit Apr 1, 2017
2cce8c5
modifications for review comments
srivassumit Apr 5, 2017
7115abd
Merge branch 'master' of https://github.com/servo/servo into Mutation…
srivassumit Apr 5, 2017
2821def
changes as per review comments
srivassumit Apr 5, 2017
a82e79d
Merge branch 'master' of https://github.com/servo/servo into Mutatio…
srivassumit Apr 5, 2017
3bd4438
removed unused imports and fixed review comments.
srivassumit Apr 5, 2017
c6739ef
removed unused import
srivassumit Apr 5, 2017
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

changes for constructor

  • Loading branch information
srivassumit committed Mar 30, 2017
commit 4db8c261a40a2e38756afd72083f197408617a7e
@@ -30,11 +30,8 @@ impl MutationObserver {

pub fn Constructor(global: &dom::bindings::js::Root<dom::window::Window>, callback: Rc<MutationCallback>) -> Result<Root<MutationObserver>, Error> {

This comment has been minimized.

Copy link
@jdm

jdm Mar 30, 2017

Member

This should be &Window instead of &Root<Window>.

let observer = MutationObserver::new(global, &callback);
match observer {
None => Err(Error::new()),
Some(_) => Ok(dom::bindings::js::Root<MutationObserver::new(global, callback)>),
}
}
ScriptThread.set_mutation_observer(observer)
}

This comment has been minimized.

Copy link
@jdm

jdm Mar 30, 2017

Member

This can't compile right now since the return type doesn't match what the code is doing. Please use the new/new_inherited methods from other files in dom/ as a guide.


}

@@ -574,6 +574,14 @@ impl ScriptThreadFactory for ScriptThread {
}

impl ScriptThread {
pub fn set_mutation_observer(observer: &MutationObserver) {

This comment has been minimized.

Copy link
@jdm

jdm Mar 30, 2017

Member

Let's call this add_mutation_observer instead.

This comment has been minimized.

Copy link
@srivassumit

srivassumit Apr 1, 2017

Author Contributor

I have changed this name, but I am not able to figure out how exactly do I reference this from the mutationobserver.rs file.

writing 'ScriptThread.add_mutation_observer(observer)' in the code, gives me an error(as expected), that ScriptThread is "not found in this scope", (probably because I havent inported anything for ScriptThread in the mutationobserver.rs file yet...) but I am not sure what exactly do I need to import in order to access the Script Thread and its methods.

This comment has been minimized.

Copy link
@KiChjang

KiChjang Apr 1, 2017

Member

You need ScriptThread::add_mutation_observer.

This comment has been minimized.

Copy link
@srivassumit

srivassumit Apr 1, 2017

Author Contributor

I tried that too, but using this also gives an error:
'Use of undeclared type or module ScriptThread'
won't I need to import something here as well?

This comment has been minimized.

Copy link
@KiChjang

KiChjang Apr 1, 2017

Member

use script_thread::ScriptThread;, or better yet, use script_thread::ScriptThread::add_mutation_observer;

This comment has been minimized.

Copy link
@jdm

jdm Apr 1, 2017

Member

The "better yet" solution can't work; static methods can't be imported like that.

SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = unsafe { &*root.get().unwrap() };
script_thread.mutation_observers
.push(*observer);
})
}

pub fn mark_document_with_no_blocked_loads(doc: &Document) {
SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = unsafe { &*root.get().unwrap() };
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.