Auto merge of #18449 - tromey:remove-get_location_with_offset, r=jdm

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.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1398869 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because tests are in rust-cssparser and/or M-C

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18449)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-12 09:44:53 -05:00 committed by GitHub
commit 7746896bc4
15 changed files with 31 additions and 41 deletions

View file

@ -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" }

View file

@ -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<Self::Prelude, ParseError<'i>> {
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) => {

View file

@ -167,7 +167,7 @@ impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a,
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>
) -> Result<AtRuleType<AtRuleNonBlockPrelude, AtRuleBlockPrelude>, 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<AtRuleType<AtRuleNonBlockPrelude, AtRuleBlockPrelude>, 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,
}
}