Skip to content

Commit 89580a2

Browse files
committed
servo: Merge #17345 - Upgrade cssparser to 0.15 (from servo:cssparserup); r=<try>
Depends on servo/rust-cssparser#159 Source-Repo: https://github.com/servo/servo Source-Revision: 75876a0e2220b7b95541feef4393288b195b090e
1 parent fec42a5 commit 89580a2

File tree

42 files changed

+234
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+234
-217
lines changed

servo/Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

servo/components/canvas/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ path = "lib.rs"
1212
[dependencies]
1313
azure = {git = "https://github.com/servo/rust-azure"}
1414
canvas_traits = {path = "../canvas_traits"}
15-
cssparser = "0.15"
15+
cssparser = "0.16"
1616
euclid = "0.15"
1717
gleam = "0.4"
1818
ipc-channel = "0.8"

servo/components/canvas_traits/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name = "canvas_traits"
1010
path = "lib.rs"
1111

1212
[dependencies]
13-
cssparser = "0.15"
13+
cssparser = "0.16"
1414
euclid = "0.15"
1515
heapsize = "0.4"
1616
heapsize_derive = "0.1"

servo/components/script/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ byteorder = "1.0"
3535
canvas_traits = {path = "../canvas_traits"}
3636
caseless = "0.1.0"
3737
cookie = "0.6"
38-
cssparser = "0.15"
38+
cssparser = "0.16"
3939
deny_public_fields = {path = "../deny_public_fields"}
4040
devtools_traits = {path = "../devtools_traits"}
4141
dom_struct = {path = "../dom_struct"}

servo/components/script/dom/bindings/str.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
//! The `ByteString` struct.
66
7+
use cssparser::CompactCowStr;
78
use html5ever::{LocalName, Namespace};
89
use servo_atoms::Atom;
910
use std::ascii::AsciiExt;
@@ -298,6 +299,12 @@ impl<'a> Into<Cow<'a, str>> for DOMString {
298299
}
299300
}
300301

302+
impl<'a> Into<CompactCowStr<'a>> for DOMString {
303+
fn into(self) -> CompactCowStr<'a> {
304+
self.0.into()
305+
}
306+
}
307+
301308
impl Extend<char> for DOMString {
302309
fn extend<I>(&mut self, iterable: I) where I: IntoIterator<Item=char> {
303310
self.0.extend(iterable)

servo/components/script_layout_interface/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ path = "lib.rs"
1313
app_units = "0.5"
1414
atomic_refcell = "0.1"
1515
canvas_traits = {path = "../canvas_traits"}
16-
cssparser = "0.15"
16+
cssparser = "0.16"
1717
euclid = "0.15"
1818
gfx_traits = {path = "../gfx_traits"}
1919
heapsize = "0.4"

servo/components/selectors/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ gecko_like_types = []
2424
[dependencies]
2525
bitflags = "0.7"
2626
matches = "0.1"
27-
cssparser = "0.15"
27+
cssparser = "0.16"
2828
log = "0.3"
2929
fnv = "1.0"
3030
phf = "0.7.18"

servo/components/selectors/parser.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use attr::{AttrSelectorWithNamespace, ParsedAttrSelectorOperation, AttrSelectorOperator};
66
use attr::{ParsedCaseSensitivity, SELECTOR_WHITESPACE, NamespaceConstraint};
77
use bloom::BLOOM_HASH_MASK;
8-
use cssparser::{ParseError, BasicParseError};
8+
use cssparser::{ParseError, BasicParseError, CompactCowStr};
99
use cssparser::{Token, Parser as CssParser, parse_nth, ToCss, serialize_identifier, CssStringWriter};
1010
use precomputed_hash::PrecomputedHash;
1111
use servo_arc::{Arc, HeaderWithLength, ThinArc};
@@ -58,7 +58,7 @@ pub enum SelectorParseError<'i, T> {
5858
PseudoElementExpectedColon,
5959
PseudoElementExpectedIdent,
6060
UnsupportedPseudoClass,
61-
UnexpectedIdent(Cow<'i, str>),
61+
UnexpectedIdent(CompactCowStr<'i>),
6262
ExpectedNamespace,
6363
Custom(T),
6464
}
@@ -133,21 +133,21 @@ pub trait Parser<'i> {
133133

134134
/// This function can return an "Err" pseudo-element in order to support CSS2.1
135135
/// pseudo-elements.
136-
fn parse_non_ts_pseudo_class(&self, name: Cow<'i, str>)
136+
fn parse_non_ts_pseudo_class(&self, name: CompactCowStr<'i>)
137137
-> Result<<Self::Impl as SelectorImpl>::NonTSPseudoClass,
138138
ParseError<'i, SelectorParseError<'i, Self::Error>>> {
139139
Err(ParseError::Custom(SelectorParseError::UnexpectedIdent(name)))
140140
}
141141

142142
fn parse_non_ts_functional_pseudo_class<'t>
143-
(&self, name: Cow<'i, str>, _arguments: &mut CssParser<'i, 't>)
143+
(&self, name: CompactCowStr<'i>, _arguments: &mut CssParser<'i, 't>)
144144
-> Result<<Self::Impl as SelectorImpl>::NonTSPseudoClass,
145145
ParseError<'i, SelectorParseError<'i, Self::Error>>>
146146
{
147147
Err(ParseError::Custom(SelectorParseError::UnexpectedIdent(name)))
148148
}
149149

150-
fn parse_pseudo_element(&self, name: Cow<'i, str>)
150+
fn parse_pseudo_element(&self, name: CompactCowStr<'i>)
151151
-> Result<<Self::Impl as SelectorImpl>::PseudoElement,
152152
ParseError<'i, SelectorParseError<'i, Self::Error>>> {
153153
Err(ParseError::Custom(SelectorParseError::UnexpectedIdent(name)))
@@ -1152,7 +1152,7 @@ fn parse_type_selector<'i, 't, P, E, Impl>(parser: &P, input: &mut CssParser<'i,
11521152
Some(name) => {
11531153
sequence.push(Component::LocalName(LocalName {
11541154
lower_name: from_cow_str(to_ascii_lowercase(&name)),
1155-
name: from_cow_str(name),
1155+
name: from_cow_str(name.into()),
11561156
}))
11571157
}
11581158
None => {
@@ -1186,7 +1186,7 @@ enum QNamePrefix<Impl: SelectorImpl> {
11861186
fn parse_qualified_name<'i, 't, P, E, Impl>
11871187
(parser: &P, input: &mut CssParser<'i, 't>,
11881188
in_attr_selector: bool)
1189-
-> Result<Option<(QNamePrefix<Impl>, Option<Cow<'i, str>>)>,
1189+
-> Result<Option<(QNamePrefix<Impl>, Option<CompactCowStr<'i>>)>,
11901190
ParseError<'i, SelectorParseError<'i, E>>>
11911191
where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
11921192
{
@@ -1217,7 +1217,7 @@ fn parse_qualified_name<'i, 't, P, E, Impl>
12171217
let position = input.position();
12181218
match input.next_including_whitespace() {
12191219
Ok(Token::Delim('|')) => {
1220-
let prefix = from_cow_str(value);
1220+
let prefix = from_cow_str(value.into());
12211221
let result = parser.namespace_for_prefix(&prefix);
12221222
let url = result.ok_or(ParseError::Custom(SelectorParseError::ExpectedNamespace))?;
12231223
explicit_namespace(input, QNamePrefix::ExplicitNamespace(prefix, url))
@@ -1300,7 +1300,7 @@ fn parse_attribute_selector<'i, 't, P, E, Impl>(parser: &P, input: &mut CssParse
13001300
// [foo]
13011301
Err(_) => {
13021302
let local_name_lower = from_cow_str(to_ascii_lowercase(&local_name));
1303-
let local_name = from_cow_str(local_name);
1303+
let local_name = from_cow_str(local_name.into());
13041304
if let Some(namespace) = namespace {
13051305
return Ok(Component::AttributeOther(Box::new(AttrSelectorWithNamespace {
13061306
namespace: namespace,
@@ -1358,7 +1358,7 @@ fn parse_attribute_selector<'i, 't, P, E, Impl>(parser: &P, input: &mut CssParse
13581358

13591359
let mut case_sensitivity = parse_attribute_flags(input)?;
13601360

1361-
let value = from_cow_str(value);
1361+
let value = from_cow_str(value.into());
13621362
let local_name_lower;
13631363
{
13641364
let local_name_lower_cow = to_ascii_lowercase(&local_name);
@@ -1371,9 +1371,9 @@ fn parse_attribute_selector<'i, 't, P, E, Impl>(parser: &P, input: &mut CssParse
13711371
ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument
13721372
}
13731373
}
1374-
local_name_lower = from_cow_str(local_name_lower_cow);
1374+
local_name_lower = from_cow_str(local_name_lower_cow.into());
13751375
}
1376-
let local_name = from_cow_str(local_name);
1376+
let local_name = from_cow_str(local_name.into());
13771377
if let Some(namespace) = namespace {
13781378
Ok(Component::AttributeOther(Box::new(AttrSelectorWithNamespace {
13791379
namespace: namespace,
@@ -1551,7 +1551,7 @@ fn parse_compound_selector<'i, 't, P, E, Impl>(
15511551

15521552
fn parse_functional_pseudo_class<'i, 't, P, E, Impl>(parser: &P,
15531553
input: &mut CssParser<'i, 't>,
1554-
name: Cow<'i, str>,
1554+
name: CompactCowStr<'i>,
15551555
inside_negation: bool)
15561556
-> Result<Component<Impl>,
15571557
ParseError<'i, SelectorParseError<'i, E>>>
@@ -1599,13 +1599,13 @@ fn parse_one_simple_selector<'i, 't, P, E, Impl>(parser: &P,
15991599
let start_position = input.position();
16001600
match input.next_including_whitespace() {
16011601
Ok(Token::IDHash(id)) => {
1602-
let id = Component::ID(from_cow_str(id));
1602+
let id = Component::ID(from_cow_str(id.into()));
16031603
Ok(Some(SimpleSelectorParseResult::SimpleSelector(id)))
16041604
}
16051605
Ok(Token::Delim('.')) => {
16061606
match input.next_including_whitespace() {
16071607
Ok(Token::Ident(class)) => {
1608-
let class = Component::Class(from_cow_str(class));
1608+
let class = Component::Class(from_cow_str(class.into()));
16091609
Ok(Some(SimpleSelectorParseResult::SimpleSelector(class)))
16101610
}
16111611
Ok(t) => Err(ParseError::Basic(BasicParseError::UnexpectedToken(t))),
@@ -1659,7 +1659,7 @@ fn parse_one_simple_selector<'i, 't, P, E, Impl>(parser: &P,
16591659
}
16601660
}
16611661

1662-
fn parse_simple_pseudo_class<'i, P, E, Impl>(parser: &P, name: Cow<'i, str>)
1662+
fn parse_simple_pseudo_class<'i, P, E, Impl>(parser: &P, name: CompactCowStr<'i>)
16631663
-> Result<Component<Impl>,
16641664
ParseError<'i, SelectorParseError<'i, E>>>
16651665
where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
@@ -1804,7 +1804,7 @@ pub mod tests {
18041804
type Impl = DummySelectorImpl;
18051805
type Error = ();
18061806

1807-
fn parse_non_ts_pseudo_class(&self, name: Cow<'i, str>)
1807+
fn parse_non_ts_pseudo_class(&self, name: CompactCowStr<'i>)
18081808
-> Result<PseudoClass,
18091809
ParseError<'i, SelectorParseError<'i, ()>>> {
18101810
match_ignore_ascii_case! { &name,
@@ -1814,7 +1814,7 @@ pub mod tests {
18141814
}
18151815
}
18161816

1817-
fn parse_non_ts_functional_pseudo_class<'t>(&self, name: Cow<'i, str>,
1817+
fn parse_non_ts_functional_pseudo_class<'t>(&self, name: CompactCowStr<'i>,
18181818
parser: &mut CssParser<'i, 't>)
18191819
-> Result<PseudoClass,
18201820
ParseError<'i, SelectorParseError<'i, ()>>> {
@@ -1824,7 +1824,7 @@ pub mod tests {
18241824
}
18251825
}
18261826

1827-
fn parse_pseudo_element(&self, name: Cow<'i, str>)
1827+
fn parse_pseudo_element(&self, name: CompactCowStr<'i>)
18281828
-> Result<PseudoElement,
18291829
ParseError<'i, SelectorParseError<'i, ()>>> {
18301830
match_ignore_ascii_case! { &name,

servo/components/style/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bitflags = "0.7"
3838
bit-vec = "0.4.3"
3939
byteorder = "1.0"
4040
cfg-if = "0.1.0"
41-
cssparser = "0.15"
41+
cssparser = "0.16"
4242
encoding = {version = "0.2", optional = true}
4343
euclid = "0.15"
4444
fnv = "1.0"

servo/components/style/counter_style/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
use Atom;
1010
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser};
11-
use cssparser::{Parser, Token, serialize_identifier, BasicParseError};
11+
use cssparser::{Parser, Token, serialize_identifier, BasicParseError, CompactCowStr};
1212
use error_reporting::ContextualParseError;
1313
#[cfg(feature = "gecko")] use gecko::rules::CounterStyleDescriptors;
1414
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSCounterDesc;
@@ -184,7 +184,7 @@ macro_rules! counter_style_descriptors {
184184
type Declaration = ();
185185
type Error = SelectorParseError<'i, StyleParseError<'i>>;
186186

187-
fn parse_value<'t>(&mut self, name: Cow<'i, str>, input: &mut Parser<'i, 't>)
187+
fn parse_value<'t>(&mut self, name: CompactCowStr<'i>, input: &mut Parser<'i, 't>)
188188
-> Result<(), ParseError<'i>> {
189189
match_ignore_ascii_case! { &*name,
190190
$(
@@ -430,7 +430,7 @@ impl Parse for Ranges {
430430

431431
fn parse_bound<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Option<i32>, ParseError<'i>> {
432432
match input.next() {
433-
Ok(Token::Number(ref v)) if v.int_value.is_some() => Ok(Some(v.int_value.unwrap())),
433+
Ok(Token::Number { int_value: Some(v), .. }) => Ok(Some(v)),
434434
Ok(Token::Ident(ref ident)) if ident.eq_ignore_ascii_case("infinite") => Ok(None),
435435
Ok(t) => Err(BasicParseError::UnexpectedToken(t).into()),
436436
Err(e) => Err(e.into()),

0 commit comments

Comments
 (0)