aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/cssrule.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-11-16 17:48:54 -0800
committerManish Goregaokar <manishsmail@gmail.com>2016-11-23 09:32:42 -0800
commitcada5d7c0354d82c0ba6053f772eb5b8b3f6d954 (patch)
tree1074317de8e2326e18aaea2bfe03ea334e028e22 /components/script/dom/cssrule.rs
parent53c99662bce82d9975c1a91e66cfdf1197ff53a2 (diff)
downloadservo-cada5d7c0354d82c0ba6053f772eb5b8b3f6d954.tar.gz
servo-cada5d7c0354d82c0ba6053f772eb5b8b3f6d954.zip
Transitively deparent on removal
Chrome and Firefox do this already, probably a spec oversight
Diffstat (limited to 'components/script/dom/cssrule.rs')
-rw-r--r--components/script/dom/cssrule.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/components/script/dom/cssrule.rs b/components/script/dom/cssrule.rs
index 7b1edcab045..ca1e52b77f0 100644
--- a/components/script/dom/cssrule.rs
+++ b/components/script/dom/cssrule.rs
@@ -9,8 +9,8 @@ use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::cssfontfacerule::CSSFontFaceRule;
-use dom::csskeyframesrule::CSSKeyframesRule;
use dom::csskeyframerule::CSSKeyframeRule;
+use dom::csskeyframesrule::CSSKeyframesRule;
use dom::cssmediarule::CSSMediaRule;
use dom::cssnamespacerule::CSSNamespaceRule;
use dom::cssstylerule::CSSStyleRule;
@@ -78,10 +78,18 @@ impl CSSRule {
}
/// Sets owner sheet/rule to null
- pub fn disown(&self) {
- self.parent.set(None);
+ pub fn detach(&self) {
+ self.deparent();
// should set parent rule to None when we add parent rule support
- // Should we disown children as well? (https://github.com/w3c/csswg-drafts/issues/722)
+ }
+
+ /// Sets owner sheet to null (and does the same for all children)
+ pub fn deparent(&self) {
+ self.parent.set(None);
+ // https://github.com/w3c/csswg-drafts/issues/722
+ // Spec doesn't ask us to do this, but it makes sense
+ // and browsers implement this behavior
+ self.as_specific().deparent_children();
}
}
@@ -110,4 +118,8 @@ impl CSSRuleMethods for CSSRule {
pub trait SpecificCSSRule {
fn ty(&self) -> u16;
fn get_css(&self) -> DOMString;
+ /// Remove CSSStyleSheet parent from all transitive children
+ fn deparent_children(&self) {
+ // most CSSRules do nothing here
+ }
}