aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/cssstyledeclaration.rs14
-rw-r--r--components/script/dom/cssstylerule.rs17
-rw-r--r--components/script/dom/cssstylesheet.rs12
-rw-r--r--components/script/dom/document.rs4
-rw-r--r--components/script/dom/shadowroot.rs4
-rw-r--r--components/script/dom/stylesheetlist.rs1
6 files changed, 17 insertions, 35 deletions
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index bbb788cceeb..d623f46005a 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -13,7 +13,7 @@ use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::cssrule::CSSRule;
use crate::dom::element::Element;
-use crate::dom::node::{document_from_node, shadow_root_from_node, window_from_node, Node};
+use crate::dom::node::{document_from_node, stylesheets_owner_from_node, window_from_node, Node};
use crate::dom::window::Window;
use dom_struct::dom_struct;
use servo_arc::Arc;
@@ -115,16 +115,8 @@ impl CSSStyleOwner {
if changed {
// If this is changed, see also
// CSSStyleRule::SetSelectorText, which does the same thing.
- if let Some(shadow_root) =
- shadow_root_from_node(rule.parent_stylesheet().owner().upcast::<Node>())
- {
- shadow_root.invalidate_stylesheets();
- } else {
- rule.global()
- .as_window()
- .Document()
- .invalidate_stylesheets();
- }
+ stylesheets_owner_from_node(rule.parent_stylesheet().owner().upcast::<Node>())
+ .invalidate_stylesheets();
}
result
},
diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs
index 173661eb30a..14d7cdcdbef 100644
--- a/components/script/dom/cssstylerule.rs
+++ b/components/script/dom/cssstylerule.rs
@@ -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();
}
}
}
diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs
index 9863dede5cb..66d2fd8a339 100644
--- a/components/script/dom/cssstylesheet.rs
+++ b/components/script/dom/cssstylesheet.rs
@@ -4,7 +4,6 @@
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};
@@ -12,7 +11,7 @@ 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::node::{stylesheets_owner_from_node, Node};
use crate::dom::stylesheet::StyleSheet;
use crate::dom::window::Window;
use dom_struct::dom_struct;
@@ -87,14 +86,7 @@ impl CSSStyleSheet {
pub fn set_disabled(&self, disabled: bool) {
if self.style_stylesheet.set_disabled(disabled) {
- 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();
- }
+ stylesheets_owner_from_node(self.owner().upcast::<Node>()).invalidate_stylesheets();
}
}
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 72c25a8fa54..861271abe43 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -4661,4 +4661,8 @@ impl StyleSheetListOwner for Dom<Document> {
&mut *self.stylesheets.borrow_mut(),
)
}
+
+ fn invalidate_stylesheets(&self) {
+ Document::invalidate_stylesheets(self);
+ }
}
diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs
index dd47187836e..d99a5f3b3d7 100644
--- a/components/script/dom/shadowroot.rs
+++ b/components/script/dom/shadowroot.rs
@@ -237,4 +237,8 @@ impl StyleSheetListOwner for Dom<ShadowRoot> {
&mut self.author_styles.borrow_mut().stylesheets,
)
}
+
+ fn invalidate_stylesheets(&self) {
+ ShadowRoot::invalidate_stylesheets(self);
+ }
}
diff --git a/components/script/dom/stylesheetlist.rs b/components/script/dom/stylesheetlist.rs
index 930af55ae14..0b10680f52a 100644
--- a/components/script/dom/stylesheetlist.rs
+++ b/components/script/dom/stylesheetlist.rs
@@ -20,6 +20,7 @@ pub trait StyleSheetListOwner: JSTraceable {
fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>>;
fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>);
fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>);
+ fn invalidate_stylesheets(&self);
}
#[dom_struct]