mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Address review comments
This commit is contained in:
parent
18742e72fa
commit
95cbf1a885
2 changed files with 16 additions and 12 deletions
|
@ -54,6 +54,7 @@ impl CSSStyleSheetMethods for CSSStyleSheet {
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssrules
|
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssrules
|
||||||
fn CssRules(&self) -> Root<CSSRuleList> {
|
fn CssRules(&self) -> Root<CSSRuleList> {
|
||||||
// XXXManishearth check origin clean flag
|
// XXXManishearth check origin clean flag
|
||||||
|
// https://github.com/servo/servo/issues/14327
|
||||||
self.rulelist()
|
self.rulelist()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,13 +74,15 @@ impl CssRules {
|
||||||
// Provides the parser state at a given insertion index
|
// Provides the parser state at a given insertion index
|
||||||
pub fn state_at_index(rules: &[CssRule], at: usize) -> State {
|
pub fn state_at_index(rules: &[CssRule], at: usize) -> State {
|
||||||
let mut state = State::Start;
|
let mut state = State::Start;
|
||||||
for rule in rules.iter().take(at) {
|
if at > 0 {
|
||||||
state = match *rule {
|
if let Some(rule) = rules.get(at - 1) {
|
||||||
// CssRule::Charset(..) => State::Start,
|
state = match *rule {
|
||||||
// CssRule::Import(..) => State::Imports,
|
// CssRule::Charset(..) => State::Start,
|
||||||
CssRule::Namespace(..) => State::Namespaces,
|
// CssRule::Import(..) => State::Imports,
|
||||||
_ => State::Body,
|
CssRule::Namespace(..) => State::Namespaces,
|
||||||
};
|
_ => State::Body,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
state
|
state
|
||||||
}
|
}
|
||||||
|
@ -89,16 +91,16 @@ impl CssRules {
|
||||||
// searching in reverse. If inserting at this index, the parser
|
// searching in reverse. If inserting at this index, the parser
|
||||||
// must not be in a state greater than this post-insertion.
|
// must not be in a state greater than this post-insertion.
|
||||||
pub fn state_at_index_rev(rules: &[CssRule], at: usize) -> State {
|
pub fn state_at_index_rev(rules: &[CssRule], at: usize) -> State {
|
||||||
let mut state = State::Body;
|
if let Some(rule) = rules.get(at) {
|
||||||
for rule in rules.iter().skip(at).rev() {
|
match *rule {
|
||||||
state = match *rule {
|
|
||||||
// CssRule::Charset(..) => State::Start,
|
// CssRule::Charset(..) => State::Start,
|
||||||
// CssRule::Import(..) => State::Imports,
|
// CssRule::Import(..) => State::Imports,
|
||||||
CssRule::Namespace(..) => State::Namespaces,
|
CssRule::Namespace(..) => State::Namespaces,
|
||||||
_ => State::Body,
|
_ => State::Body,
|
||||||
};
|
}
|
||||||
|
} else {
|
||||||
|
State::Body
|
||||||
}
|
}
|
||||||
state
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +195,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,
|
||||||
context: context,
|
context: context,
|
||||||
state: Cell::new(state),
|
state: Cell::new(state),
|
||||||
namespaces: &mut namespaces,
|
namespaces: &mut namespaces,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue