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 upfont-family parsing-serialization is not idempotent with quotes #15059
Comments
|
In addition, values like |
|
This seems to be an issue probably need to fix in the css parser in conjuction with font-family parsing code. I suspect this may need some deeper change in the parser, though I'm not completely sure. cc @SimonSapin |
|
Some additional cases:
We probably want to migrate Gecko's test_font_family_parsing.html to wpt. |
|
I think this is because the serializer for |
|
I think this is correct, but it still needs tests. diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs
index fed23f1..013b6be 100644
--- a/components/style/properties/longhand/font.mako.rs
+++ b/components/style/properties/longhand/font.mako.rs
@@ -19,7 +19,8 @@
impl NoViewportPercentage for SpecifiedValue {}
pub mod computed_value {
- use std::fmt;
+ use cssparser::CssStringWriter;
+ use std::fmt::{self, Write};
use Atom;
use style_traits::ToCss;
pub use self::FontFamily as SingleComputedValue;
@@ -72,7 +73,16 @@
impl ToCss for FontFamily {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- self.atom().with_str(|s| dest.write_str(s))
+ match *self {
+ FontFamily::FamilyName(ref name) => {
+ dest.write_char('"')?;
+ write!(CssStringWriter::new(dest), "{}", name)?;
+ dest.write_char('"')
+ }
+
+ // All generic values accepted by the parser are known to not require escaping.
+ FontFamily::Generic(ref name) => write!(dest, "{}", name),
+ }
}
} |
|
To test this, you can run |
|
Note that in some cases, the failure may not really make much sense, e.g. |
Fix parsing and serialization of font-family <!-- Please describe your changes on the following line: --> --- <!-- 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 #15059 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Fix parsing and serialization of font-family <!-- Please describe your changes on the following line: --> --- <!-- 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 #15059 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15183) <!-- Reviewable:end -->
Fix parsing and serialization of font-family <!-- Please describe your changes on the following line: --> --- <!-- 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 #15059 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15183) <!-- Reviewable:end -->
See the following code:
It shows
"times new romanwhich is a different value from\"times new roman.