aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/storage.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-09-16 01:15:44 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-09-16 03:47:14 +0200
commit69275162b03d663394cd7bfe564890187e00de52 (patch)
treedc6984c787333d65e2f08b9f63ef8c5f941ef6d7 /components/script/dom/storage.rs
parent4b596f291226df607b6ff012c70fecfbb73fb865 (diff)
downloadservo-69275162b03d663394cd7bfe564890187e00de52.tar.gz
servo-69275162b03d663394cd7bfe564890187e00de52.zip
Clean up Storage::queue_storage_event
This moves the Runnable type directly in the method and makes it not use main_thread_handler, which is unneeded here anyway.
Diffstat (limited to 'components/script/dom/storage.rs')
-rw-r--r--components/script/dom/storage.rs89
1 files changed, 44 insertions, 45 deletions
diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs
index f14f1aad67f..1f7cba224f6 100644
--- a/components/script/dom/storage.rs
+++ b/components/script/dom/storage.rs
@@ -17,7 +17,7 @@ use dom_struct::dom_struct;
use ipc_channel::ipc::{self, IpcSender};
use net_traits::IpcSend;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
-use script_thread::{Runnable, ScriptThread};
+use script_thread::Runnable;
use script_traits::ScriptMsg;
use servo_url::ServoUrl;
use task_source::TaskSource;
@@ -158,50 +158,49 @@ impl Storage {
}
/// https://html.spec.whatwg.org/multipage/#send-a-storage-notification
- pub fn queue_storage_event(&self, url: ServoUrl,
- key: Option<String>, old_value: Option<String>, new_value: Option<String>) {
+ pub fn queue_storage_event(
+ &self,
+ url: ServoUrl,
+ key: Option<String>,
+ old_value: Option<String>,
+ new_value: Option<String>,
+ ) {
let global = self.global();
- let window = global.as_window();
- let task_source = window.dom_manipulation_task_source();
- let trusted_storage = Trusted::new(self);
- task_source
- .queue(
- box StorageEventRunnable::new(trusted_storage, url, key, old_value, new_value), &global)
- .unwrap();
- }
-}
-
-pub struct StorageEventRunnable {
- element: Trusted<Storage>,
- url: ServoUrl,
- key: Option<String>,
- old_value: Option<String>,
- new_value: Option<String>
-}
-
-impl StorageEventRunnable {
- fn new(storage: Trusted<Storage>, url: ServoUrl,
- key: Option<String>, old_value: Option<String>, new_value: Option<String>) -> StorageEventRunnable {
- StorageEventRunnable { element: storage, url: url, key: key, old_value: old_value, new_value: new_value }
- }
-}
-
-impl Runnable for StorageEventRunnable {
- fn main_thread_handler(self: Box<StorageEventRunnable>, _: &ScriptThread) {
- let this = *self;
- let storage = this.element.root();
- let global = storage.global();
- let window = global.as_window();
-
- let storage_event = StorageEvent::new(
- &window,
- atom!("storage"),
- EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
- this.key.map(DOMString::from), this.old_value.map(DOMString::from), this.new_value.map(DOMString::from),
- DOMString::from(this.url.into_string()),
- Some(&storage)
- );
-
- storage_event.upcast::<Event>().fire(window.upcast());
+ global.as_window().dom_manipulation_task_source().queue(
+ box StorageEventRunnable {
+ element: Trusted::new(self),
+ url,
+ key,
+ old_value,
+ new_value,
+ },
+ global.upcast(),
+ ).unwrap();
+ struct StorageEventRunnable {
+ element: Trusted<Storage>,
+ url: ServoUrl,
+ key: Option<String>,
+ old_value: Option<String>,
+ new_value: Option<String>
+ }
+ impl Runnable for StorageEventRunnable {
+ fn handler(self: Box<Self>) {
+ let this = *self;
+ let storage = this.element.root();
+ let global = storage.global();
+ let storage_event = StorageEvent::new(
+ global.as_window(),
+ atom!("storage"),
+ EventBubbles::DoesNotBubble,
+ EventCancelable::NotCancelable,
+ this.key.map(DOMString::from),
+ this.old_value.map(DOMString::from),
+ this.new_value.map(DOMString::from),
+ DOMString::from(this.url.into_string()),
+ Some(&storage)
+ );
+ storage_event.upcast::<Event>().fire(global.upcast());
+ }
+ }
}
}