From cc046300f0390eadfcff65dcc6d8cea5bed9513e Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sat, 18 Mar 2017 14:00:01 +0100 Subject: [PATCH] Remove some indirection. --- components/script/stylesheet_loader.rs | 17 +++++------------ 1 file 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, }, - Import(Arc>), + Import(Arc), } /// 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> { 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) } }