mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
style: Update cssparser to get ParserState in rule parser.
The changes should be trivial. The third_party changes are up for review in https://github.com/servo/rust-cssparser/pull/277 (and of course I'll land with a bump to 0.28 rather than the override after that gets r+'d). The basic idea is that with this we have the actual start offset of the rule, so we wouldn't include html comments or other invalid stuff we discard during sanitization in bug 1680084. But that's a separate change. Differential Revision: https://phabricator.services.mozilla.com/D98677
This commit is contained in:
parent
5277275263
commit
bd2566d391
4 changed files with 26 additions and 26 deletions
|
@ -35,7 +35,7 @@ arrayvec = "0.5"
|
|||
atomic_refcell = "0.1"
|
||||
bitflags = "1.0"
|
||||
byteorder = "1.0"
|
||||
cssparser = "0.27"
|
||||
cssparser = "0.28"
|
||||
derive_more = "0.99"
|
||||
encoding_rs = { version = "0.8", optional = true }
|
||||
euclid = "0.22"
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::values::serialize_atom_identifier;
|
|||
use crate::Atom;
|
||||
use cssparser::{AtRuleParser, AtRuleType, BasicParseErrorKind, CowRcStr};
|
||||
use cssparser::{DeclarationListParser, DeclarationParser, Parser};
|
||||
use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, Token};
|
||||
use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, ParserState, Token};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
|
||||
|
@ -413,7 +413,7 @@ macro_rules! font_feature_values_blocks {
|
|||
fn parse_block<'t>(
|
||||
&mut self,
|
||||
prelude: BlockType,
|
||||
_location: SourceLocation,
|
||||
_: &ParserState,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self::AtRule, ParseError<'i>> {
|
||||
debug_assert_eq!(self.context.rule_type(), CssRuleType::FontFeatureValues);
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::str::CssStringWriter;
|
|||
use crate::stylesheets::rule_parser::VendorPrefix;
|
||||
use crate::stylesheets::{CssRuleType, StylesheetContents};
|
||||
use crate::values::{serialize_percentage, KeyframesName};
|
||||
use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, SourceLocation, Token};
|
||||
use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, ParserState, SourceLocation, Token};
|
||||
use cssparser::{AtRuleParser, CowRcStr, Parser, ParserInput, QualifiedRuleParser, RuleListParser};
|
||||
use servo_arc::Arc;
|
||||
use std::fmt::{self, Write};
|
||||
|
@ -533,7 +533,7 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> {
|
|||
fn parse_block<'t>(
|
||||
&mut self,
|
||||
selector: Self::Prelude,
|
||||
source_location: SourceLocation,
|
||||
start: &ParserState,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self::QualifiedRule, ParseError<'i>> {
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
|
@ -566,7 +566,7 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> {
|
|||
Ok(Arc::new(self.shared_lock.wrap(Keyframe {
|
||||
selector,
|
||||
block: Arc::new(self.shared_lock.wrap(block)),
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use crate::values::computed::font::FamilyName;
|
|||
use crate::values::{CssUrl, CustomIdent, KeyframesName};
|
||||
use crate::{Namespace, Prefix};
|
||||
use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser};
|
||||
use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, SourceLocation};
|
||||
use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, ParserState};
|
||||
use selectors::SelectorList;
|
||||
use servo_arc::Arc;
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
|
@ -251,10 +251,10 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
fn parse_block<'t>(
|
||||
&mut self,
|
||||
prelude: AtRuleBlockPrelude,
|
||||
location: SourceLocation,
|
||||
start: &ParserState,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<CssRule, ParseError<'i>> {
|
||||
AtRuleParser::parse_block(&mut self.nested(), prelude, location, input).map(|rule| {
|
||||
AtRuleParser::parse_block(&mut self.nested(), prelude, start, input).map(|rule| {
|
||||
self.state = State::Body;
|
||||
rule
|
||||
})
|
||||
|
@ -264,8 +264,8 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
fn rule_without_block(
|
||||
&mut self,
|
||||
prelude: AtRuleNonBlockPrelude,
|
||||
source_location: SourceLocation,
|
||||
) -> CssRule {
|
||||
start: &ParserState,
|
||||
) -> Self::AtRule {
|
||||
match prelude {
|
||||
AtRuleNonBlockPrelude::Import(url, media) => {
|
||||
let loader = self
|
||||
|
@ -274,7 +274,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
|
||||
let import_rule = loader.request_stylesheet(
|
||||
url,
|
||||
source_location,
|
||||
start.source_location(),
|
||||
&self.context,
|
||||
&self.shared_lock,
|
||||
media,
|
||||
|
@ -296,7 +296,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
CssRule::Namespace(Arc::new(self.shared_lock.wrap(NamespaceRule {
|
||||
prefix,
|
||||
url,
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
})))
|
||||
},
|
||||
}
|
||||
|
@ -324,10 +324,10 @@ impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
fn parse_block<'t>(
|
||||
&mut self,
|
||||
prelude: Self::Prelude,
|
||||
location: SourceLocation,
|
||||
start: &ParserState,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<CssRule, ParseError<'i>> {
|
||||
QualifiedRuleParser::parse_block(&mut self.nested(), prelude, location, input).map(
|
||||
QualifiedRuleParser::parse_block(&mut self.nested(), prelude, start, input).map(
|
||||
|result| {
|
||||
self.state = State::Body;
|
||||
result
|
||||
|
@ -461,7 +461,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
fn parse_block<'t>(
|
||||
&mut self,
|
||||
prelude: AtRuleBlockPrelude,
|
||||
source_location: SourceLocation,
|
||||
start: &ParserState,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<CssRule, ParseError<'i>> {
|
||||
match prelude {
|
||||
|
@ -473,7 +473,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
);
|
||||
|
||||
Ok(CssRule::FontFace(Arc::new(self.shared_lock.wrap(
|
||||
parse_font_face_block(&context, input, source_location).into(),
|
||||
parse_font_face_block(&context, input, start.source_location()).into(),
|
||||
))))
|
||||
},
|
||||
AtRuleBlockPrelude::FontFeatureValues(family_names) => {
|
||||
|
@ -484,7 +484,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
);
|
||||
|
||||
Ok(CssRule::FontFeatureValues(Arc::new(self.shared_lock.wrap(
|
||||
FontFeatureValuesRule::parse(&context, input, family_names, source_location),
|
||||
FontFeatureValuesRule::parse(&context, input, family_names, start.source_location()),
|
||||
))))
|
||||
},
|
||||
AtRuleBlockPrelude::CounterStyle(name) => {
|
||||
|
@ -495,14 +495,14 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
);
|
||||
|
||||
Ok(CssRule::CounterStyle(Arc::new(self.shared_lock.wrap(
|
||||
parse_counter_style_body(name, &context, input, source_location)?.into(),
|
||||
parse_counter_style_body(name, &context, input, start.source_location())?.into(),
|
||||
))))
|
||||
},
|
||||
AtRuleBlockPrelude::Media(media_queries) => {
|
||||
Ok(CssRule::Media(Arc::new(self.shared_lock.wrap(MediaRule {
|
||||
media_queries,
|
||||
rules: self.parse_nested_rules(input, CssRuleType::Media),
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
}))))
|
||||
},
|
||||
AtRuleBlockPrelude::Supports(condition) => {
|
||||
|
@ -518,7 +518,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
condition,
|
||||
rules: self.parse_nested_rules(input, CssRuleType::Supports),
|
||||
enabled,
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
},
|
||||
))))
|
||||
},
|
||||
|
@ -545,7 +545,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
name,
|
||||
keyframes: parse_keyframe_list(&context, input, self.shared_lock),
|
||||
vendor_prefix,
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
},
|
||||
))))
|
||||
},
|
||||
|
@ -559,7 +559,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
let declarations = parse_property_declaration_list(&context, input, None);
|
||||
Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule {
|
||||
block: Arc::new(self.shared_lock.wrap(declarations)),
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
}))))
|
||||
},
|
||||
AtRuleBlockPrelude::Document(condition) => {
|
||||
|
@ -570,7 +570,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
DocumentRule {
|
||||
condition,
|
||||
rules: self.parse_nested_rules(input, CssRuleType::Document),
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
},
|
||||
))))
|
||||
},
|
||||
|
@ -598,7 +598,7 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
fn parse_block<'t>(
|
||||
&mut self,
|
||||
selectors: Self::Prelude,
|
||||
source_location: SourceLocation,
|
||||
start: &ParserState,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<CssRule, ParseError<'i>> {
|
||||
let context =
|
||||
|
@ -609,7 +609,7 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule {
|
||||
selectors,
|
||||
block,
|
||||
source_location,
|
||||
source_location: start.source_location(),
|
||||
}))))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue