Skip to content
Permalink
Browse files
font-weight should be clamped to 1 as minimum
https://bugs.webkit.org/show_bug.cgi?id=246575
rdar://problem/101441591

Reviewed by Tim Nguyen.

* LayoutTests/fast/text/font-weight-parse-expected.txt: Updated to expect PASS.
* LayoutTests/fast/text/font-weight-parse.html: Changed to expect a minimum of 1 rather than of 0.

* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-shorthand-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-weight-parsing-expected.txt:
Updated to expect more PASS.

* LayoutTests/platform/gtk/fast/text/font-weight-parse-expected.txt: Removed.
* LayoutTests/platform/ios/fast/text/font-weight-parse-expected.txt: Removed.
* LayoutTests/platform/mac/fast/text/font-weight-parse-expected.txt: Removed.
* LayoutTests/platform/wpe/fast/text/font-weight-parse-expected.txt: Removed.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeFontWeightNumberRaw): Clamp to [1,1000].

Canonical link: https://commits.webkit.org/255873@main
  • Loading branch information
darinadler committed Oct 22, 2022
1 parent 8d82a00 commit 00db99db9acfe127589e95787d0b8923146676a9
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 305 deletions.
@@ -1,5 +1,5 @@
PASS window.getComputedStyle(document.getElementById('test1')).fontWeight is "400"
FAIL window.getComputedStyle(document.getElementById('test2')).fontWeight should be 1. Was normal.
PASS window.getComputedStyle(document.getElementById('test2')).fontWeight is "1"
PASS window.getComputedStyle(document.getElementById('test3')).fontWeight is "100"
PASS window.getComputedStyle(document.getElementById('test4')).fontWeight is "200"
PASS window.getComputedStyle(document.getElementById('test5')).fontWeight is "300"
@@ -13,22 +13,22 @@ PASS window.getComputedStyle(document.getElementById('test12')).fontWeight is "8
PASS window.getComputedStyle(document.getElementById('test13')).fontWeight is "900"
PASS window.getComputedStyle(document.getElementById('test14')).fontWeight is "400"
PASS window.getComputedStyle(document.getElementById('test15')).fontWeight is "400"
FAIL window.getComputedStyle(document.getElementById('test16')).fontWeight should be 7. Was normal.
PASS window.getComputedStyle(document.getElementById('test16')).fontWeight is "7"
PASS window.getComputedStyle(document.getElementById('test17')).fontWeight is "300"
PASS window.getComputedStyle(document.getElementById('test18')).fontWeight is "200"
PASS window.getComputedStyle(document.getElementById('test19')).fontWeight is "100"
PASS window.getComputedStyle(document.getElementById('test20')).fontWeight is "100"
PASS window.getComputedStyle(document.getElementById('test21')).fontWeight is "400"
PASS window.getComputedStyle(document.getElementById('test22')).fontWeight is "100"
PASS window.getComputedStyle(document.getElementById('test23')).fontWeight is "100"
FAIL window.getComputedStyle(document.getElementById('test24')).fontWeight should be 123. Was normal.
PASS window.getComputedStyle(document.getElementById('test24')).fontWeight is "123"
PASS window.getComputedStyle(document.getElementById('test25')).fontWeight is "400"
PASS window.getComputedStyle(document.getElementById('test26')).fontWeight is "400"
PASS window.getComputedStyle(document.getElementById('test27')).fontWeight is "400"
FAIL window.getComputedStyle(document.getElementById('test28')).fontWeight should be 0. Was normal.
FAIL window.getComputedStyle(document.getElementById('test29')).fontWeight should be 1000. Was normal.
PASS window.getComputedStyle(document.getElementById('test28')).fontWeight is "1"
PASS window.getComputedStyle(document.getElementById('test29')).fontWeight is "1000"
PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times"
FAIL window.getComputedStyle(document.getElementById('test2')).font should be 16px/18px Times. Was normal normal normal normal 16px/18px Times.
PASS window.getComputedStyle(document.getElementById('test2')).font is "16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test3')).font is "normal normal 100 normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test4')).font is "normal normal 200 normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test5')).font is "normal normal 300 normal 16px/18px Times"
@@ -42,27 +42,27 @@ PASS window.getComputedStyle(document.getElementById('test12')).font is "normal
PASS window.getComputedStyle(document.getElementById('test13')).font is "normal normal 900 normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test14')).font is "normal normal normal normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test15')).font is "normal normal normal normal 16px/18px Times"
FAIL window.getComputedStyle(document.getElementById('test16')).font should be 16px/18px Times. Was normal normal normal normal 16px/18px Times.
PASS window.getComputedStyle(document.getElementById('test16')).font is "16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test17')).font is "normal normal 300 normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test18')).font is "normal normal 200 normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test19')).font is "normal normal 100 extra-condensed 48px/49px \"Helvetica Neue\""
PASS window.getComputedStyle(document.getElementById('test20')).font is "normal normal 100 extra-condensed 48px/49px \"Helvetica Neue\""
PASS window.getComputedStyle(document.getElementById('test21')).font is "normal normal normal extra-condensed 48px/49px \"Helvetica Neue\""
PASS window.getComputedStyle(document.getElementById('test22')).font is "normal normal 100 normal 48px/49px \"Helvetica Neue\""
PASS window.getComputedStyle(document.getElementById('test23')).font is "italic small-caps 100 extra-expanded 48px/49px \"Helvetica Neue\""
FAIL window.getComputedStyle(document.getElementById('test24')).font should be 48px/49px "Helvetica Neue". Was normal normal normal normal 16px/18px Times.
PASS window.getComputedStyle(document.getElementById('test24')).font is "48px/49px \"Helvetica Neue\""
PASS window.getComputedStyle(document.getElementById('test25')).font is "normal normal normal normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test26')).font is "normal normal normal normal 16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test27')).font is "normal normal normal normal 16px/18px Times"
FAIL window.getComputedStyle(document.getElementById('test28')).font should be 16px/18px Times. Was normal normal normal normal 16px/18px Times.
FAIL window.getComputedStyle(document.getElementById('test29')).font should be 16px/18px Times. Was normal normal normal normal 16px/18px Times.
PASS window.getComputedStyle(document.getElementById('test28')).font is "16px/18px Times"
PASS window.getComputedStyle(document.getElementById('test29')).font is "16px/18px Times"
PASS document.getElementById('test1').style.font is ""
PASS document.getElementById('test19').style.font is "100 extra-condensed 48px/49px \"Helvetica Neue\""
PASS document.getElementById('test20').style.font is "100 extra-condensed 48px/49px \"Helvetica Neue\""
PASS document.getElementById('test21').style.font is "extra-condensed 48px/49px \"Helvetica Neue\""
PASS document.getElementById('test22').style.font is "100 48px/49px \"Helvetica Neue\""
PASS document.getElementById('test23').style.font is "italic small-caps 100 extra-expanded 48px/49px \"Helvetica Neue\""
FAIL document.getElementById('test24').style.font should be italic small-caps 123 extra-expanded 48px/49px "Helvetica Neue". Was .
PASS document.getElementById('test24').style.font is "italic small-caps 123 extra-expanded 48px/49px \"Helvetica Neue\""
PASS successfullyParsed is true

TEST COMPLETE
@@ -63,7 +63,7 @@
shouldBeEqualToString("window.getComputedStyle(document.getElementById('test25')).fontWeight", "400");
shouldBeEqualToString("window.getComputedStyle(document.getElementById('test26')).fontWeight", "400");
shouldBeEqualToString("window.getComputedStyle(document.getElementById('test27')).fontWeight", "400");
shouldBeEqualToString("window.getComputedStyle(document.getElementById('test28')).fontWeight", "0");
shouldBeEqualToString("window.getComputedStyle(document.getElementById('test28')).fontWeight", "1");
shouldBeEqualToString("window.getComputedStyle(document.getElementById('test29')).fontWeight", "1000");

shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).font", "normal normal normal normal 16px/18px Times");
@@ -5,7 +5,7 @@ PASS Font shorthand: Font weight specified as number
PASS Font shorthand: Font weight specified as number, value less than 1
PASS Font shorthand: Font weight specified as number, value greater than 1000
PASS Font shorthand: Font weight specified as calc()
FAIL Font shorthand: Font weight specified as calc(), value smaller than 1 assert_equals: Font shorthand expected weight: Font weight specified as calc(), value smaller than 1 expected "1" but got "0.25"
PASS Font shorthand: Font weight specified as calc(), value smaller than 1
PASS Font shorthand: Font weight specified as calc(), value greater than 1000
PASS Font shorthand: 'oblique' with positive angle
PASS Font shorthand: 'oblique' with negative angle
@@ -22,7 +22,7 @@ PASS Computed style: Non-integer Values should be parsed successfully
PASS Computed style: Minimum allowed value should be parsed successfully
PASS Computed style: Maximum allowed value should be parsed successfully
PASS Computed style: Simple calc value
FAIL Computed style: Negative simple calc value (to be clamped) assert_equals: Negative simple calc value (to be clamped) expected "1" but got "0"
PASS Computed style: Negative simple calc value (to be clamped)
PASS Computed style: Out-of-range simple calc value (to be clamped)
PASS Computed style: Valid calc expression
PASS Computed style: Valid calc expression with out-of-range value (to be clamped)

This file was deleted.

0 comments on commit 00db99d

Please sign in to comment.