Remove global field from Storage

This commit is contained in:
Chad Kimes 2016-01-10 22:07:59 -05:00
parent 0d217b5f71
commit c62f1e15fb

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::StorageBinding;
use dom::bindings::codegen::Bindings::StorageBinding::StorageMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::global::{GlobalField, GlobalRef};
use dom::bindings::global::{GlobalRef, global_root_from_reflector};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootedReference};
use dom::bindings::refcounted::Trusted;
@ -24,31 +24,29 @@ use util::str::DOMString;
#[dom_struct]
pub struct Storage {
reflector_: Reflector,
global: GlobalField,
storage_type: StorageType
}
impl Storage {
fn new_inherited(global: &GlobalRef, storage_type: StorageType) -> Storage {
fn new_inherited(storage_type: StorageType) -> Storage {
Storage {
reflector_: Reflector::new(),
global: GlobalField::from_rooted(global),
storage_type: storage_type
}
}
pub fn new(global: &GlobalRef, storage_type: StorageType) -> Root<Storage> {
reflect_dom_object(box Storage::new_inherited(global, storage_type), *global, StorageBinding::Wrap)
reflect_dom_object(box Storage::new_inherited(storage_type), *global, StorageBinding::Wrap)
}
fn get_url(&self) -> Url {
let global_root = self.global.root();
let global_root = global_root_from_reflector(self);
let global_ref = global_root.r();
global_ref.get_url()
}
fn get_storage_thread(&self) -> StorageThread {
let global_root = self.global.root();
let global_root = global_root_from_reflector(self);
let global_ref = global_root.r();
global_ref.as_window().storage_thread()
}
@ -154,7 +152,7 @@ impl Storage {
/// https://html.spec.whatwg.org/multipage/#send-a-storage-notification
fn broadcast_change_notification(&self, key: Option<String>, old_value: Option<String>,
new_value: Option<String>) {
let global_root = self.global.root();
let global_root = global_root_from_reflector(self);
let global_ref = global_root.r();
let main_script_chan = global_ref.as_window().main_thread_script_chan();
let script_chan = global_ref.dom_manipulation_thread_source();
@ -183,7 +181,7 @@ impl MainThreadRunnable for StorageEventRunnable {
let this = *self;
let storage_root = this.element.root();
let storage = storage_root.r();
let global_root = storage.global.root();
let global_root = global_root_from_reflector(storage);
let global_ref = global_root.r();
let ev_window = global_ref.as_window();
let ev_url = storage.get_url();