diff options
author | Josh Matthews <josh@joshmatthews.net> | 2017-04-13 16:02:17 +1000 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2017-04-13 16:02:17 +1000 |
commit | 3c3311b16a0a1f0c84d02ff10283fb0800529184 (patch) | |
tree | f11cd2458ea31d5c7b56b51919e083ab5114c778 /components/script | |
parent | ca3cd64d6b1999292d634bfa237c2705e6d575c1 (diff) | |
download | servo-3c3311b16a0a1f0c84d02ff10283fb0800529184.tar.gz servo-3c3311b16a0a1f0c84d02ff10283fb0800529184.zip |
Allow loading multiple stylesheets for the same link element.
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/htmllinkelement.rs | 6 | ||||
-rw-r--r-- | components/script/stylesheet_loader.rs | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index d29a94a11f0..bb7fe85366d 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -24,6 +24,7 @@ use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever_atoms::LocalName; use net_traits::ReferrerPolicy; +use script_layout_interface::message::Msg; use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg}; use std::ascii::AsciiExt; use std::borrow::ToOwned; @@ -96,8 +97,9 @@ impl HTMLLinkElement { } pub fn set_stylesheet(&self, s: Arc<Stylesheet>) { - assert!(self.stylesheet.borrow().is_none()); // Useful for catching timing issues. - *self.stylesheet.borrow_mut() = Some(s); + *self.stylesheet.borrow_mut() = Some(s.clone()); + window_from_node(self).layout_chan().send(Msg::AddStylesheet(s)).unwrap(); + document_from_node(self).invalidate_stylesheets(); } pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index cdafde510c9..37b41f53d70 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -22,7 +22,6 @@ use ipc_channel::router::ROUTER; use net_traits::{FetchResponseListener, FetchMetadata, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy}; use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode, Type as RequestType}; use network_listener::{NetworkListener, PreInvoke}; -use script_layout_interface::message::Msg; use servo_url::ServoUrl; use std::mem; use std::sync::{Arc, Mutex}; @@ -151,9 +150,7 @@ impl FetchResponseListener for StylesheetContext { sheet.set_disabled(true); } - link.set_stylesheet(sheet.clone()); - - win.layout_chan().send(Msg::AddStylesheet(sheet)).unwrap(); + link.set_stylesheet(sheet); } } StylesheetContextSource::Import(ref stylesheet) => { |