Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReport more informative CSS errors #16752
Conversation
highfive
commented
May 6, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
May 6, 2017
| #[cfg(feature = "gecko")] | ||
| pub fn create_error_reporter() -> RustLogReporter { | ||
| RustLogReporter | ||
| } |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc @servo/style |
|
Wow, that's a big diff. Haven't gone through it with detail, would love help from @nox/@SimonSapin reviewing. Some questions below. |
| let location = input.source_location(position); | ||
| let line_offset = location.line + line_number_offset as usize; | ||
| if log_enabled!(log::LogLevel::Info) { | ||
| info!("Url:\t{}\n{}:{} {}", | ||
| url.as_str(), | ||
| line_offset, | ||
| location.column, | ||
| message) | ||
| error.to_string()) |
This comment has been minimized.
This comment has been minimized.
emilio
May 6, 2017
Member
Perhaps we should implement Display for ContextualParseError? Fine as a followup I guess.
| pub enum SelectorParseError<T> { | ||
| PseudoElementInComplexSelector, | ||
| NoQualifiedNameInAttributeSelector, | ||
| TooManyCompoundSelectorComponents, |
This comment has been minimized.
This comment has been minimized.
emilio
May 6, 2017
Member
Let's rename this to TooManyCompoundSelectorComponentsInNegation, or perhaps TooComplexNegationSelector?
|
|
||
| impl<'a> ContextualParseError<'a> { | ||
| /// Turn a parse error into a string representation. | ||
| pub fn to_string(&self) -> String { |
This comment has been minimized.
This comment has been minimized.
emilio
May 6, 2017
Member
Perhaps we should implement Display and implement to_string as format!("{}", self)? Fine also as a followup/easy issue I guess :)
| let result: Result<_, ParseError> = input.try(|input| { | ||
| match input.expect_ident() { | ||
| Ok(ident) => { | ||
| (match_ignore_ascii_case! { &ident, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jdm
May 7, 2017
Author
Member
Fixing this will be kind of annoying given how often this pattern appears. I would prefer not to, if that's alright.
This comment has been minimized.
This comment has been minimized.
| where F: FnMut(Keyword) -> bool | ||
| { | ||
| let (mut pos, mut keyword) = (None, None); | ||
| for _ in 0..2 { | ||
| if let Ok(l) = input.try(|i| L::parse(context, i)) { | ||
| if pos.is_some() { | ||
| return Err(()) | ||
| return Err(StyleParseError::UnspecifiedError.into()) |
This comment has been minimized.
This comment has been minimized.
emilio
May 6, 2017
Member
Is there an intention to convert all the UnspecifiedErrors into more explicit error kinds as followup work?
This comment has been minimized.
This comment has been minimized.
jdm
May 6, 2017
Author
Member
Yes. It's a nice source of easy issues and a lot of effort for this patch in particular.
| }; | ||
| if !valid { | ||
| return Err(BasicParseError::UnexpectedToken(Token::Ident(ident)).into()); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| "auto" => Ok(ALIGN_AUTO), | ||
| "normal" => Ok(ALIGN_NORMAL), | ||
| "stretch" => Ok(ALIGN_STRETCH), | ||
| _ => Err(()) | ||
| } | ||
| }).map_err(|()| BasicParseError::UnexpectedToken(Token::Ident(ident)).into()) |
This comment has been minimized.
This comment has been minimized.
emilio
May 6, 2017
Member
I'm assuming this funky way of doing this is because ident is borrowed in the match expression, is that right? If so, that's kind of unfortunate, I guess... :(
This comment has been minimized.
This comment has been minimized.
| match input.try(|i| i.expect_function()) { | ||
| Ok(ref s) if s.eq_ignore_ascii_case("inset") => | ||
| input.parse_nested_block(|i| GenericInsetRect::parse_function_arguments(context, i)), | ||
| _ => Err(()) | ||
| _ => Err(BasicParseError::ExpectedToken(Token::Function("inset".into())).into()) |
This comment has been minimized.
This comment has been minimized.
emilio
May 6, 2017
Member
Do you know if this "inset".into() will allocate or not? I'm assuming that since it's an static string it shouldn't need to, but I worry that perhaps to coerce it to do that you may need to be explicit about it. Not a big deal in any case I think
This comment has been minimized.
This comment has been minimized.
|
|
|
Reviewed 9 of 9 files at r1, 4 of 4 files at r2, 1 of 1 files at r3, 75 of 75 files at r4. components/style/custom_properties.rs, line 241 at r4 (raw file):
These are not just (various kinds of) closing brackets, they are unbalanced / improperly nested ones. components/style/media_queries.rs, line 227 at r4 (raw file):
Could you avoid creating tokens like this? I have plans to change the Comments from Reviewable |
|
@SimonSapin I have addressed the review comments and made a new commit which applies to the existing code that you reviewed. I'm going to go ahead and rebase all of my changes separately now, and I won't push them until you are done reviewing the existing code. |
|
r+ Reviewed 54 of 54 files at r5. components/style/values/specified/basic_shape.rs, line 131 at r4 (raw file): Previously, jdm (Josh Matthews) wrote…
Indeed, this uses Comments from Reviewable |
bedea39
to
98d0fb2
|
@bors-servo: try |
Report more informative CSS errors This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes <!-- 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/16752) <!-- Reviewable:end -->
|
|
Return meaningful error values when parsing This is #143 with an extra commit added to accommodate changes requested in servo/servo#16752. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/155) <!-- Reviewable:end -->
|
@bors-servo: r=SimonSapin |
|
|
|
@bors-servo: p=1 |
Report more informative CSS errors This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes <!-- 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/16752) <!-- Reviewable:end -->
|
|
|
@jdm What was the problem with not sharing the same |
| let horizontal = try!(horizontal); | ||
| let vertical = input.try(RepeatKeyword::parse).ok(); | ||
| Ok(SpecifiedValue::Other(horizontal, vertical)) | ||
| }) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@nox I'm not sure I understand the question. If it is why rust-cssparser's ParseError does not contain every possible error, the answer is because that's really inconvenient API design. |
jdm commentedMay 6, 2017
•
edited by larsbergstrom
This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work.
This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is