diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-02-13 17:01:30 +0100 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-04-26 10:17:47 +0200 |
commit | 519cc2c31754d75c1b6cab7db0cfb0c1aaabbdf7 (patch) | |
tree | 6c0c371647b8237f53378195d893236a27fc1856 /components/script/dom/cssstylesheet.rs | |
parent | 18c1b8f6908e6f5eddce5413b37a83e34268d8e5 (diff) | |
download | servo-519cc2c31754d75c1b6cab7db0cfb0c1aaabbdf7.tar.gz servo-519cc2c31754d75c1b6cab7db0cfb0c1aaabbdf7.zip |
Invalidate and flush shadow tree stylesheets where needed
Diffstat (limited to 'components/script/dom/cssstylesheet.rs')
-rw-r--r-- | components/script/dom/cssstylesheet.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index 2def47d7aaa..9863dede5cb 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -6,11 +6,13 @@ use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding; use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; +use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::cssrulelist::{CSSRuleList, RulesSource}; use crate::dom::element::Element; +use crate::dom::node::{shadow_root_from_node, Node}; use crate::dom::stylesheet::StyleSheet; use crate::dom::window::Window; use dom_struct::dom_struct; @@ -64,6 +66,10 @@ impl CSSStyleSheet { ) } + pub fn owner(&self) -> DomRoot<Element> { + DomRoot::from_ref(&*self.owner) + } + fn rulelist(&self) -> DomRoot<CSSRuleList> { self.rulelist.or_init(|| { let rules = self.style_stylesheet.contents.rules.clone(); @@ -81,10 +87,14 @@ impl CSSStyleSheet { pub fn set_disabled(&self, disabled: bool) { if self.style_stylesheet.set_disabled(disabled) { - self.global() - .as_window() - .Document() - .invalidate_stylesheets(); + if let Some(shadow_root) = shadow_root_from_node(self.owner.upcast::<Node>()) { + shadow_root.invalidate_stylesheets(); + } else { + self.global() + .as_window() + .Document() + .invalidate_stylesheets(); + } } } |