From 4768597b130915a2032abf87a84dc72459cb0687 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 11 Sep 2017 14:19:04 -0600 Subject: [PATCH] Remove get_location_with_offset Now that rust-cssparser reports 1-based locations, bump the required cssparser version and remove get_location_with_offset. Previously, some code paths were not calling get_location_with_offset; see https://bugzilla.mozilla.org/show_bug.cgi?id=1398869 for some background. --- Cargo.lock | 26 +++++++++---------- components/canvas/Cargo.toml | 2 +- components/canvas_traits/Cargo.toml | 2 +- components/script/Cargo.toml | 2 +- components/script_layout_interface/Cargo.toml | 2 +- components/selectors/Cargo.toml | 2 +- components/style/Cargo.toml | 2 +- .../style/stylesheets/keyframes_rule.rs | 5 ++-- components/style/stylesheets/rule_parser.rs | 15 +++-------- components/style_traits/Cargo.toml | 2 +- ports/geckolib/Cargo.toml | 2 +- tests/unit/gfx/Cargo.toml | 2 +- tests/unit/style/Cargo.toml | 2 +- tests/unit/style/stylesheets.rs | 4 +-- tests/unit/stylo/Cargo.toml | 2 +- 15 files changed, 31 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a5c4cf19fc..c6f4b06e23b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,7 +327,7 @@ dependencies = [ "azure 0.21.0 (git+https://github.com/servo/rust-azure)", "canvas_traits 0.0.1", "compositing 0.0.1", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -343,7 +343,7 @@ dependencies = [ name = "canvas_traits" version = "0.0.1" dependencies = [ - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -591,7 +591,7 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.20.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1077,7 +1077,7 @@ name = "geckoservo" version = "0.0.1" dependencies = [ "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1146,7 +1146,7 @@ dependencies = [ name = "gfx_tests" version = "0.0.1" dependencies = [ - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "ipc-channel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", @@ -2566,7 +2566,7 @@ dependencies = [ "caseless 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "cookie 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "deny_public_fields 0.0.1", "devtools_traits 0.0.1", "dom_struct 0.0.1", @@ -2638,7 +2638,7 @@ dependencies = [ "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "canvas_traits 0.0.1", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2710,7 +2710,7 @@ name = "selectors" version = "0.19.0" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", @@ -3115,7 +3115,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "fallible 0.0.1", @@ -3176,7 +3176,7 @@ version = "0.0.1" dependencies = [ "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3198,7 +3198,7 @@ version = "0.0.1" dependencies = [ "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3213,7 +3213,7 @@ name = "stylo_tests" version = "0.0.1" dependencies = [ "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "geckoservo 0.0.1", @@ -3803,7 +3803,7 @@ dependencies = [ "checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624" "checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79" "checksum core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ce16d9ed00181016c11ff48e561314bec92bfbce9fe48f319366618d4e5de6" -"checksum cssparser 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71773af1c6bbbafa27cba64f310b95fea1f87cd82d5a8cd827bd96b4559e5c48" +"checksum cssparser 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e88f0308699ff4e42b2ae57f170673f180a5b41f59364c95ae5c0c8022dbcbd1" "checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df" "checksum darling 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9861a8495606435477df581bc858ccf15a3469747edf175b94a4704fd9aaedac" "checksum darling_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1486a8b00b45062c997f767738178b43219133dd0c8c826cb811e60563810821" diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index 6b35891e899..ac91c12a7c6 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -13,7 +13,7 @@ path = "lib.rs" azure = {git = "https://github.com/servo/rust-azure"} canvas_traits = {path = "../canvas_traits"} compositing = {path = "../compositing"} -cssparser = "0.20.2" +cssparser = "0.21.0" euclid = "0.15" fnv = "1.0" gleam = "0.4" diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index a4964011ed3..3ac95080897 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -10,7 +10,7 @@ name = "canvas_traits" path = "lib.rs" [dependencies] -cssparser = "0.20.2" +cssparser = "0.21.0" euclid = "0.15" heapsize = "0.4" heapsize_derive = "0.1" diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 28e147d7193..8bb61ec57cf 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -33,7 +33,7 @@ byteorder = "1.0" canvas_traits = {path = "../canvas_traits"} caseless = "0.1.0" cookie = "0.6" -cssparser = "0.20.2" +cssparser = "0.21.0" deny_public_fields = {path = "../deny_public_fields"} devtools_traits = {path = "../devtools_traits"} dom_struct = {path = "../dom_struct"} diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index 442a89d3015..8a078aa643e 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -13,7 +13,7 @@ path = "lib.rs" app_units = "0.5" atomic_refcell = "0.1" canvas_traits = {path = "../canvas_traits"} -cssparser = "0.20.2" +cssparser = "0.21.0" euclid = "0.15" gfx_traits = {path = "../gfx_traits"} heapsize = "0.4" diff --git a/components/selectors/Cargo.toml b/components/selectors/Cargo.toml index d7c666dc22e..3ae6e7feec5 100644 --- a/components/selectors/Cargo.toml +++ b/components/selectors/Cargo.toml @@ -25,7 +25,7 @@ unstable = [] [dependencies] bitflags = "0.7" matches = "0.1" -cssparser = "0.20.2" +cssparser = "0.21.0" log = "0.3" fnv = "1.0" malloc_size_of = { path = "../malloc_size_of" } diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index ea9e779be83..3dc910a976f 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -37,7 +37,7 @@ atomic_refcell = "0.1" bitflags = "0.7" byteorder = "1.0" cfg-if = "0.1.0" -cssparser = "0.20.2" +cssparser = "0.21.0" encoding = {version = "0.2", optional = true} euclid = "0.15" fallible = { path = "../fallible" } diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs index 0fa623337d9..226b72bd560 100644 --- a/components/style/stylesheets/keyframes_rule.rs +++ b/components/style/stylesheets/keyframes_rule.rs @@ -20,7 +20,7 @@ use std::fmt; use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError, StyleParseError}; use style_traits::PropertyDeclarationParseError; use stylesheets::{CssRuleType, StylesheetContents}; -use stylesheets::rule_parser::{VendorPrefix, get_location_with_offset}; +use stylesheets::rule_parser::VendorPrefix; use values::{KeyframesName, serialize_percentage}; /// A [`@keyframes`][keyframes] rule. @@ -507,12 +507,11 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListPars fn parse_prelude<'t>(&mut self, input: &mut Parser<'i, 't>) -> Result> { let start_position = input.position(); let start_location = input.current_source_location(); - let location = get_location_with_offset(start_location); match KeyframeSelector::parse(input) { Ok(sel) => { Ok(KeyframeSelectorParserPrelude { selector: sel, - source_location: location, + source_location: start_location, }) }, Err(e) => { diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 7dce3fc64f8..30d1219dab1 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -167,7 +167,7 @@ impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a, name: CowRcStr<'i>, input: &mut Parser<'i, 't> ) -> Result, ParseError<'i>> { - let location = get_location_with_offset(input.current_source_location()); + let location = input.current_source_location(); match_ignore_ascii_case! { &*name, "import" => { if self.state > State::Imports { @@ -352,7 +352,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a name: CowRcStr<'i>, input: &mut Parser<'i, 't> ) -> Result, ParseError<'i>> { - let location = get_location_with_offset(input.current_source_location()); + let location = input.current_source_location(); match_ignore_ascii_case! { &*name, "media" => { @@ -560,7 +560,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for NestedRulePa url_data: Some(self.context.url_data), }; - let location = get_location_with_offset(input.current_source_location()); + let location = input.current_source_location(); let selectors = SelectorList::parse(&selector_parser, input)?; Ok(QualifiedRuleParserPrelude { @@ -588,12 +588,3 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for NestedRulePa })))) } } - -/// Adjust a location's column to accommodate DevTools. -pub fn get_location_with_offset(location: SourceLocation) -> SourceLocation { - SourceLocation { - line: location.line, - // Column offsets are not yet supported, but Gecko devtools expect 1-based columns. - column: location.column + 1, - } -} diff --git a/components/style_traits/Cargo.toml b/components/style_traits/Cargo.toml index 0e29ef33646..95cee727ef7 100644 --- a/components/style_traits/Cargo.toml +++ b/components/style_traits/Cargo.toml @@ -16,7 +16,7 @@ gecko = [] [dependencies] app_units = "0.5" bitflags = "0.7" -cssparser = "0.20.2" +cssparser = "0.21.0" euclid = "0.15" heapsize = {version = "0.4", optional = true} heapsize_derive = {version = "0.1", optional = true} diff --git a/ports/geckolib/Cargo.toml b/ports/geckolib/Cargo.toml index 24a8cc067e8..082808a713a 100644 --- a/ports/geckolib/Cargo.toml +++ b/ports/geckolib/Cargo.toml @@ -15,7 +15,7 @@ gecko_debug = ["style/gecko_debug"] [dependencies] atomic_refcell = "0.1" -cssparser = "0.20.2" +cssparser = "0.21.0" env_logger = {version = "0.4", default-features = false} # disable `regex` to reduce code size libc = "0.2" log = {version = "0.3.5", features = ["release_max_level_info"]} diff --git a/tests/unit/gfx/Cargo.toml b/tests/unit/gfx/Cargo.toml index 9c8a8a3be1e..0e884926b01 100644 --- a/tests/unit/gfx/Cargo.toml +++ b/tests/unit/gfx/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -cssparser = "0.20.2" +cssparser = "0.21.0" gfx = {path = "../../../components/gfx"} ipc-channel = "0.8" style = {path = "../../../components/style"} diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml index 2cc97db8275..a5bb083f4d0 100644 --- a/tests/unit/style/Cargo.toml +++ b/tests/unit/style/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] byteorder = "1.0" app_units = "0.5" -cssparser = "0.20.2" +cssparser = "0.21.0" euclid = "0.15" html5ever = "0.19" parking_lot = "0.4" diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index ea0167201e5..705945fd812 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -320,13 +320,13 @@ fn test_report_error_stylesheet() { assert_eq!("Unsupported property declaration: 'invalid: true;', \ Custom(PropertyDeclaration(UnknownProperty(\"invalid\")))", error.message); assert_eq!(9, error.line); - assert_eq!(8, error.column); + assert_eq!(9, error.column); let error = errors.pop().unwrap(); assert_eq!("Unsupported property declaration: 'display: invalid;', \ Custom(PropertyDeclaration(InvalidValue(\"display\", None)))", error.message); assert_eq!(8, error.line); - assert_eq!(8, error.column); + assert_eq!(9, error.column); // testing for the url assert_eq!(url, error.url); diff --git a/tests/unit/stylo/Cargo.toml b/tests/unit/stylo/Cargo.toml index 99764c66526..4a7528e6588 100644 --- a/tests/unit/stylo/Cargo.toml +++ b/tests/unit/stylo/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] atomic_refcell = "0.1" -cssparser = "0.20.2" +cssparser = "0.21.0" env_logger = "0.4" euclid = "0.15" geckoservo = {path = "../../../ports/geckolib"}