Skip to content

Commit

Permalink
Remove global field from Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
chkimes committed Jan 11, 2016
1 parent 0d217b5 commit c62f1e1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions components/script/dom/storage.rs
Expand Up @@ -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;
Expand All @@ -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()
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c62f1e1

Please sign in to comment.