Auto merge of #15360 - atheed:font-weight-keyword, r=emilio

Ensured all font-weight keywords are preserved until computed-value time

Fixed the serialization of `font-weight` keywords (i.e. `bold`, `normal`, etc.) to ensure that Servo preserves the keyword until computed-value time (just as other major browsers do).

---
<!-- 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 #15337

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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/15360)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-02-08 11:04:29 -08:00 committed by GitHub
commit 287b02e21f
3 changed files with 26 additions and 6 deletions

View file

@ -6,7 +6,7 @@ use cssparser::Parser;
use media_queries::CSSErrorReporterTest;
use servo_url::ServoUrl;
use style::parser::ParserContext;
use style::properties::longhands::font_feature_settings;
use style::properties::longhands::{font_feature_settings, font_weight};
use style::properties::longhands::font_feature_settings::computed_value;
use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue;
use style::stylesheets::Origin;
@ -98,6 +98,21 @@ fn font_language_override_should_parse_properly() {
assert_eq!(danish, SpecifiedValue::Override("DAN".to_string()));
}
#[test]
fn font_weight_keyword_should_preserve_keyword() {
use style::properties::longhands::font_weight::SpecifiedValue;
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("normal");
let result = font_weight::parse(&context, &mut parser);
assert_eq!(result.unwrap(), SpecifiedValue::Normal);
let mut parser = Parser::new("bold");
let result = font_weight::parse(&context, &mut parser);
assert_eq!(result.unwrap(), SpecifiedValue::Bold);
}
#[test]
#[should_panic]
fn font_language_override_should_fail_on_empty_str() {

View file

@ -33,6 +33,3 @@
[list is expected to be list-style: circle inside;]
expected: FAIL
[font-family is expected to be font-family: sans-serif; line-height: 2em; font-size: 3em; font-style: italic; font-weight: bold;]
expected: FAIL