aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/stylesheet_loader.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2016-12-22 16:38:55 -0500
committerJosh Matthews <josh@joshmatthews.net>2017-01-04 09:55:45 -0500
commit318a047ee53310f0a127e113f56c5cdb1c05fdb0 (patch)
tree9ee6ec545b7ad923fcefee0d1573ba3d77fe7daf /components/script/stylesheet_loader.rs
parent1e927ca88bf6622d5a87db75863f76976a1df56c (diff)
downloadservo-318a047ee53310f0a127e113f56c5cdb1c05fdb0.tar.gz
servo-318a047ee53310f0a127e113f56c5cdb1c05fdb0.zip
Interact with the originating document for stylesheet loads, rather than the element's current document.
Diffstat (limited to 'components/script/stylesheet_loader.rs')
-rw-r--r--components/script/stylesheet_loader.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs
index 427593c8500..28c5e86b6b5 100644
--- a/components/script/stylesheet_loader.rs
+++ b/components/script/stylesheet_loader.rs
@@ -6,6 +6,7 @@ use document_loader::LoadType;
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
+use dom::document::Document;
use dom::element::Element;
use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
@@ -78,6 +79,8 @@ pub struct StylesheetContext {
metadata: Option<Metadata>,
/// The response body received to date.
data: Vec<u8>,
+ /// The node document for elem when the load was initiated.
+ document: Trusted<Document>,
}
impl PreInvoke for StylesheetContext {}
@@ -103,7 +106,7 @@ impl FetchResponseListener for StylesheetContext {
fn process_response_eof(&mut self, status: Result<(), NetworkError>) {
let elem = self.elem.root();
- let document = document_from_node(&*elem);
+ let document = self.document.root();
let mut successful = false;
if status.is_ok() {
@@ -192,15 +195,15 @@ impl<'a> StylesheetLoader<'a> {
impl<'a> StylesheetLoader<'a> {
pub fn load(&self, source: StylesheetContextSource) {
let url = source.url();
+ let document = document_from_node(self.elem);
let context = Arc::new(Mutex::new(StylesheetContext {
elem: Trusted::new(&*self.elem),
source: source,
metadata: None,
data: vec![],
+ document: Trusted::new(&*document),
}));
- let document = document_from_node(self.elem);
-
let (action_sender, action_receiver) = ipc::channel().unwrap();
let listener = NetworkListener {
context: context,