Make TaskSource::queue take a &GlobalScope

This commit is contained in:
Anthony Ramine 2016-10-04 15:49:48 +02:00
parent 514819f37a
commit 44ca9f3d71
9 changed files with 25 additions and 27 deletions

View file

@ -5,7 +5,6 @@
use dom::attr::Attr; use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding; use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding;
use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods; use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
@ -79,7 +78,7 @@ impl VirtualMethods for HTMLDetailsElement {
element: details, element: details,
toggle_number: counter toggle_number: counter
}; };
let _ = task_source.queue(runnable, GlobalRef::Window(&window)); let _ = task_source.queue(runnable, window.upcast());
} }
} }
} }

View file

@ -12,7 +12,6 @@ use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMet
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
use dom::bindings::conversions::DerivedFrom; use dom::bindings::conversions::DerivedFrom;
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
@ -444,7 +443,7 @@ impl HTMLFormElement {
}; };
// Step 3 // Step 3
window.dom_manipulation_task_source().queue(nav, GlobalRef::Window(&window)).unwrap(); window.dom_manipulation_task_source().queue(nav, window.upcast()).unwrap();
} }
/// Interactively validate the constraints of form elements /// Interactively validate the constraints of form elements

View file

@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods; use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::{LayoutJS, Root}; use dom::bindings::js::{LayoutJS, Root};
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
@ -192,7 +191,7 @@ impl HTMLImageElement {
src: src.into(), src: src.into(),
}; };
let task = window.dom_manipulation_task_source(); let task = window.dom_manipulation_task_source();
let _ = task.queue(runnable, GlobalRef::Window(window)); let _ = task.queue(runnable, window.upcast());
} }
} }
} }

View file

@ -12,7 +12,6 @@ use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementC
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods; use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods;
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*; use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*;
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods; use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, MutNullableHeap, JS}; use dom::bindings::js::{Root, MutNullableHeap, JS};
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
@ -276,7 +275,7 @@ impl HTMLMediaElement {
elem: Trusted::new(self), elem: Trusted::new(self),
}; };
let win = window_from_node(self); let win = window_from_node(self);
let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win)); let _ = win.dom_manipulation_task_source().queue(task, win.upcast());
} }
// https://html.spec.whatwg.org/multipage/#internal-pause-steps step 2.2 // https://html.spec.whatwg.org/multipage/#internal-pause-steps step 2.2
@ -300,13 +299,13 @@ impl HTMLMediaElement {
elem: Trusted::new(self), elem: Trusted::new(self),
}; };
let win = window_from_node(self); let win = window_from_node(self);
let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win)); let _ = win.dom_manipulation_task_source().queue(task, win.upcast());
} }
fn queue_fire_simple_event(&self, type_: &'static str) { fn queue_fire_simple_event(&self, type_: &'static str) {
let win = window_from_node(self); let win = window_from_node(self);
let task = box FireSimpleEventTask::new(self, type_); let task = box FireSimpleEventTask::new(self, type_);
let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win)); let _ = win.dom_manipulation_task_source().queue(task, win.upcast());
} }
fn fire_simple_event(&self, type_: &str) { fn fire_simple_event(&self, type_: &str) {
@ -533,8 +532,8 @@ impl HTMLMediaElement {
fn queue_dedicated_media_source_failure_steps(&self) { fn queue_dedicated_media_source_failure_steps(&self) {
let window = window_from_node(self); let window = window_from_node(self);
let _ = window.dom_manipulation_task_source().queue(box DedicatedMediaSourceFailureTask::new(self), let _ = window.dom_manipulation_task_source().queue(
GlobalRef::Window(&window)); box DedicatedMediaSourceFailureTask::new(self), window.upcast());
} }
// https://html.spec.whatwg.org/multipage/#dedicated-media-source-failure-steps // https://html.spec.whatwg.org/multipage/#dedicated-media-source-failure-steps

View file

@ -150,13 +150,14 @@ impl Storage {
/// https://html.spec.whatwg.org/multipage/#send-a-storage-notification /// https://html.spec.whatwg.org/multipage/#send-a-storage-notification
fn broadcast_change_notification(&self, key: Option<String>, old_value: Option<String>, fn broadcast_change_notification(&self, key: Option<String>, old_value: Option<String>,
new_value: Option<String>) { new_value: Option<String>) {
let global_root = self.global(); let global = self.global_scope();
let global_ref = global_root.r(); let window = global.as_window();
let window = global_ref.as_global_scope().as_window();
let task_source = window.dom_manipulation_task_source(); let task_source = window.dom_manipulation_task_source();
let trusted_storage = Trusted::new(self); let trusted_storage = Trusted::new(self);
task_source.queue(box StorageEventRunnable::new(trusted_storage, key, old_value, new_value), task_source
global_ref).unwrap(); .queue(
box StorageEventRunnable::new(trusted_storage, key, old_value, new_value), &global)
.unwrap();
} }
} }

View file

@ -1192,7 +1192,7 @@ impl ScriptThread {
// https://html.spec.whatwg.org/multipage/#the-end step 7 // https://html.spec.whatwg.org/multipage/#the-end step 7
let handler = box DocumentProgressHandler::new(Trusted::new(doc)); let handler = box DocumentProgressHandler::new(Trusted::new(doc));
self.dom_manipulation_task_source.queue(handler, GlobalRef::Window(doc.window())).unwrap(); self.dom_manipulation_task_source.queue(handler, doc.window().upcast()).unwrap();
if let Some(fragment) = doc.url().fragment() { if let Some(fragment) = doc.url().fragment() {
self.check_and_scroll_fragment(fragment, pipeline, doc); self.check_and_scroll_fragment(fragment, pipeline, doc);
@ -2183,7 +2183,8 @@ impl ScriptThread {
pub fn flush_promise_jobs(global: GlobalRef) { pub fn flush_promise_jobs(global: GlobalRef) {
SCRIPT_THREAD_ROOT.with(|root| { SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = unsafe { &*root.get().unwrap() }; let script_thread = unsafe { &*root.get().unwrap() };
let _ = script_thread.dom_manipulation_task_source.queue(box FlushPromiseJobs, global); let _ = script_thread.dom_manipulation_task_source.queue(
box FlushPromiseJobs, global.as_global_scope());
}) })
} }

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventRunnable, SimpleEventRunnable}; use dom::event::{EventBubbles, EventCancelable, EventRunnable, SimpleEventRunnable};
use dom::eventtarget::EventTarget; use dom::eventtarget::EventTarget;
@ -41,7 +41,7 @@ impl DOMManipulationTaskSource {
bubbles: bubbles, bubbles: bubbles,
cancelable: cancelable, cancelable: cancelable,
}; };
let _ = self.queue(runnable, GlobalRef::Window(window)); let _ = self.queue(runnable, window.upcast());
} }
pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) { pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
@ -50,7 +50,7 @@ impl DOMManipulationTaskSource {
target: target, target: target,
name: name, name: name,
}; };
let _ = self.queue(runnable, GlobalRef::Window(window)); let _ = self.queue(runnable, window.upcast());
} }
} }

View file

@ -8,7 +8,7 @@ pub mod history_traversal;
pub mod networking; pub mod networking;
pub mod user_interaction; pub mod user_interaction;
use dom::bindings::global::GlobalRef; use dom::globalscope::GlobalScope;
use script_thread::{Runnable, RunnableWrapper}; use script_thread::{Runnable, RunnableWrapper};
use std::result::Result; use std::result::Result;
@ -18,7 +18,7 @@ pub trait TaskSource {
wrapper: &RunnableWrapper) wrapper: &RunnableWrapper)
-> Result<(), ()> -> Result<(), ()>
where T: Runnable + Send + 'static; where T: Runnable + Send + 'static;
fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, global: GlobalRef) -> Result<(), ()> { fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, global: &GlobalScope) -> Result<(), ()> {
self.queue_with_wrapper(msg, &global.as_global_scope().get_runnable_wrapper()) self.queue_with_wrapper(msg, &global.get_runnable_wrapper())
} }
} }

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventRunnable}; use dom::event::{EventBubbles, EventCancelable, EventRunnable};
use dom::eventtarget::EventTarget; use dom::eventtarget::EventTarget;
@ -41,7 +41,7 @@ impl UserInteractionTaskSource {
bubbles: bubbles, bubbles: bubbles,
cancelable: cancelable, cancelable: cancelable,
}; };
let _ = self.queue(runnable, GlobalRef::Window(window)); let _ = self.queue(runnable, window.upcast());
} }
} }