Add invalidate_stylesheets to StyleSheetsListOwner trait

This commit is contained in:
Fernando Jiménez Moreno 2019-02-21 16:54:37 +01:00
parent 3dd38151d4
commit d77b9c6775
6 changed files with 17 additions and 35 deletions

View file

@ -3,7 +3,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::CSSStyleRuleBinding::{self, CSSStyleRuleMethods};
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
@ -11,7 +10,7 @@ use crate::dom::bindings::str::DOMString;
use crate::dom::cssrule::{CSSRule, SpecificCSSRule};
use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
use crate::dom::cssstylesheet::CSSStyleSheet;
use crate::dom::node::{shadow_root_from_node, Node};
use crate::dom::node::{stylesheets_owner_from_node, Node};
use crate::dom::window::Window;
use cssparser::ToCss;
use cssparser::{Parser as CssParser, ParserInput as CssParserInput};
@ -119,18 +118,8 @@ impl CSSStyleRuleMethods for CSSStyleRule {
let mut guard = self.cssrule.shared_lock().write();
let stylerule = self.stylerule.write_with(&mut guard);
mem::swap(&mut stylerule.selectors, &mut s);
if let Some(shadow_root) =
shadow_root_from_node(self.cssrule.parent_stylesheet().owner().upcast::<Node>())
{
shadow_root.invalidate_stylesheets();
} else {
// It seems like we will want to avoid having to invalidate all
// stylesheets eventually!
self.global()
.as_window()
.Document()
.invalidate_stylesheets();
}
stylesheets_owner_from_node(self.cssrule.parent_stylesheet().owner().upcast::<Node>())
.invalidate_stylesheets();
}
}
}