diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2017-03-18 14:00:01 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2017-03-19 22:30:39 +0100 |
commit | cc046300f0390eadfcff65dcc6d8cea5bed9513e (patch) | |
tree | d0dd1e568c2efa3f920a0b695304a766f16dc519 /components/script/stylesheet_loader.rs | |
parent | 1e380137831eaf94a1f602c9d8dfae08f10893fa (diff) | |
download | servo-cc046300f0390eadfcff65dcc6d8cea5bed9513e.tar.gz servo-cc046300f0390eadfcff65dcc6d8cea5bed9513e.zip |
Remove some indirection.
Diffstat (limited to 'components/script/stylesheet_loader.rs')
-rw-r--r-- | components/script/stylesheet_loader.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index 7f544e42d08..fc838319695 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -55,7 +55,7 @@ pub trait StylesheetOwner { pub enum StylesheetContextSource { // NB: `media` is just an option so we avoid cloning it. LinkElement { media: Option<MediaList>, }, - Import(Arc<StyleLocked<ImportRule>>), + Import(Arc<Stylesheet>), } /// The context required for asynchronously loading an external stylesheet. @@ -158,16 +158,9 @@ impl FetchResponseListener for StylesheetContext { win.layout_chan().send(Msg::AddStylesheet(sheet)).unwrap(); } } - StylesheetContextSource::Import(ref import) => { + StylesheetContextSource::Import(ref stylesheet) => { let mut guard = document.style_shared_lock().write(); - // Clone an Arc because we can’t borrow `guard` twice at the same time. - - // FIXME(SimonSapin): allow access to multiple objects with one write guard? - // Would need a set of usize pointer addresses or something, - // the same object is not accessed more than once. - let stylesheet = Arc::clone(&import.write_with(&mut guard).stylesheet); - Stylesheet::update_from_bytes(&stylesheet, &data, protocol_encoding_label, @@ -289,12 +282,12 @@ impl<'a> StyleStylesheetLoader for StylesheetLoader<'a> { ) -> Arc<StyleLocked<ImportRule>> { let import = make_import(media); let url = import.url.url().expect("Invalid urls shouldn't enter the loader").clone(); - let arc = make_arc(import); //TODO (mrnayak) : Whether we should use the original loader's CORS setting? //Fix this when spec has more details. - self.load(StylesheetContextSource::Import(arc.clone()), url, None, "".to_owned()); + let source = StylesheetContextSource::Import(import.stylesheet.clone()); + self.load(source, url, None, "".to_owned()); - arc + make_arc(import) } } |