mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #14395 - servo:stylesheet-metadata, r=Manishearth
Use stylesheet’s base URL and ns prefixes in CSSOM insert/appendRule. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14395) <!-- Reviewable:end -->
This commit is contained in:
commit
40917e7991
15 changed files with 143 additions and 112 deletions
|
@ -22,17 +22,18 @@ pub struct CSSFontFaceRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSFontFaceRule {
|
impl CSSFontFaceRule {
|
||||||
fn new_inherited(parent: Option<&CSSStyleSheet>, fontfacerule: Arc<RwLock<FontFaceRule>>) -> CSSFontFaceRule {
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, fontfacerule: Arc<RwLock<FontFaceRule>>)
|
||||||
|
-> CSSFontFaceRule {
|
||||||
CSSFontFaceRule {
|
CSSFontFaceRule {
|
||||||
cssrule: CSSRule::new_inherited(parent),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
fontfacerule: fontfacerule,
|
fontfacerule: fontfacerule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
fontfacerule: Arc<RwLock<FontFaceRule>>) -> Root<CSSFontFaceRule> {
|
fontfacerule: Arc<RwLock<FontFaceRule>>) -> Root<CSSFontFaceRule> {
|
||||||
reflect_dom_object(box CSSFontFaceRule::new_inherited(parent, fontfacerule),
|
reflect_dom_object(box CSSFontFaceRule::new_inherited(parent_stylesheet, fontfacerule),
|
||||||
window,
|
window,
|
||||||
CSSFontFaceRuleBinding::Wrap)
|
CSSFontFaceRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding;
|
||||||
use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMethods;
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleBinding::CSSRuleMethods;
|
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
|
@ -25,27 +24,26 @@ pub struct CSSGroupingRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSGroupingRule {
|
impl CSSGroupingRule {
|
||||||
pub fn new_inherited(parent: Option<&CSSStyleSheet>,
|
pub fn new_inherited(parent_stylesheet: &CSSStyleSheet,
|
||||||
rules: StyleCssRules) -> CSSGroupingRule {
|
rules: StyleCssRules) -> CSSGroupingRule {
|
||||||
CSSGroupingRule {
|
CSSGroupingRule {
|
||||||
cssrule: CSSRule::new_inherited(parent),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
rules: rules,
|
rules: rules,
|
||||||
rulelist: MutNullableHeap::new(None),
|
rulelist: MutNullableHeap::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>, rules: StyleCssRules) -> Root<CSSGroupingRule> {
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, rules: StyleCssRules) -> Root<CSSGroupingRule> {
|
||||||
reflect_dom_object(box CSSGroupingRule::new_inherited(parent, rules),
|
reflect_dom_object(box CSSGroupingRule::new_inherited(parent_stylesheet, rules),
|
||||||
window,
|
window,
|
||||||
CSSGroupingRuleBinding::Wrap)
|
CSSGroupingRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
fn rulelist(&self) -> Root<CSSRuleList> {
|
||||||
let sheet = self.upcast::<CSSRule>().GetParentStyleSheet();
|
let parent_stylesheet = self.upcast::<CSSRule>().parent_stylesheet();
|
||||||
let sheet = sheet.as_ref().map(|s| &**s);
|
|
||||||
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
||||||
sheet,
|
parent_stylesheet,
|
||||||
RulesSource::Rules(self.rules.clone())))
|
RulesSource::Rules(self.rules.clone())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,18 @@ pub struct CSSKeyframeRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSKeyframeRule {
|
impl CSSKeyframeRule {
|
||||||
fn new_inherited(parent: Option<&CSSStyleSheet>, keyframerule: Arc<RwLock<Keyframe>>) -> CSSKeyframeRule {
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, keyframerule: Arc<RwLock<Keyframe>>)
|
||||||
|
-> CSSKeyframeRule {
|
||||||
CSSKeyframeRule {
|
CSSKeyframeRule {
|
||||||
cssrule: CSSRule::new_inherited(parent),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
keyframerule: keyframerule,
|
keyframerule: keyframerule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
keyframerule: Arc<RwLock<Keyframe>>) -> Root<CSSKeyframeRule> {
|
keyframerule: Arc<RwLock<Keyframe>>) -> Root<CSSKeyframeRule> {
|
||||||
reflect_dom_object(box CSSKeyframeRule::new_inherited(parent, keyframerule),
|
reflect_dom_object(box CSSKeyframeRule::new_inherited(parent_stylesheet, keyframerule),
|
||||||
window,
|
window,
|
||||||
CSSKeyframeRuleBinding::Wrap)
|
CSSKeyframeRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
|
||||||
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods;
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
|
@ -20,7 +19,7 @@ use parking_lot::RwLock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::keyframes::{Keyframe, KeyframeSelector};
|
use style::keyframes::{Keyframe, KeyframeSelector};
|
||||||
use style::parser::ParserContextExtraData;
|
use style::parser::ParserContextExtraData;
|
||||||
use style::stylesheets::{KeyframesRule, Origin};
|
use style::stylesheets::KeyframesRule;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -32,28 +31,28 @@ pub struct CSSKeyframesRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSKeyframesRule {
|
impl CSSKeyframesRule {
|
||||||
fn new_inherited(parent: Option<&CSSStyleSheet>, keyframesrule: Arc<RwLock<KeyframesRule>>) -> CSSKeyframesRule {
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, keyframesrule: Arc<RwLock<KeyframesRule>>)
|
||||||
|
-> CSSKeyframesRule {
|
||||||
CSSKeyframesRule {
|
CSSKeyframesRule {
|
||||||
cssrule: CSSRule::new_inherited(parent),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
keyframesrule: keyframesrule,
|
keyframesrule: keyframesrule,
|
||||||
rulelist: MutNullableHeap::new(None),
|
rulelist: MutNullableHeap::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
keyframesrule: Arc<RwLock<KeyframesRule>>) -> Root<CSSKeyframesRule> {
|
keyframesrule: Arc<RwLock<KeyframesRule>>) -> Root<CSSKeyframesRule> {
|
||||||
reflect_dom_object(box CSSKeyframesRule::new_inherited(parent, keyframesrule),
|
reflect_dom_object(box CSSKeyframesRule::new_inherited(parent_stylesheet, keyframesrule),
|
||||||
window,
|
window,
|
||||||
CSSKeyframesRuleBinding::Wrap)
|
CSSKeyframesRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
fn rulelist(&self) -> Root<CSSRuleList> {
|
||||||
self.rulelist.or_init(|| {
|
self.rulelist.or_init(|| {
|
||||||
let sheet = self.upcast::<CSSRule>().GetParentStyleSheet();
|
let parent_stylesheet = &self.upcast::<CSSRule>().parent_stylesheet();
|
||||||
let sheet = sheet.as_ref().map(|s| &**s);
|
|
||||||
CSSRuleList::new(self.global().as_window(),
|
CSSRuleList::new(self.global().as_window(),
|
||||||
sheet,
|
parent_stylesheet,
|
||||||
RulesSource::Keyframes(self.keyframesrule.clone()))
|
RulesSource::Keyframes(self.keyframesrule.clone()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -84,8 +83,7 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
|
||||||
fn AppendRule(&self, rule: DOMString) {
|
fn AppendRule(&self, rule: DOMString) {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
let doc = window.Document();
|
let rule = Keyframe::parse(&rule, self.cssrule.parent_stylesheet().style_stylesheet(),
|
||||||
let rule = Keyframe::parse(&rule, Origin::Author, doc.url().clone(),
|
|
||||||
ParserContextExtraData::default());
|
ParserContextExtraData::default());
|
||||||
if let Ok(rule) = rule {
|
if let Ok(rule) = rule {
|
||||||
self.keyframesrule.write().keyframes.push(rule);
|
self.keyframesrule.write().keyframes.push(rule);
|
||||||
|
|
|
@ -23,18 +23,19 @@ pub struct CSSMediaRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSMediaRule {
|
impl CSSMediaRule {
|
||||||
fn new_inherited(parent: Option<&CSSStyleSheet>, mediarule: Arc<RwLock<MediaRule>>) -> CSSMediaRule {
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, mediarule: Arc<RwLock<MediaRule>>)
|
||||||
|
-> CSSMediaRule {
|
||||||
let list = mediarule.read().rules.clone();
|
let list = mediarule.read().rules.clone();
|
||||||
CSSMediaRule {
|
CSSMediaRule {
|
||||||
cssrule: CSSGroupingRule::new_inherited(parent, list),
|
cssrule: CSSGroupingRule::new_inherited(parent_stylesheet, list),
|
||||||
mediarule: mediarule,
|
mediarule: mediarule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
mediarule: Arc<RwLock<MediaRule>>) -> Root<CSSMediaRule> {
|
mediarule: Arc<RwLock<MediaRule>>) -> Root<CSSMediaRule> {
|
||||||
reflect_dom_object(box CSSMediaRule::new_inherited(parent, mediarule),
|
reflect_dom_object(box CSSMediaRule::new_inherited(parent_stylesheet, mediarule),
|
||||||
window,
|
window,
|
||||||
CSSMediaRuleBinding::Wrap)
|
CSSMediaRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,18 @@ pub struct CSSNamespaceRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSNamespaceRule {
|
impl CSSNamespaceRule {
|
||||||
fn new_inherited(parent: Option<&CSSStyleSheet>, namespacerule: Arc<RwLock<NamespaceRule>>) -> CSSNamespaceRule {
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, namespacerule: Arc<RwLock<NamespaceRule>>)
|
||||||
|
-> CSSNamespaceRule {
|
||||||
CSSNamespaceRule {
|
CSSNamespaceRule {
|
||||||
cssrule: CSSRule::new_inherited(parent),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
namespacerule: namespacerule,
|
namespacerule: namespacerule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
namespacerule: Arc<RwLock<NamespaceRule>>) -> Root<CSSNamespaceRule> {
|
namespacerule: Arc<RwLock<NamespaceRule>>) -> Root<CSSNamespaceRule> {
|
||||||
reflect_dom_object(box CSSNamespaceRule::new_inherited(parent, namespacerule),
|
reflect_dom_object(box CSSNamespaceRule::new_inherited(parent_stylesheet, namespacerule),
|
||||||
window,
|
window,
|
||||||
CSSNamespaceRuleBinding::Wrap)
|
CSSNamespaceRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSRuleBinding;
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssfontfacerule::CSSFontFaceRule;
|
use dom::cssfontfacerule::CSSFontFaceRule;
|
||||||
|
@ -17,27 +17,34 @@ use dom::cssstylerule::CSSStyleRule;
|
||||||
use dom::cssstylesheet::CSSStyleSheet;
|
use dom::cssstylesheet::CSSStyleSheet;
|
||||||
use dom::cssviewportrule::CSSViewportRule;
|
use dom::cssviewportrule::CSSViewportRule;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
use std::cell::Cell;
|
||||||
use style::stylesheets::CssRule as StyleCssRule;
|
use style::stylesheets::CssRule as StyleCssRule;
|
||||||
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct CSSRule {
|
pub struct CSSRule {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
parent: MutNullableHeap<JS<CSSStyleSheet>>,
|
parent_stylesheet: JS<CSSStyleSheet>,
|
||||||
|
|
||||||
|
/// Whether the parentStyleSheet attribute should return null.
|
||||||
|
/// We keep parent_stylesheet in that case because insertRule needs it
|
||||||
|
/// for the stylesheet’s base URL and namespace prefixes.
|
||||||
|
parent_stylesheet_removed: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSRule {
|
impl CSSRule {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new_inherited(parent: Option<&CSSStyleSheet>) -> CSSRule {
|
pub fn new_inherited(parent_stylesheet: &CSSStyleSheet) -> CSSRule {
|
||||||
CSSRule {
|
CSSRule {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
parent: MutNullableHeap::new(parent),
|
parent_stylesheet: JS::from_ref(parent_stylesheet),
|
||||||
|
parent_stylesheet_removed: Cell::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>) -> Root<CSSRule> {
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet) -> Root<CSSRule> {
|
||||||
reflect_dom_object(box CSSRule::new_inherited(parent),
|
reflect_dom_object(box CSSRule::new_inherited(parent_stylesheet),
|
||||||
window,
|
window,
|
||||||
CSSRuleBinding::Wrap)
|
CSSRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
@ -64,16 +71,16 @@ impl CSSRule {
|
||||||
|
|
||||||
// Given a StyleCssRule, create a new instance of a derived class of
|
// Given a StyleCssRule, create a new instance of a derived class of
|
||||||
// CSSRule based on which rule it is
|
// CSSRule based on which rule it is
|
||||||
pub fn new_specific(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new_specific(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
rule: StyleCssRule) -> Root<CSSRule> {
|
rule: StyleCssRule) -> Root<CSSRule> {
|
||||||
// be sure to update the match in as_specific when this is updated
|
// be sure to update the match in as_specific when this is updated
|
||||||
match rule {
|
match rule {
|
||||||
StyleCssRule::Style(s) => Root::upcast(CSSStyleRule::new(window, parent, s)),
|
StyleCssRule::Style(s) => Root::upcast(CSSStyleRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::FontFace(s) => Root::upcast(CSSFontFaceRule::new(window, parent, s)),
|
StyleCssRule::FontFace(s) => Root::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Keyframes(s) => Root::upcast(CSSKeyframesRule::new(window, parent, s)),
|
StyleCssRule::Keyframes(s) => Root::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Media(s) => Root::upcast(CSSMediaRule::new(window, parent, s)),
|
StyleCssRule::Media(s) => Root::upcast(CSSMediaRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Namespace(s) => Root::upcast(CSSNamespaceRule::new(window, parent, s)),
|
StyleCssRule::Namespace(s) => Root::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Viewport(s) => Root::upcast(CSSViewportRule::new(window, parent, s)),
|
StyleCssRule::Viewport(s) => Root::upcast(CSSViewportRule::new(window, parent_stylesheet, s)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +92,16 @@ impl CSSRule {
|
||||||
|
|
||||||
/// Sets owner sheet to null (and does the same for all children)
|
/// Sets owner sheet to null (and does the same for all children)
|
||||||
pub fn deparent(&self) {
|
pub fn deparent(&self) {
|
||||||
self.parent.set(None);
|
self.parent_stylesheet_removed.set(true);
|
||||||
// https://github.com/w3c/csswg-drafts/issues/722
|
// https://github.com/w3c/csswg-drafts/issues/722
|
||||||
// Spec doesn't ask us to do this, but it makes sense
|
// Spec doesn't ask us to do this, but it makes sense
|
||||||
// and browsers implement this behavior
|
// and browsers implement this behavior
|
||||||
self.as_specific().deparent_children();
|
self.as_specific().deparent_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parent_stylesheet(&self) -> &CSSStyleSheet {
|
||||||
|
&self.parent_stylesheet
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSRuleMethods for CSSRule {
|
impl CSSRuleMethods for CSSRule {
|
||||||
|
@ -101,7 +112,11 @@ impl CSSRuleMethods for CSSRule {
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssrule-parentstylesheet
|
// https://drafts.csswg.org/cssom/#dom-cssrule-parentstylesheet
|
||||||
fn GetParentStyleSheet(&self) -> Option<Root<CSSStyleSheet>> {
|
fn GetParentStyleSheet(&self) -> Option<Root<CSSStyleSheet>> {
|
||||||
self.parent.get()
|
if self.parent_stylesheet_removed.get() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(Root::from_ref(&*self.parent_stylesheet))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssrule-csstext
|
// https://drafts.csswg.org/cssom/#dom-cssrule-csstext
|
||||||
|
@ -118,7 +133,7 @@ impl CSSRuleMethods for CSSRule {
|
||||||
pub trait SpecificCSSRule {
|
pub trait SpecificCSSRule {
|
||||||
fn ty(&self) -> u16;
|
fn ty(&self) -> u16;
|
||||||
fn get_css(&self) -> DOMString;
|
fn get_css(&self) -> DOMString;
|
||||||
/// Remove CSSStyleSheet parent from all transitive children
|
/// Remove parentStylesheet from all transitive children
|
||||||
fn deparent_children(&self) {
|
fn deparent_children(&self) {
|
||||||
// most CSSRules do nothing here
|
// most CSSRules do nothing here
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl From<RulesMutateError> for Error {
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct CSSRuleList {
|
pub struct CSSRuleList {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
sheet: MutNullableHeap<JS<CSSStyleSheet>>,
|
parent_stylesheet: JS<CSSStyleSheet>,
|
||||||
#[ignore_heap_size_of = "Arc"]
|
#[ignore_heap_size_of = "Arc"]
|
||||||
rules: RulesSource,
|
rules: RulesSource,
|
||||||
dom_rules: DOMRefCell<Vec<MutNullableHeap<JS<CSSRule>>>>
|
dom_rules: DOMRefCell<Vec<MutNullableHeap<JS<CSSRule>>>>
|
||||||
|
@ -47,7 +47,7 @@ pub enum RulesSource {
|
||||||
|
|
||||||
impl CSSRuleList {
|
impl CSSRuleList {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new_inherited(sheet: Option<&CSSStyleSheet>, rules: RulesSource) -> CSSRuleList {
|
pub fn new_inherited(parent_stylesheet: &CSSStyleSheet, rules: RulesSource) -> CSSRuleList {
|
||||||
let dom_rules = match rules {
|
let dom_rules = match rules {
|
||||||
RulesSource::Rules(ref rules) => {
|
RulesSource::Rules(ref rules) => {
|
||||||
rules.0.read().iter().map(|_| MutNullableHeap::new(None)).collect()
|
rules.0.read().iter().map(|_| MutNullableHeap::new(None)).collect()
|
||||||
|
@ -59,16 +59,16 @@ impl CSSRuleList {
|
||||||
|
|
||||||
CSSRuleList {
|
CSSRuleList {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
sheet: MutNullableHeap::new(sheet),
|
parent_stylesheet: JS::from_ref(parent_stylesheet),
|
||||||
rules: rules,
|
rules: rules,
|
||||||
dom_rules: DOMRefCell::new(dom_rules),
|
dom_rules: DOMRefCell::new(dom_rules),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, sheet: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
rules: RulesSource) -> Root<CSSRuleList> {
|
rules: RulesSource) -> Root<CSSRuleList> {
|
||||||
reflect_dom_object(box CSSRuleList::new_inherited(sheet, rules),
|
reflect_dom_object(box CSSRuleList::new_inherited(parent_stylesheet, rules),
|
||||||
window,
|
window,
|
||||||
CSSRuleListBinding::Wrap)
|
CSSRuleListBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
@ -84,14 +84,13 @@ impl CSSRuleList {
|
||||||
|
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
let doc = window.Document();
|
|
||||||
let index = idx as usize;
|
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 sheet = self.sheet.get();
|
let parent_stylesheet = &*self.parent_stylesheet;
|
||||||
let sheet = sheet.as_ref().map(|sheet| &**sheet);
|
let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule);
|
||||||
let dom_rule = CSSRule::new_specific(&window, sheet, new_rule);
|
|
||||||
self.dom_rules.borrow_mut().insert(index, MutNullableHeap::new(Some(&*dom_rule)));
|
self.dom_rules.borrow_mut().insert(index, MutNullableHeap::new(Some(&*dom_rule)));
|
||||||
Ok((idx))
|
Ok((idx))
|
||||||
}
|
}
|
||||||
|
@ -129,17 +128,16 @@ impl CSSRuleList {
|
||||||
pub fn item(&self, idx: u32) -> Option<Root<CSSRule>> {
|
pub fn item(&self, idx: u32) -> Option<Root<CSSRule>> {
|
||||||
self.dom_rules.borrow().get(idx as usize).map(|rule| {
|
self.dom_rules.borrow().get(idx as usize).map(|rule| {
|
||||||
rule.or_init(|| {
|
rule.or_init(|| {
|
||||||
let sheet = self.sheet.get();
|
let parent_stylesheet = &self.parent_stylesheet;
|
||||||
let sheet = sheet.as_ref().map(|sheet| &**sheet);
|
|
||||||
match self.rules {
|
match self.rules {
|
||||||
RulesSource::Rules(ref rules) => {
|
RulesSource::Rules(ref rules) => {
|
||||||
CSSRule::new_specific(self.global().as_window(),
|
CSSRule::new_specific(self.global().as_window(),
|
||||||
sheet,
|
parent_stylesheet,
|
||||||
rules.0.read()[idx as usize].clone())
|
rules.0.read()[idx as usize].clone())
|
||||||
}
|
}
|
||||||
RulesSource::Keyframes(ref rules) => {
|
RulesSource::Keyframes(ref rules) => {
|
||||||
Root::upcast(CSSKeyframeRule::new(self.global().as_window(),
|
Root::upcast(CSSKeyframeRule::new(self.global().as_window(),
|
||||||
sheet,
|
parent_stylesheet,
|
||||||
rules.read()
|
rules.read()
|
||||||
.keyframes[idx as usize]
|
.keyframes[idx as usize]
|
||||||
.clone()))
|
.clone()))
|
||||||
|
|
|
@ -22,17 +22,18 @@ pub struct CSSStyleRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSStyleRule {
|
impl CSSStyleRule {
|
||||||
fn new_inherited(parent: Option<&CSSStyleSheet>, stylerule: Arc<RwLock<StyleRule>>) -> CSSStyleRule {
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, stylerule: Arc<RwLock<StyleRule>>)
|
||||||
|
-> CSSStyleRule {
|
||||||
CSSStyleRule {
|
CSSStyleRule {
|
||||||
cssrule: CSSRule::new_inherited(parent),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
stylerule: stylerule,
|
stylerule: stylerule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
stylerule: Arc<RwLock<StyleRule>>) -> Root<CSSStyleRule> {
|
stylerule: Arc<RwLock<StyleRule>>) -> Root<CSSStyleRule> {
|
||||||
reflect_dom_object(box CSSStyleRule::new_inherited(parent, stylerule),
|
reflect_dom_object(box CSSStyleRule::new_inherited(parent_stylesheet, stylerule),
|
||||||
window,
|
window,
|
||||||
CSSStyleRuleBinding::Wrap)
|
CSSStyleRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl CSSStyleSheet {
|
||||||
|
|
||||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
fn rulelist(&self) -> Root<CSSRuleList> {
|
||||||
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
||||||
Some(self),
|
self,
|
||||||
RulesSource::Rules(self.style_stylesheet
|
RulesSource::Rules(self.style_stylesheet
|
||||||
.rules.clone())))
|
.rules.clone())))
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,10 @@ impl CSSStyleSheet {
|
||||||
self.global().as_window().Document().invalidate_stylesheets();
|
self.global().as_window().Document().invalidate_stylesheets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn style_stylesheet(&self) -> &StyleStyleSheet {
|
||||||
|
&self.style_stylesheet
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSStyleSheetMethods for CSSStyleSheet {
|
impl CSSStyleSheetMethods for CSSStyleSheet {
|
||||||
|
|
|
@ -22,17 +22,17 @@ pub struct CSSViewportRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSViewportRule {
|
impl CSSViewportRule {
|
||||||
fn new_inherited(parent: Option<&CSSStyleSheet>, viewportrule: Arc<RwLock<ViewportRule>>) -> CSSViewportRule {
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, viewportrule: Arc<RwLock<ViewportRule>>) -> CSSViewportRule {
|
||||||
CSSViewportRule {
|
CSSViewportRule {
|
||||||
cssrule: CSSRule::new_inherited(parent),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
viewportrule: viewportrule,
|
viewportrule: viewportrule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent: Option<&CSSStyleSheet>,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
viewportrule: Arc<RwLock<ViewportRule>>) -> Root<CSSViewportRule> {
|
viewportrule: Arc<RwLock<ViewportRule>>) -> Root<CSSViewportRule> {
|
||||||
reflect_dom_object(box CSSViewportRule::new_inherited(parent, viewportrule),
|
reflect_dom_object(box CSSViewportRule::new_inherited(parent_stylesheet, viewportrule),
|
||||||
window,
|
window,
|
||||||
CSSViewportRuleBinding::Wrap)
|
CSSViewportRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,8 @@ impl HTMLMetaElement {
|
||||||
*self.stylesheet.borrow_mut() = Some(Arc::new(Stylesheet {
|
*self.stylesheet.borrow_mut() = Some(Arc::new(Stylesheet {
|
||||||
rules: vec![CssRule::Viewport(Arc::new(RwLock::new(translated_rule)))].into(),
|
rules: vec![CssRule::Viewport(Arc::new(RwLock::new(translated_rule)))].into(),
|
||||||
origin: Origin::Author,
|
origin: Origin::Author,
|
||||||
|
base_url: window_from_node(self).get_url(),
|
||||||
|
namespaces: Default::default(),
|
||||||
media: Default::default(),
|
media: Default::default(),
|
||||||
// Viewport constraints are always recomputed on resize; they don't need to
|
// Viewport constraints are always recomputed on resize; they don't need to
|
||||||
// force all styles to be recomputed.
|
// force all styles to be recomputed.
|
||||||
|
|
|
@ -9,11 +9,10 @@ use parser::{ParserContext, ParserContextExtraData, log_css_error};
|
||||||
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
||||||
use properties::PropertyDeclarationParseResult;
|
use properties::PropertyDeclarationParseResult;
|
||||||
use properties::animated_properties::TransitionProperty;
|
use properties::animated_properties::TransitionProperty;
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use stylesheets::{MemoryHoleReporter, Origin};
|
use stylesheets::{MemoryHoleReporter, Stylesheet};
|
||||||
|
|
||||||
/// A number from 1 to 100, indicating the percentage of the animation where
|
/// A number from 1 to 100, indicating the percentage of the animation where
|
||||||
/// this keyframe should run.
|
/// this keyframe should run.
|
||||||
|
@ -108,11 +107,11 @@ impl ToCss for Keyframe {
|
||||||
|
|
||||||
|
|
||||||
impl Keyframe {
|
impl Keyframe {
|
||||||
pub fn parse(css: &str, origin: Origin,
|
pub fn parse(css: &str, parent_stylesheet: &Stylesheet, extra_data: ParserContextExtraData)
|
||||||
base_url: ServoUrl,
|
-> Result<Arc<RwLock<Self>>, ()> {
|
||||||
extra_data: ParserContextExtraData) -> Result<Arc<RwLock<Self>>, ()> {
|
|
||||||
let error_reporter = Box::new(MemoryHoleReporter);
|
let error_reporter = Box::new(MemoryHoleReporter);
|
||||||
let context = ParserContext::new_with_extra_data(origin, &base_url,
|
let context = ParserContext::new_with_extra_data(parent_stylesheet.origin,
|
||||||
|
&parent_stylesheet.base_url,
|
||||||
error_reporter,
|
error_reporter,
|
||||||
extra_data);
|
extra_data);
|
||||||
let mut input = Parser::new(css);
|
let mut input = Parser::new(css);
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub enum Origin {
|
||||||
User,
|
User,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct Namespaces {
|
pub struct Namespaces {
|
||||||
pub default: Option<Namespace>,
|
pub default: Option<Namespace>,
|
||||||
|
@ -88,7 +88,7 @@ impl CssRules {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#insert-a-css-rule
|
// https://drafts.csswg.org/cssom/#insert-a-css-rule
|
||||||
pub fn insert_rule(&self, rule: &str, base_url: ServoUrl, index: usize, nested: bool)
|
pub fn insert_rule(&self, rule: &str, parent_stylesheet: &Stylesheet, index: usize, nested: bool)
|
||||||
-> Result<CssRule, RulesMutateError> {
|
-> Result<CssRule, RulesMutateError> {
|
||||||
let mut rules = self.0.write();
|
let mut rules = self.0.write();
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ impl CssRules {
|
||||||
|
|
||||||
// Step 3, 4
|
// Step 3, 4
|
||||||
// XXXManishearth should we also store the namespace map?
|
// XXXManishearth should we also store the namespace map?
|
||||||
let (new_rule, new_state) = try!(CssRule::parse(&rule, Origin::Author, base_url,
|
let (new_rule, new_state) = try!(CssRule::parse(&rule, parent_stylesheet,
|
||||||
ParserContextExtraData::default(), state));
|
ParserContextExtraData::default(), state));
|
||||||
|
|
||||||
// Step 5
|
// Step 5
|
||||||
|
@ -166,6 +166,8 @@ pub struct Stylesheet {
|
||||||
/// List of media associated with the Stylesheet.
|
/// List of media associated with the Stylesheet.
|
||||||
pub media: Arc<RwLock<MediaList>>,
|
pub media: Arc<RwLock<MediaList>>,
|
||||||
pub origin: Origin,
|
pub origin: Origin,
|
||||||
|
pub base_url: ServoUrl,
|
||||||
|
pub namespaces: RwLock<Namespaces>,
|
||||||
pub dirty_on_viewport_size_change: AtomicBool,
|
pub dirty_on_viewport_size_change: AtomicBool,
|
||||||
pub disabled: AtomicBool,
|
pub disabled: AtomicBool,
|
||||||
}
|
}
|
||||||
|
@ -280,13 +282,15 @@ impl CssRule {
|
||||||
|
|
||||||
// input state is None for a nested rule
|
// input state is None for a nested rule
|
||||||
// Returns a parsed CSS rule and the final state of the parser
|
// Returns a parsed CSS rule and the final state of the parser
|
||||||
pub fn parse(css: &str, origin: Origin,
|
pub fn parse(css: &str,
|
||||||
base_url: ServoUrl,
|
parent_stylesheet: &Stylesheet,
|
||||||
extra_data: ParserContextExtraData,
|
extra_data: ParserContextExtraData,
|
||||||
state: Option<State>) -> Result<(Self, State), SingleRuleParseError> {
|
state: Option<State>)
|
||||||
|
-> Result<(Self, State), SingleRuleParseError> {
|
||||||
let error_reporter = Box::new(MemoryHoleReporter);
|
let error_reporter = Box::new(MemoryHoleReporter);
|
||||||
let mut namespaces = Namespaces::default();
|
let mut namespaces = parent_stylesheet.namespaces.write();
|
||||||
let context = ParserContext::new_with_extra_data(origin, &base_url,
|
let context = ParserContext::new_with_extra_data(parent_stylesheet.origin,
|
||||||
|
&parent_stylesheet.base_url,
|
||||||
error_reporter.clone(),
|
error_reporter.clone(),
|
||||||
extra_data);
|
extra_data);
|
||||||
let mut input = Parser::new(css);
|
let mut input = Parser::new(css);
|
||||||
|
@ -294,7 +298,7 @@ impl CssRule {
|
||||||
// nested rules are in the body state
|
// nested rules are in the body state
|
||||||
let state = state.unwrap_or(State::Body);
|
let state = state.unwrap_or(State::Body);
|
||||||
let mut rule_parser = TopLevelRuleParser {
|
let mut rule_parser = TopLevelRuleParser {
|
||||||
stylesheet_origin: origin,
|
stylesheet_origin: parent_stylesheet.origin,
|
||||||
context: context,
|
context: context,
|
||||||
state: Cell::new(state),
|
state: Cell::new(state),
|
||||||
namespaces: &mut namespaces,
|
namespaces: &mut namespaces,
|
||||||
|
@ -435,17 +439,17 @@ impl Stylesheet {
|
||||||
error_reporter: Box<ParseErrorReporter + Send>,
|
error_reporter: Box<ParseErrorReporter + Send>,
|
||||||
extra_data: ParserContextExtraData) -> Stylesheet {
|
extra_data: ParserContextExtraData) -> Stylesheet {
|
||||||
let mut namespaces = Namespaces::default();
|
let mut namespaces = Namespaces::default();
|
||||||
|
let mut rules = vec![];
|
||||||
|
let dirty_on_viewport_size_change;
|
||||||
|
{
|
||||||
let rule_parser = TopLevelRuleParser {
|
let rule_parser = TopLevelRuleParser {
|
||||||
stylesheet_origin: origin,
|
stylesheet_origin: origin,
|
||||||
namespaces: &mut namespaces,
|
namespaces: &mut namespaces,
|
||||||
context: ParserContext::new_with_extra_data(origin, &base_url, error_reporter.clone(),
|
context: ParserContext::new_with_extra_data(origin, &base_url, error_reporter, extra_data),
|
||||||
extra_data),
|
|
||||||
state: Cell::new(State::Start),
|
state: Cell::new(State::Start),
|
||||||
};
|
};
|
||||||
let mut input = Parser::new(css);
|
let mut input = Parser::new(css);
|
||||||
input.look_for_viewport_percentages();
|
input.look_for_viewport_percentages();
|
||||||
|
|
||||||
let mut rules = vec![];
|
|
||||||
{
|
{
|
||||||
let mut iter = RuleListParser::new_for_stylesheet(&mut input, rule_parser);
|
let mut iter = RuleListParser::new_for_stylesheet(&mut input, rule_parser);
|
||||||
while let Some(result) = iter.next() {
|
while let Some(result) = iter.next() {
|
||||||
|
@ -454,18 +458,21 @@ impl Stylesheet {
|
||||||
Err(range) => {
|
Err(range) => {
|
||||||
let pos = range.start;
|
let pos = range.start;
|
||||||
let message = format!("Invalid rule: '{}'", iter.input.slice(range));
|
let message = format!("Invalid rule: '{}'", iter.input.slice(range));
|
||||||
let context = ParserContext::new(origin, &base_url, error_reporter.clone());
|
log_css_error(iter.input, pos, &*message, &iter.parser.context);
|
||||||
log_css_error(iter.input, pos, &*message, &context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dirty_on_viewport_size_change = input.seen_viewport_percentages();
|
||||||
|
}
|
||||||
|
|
||||||
Stylesheet {
|
Stylesheet {
|
||||||
origin: origin,
|
origin: origin,
|
||||||
|
base_url: base_url,
|
||||||
|
namespaces: RwLock::new(namespaces),
|
||||||
rules: rules.into(),
|
rules: rules.into(),
|
||||||
media: Arc::new(RwLock::new(media)),
|
media: Arc::new(RwLock::new(media)),
|
||||||
dirty_on_viewport_size_change: AtomicBool::new(input.seen_viewport_percentages()),
|
dirty_on_viewport_size_change: AtomicBool::new(dirty_on_viewport_size_change),
|
||||||
disabled: AtomicBool::new(false),
|
disabled: AtomicBool::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ use style::parser::ParserContextExtraData;
|
||||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue, longhands};
|
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue, longhands};
|
||||||
use style::properties::Importance;
|
use style::properties::Importance;
|
||||||
use style::properties::longhands::animation_play_state;
|
use style::properties::longhands::animation_play_state;
|
||||||
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, StyleRule, KeyframesRule, Origin};
|
use style::stylesheets::{Origin, Namespaces};
|
||||||
|
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, StyleRule, KeyframesRule};
|
||||||
use style::values::specified::{LengthOrPercentageOrAuto, Percentage};
|
use style::values::specified::{LengthOrPercentageOrAuto, Percentage};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -50,12 +51,16 @@ fn test_parse_stylesheet() {
|
||||||
}
|
}
|
||||||
}";
|
}";
|
||||||
let url = ServoUrl::parse("about::test").unwrap();
|
let url = ServoUrl::parse("about::test").unwrap();
|
||||||
let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent, Default::default(),
|
let stylesheet = Stylesheet::from_str(css, url.clone(), Origin::UserAgent, Default::default(),
|
||||||
Box::new(CSSErrorReporterTest),
|
Box::new(CSSErrorReporterTest),
|
||||||
ParserContextExtraData::default());
|
ParserContextExtraData::default());
|
||||||
|
let mut namespaces = Namespaces::default();
|
||||||
|
namespaces.default = Some(ns!(html));
|
||||||
let expected = Stylesheet {
|
let expected = Stylesheet {
|
||||||
origin: Origin::UserAgent,
|
origin: Origin::UserAgent,
|
||||||
media: Default::default(),
|
media: Default::default(),
|
||||||
|
namespaces: RwLock::new(namespaces),
|
||||||
|
base_url: url,
|
||||||
dirty_on_viewport_size_change: AtomicBool::new(false),
|
dirty_on_viewport_size_change: AtomicBool::new(false),
|
||||||
disabled: AtomicBool::new(false),
|
disabled: AtomicBool::new(false),
|
||||||
rules: vec![
|
rules: vec![
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue