Use stylesheet’s base URL and ns prefixes in CSSOM insert/appendRule.

This commit is contained in:
Simon Sapin 2016-11-28 17:48:32 +01:00
parent f1d49d3773
commit 70b250fe2a
5 changed files with 24 additions and 20 deletions

View file

@ -19,7 +19,7 @@ use parking_lot::RwLock;
use std::sync::Arc;
use style::keyframes::{Keyframe, KeyframeSelector};
use style::parser::ParserContextExtraData;
use style::stylesheets::{KeyframesRule, Origin};
use style::stylesheets::KeyframesRule;
use style_traits::ToCss;
#[dom_struct]
@ -83,8 +83,7 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
fn AppendRule(&self, rule: DOMString) {
let global = self.global();
let window = global.as_window();
let doc = window.Document();
let rule = Keyframe::parse(&rule, Origin::Author, doc.url().clone(),
let rule = Keyframe::parse(&rule, self.cssrule.parent_stylesheet().style_stylesheet(),
ParserContextExtraData::default());
if let Ok(rule) = rule {
self.keyframesrule.write().keyframes.push(rule);

View file

@ -84,10 +84,10 @@ impl CSSRuleList {
let global = self.global();
let window = global.as_window();
let doc = window.Document();
let index = idx as usize;
let new_rule = css_rules.insert_rule(rule, doc.url().clone(), index, nested)?;
let parent_stylesheet = self.parent_stylesheet.style_stylesheet();
let new_rule = css_rules.insert_rule(rule, parent_stylesheet, index, nested)?;
let parent_stylesheet = &*self.parent_stylesheet;
let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule);

View file

@ -67,6 +67,10 @@ impl CSSStyleSheet {
self.global().as_window().Document().invalidate_stylesheets();
}
}
pub fn style_stylesheet(&self) -> &StyleStyleSheet {
&self.style_stylesheet
}
}
impl CSSStyleSheetMethods for CSSStyleSheet {