aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlmetaelement.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-08-16 15:46:17 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-08-18 14:31:35 +0200
commitd1725b1f195652bf947d5ce00622807597bc0b9c (patch)
tree5c0416212d033bcbbf19574134ff7fc74531a17a /components/script/dom/htmlmetaelement.rs
parentb8159e659e787c1e792d13b0939bb88e978ae84e (diff)
downloadservo-d1725b1f195652bf947d5ce00622807597bc0b9c.tar.gz
servo-d1725b1f195652bf947d5ce00622807597bc0b9c.zip
style: Replicate the list of stylesheets on the layout thread.
This is a patch that unifies a bit how Gecko and Stylo stylesheets work, in order to be able to eventually move the stylesheets into the stylist, and be able to incrementally update the invalidation map.
Diffstat (limited to 'components/script/dom/htmlmetaelement.rs')
-rw-r--r--components/script/dom/htmlmetaelement.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs
index 481da1c092f..d2cb332e7e4 100644
--- a/components/script/dom/htmlmetaelement.rs
+++ b/components/script/dom/htmlmetaelement.rs
@@ -99,10 +99,10 @@ impl HTMLMetaElement {
let content = content.value();
if !content.is_empty() {
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
- let document = self.upcast::<Node>().owner_doc();
+ let document = document_from_node(self);
let shared_lock = document.style_shared_lock();
let rule = CssRule::Viewport(Arc::new(shared_lock.wrap(translated_rule)));
- *self.stylesheet.borrow_mut() = Some(Arc::new(Stylesheet {
+ let sheet = Arc::new(Stylesheet {
contents: StylesheetContents {
rules: CssRules::new(vec![rule], shared_lock),
origin: Origin::Author,
@@ -118,9 +118,9 @@ impl HTMLMetaElement {
media: Arc::new(shared_lock.wrap(MediaList::empty())),
shared_lock: shared_lock.clone(),
disabled: AtomicBool::new(false),
- }));
- let doc = document_from_node(self);
- doc.invalidate_stylesheets();
+ });
+ *self.stylesheet.borrow_mut() = Some(sheet.clone());
+ document.add_stylesheet(self.upcast(), sheet);
}
}
}
@@ -199,6 +199,10 @@ impl VirtualMethods for HTMLMetaElement {
if context.tree_in_doc {
self.process_referrer_attribute();
+
+ if let Some(ref s) = *self.stylesheet.borrow() {
+ document_from_node(self).remove_stylesheet(self.upcast(), s);
+ }
}
}
}