diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-04-29 08:38:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-29 08:38:50 -0400 |
commit | 799490a02e9bea575bf34c39f045ef0883539f05 (patch) | |
tree | 278cada683564db36997cf3f96c92513b89c3096 /components/script/dom/htmlmetaelement.rs | |
parent | d58ea974baff1b51a43d2e2bf4b287ff11991a8d (diff) | |
parent | 37e88e77cdf00e3555599dd4004d03548bd95dcf (diff) | |
download | servo-799490a02e9bea575bf34c39f045ef0883539f05.tar.gz servo-799490a02e9bea575bf34c39f045ef0883539f05.zip |
Auto merge of #22743 - ferjm:shadowdom, r=emilio
Partial ShadowDOM support
This is just an early WIP, not to take it very seriously yet.
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22719
- [x] There are tests for these changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22743)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlmetaelement.rs')
-rw-r--r-- | components/script/dom/htmlmetaelement.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index a8e829c3d1c..11b5706516d 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -15,7 +15,10 @@ use crate::dom::document::Document; use crate::dom::element::{AttributeMutation, Element}; use crate::dom::htmlelement::HTMLElement; use crate::dom::htmlheadelement::HTMLHeadElement; -use crate::dom::node::{document_from_node, window_from_node, Node, UnbindContext}; +use crate::dom::node::{ + document_from_node, stylesheets_owner_from_node, window_from_node, BindContext, Node, + UnbindContext, +}; use crate::dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; @@ -97,6 +100,7 @@ impl HTMLMetaElement { } } + #[allow(unrooted_must_root)] fn apply_viewport(&self) { if !pref!(layout.viewport.enabled) { return; @@ -106,6 +110,7 @@ impl HTMLMetaElement { let content = content.value(); if !content.is_empty() { if let Some(translated_rule) = ViewportRule::from_meta(&**content) { + let stylesheets_owner = stylesheets_owner_from_node(self); let document = document_from_node(self); let shared_lock = document.style_shared_lock(); let rule = CssRule::Viewport(Arc::new(shared_lock.wrap(translated_rule))); @@ -124,7 +129,7 @@ impl HTMLMetaElement { disabled: AtomicBool::new(false), }); *self.stylesheet.borrow_mut() = Some(sheet.clone()); - document.add_stylesheet(self.upcast(), sheet); + stylesheets_owner.add_stylesheet(self.upcast(), sheet); } } } @@ -171,12 +176,12 @@ impl VirtualMethods for HTMLMetaElement { Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } - fn bind_to_tree(&self, tree_in_doc: bool) { + fn bind_to_tree(&self, context: &BindContext) { if let Some(ref s) = self.super_type() { - s.bind_to_tree(tree_in_doc); + s.bind_to_tree(context); } - if tree_in_doc { + if context.tree_connected { self.process_attributes(); } } @@ -204,11 +209,11 @@ impl VirtualMethods for HTMLMetaElement { s.unbind_from_tree(context); } - if context.tree_in_doc { + if context.tree_connected { self.process_referrer_attribute(); if let Some(s) = self.stylesheet.borrow_mut().take() { - document_from_node(self).remove_stylesheet(self.upcast(), &s); + stylesheets_owner_from_node(self).remove_stylesheet(self.upcast(), &s); } } } |