servo: Merge #16407 - Allow loading multiple stylesheets for the same link element (from jdm:style_panic); r=emilio

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #16399
- [x] There are tests for these changes

Source-Repo: https://github.com/servo/servo
Source-Revision: ebc61bb2c3ac682ca366019b21160819ec3c7882

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 614db8977f7f52f38ccb5f6f8da2a63aec3217ac
This commit is contained in:
Josh Matthews 2017-04-13 11:29:58 -05:00
parent cceb97c342
commit d902167d75
2 changed files with 5 additions and 6 deletions

View File

@ -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;
@ -97,8 +98,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>> {

View File

@ -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) => {