stylo: Fix StyleSheetInner/Stylesheet mapping

The key of this patch is the split between Stylesheet and StylesheetContents.

Gecko will use StylesheetContents, which maps to a ServoStyleSheetInner.
This commit is contained in:
Emilio Cobos Álvarez 2017-06-28 12:12:14 -07:00
parent fd65ac8924
commit 1263075776
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
38 changed files with 3818 additions and 2931 deletions

View file

@ -82,7 +82,13 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-appendrule
fn AppendRule(&self, rule: DOMString) {
let rule = Keyframe::parse(&rule, self.cssrule.parent_stylesheet().style_stylesheet());
let style_stylesheet = self.cssrule.parent_stylesheet().style_stylesheet();
let rule = Keyframe::parse(
&rule,
&style_stylesheet.contents,
&style_stylesheet.shared_lock
);
if let Ok(rule) = rule {
let mut guard = self.cssrule.shared_lock().write();
self.keyframesrule.write_with(&mut guard).keyframes.push(rule);

View file

@ -93,7 +93,7 @@ impl CSSRuleList {
let new_rule =
css_rules.insert_rule(&parent_stylesheet.shared_lock,
rule,
parent_stylesheet,
&parent_stylesheet.contents,
index,
nested,
None)?;

View file

@ -146,7 +146,7 @@ impl CSSStyleOwner {
match *self {
CSSStyleOwner::Element(ref el) => window_from_node(&**el).Document().base_url(),
CSSStyleOwner::CSSRule(ref rule, _) => {
(*rule.parent_stylesheet().style_stylesheet().url_data.read()).clone()
(*rule.parent_stylesheet().style_stylesheet().contents.url_data.read()).clone()
}
}
}

View file

@ -57,10 +57,14 @@ impl CSSStyleSheet {
}
fn rulelist(&self) -> Root<CSSRuleList> {
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
self,
RulesSource::Rules(self.style_stylesheet
.rules.clone())))
self.rulelist.or_init(|| {
let rules = self.style_stylesheet.contents.rules.clone();
CSSRuleList::new(
self.global().as_window(),
self,
RulesSource::Rules(rules)
)
})
}
pub fn disabled(&self) -> bool {

View file

@ -27,7 +27,7 @@ use style::attr::AttrValue;
use style::media_queries::MediaList;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylearc::Arc;
use style::stylesheets::{Stylesheet, CssRule, CssRules, Origin, ViewportRule};
use style::stylesheets::{Stylesheet, StylesheetContents, CssRule, CssRules, Origin, ViewportRule};
#[dom_struct]
pub struct HTMLMetaElement {
@ -103,17 +103,20 @@ impl HTMLMetaElement {
let shared_lock = document.style_shared_lock();
let rule = CssRule::Viewport(Arc::new(shared_lock.wrap(translated_rule)));
*self.stylesheet.borrow_mut() = Some(Arc::new(Stylesheet {
rules: CssRules::new(vec![rule], shared_lock),
origin: Origin::Author,
shared_lock: shared_lock.clone(),
url_data: RwLock::new(window_from_node(self).get_url()),
namespaces: Default::default(),
contents: StylesheetContents {
rules: CssRules::new(vec![rule], shared_lock),
origin: Origin::Author,
namespaces: Default::default(),
quirks_mode: document.quirks_mode(),
url_data: RwLock::new(window_from_node(self).get_url()),
// Viewport constraints are always recomputed on
// resize; they don't need to force all styles to be
// recomputed.
dirty_on_viewport_size_change: AtomicBool::new(false),
},
media: Arc::new(shared_lock.wrap(MediaList::empty())),
// Viewport constraints are always recomputed on resize; they don't need to
// force all styles to be recomputed.
dirty_on_viewport_size_change: AtomicBool::new(false),
shared_lock: shared_lock.clone(),
disabled: AtomicBool::new(false),
quirks_mode: document.quirks_mode(),
}));
let doc = document_from_node(self);
doc.invalidate_stylesheets();