Changeset 214324 in webkit
- Timestamp:
- Mar 23, 2017 4:14:02 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r214322 r214324 1 2017-03-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 font shorthand should accept variation values 4 https://bugs.webkit.org/show_bug.cgi?id=168998 5 6 Reviewed by Simon Fraser. 7 8 * fast/text/font-style-parse-expected.txt: 9 * fast/text/font-style-parse.html: 10 * fast/text/font-weight-parse-expected.txt: 11 * fast/text/font-weight-parse.html: 12 1 13 2017-03-23 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/fast/text/font-style-parse-expected.txt
r213464 r214324 19 19 PASS window.getComputedStyle(document.getElementById('test19')).fontStyle is "italic" 20 20 PASS window.getComputedStyle(document.getElementById('test20')).fontStyle is "normal" 21 PASS window.getComputedStyle(document.getElementById('test21')).fontStyle is "14deg" 21 22 PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times" 22 23 PASS window.getComputedStyle(document.getElementById('test2')).font is "16px/18px Times" … … 39 40 PASS window.getComputedStyle(document.getElementById('test19')).font is "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'" 40 41 PASS window.getComputedStyle(document.getElementById('test20')).font is "normal normal normal normal 16px/18px Times" 42 PASS window.getComputedStyle(document.getElementById('test21')).font is "48px/49px 'Helvetica Neue'" 41 43 PASS document.getElementById('test1').style.font is "" 42 44 PASS document.getElementById('test15').style.font is "italic 100 48px/49px 'Helvetica Neue'" … … 46 48 PASS document.getElementById('test19').style.font is "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'" 47 49 PASS document.getElementById('test20').style.font is "" 50 PASS document.getElementById('test21').style.font is "14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'" 48 51 PASS successfullyParsed is true 49 52 -
trunk/LayoutTests/fast/text/font-style-parse.html
r213464 r214324 26 26 <div id="test19" style="font: italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue';"></div> 27 27 <div id="test20" style="font: 13deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue';"></div> 28 <div id="test21" style="font: oblique 14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue';"></div> 28 29 </div> 29 30 <script> … … 48 49 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test19')).fontStyle", "italic"); 49 50 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test20')).fontStyle", "normal"); 51 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).fontStyle", "14deg"); 50 52 51 53 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).font", "normal normal normal normal 16px/18px Times"); … … 69 71 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test19')).font", "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'"); 70 72 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test20')).font", "normal normal normal normal 16px/18px Times"); 73 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).font", "48px/49px 'Helvetica Neue'"); 71 74 72 75 shouldBeEqualToString("document.getElementById('test1').style.font", ""); … … 77 80 shouldBeEqualToString("document.getElementById('test19').style.font", "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'"); 78 81 shouldBeEqualToString("document.getElementById('test20').style.font", ""); 82 shouldBeEqualToString("document.getElementById('test21').style.font", "14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'"); 79 83 </script> 80 84 <script src="../../resources/js-test-post.js"></script> -
trunk/LayoutTests/fast/text/font-weight-parse-expected.txt
r213464 r214324 22 22 PASS window.getComputedStyle(document.getElementById('test22')).fontWeight is "100" 23 23 PASS window.getComputedStyle(document.getElementById('test23')).fontWeight is "100" 24 PASS window.getComputedStyle(document.getElementById('test24')).fontWeight is "normal" 24 PASS window.getComputedStyle(document.getElementById('test24')).fontWeight is "123" 25 PASS window.getComputedStyle(document.getElementById('test25')).fontWeight is "normal" 26 PASS window.getComputedStyle(document.getElementById('test26')).fontWeight is "normal" 27 PASS window.getComputedStyle(document.getElementById('test27')).fontWeight is "normal" 28 PASS window.getComputedStyle(document.getElementById('test28')).fontWeight is "0" 29 PASS window.getComputedStyle(document.getElementById('test29')).fontWeight is "1000" 25 30 PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times" 26 31 PASS window.getComputedStyle(document.getElementById('test2')).font is "16px/18px Times" … … 46 51 PASS window.getComputedStyle(document.getElementById('test22')).font is "normal normal 100 normal 48px/49px 'Helvetica Neue'" 47 52 PASS window.getComputedStyle(document.getElementById('test23')).font is "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'" 48 PASS window.getComputedStyle(document.getElementById('test24')).font is "italic small-caps normal extra-expanded 48px/49px 'Helvetica Neue'" 53 PASS window.getComputedStyle(document.getElementById('test24')).font is "48px/49px 'Helvetica Neue'" 54 PASS window.getComputedStyle(document.getElementById('test25')).font is "normal normal normal normal 16px/18px Times" 55 PASS window.getComputedStyle(document.getElementById('test26')).font is "normal normal normal normal 16px/18px Times" 56 PASS window.getComputedStyle(document.getElementById('test27')).font is "normal normal normal normal 16px/18px Times" 57 PASS window.getComputedStyle(document.getElementById('test28')).font is "16px/18px Times" 58 PASS window.getComputedStyle(document.getElementById('test29')).font is "16px/18px Times" 49 59 PASS document.getElementById('test1').style.font is "" 50 60 PASS document.getElementById('test19').style.font is "100 extra-condensed 48px/49px 'Helvetica Neue'" … … 53 63 PASS document.getElementById('test22').style.font is "100 48px/49px 'Helvetica Neue'" 54 64 PASS document.getElementById('test23').style.font is "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'" 55 PASS document.getElementById('test24').style.font is "italic small-caps extra-expanded 48px/49px 'Helvetica Neue'"65 PASS document.getElementById('test24').style.font is "italic small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'" 56 66 PASS successfullyParsed is true 57 67 -
trunk/LayoutTests/fast/text/font-weight-parse.html
r213464 r214324 30 30 <div id="test23" style="font: italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue';"></div> 31 31 <div id="test24" style="font: italic small-caps 123 extra-expanded 48px/49px 'Helvetica Neue';"></div> 32 <div id="test25" style="font-weight: 0;"></div> 33 <div id="test26" style="font-weight: -7;"></div> 34 <div id="test27" style="font-weight: 1623;"></div> 35 <div id="test28" style="font-weight: calc(-4 - 5);"></div> 36 <div id="test29" style="font-weight: calc(600 + 700);"></div> 32 37 </div> 33 38 <script> … … 55 60 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test22')).fontWeight", "100"); 56 61 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test23')).fontWeight", "100"); 57 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test24')).fontWeight", "normal"); 62 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test24')).fontWeight", "123"); 63 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test25')).fontWeight", "normal"); 64 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test26')).fontWeight", "normal"); 65 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test27')).fontWeight", "normal"); 66 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test28')).fontWeight", "0"); 67 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test29')).fontWeight", "1000"); 58 68 59 69 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).font", "normal normal normal normal 16px/18px Times"); … … 80 90 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test22')).font", "normal normal 100 normal 48px/49px 'Helvetica Neue'"); 81 91 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test23')).font", "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'"); 82 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test24')).font", "italic small-caps normal extra-expanded 48px/49px 'Helvetica Neue'"); 92 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test24')).font", "48px/49px 'Helvetica Neue'"); 93 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test25')).font", "normal normal normal normal 16px/18px Times"); 94 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test26')).font", "normal normal normal normal 16px/18px Times"); 95 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test27')).font", "normal normal normal normal 16px/18px Times"); 96 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test28')).font", "16px/18px Times"); 97 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test29')).font", "16px/18px Times"); 83 98 84 99 shouldBeEqualToString("document.getElementById('test1').style.font", ""); … … 88 103 shouldBeEqualToString("document.getElementById('test22').style.font", "100 48px/49px 'Helvetica Neue'"); 89 104 shouldBeEqualToString("document.getElementById('test23').style.font", "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'"); 90 shouldBeEqualToString("document.getElementById('test24').style.font", "italic small-caps extra-expanded 48px/49px 'Helvetica Neue'");105 shouldBeEqualToString("document.getElementById('test24').style.font", "italic small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'"); 91 106 </script> 92 107 <script src="../../resources/js-test-post.js"></script> -
trunk/Source/WebCore/ChangeLog
r214322 r214324 1 2017-03-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 font shorthand should accept variation values 4 https://bugs.webkit.org/show_bug.cgi?id=168998 5 6 Reviewed by Simon Fraser. 7 8 The CSS Fonts 4 spec has stabilized as to which variation values are allowed in 9 the font shorthand property. Weights are allowed because a 0 weight is considered 10 as a parse error, so there is no conflict with a unitless font-size of 0. 11 font-style accepts angles, so there is no conflict there. However, font-stretch 12 accepts percentages, which are also accepted by font-size, which means the newly 13 extended grammar for font-stretch can't be accepted in the shorthand. 14 15 Tests: fast/text/font-style-parse.html 16 fast/text/font-weight-parse.html 17 18 * css/parser/CSSPropertyParser.cpp: 19 (WebCore::consumeFontWeight): 20 (WebCore::consumeFontStyle): 21 (WebCore::CSSPropertyParser::consumeFont): 22 (WebCore::consumeFontWeightCSS21): Deleted. 23 * css/parser/CSSPropertyParserHelpers.cpp: 24 (WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber): 25 * css/parser/CSSPropertyParserHelpers.h: 26 1 27 2017-03-23 Chris Dumez <cdumez@apple.com> 2 28 -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r213831 r214324 870 870 } 871 871 872 static RefPtr<CSSPrimitiveValue> consumeFontWeight CSS21(CSSParserTokenRange& range)872 static RefPtr<CSSPrimitiveValue> consumeFontWeight(CSSParserTokenRange& range) 873 873 { 874 874 if (auto result = consumeFontWeightKeywordValue(range)) 875 875 return result; 876 int weight; 877 if (!consumePositiveIntegerRaw(range, weight)) 878 return nullptr; 879 if (!isCSS21Weight(weight)) 880 return nullptr; 881 return CSSValuePool::singleton().createValue(weight, CSSPrimitiveValue::CSS_NUMBER); 882 } 883 884 static RefPtr<CSSPrimitiveValue> consumeFontWeight(CSSParserTokenRange& range) 885 { 886 if (auto result = consumeFontWeightKeywordValue(range)) 887 return result; 888 return consumeNumber(range, ValueRangeAll); 876 return consumeFontWeightNumber(range); 889 877 } 890 878 … … 983 971 if (auto number = consumeNumber(range, ValueRangeAll)) 984 972 return number; 985 return nullptr;986 973 } 987 974 return result; … … 4431 4418 CSSValueID id = m_range.peek().id(); 4432 4419 if (!fontStyle) { 4433 fontStyle = consumeFontStyle KeywordValue(m_range);4420 fontStyle = consumeFontStyle(m_range, m_context.mode); 4434 4421 if (fontStyle) 4435 4422 continue; … … 4443 4430 } 4444 4431 if (!fontWeight) { 4445 fontWeight = consumeFontWeight CSS21(m_range);4432 fontWeight = consumeFontWeight(m_range); 4446 4433 if (fontWeight) 4447 4434 continue; -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r212131 r214324 195 195 return calcParser.consumeNumber(); 196 196 } 197 return nullptr; 198 } 199 200 RefPtr<CSSPrimitiveValue> consumeFontWeightNumber(CSSParserTokenRange& range) 201 { 202 // Values less than or equal to 0 or greater than or equal to 1000 are parse errors. 203 auto& token = range.peek(); 204 if (token.type() == NumberToken && token.numericValue() > 0 && token.numericValue() < 1000) 205 return consumeNumber(range, ValueRangeAll); 206 207 // "[For calc()], the used value resulting from an expression must be clamped to the range allowed in the target context." 208 CalcParser calcParser(range, ValueRangeAll); 209 double result; 210 if (calcParser.consumeNumberRaw(result)) { 211 result = std::min(std::max(result, std::nextafter(0., 1.)), std::nextafter(1000., 0.)); 212 return CSSValuePool::singleton().createValue(result, CSSPrimitiveValue::UnitType::CSS_NUMBER); 213 } 214 197 215 return nullptr; 198 216 } -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h
r209526 r214324 63 63 bool consumeNumberRaw(CSSParserTokenRange&, double& result); 64 64 RefPtr<CSSPrimitiveValue> consumeNumber(CSSParserTokenRange&, ValueRange); 65 RefPtr<CSSPrimitiveValue> consumeFontWeightNumber(CSSParserTokenRange&); 65 66 RefPtr<CSSPrimitiveValue> consumeLength(CSSParserTokenRange&, CSSParserMode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid); 66 67 RefPtr<CSSPrimitiveValue> consumePercent(CSSParserTokenRange&, ValueRange);
Note: See TracChangeset
for help on using the changeset viewer.