⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283279 in webkit


Ignore:
Timestamp:
Sep 29, 2021, 4:31:34 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Implement the 'ic' unit from CSS Values 4
https://bugs.webkit.org/show_bug.cgi?id=204276
<rdar://problem/57256127>

Patch by Kiet Ho <Kiet Ho> on 2021-09-29
Reviewed by Myles C. Maxfield.

LayoutTests/imported/w3c:

Fix ic-unit-{001..012} tests and references to use the IcTestFullWidth font,
which includes the CJK water glyph as a full width character. This avoids an
issue on macOS Catalina where the chosen fallback font renders the glyph
outside of the em box.

Fix ic-unit-{001..004} references to not use the ic unit.

Add two new tests where the CJK water glyph is half-width (ic-unit-013) and zero-width
(ic-unit-014).

  • web-platform-tests/css/css-values/ic-unit-001-expected.html:
  • web-platform-tests/css/css-values/ic-unit-001.html:
  • web-platform-tests/css/css-values/ic-unit-002-expected.html:
  • web-platform-tests/css/css-values/ic-unit-002.html:
  • web-platform-tests/css/css-values/ic-unit-003-expected.html:
  • web-platform-tests/css/css-values/ic-unit-003.html:
  • web-platform-tests/css/css-values/ic-unit-004-expected.html:
  • web-platform-tests/css/css-values/ic-unit-004.html:
  • web-platform-tests/css/css-values/ic-unit-008-expected.html:
  • web-platform-tests/css/css-values/ic-unit-008.html:
  • web-platform-tests/css/css-values/ic-unit-009-expected.html:
  • web-platform-tests/css/css-values/ic-unit-009.html:
  • web-platform-tests/css/css-values/ic-unit-010-expected.html:
  • web-platform-tests/css/css-values/ic-unit-010.html:
  • web-platform-tests/css/css-values/ic-unit-011-expected.html:
  • web-platform-tests/css/css-values/ic-unit-011.html:
  • web-platform-tests/css/css-values/ic-unit-012-expected.html:
  • web-platform-tests/css/css-values/ic-unit-012.html:
  • web-platform-tests/css/css-values/ic-unit-013-expected.html: Added.
  • web-platform-tests/css/css-values/ic-unit-013.html: Added.
  • web-platform-tests/css/css-values/ic-unit-014-expected.html: Added.
  • web-platform-tests/css/css-values/ic-unit-014.html: Added.
  • web-platform-tests/css/css-values/resources/IcTestFullWidth.woff2: Added.
  • web-platform-tests/css/css-values/resources/IcTestHalfWidth.woff2: Added.
  • web-platform-tests/css/css-values/resources/IcTestZeroWidth.woff2: Added.

Source/WebCore:

Tests: fast/css/CSSPrimitiveValue-ic.html

imported/w3c/web-platform-tests/css/css-values/ic-unit-013.html
imported/w3c/web-platform-tests/css/css-values/ic-unit-014.html

  • css/CSSPrimitiveValue.cpp:

(WebCore::isValidCSSUnitTypeForDoubleConversion):
(WebCore::isStringType):
(WebCore::CSSPrimitiveValue::cleanup):
(WebCore::CSSPrimitiveValue::computeUnzoomedNonCalcLengthDouble):
(WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
(WebCore::CSSPrimitiveValue::unitTypeString):
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
(WebCore::CSSPrimitiveValue::equals const):
(WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const):

  • css/CSSPrimitiveValue.h:

(WebCore::CSSPrimitiveValue::isFontRelativeLength):
(WebCore::CSSPrimitiveValue::isLength):

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const):

  • css/CSSUnits.cpp:

(WebCore::unitCategory):
(WebCore::operator<<):

  • css/CSSUnits.h:
  • css/DeprecatedCSSOMPrimitiveValue.cpp:

(WebCore::DeprecatedCSSOMPrimitiveValue::primitiveType const):

  • css/calc/CSSCalcCategoryMapping.cpp:

(WebCore::calcUnitCategory):
(WebCore::calculationCategoryForCombination):
(WebCore::hasDoubleValue):

  • css/parser/CSSParserToken.cpp:

(WebCore::cssPrimitiveValueUnitFromTrie):

  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::consumeLengthRawWithKnownTokenTypeDimension):

  • css/parser/SizesAttributeParser.cpp:

(WebCore::SizesAttributeParser::computeLength):

  • platform/graphics/Font.cpp:

(WebCore::Font::platformGlyphInit): simplyfy logic, reorder misplaced comment.

  • platform/graphics/Font.h: remove property m_zeroGlyph only used once in

WebCore::Font::platformGlyphInit. Remove unused getters adjustedSpaceWidth(),
setSpaceWidths(), setSpaceGlyph(), setZeroWidthSpaceGlyph(), zeroGlyph(), setZeroGlyph().
(WebCore::Font::spaceWidth const):
(WebCore::Font::spaceGlyph const):
(WebCore::Font::zeroWidthSpaceGlyph const):
(WebCore::Font::isZeroWidthSpaceGlyph const):

  • platform/graphics/FontMetrics.h:

(WebCore::FontMetrics::ideogramWidth const): add metric containing the width of an ideogram
glyph in the font. This width is approximated from the width of the CJK water glyph (U+6C34).
(WebCore::FontMetrics::setIdeogramWidth):
(WebCore::FontMetrics::reset):

Source/WTF:

  • wtf/unicode/CharacterNames.h: add CJK water glyph (U+6C34) constant.

LayoutTests:

Added tests for behavior of CSSPrimitiveValue on ic unit.

  • TestExpectations: remove ImageOnlyFailure expectations for ic-unit-* tests, now that they should pass.
  • fast/css/CSSPrimitiveValue-ic-expected.txt: Added.
  • fast/css/CSSPrimitiveValue-ic.html: Added.
Location:
trunk
Files:
9 added
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r283274 r283279  
     12021-09-29  Kiet Ho  <tho22@apple.com>
     2
     3        Implement the 'ic' unit from CSS Values 4
     4        https://bugs.webkit.org/show_bug.cgi?id=204276
     5        <rdar://problem/57256127>
     6
     7        Reviewed by Myles C. Maxfield.
     8
     9        Added tests for behavior of CSSPrimitiveValue on ic unit.
     10
     11        * TestExpectations: remove ImageOnlyFailure expectations for ic-unit-* tests, now that they should pass.
     12        * fast/css/CSSPrimitiveValue-ic-expected.txt: Added.
     13        * fast/css/CSSPrimitiveValue-ic.html: Added.
     14
    1152021-09-29  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/LayoutTests/TestExpectations

    r283223 r283279  
    32743274webkit.org/b/203333 imported/w3c/web-platform-tests/css/css-values/ch-unit-003.html [ ImageOnlyFailure ]
    32753275webkit.org/b/203333 imported/w3c/web-platform-tests/css/css-values/ch-unit-010.html [ ImageOnlyFailure ]
    3276 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-001.html [ ImageOnlyFailure ]
    3277 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-002.html [ ImageOnlyFailure ]
    3278 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-003.html [ ImageOnlyFailure ]
    3279 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-004.html [ ImageOnlyFailure ]
    3280 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-008.html [ ImageOnlyFailure ]
    3281 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-009.html [ ImageOnlyFailure ]
    3282 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-010.html [ ImageOnlyFailure ]
    3283 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-011.html [ ImageOnlyFailure ]
    3284 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-012.html [ ImageOnlyFailure ]
    32853276webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-001.html [ Pass ]
    32863277webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-002.html [ Pass ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r283274 r283279  
     12021-09-29  Kiet Ho  <tho22@apple.com>
     2
     3        Implement the 'ic' unit from CSS Values 4
     4        https://bugs.webkit.org/show_bug.cgi?id=204276
     5        <rdar://problem/57256127>
     6
     7        Reviewed by Myles C. Maxfield.
     8
     9        Fix ic-unit-{001..012} tests and references to use the IcTestFullWidth font,
     10        which includes the CJK water glyph as a full width character. This avoids an
     11        issue on macOS Catalina where the chosen fallback font renders the glyph
     12        outside of the em box.
     13
     14        Fix ic-unit-{001..004} references to not use the ic unit.
     15
     16        Add two new tests where the CJK water glyph is half-width (ic-unit-013) and zero-width
     17        (ic-unit-014).
     18
     19        * web-platform-tests/css/css-values/ic-unit-001-expected.html:
     20        * web-platform-tests/css/css-values/ic-unit-001.html:
     21        * web-platform-tests/css/css-values/ic-unit-002-expected.html:
     22        * web-platform-tests/css/css-values/ic-unit-002.html:
     23        * web-platform-tests/css/css-values/ic-unit-003-expected.html:
     24        * web-platform-tests/css/css-values/ic-unit-003.html:
     25        * web-platform-tests/css/css-values/ic-unit-004-expected.html:
     26        * web-platform-tests/css/css-values/ic-unit-004.html:
     27        * web-platform-tests/css/css-values/ic-unit-008-expected.html:
     28        * web-platform-tests/css/css-values/ic-unit-008.html:
     29        * web-platform-tests/css/css-values/ic-unit-009-expected.html:
     30        * web-platform-tests/css/css-values/ic-unit-009.html:
     31        * web-platform-tests/css/css-values/ic-unit-010-expected.html:
     32        * web-platform-tests/css/css-values/ic-unit-010.html:
     33        * web-platform-tests/css/css-values/ic-unit-011-expected.html:
     34        * web-platform-tests/css/css-values/ic-unit-011.html:
     35        * web-platform-tests/css/css-values/ic-unit-012-expected.html:
     36        * web-platform-tests/css/css-values/ic-unit-012.html:
     37        * web-platform-tests/css/css-values/ic-unit-013-expected.html: Added.
     38        * web-platform-tests/css/css-values/ic-unit-013.html: Added.
     39        * web-platform-tests/css/css-values/ic-unit-014-expected.html: Added.
     40        * web-platform-tests/css/css-values/ic-unit-014.html: Added.
     41        * web-platform-tests/css/css-values/resources/IcTestFullWidth.woff2: Added.
     42        * web-platform-tests/css/css-values/resources/IcTestHalfWidth.woff2: Added.
     43        * web-platform-tests/css/css-values/resources/IcTestZeroWidth.woff2: Added.
     44
    1452021-09-29  Chris Dumez  <cdumez@apple.com>
    246
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-001-expected.html

    r251521 r283279  
    44<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">
    55<style>
    6 svg { width: 10ic; }
     6.ref {
     7    width: 200px;
     8    height: 200px;
     9    background: green;
     10}
    711</style>
    812<body>
    913    <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
    10     <svg viewBox="0 0 100 100"><rect x="0" y="0" width="100" height="100" fill="green"></svg>
     14    <div class="ref"></div>
    1115</body>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-001.html

    r251521 r283279  
    77<meta name="assert" content="The ic unit is equal to the used advance measure of the 水 (CJK water ideograph, U+6C34) glyph found in the font used to render it.">
    88<style>
     9@font-face {
     10    font-family: IcTestFullWidth;
     11    src: url(resources/IcTestFullWidth.woff2);
     12}
     13
    914span {
     15    font: 20px IcTestFullWidth;
    1016    background: green;
    1117    color: green;
     
    1420}
    1521div {
     22    font: 20px IcTestFullWidth;
    1623    background: red;
    1724    color: red;
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-002-expected.html

    r251521 r283279  
    44<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">
    55<style>
    6 svg {
    7     width: 10ic;
    8     writing-mode: vertical-rl;
    9     text-orientation: upright;
     6.ref {
     7    width: 200px;
     8    height: 200px;
     9    background: green;
    1010}
    1111</style>
    1212<body>
    1313    <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
    14     <svg viewBox="0 0 100 100"><rect x="0" y="0" width="100" height="100" fill="green"></svg>
     14    <div class="ref"></div>
    1515</body>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-002.html

    r251521 r283279  
    99<meta name="assert" content="In vertical upright, the ic unit is equal to the used vertical advance measure of the 水 (CJK water ideograph, U+6C34) glyph found in the font used to render it.">
    1010<style>
     11@font-face {
     12    font-family: IcTestFullWidth;
     13    src: url(resources/IcTestFullWidth.woff2);
     14}
     15
    1116span {
     17    font: 20px IcTestFullWidth;
    1218    background: green;
    1319    color: green;
     
    1521    position: absolute;
    1622}
     23
    1724div {
     25    font: 20px IcTestFullWidth;
    1826    background: red;
    1927    color: red;
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-003-expected.html

    r251521 r283279  
    44<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">
    55<style>
    6 svg {
    7     width: 10ic;
    8     writing-mode: vertical-rl;
    9     text-orientation: upright;
     6.ref {
     7    width: 200px;
     8    height: 200px;
     9    background: green;
    1010}
    1111</style>
    1212<body>
    1313    <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
    14     <svg viewBox="0 0 100 100"><rect x="0" y="0" width="100" height="100" fill="green"></svg>
     14    <div class="ref"></div>
    1515</body>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-003.html

    r251521 r283279  
    99<meta name="assert" content="In vertical mixed, the ic unit is equal to the used vertical advance measure of the 水 (CJK water ideograph, U+6C34) glyph found in the font used to render it.">
    1010<style>
     11@font-face {
     12    font-family: IcTestFullWidth;
     13    src: url(resources/IcTestFullWidth.woff2);
     14}
     15
    1116span {
     17    font: 20px IcTestFullWidth;
    1218    background: green;
    1319    color: green;
     
    1521    position: absolute;
    1622}
     23
    1724div {
     25    font: 20px IcTestFullWidth;
    1826    background: red;
    1927    color: red;
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-004-expected.html

    r251521 r283279  
    44<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">
    55<style>
    6 svg { width: 10ic; }
     6.ref {
     7    width: 200px;
     8    height: 200px;
     9    background: green;
     10}
    711</style>
    812<body>
    913    <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
    10     <svg viewBox="0 0 100 100"><rect x="0" y="0" width="100" height="100" fill="green"></svg>
     14    <div class="ref"></div>
    1115</body>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-004.html

    r251521 r283279  
    99<meta name="assert" content="In vertical sideways, the ic unit is equal to the used horizontal advance measure of the 水 (CJK water ideograph, U+6C34) glyph found in the font used to render it.">
    1010<style>
     11@font-face {
     12    font-family: IcTestFullWidth;
     13    src: url(resources/IcTestFullWidth.woff2);
     14}
     15
    1116span {
     17    font: 20px IcTestFullWidth;
    1218    background: green;
    1319    color: green;
     
    1521    position: absolute;
    1622}
     23
    1724div {
     25    font: 20px IcTestFullWidth;
    1826    background: red;
    1927    color: red;
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-008-expected.html

    r251521 r283279  
    88
    99  <style>
     10  @font-face
     11    {
     12      font-family: IcTestFullWidth;
     13      src: url(resources/IcTestFullWidth.woff2);
     14    }
     15
    1016  div
    1117    {
    1218      float: left;
     19      font-family: IcTestFullWidth;
    1320      font-size: 80px; /* arbitrary font size */
    1421      line-height: 1.8; /* arbitrary line-height */
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-008.html

    r251521 r283279  
    1313
    1414  <style>
     15  @font-face
     16    {
     17      font-family: IcTestFullWidth;
     18      src: url(resources/IcTestFullWidth.woff2);
     19    }
     20
    1521  div
    1622    {
    1723      float: left;
     24      font-family: IcTestFullWidth;
    1825      font-size: 80px; /* arbitrary font size */
    1926    }
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-009-expected.html

    r251521 r283279  
    88
    99  <style>
     10  @font-face
     11    {
     12      font-family: IcTestFullWidth;
     13      src: url(resources/IcTestFullWidth.woff2);
     14    }
     15
    1016  div
    1117    {
    1218      float: left;
     19      font-family: IcTestFullWidth;
    1320      font-size: 80px; /* arbitrary font size */
    1421      line-height: 1.8; /* arbitrary line-height */
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-009.html

    r251521 r283279  
    1313
    1414  <style>
     15  @font-face
     16    {
     17      font-family: IcTestFullWidth;
     18      src: url(resources/IcTestFullWidth.woff2);
     19    }
     20
    1521  div
    1622    {
    1723      float: left;
     24      font-family: IcTestFullWidth;
    1825      font-size: 80px; /* arbitrary font size */
    1926      writing-mode: vertical-rl;
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-010-expected.html

    r251521 r283279  
    88
    99  <style>
     10  @font-face
     11    {
     12      font-family: IcTestFullWidth;
     13      src: url(resources/IcTestFullWidth.woff2);
     14    }
     15
    1016  div
    1117    {
    1218      float: left;
     19      font-family: IcTestFullWidth;
    1320      font-size: 80px; /* arbitrary font size */
    1421      line-height: 1.8; /* arbitrary line-height */
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-010.html

    r251521 r283279  
    1313
    1414  <style>
     15  @font-face
     16    {
     17      font-family: IcTestFullWidth;
     18      src: url(resources/IcTestFullWidth.woff2);
     19    }
     20
    1521  div
    1622    {
    1723      float: left;
     24      font-family: IcTestFullWidth;
    1825      font-size: 80px; /* arbitrary font size */
    1926      text-orientation: mixed;
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-011-expected.html

    r251521 r283279  
    88
    99  <style>
     10  @font-face
     11    {
     12      font-family: IcTestFullWidth;
     13      src: url(resources/IcTestFullWidth.woff2);
     14    }
     15
    1016  div
    1117    {
    1218      float: left;
     19      font-family: IcTestFullWidth;
    1320      font-size: 80px; /* arbitrary font size */
    1421      line-height: 1.8; /* arbitrary line-height */
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-011.html

    r251521 r283279  
    1313
    1414  <style>
     15  @font-face
     16    {
     17      font-family: IcTestFullWidth;
     18      src: url(resources/IcTestFullWidth.woff2);
     19    }
     20
    1521  div
    1622    {
    1723      float: left;
     24      font-family: IcTestFullWidth;
    1825      font-size: 80px; /* arbitrary font size */
    1926      text-orientation: upright;
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-012-expected.html

    r251521 r283279  
    88
    99  <style>
     10  @font-face
     11    {
     12      font-family: IcTestFullWidth;
     13      src: url(resources/IcTestFullWidth.woff2);
     14    }
     15
    1016  div
    1117    {
    1218      float: left;
     19      font-family: IcTestFullWidth;
    1320      font-size: 80px; /* arbitrary font size */
    1421      line-height: 1.8; /* arbitrary line-height */
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/ic-unit-012.html

    r251521 r283279  
    1313
    1414  <style>
     15  @font-face
     16    {
     17      font-family: IcTestFullWidth;
     18      src: url(resources/IcTestFullWidth.woff2);
     19    }
     20
    1521  div
    1622    {
    1723      float: left;
     24      font-family: IcTestFullWidth;
    1825      font-size: 80px; /* arbitrary font size */
    1926      text-orientation: sideways;
  • trunk/Source/WTF/ChangeLog

    r283218 r283279  
     12021-09-29  Kiet Ho  <tho22@apple.com>
     2
     3        Implement the 'ic' unit from CSS Values 4
     4        https://bugs.webkit.org/show_bug.cgi?id=204276
     5        <rdar://problem/57256127>
     6
     7        Reviewed by Myles C. Maxfield.
     8
     9        * wtf/unicode/CharacterNames.h: add CJK water glyph (U+6C34) constant.
     10
    1112021-09-29  Antti Koivisto  <antti@apple.com>
    212
  • trunk/Source/WTF/wtf/unicode/CharacterNames.h

    r282415 r283279  
    5151constexpr UChar byteOrderMark = 0xFEFF;
    5252constexpr UChar carriageReturn = 0x000D;
     53constexpr UChar cjkWater = 0x6C34;
    5354constexpr UChar combiningEnclosingKeycap = 0x20E3;
    5455constexpr UChar deleteCharacter = 0x007F;
     
    130131using WTF::Unicode::byteOrderMark;
    131132using WTF::Unicode::carriageReturn;
     133using WTF::Unicode::cjkWater;
    132134using WTF::Unicode::combiningEnclosingKeycap;
    133135using WTF::Unicode::deleteCharacter;
  • trunk/Source/WebCore/ChangeLog

    r283276 r283279  
     12021-09-29  Kiet Ho  <tho22@apple.com>
     2
     3        Implement the 'ic' unit from CSS Values 4
     4        https://bugs.webkit.org/show_bug.cgi?id=204276
     5        <rdar://problem/57256127>
     6
     7        Reviewed by Myles C. Maxfield.
     8
     9        Tests: fast/css/CSSPrimitiveValue-ic.html
     10               imported/w3c/web-platform-tests/css/css-values/ic-unit-013.html
     11               imported/w3c/web-platform-tests/css/css-values/ic-unit-014.html
     12
     13        * css/CSSPrimitiveValue.cpp:
     14        (WebCore::isValidCSSUnitTypeForDoubleConversion):
     15        (WebCore::isStringType):
     16        (WebCore::CSSPrimitiveValue::cleanup):
     17        (WebCore::CSSPrimitiveValue::computeUnzoomedNonCalcLengthDouble):
     18        (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
     19        (WebCore::CSSPrimitiveValue::unitTypeString):
     20        (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
     21        (WebCore::CSSPrimitiveValue::equals const):
     22        (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const):
     23        * css/CSSPrimitiveValue.h:
     24        (WebCore::CSSPrimitiveValue::isFontRelativeLength):
     25        (WebCore::CSSPrimitiveValue::isLength):
     26        * css/CSSPrimitiveValueMappings.h:
     27        (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const):
     28        * css/CSSUnits.cpp:
     29        (WebCore::unitCategory):
     30        (WebCore::operator<<):
     31        * css/CSSUnits.h:
     32        * css/DeprecatedCSSOMPrimitiveValue.cpp:
     33        (WebCore::DeprecatedCSSOMPrimitiveValue::primitiveType const):
     34        * css/calc/CSSCalcCategoryMapping.cpp:
     35        (WebCore::calcUnitCategory):
     36        (WebCore::calculationCategoryForCombination):
     37        (WebCore::hasDoubleValue):
     38        * css/parser/CSSParserToken.cpp:
     39        (WebCore::cssPrimitiveValueUnitFromTrie):
     40        * css/parser/CSSPropertyParserHelpers.cpp:
     41        (WebCore::CSSPropertyParserHelpers::consumeLengthRawWithKnownTokenTypeDimension):
     42        * css/parser/SizesAttributeParser.cpp:
     43        (WebCore::SizesAttributeParser::computeLength):
     44        * platform/graphics/Font.cpp:
     45        (WebCore::Font::platformGlyphInit): simplyfy logic, reorder misplaced comment.
     46        * platform/graphics/Font.h: remove property `m_zeroGlyph` only used once in
     47        WebCore::Font::platformGlyphInit. Remove unused getters adjustedSpaceWidth(),
     48        setSpaceWidths(), setSpaceGlyph(), setZeroWidthSpaceGlyph(), zeroGlyph(), setZeroGlyph().
     49        (WebCore::Font::spaceWidth const):
     50        (WebCore::Font::spaceGlyph const):
     51        (WebCore::Font::zeroWidthSpaceGlyph const):
     52        (WebCore::Font::isZeroWidthSpaceGlyph const):
     53        * platform/graphics/FontMetrics.h:
     54        (WebCore::FontMetrics::ideogramWidth const): add metric containing the width of an ideogram
     55        glyph in the font. This width is approximated from the width of the CJK water glyph (U+6C34).
     56        (WebCore::FontMetrics::setIdeogramWidth):
     57        (WebCore::FontMetrics::reset):
     58
    1592021-09-29  BJ Burg  <bburg@apple.com>
    260
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r282396 r283279  
    5757    case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_NUMBER:
    5858    case CSSUnitType::CSS_CHS:
     59    case CSSUnitType::CSS_IC:
    5960    case CSSUnitType::CSS_CM:
    6061    case CSSUnitType::CSS_DEG:
     
    131132    case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_NUMBER:
    132133    case CSSUnitType::CSS_CHS:
     134    case CSSUnitType::CSS_IC:
    133135    case CSSUnitType::CSS_CM:
    134136    case CSSUnitType::CSS_COUNTER:
     
    494496    case CSSUnitType::CSS_REMS:
    495497    case CSSUnitType::CSS_CHS:
     498    case CSSUnitType::CSS_IC:
    496499    case CSSUnitType::CSS_PX:
    497500    case CSSUnitType::CSS_CM:
     
    614617        ASSERT(fontMetrics);
    615618        return fontMetrics->zeroWidth() * value;
     619    case CSSUnitType::CSS_IC:
     620        ASSERT(fontMetrics);
     621        return fontMetrics->ideogramWidth() * value;
    616622    case CSSUnitType::CSS_PX:
    617623        return value;
     
    681687
    682688    case CSSUnitType::CSS_CHS:
     689    case CSSUnitType::CSS_IC:
    683690        ASSERT(conversionData.style());
    684691        value = computeUnzoomedNonCalcLengthDouble(primitiveType, value, conversionData.propertyToCompute(), &conversionData.style()->fontMetrics());
     
    983990        case CSSUnitType::CSS_REMS: return "rem";
    984991        case CSSUnitType::CSS_CHS: return "ch";
     992        case CSSUnitType::CSS_IC: return "ic";
    985993
    986994        case CSSUnitType::CSS_UNKNOWN:
     
    10311039    case CSSUnitType::CSS_CHS:
    10321040        return formatNumberValue("ch");
     1041    case CSSUnitType::CSS_IC:
     1042        return formatNumberValue("ic");
    10331043    case CSSUnitType::CSS_PX:
    10341044        return formatNumberValue("px");
     
    11751185    case CSSUnitType::CSS_REMS:
    11761186    case CSSUnitType::CSS_CHS:
     1187    case CSSUnitType::CSS_IC:
    11771188    case CSSUnitType::CSS_PX:
    11781189    case CSSUnitType::CSS_CM:
     
    12531264    case CSSUnitType::CSS_EXS:
    12541265    case CSSUnitType::CSS_CHS:
     1266    case CSSUnitType::CSS_IC:
    12551267        values.add(CSSPropertyFontSize);
    12561268        break;
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r282396 r283279  
    283283        || type == CSSUnitType::CSS_REMS
    284284        || type == CSSUnitType::CSS_CHS
     285        || type == CSSUnitType::CSS_IC
    285286        || type == CSSUnitType::CSS_QUIRKY_EMS;
    286287}
     
    298299        || type == CSSUnitType::CSS_REMS
    299300        || type == CSSUnitType::CSS_CHS
     301        || type == CSSUnitType::CSS_IC
    300302        || type == CSSUnitType::CSS_Q
    301303        || type == CSSUnitType::CSS_LHS
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r282920 r283279  
    44094409    case CSSUnitType::CSS_EXS:
    44104410    case CSSUnitType::CSS_CHS:
     4411    case CSSUnitType::CSS_IC:
    44114412    case CSSUnitType::CSS_LHS:
    44124413        return lengthConversion & (FixedIntegerConversion | FixedFloatConversion);
  • trunk/Source/WebCore/css/CSSUnits.cpp

    r282396 r283279  
    4040    case CSSUnitType::CSS_PC:
    4141    case CSSUnitType::CSS_Q:
     42    case CSSUnitType::CSS_IC:
    4243        return CSSUnitCategory::Length;
    4344    case CSSUnitType::CSS_MS:
     
    151152    case CSSUnitType::CSS_REMS: ts << "rems"; break;
    152153    case CSSUnitType::CSS_CHS: ts << "chs"; break;
     154    case CSSUnitType::CSS_IC: ts << "ics"; break;
    153155    case CSSUnitType::CSS_COUNTER_NAME: ts << "counter_name"; break;
    154156    case CSSUnitType::CSS_SHAPE: ts << "shape"; break;
  • trunk/Source/WebCore/css/CSSUnits.h

    r282396 r283279  
    7676    CSS_REMS,
    7777    CSS_CHS,
     78    CSS_IC,
    7879
    7980    CSS_COUNTER_NAME,
  • trunk/Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.cpp

    r282396 r283279  
    4444    case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_NUMBER:  return 114;
    4545    case CSSUnitType::CSS_CHS:                          return 109;
     46    case CSSUnitType::CSS_IC:                           return CSS_UNKNOWN;
    4647    case CSSUnitType::CSS_CM:                           return CSS_CM;
    4748    case CSSUnitType::CSS_COUNTER:                      return CSS_COUNTER;
  • trunk/Source/WebCore/css/calc/CSSCalcCategoryMapping.cpp

    r282396 r283279  
    5050    case CSSUnitType::CSS_REMS:
    5151    case CSSUnitType::CSS_CHS:
     52    case CSSUnitType::CSS_IC:
    5253    case CSSUnitType::CSS_VW:
    5354    case CSSUnitType::CSS_VH:
     
    105106    case CSSUnitType::CSS_RLHS:
    106107    case CSSUnitType::CSS_CHS:
     108    case CSSUnitType::CSS_IC:
    107109    case CSSUnitType::CSS_VW:
    108110    case CSSUnitType::CSS_VH:
     
    140142    case CSSUnitType::CSS_EXS:
    141143    case CSSUnitType::CSS_CHS:
     144    case CSSUnitType::CSS_IC:
    142145    case CSSUnitType::CSS_REMS:
    143146    case CSSUnitType::CSS_PX:
  • trunk/Source/WebCore/css/parser/CSSParserToken.cpp

    r282396 r283279  
    8484            break;
    8585        case 'i':
    86             if (toASCIILower(data[1]) == 'n')
     86            switch (toASCIILower(data[1])) {
     87            case 'c':
     88                return CSSUnitType::CSS_IC;
     89            case 'n':
    8790                return CSSUnitType::CSS_IN;
     91            }
    8892            break;
    8993        case 'l':
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

    r283221 r283279  
    474474    case CSSUnitType::CSS_RLHS:
    475475    case CSSUnitType::CSS_CHS:
     476    case CSSUnitType::CSS_IC:
    476477    case CSSUnitType::CSS_EXS:
    477478    case CSSUnitType::CSS_PX:
  • trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp

    r259703 r283279  
    5858    // RenderView, which has its font information hardcoded in resolveForDocument() to be -webkit-standard, whose operations
    5959    // don't require a font selector.
    60     if (type == CSSUnitType::CSS_EXS || type == CSSUnitType::CSS_CHS) {
     60    if (type == CSSUnitType::CSS_EXS || type == CSSUnitType::CSS_CHS || type == CSSUnitType::CSS_IC) {
    6161        RefPtr<FontSelector> fontSelector = style.fontCascade().fontSelector();
    6262        style.fontCascade().update(nullptr);
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r282863 r283279  
    140140    UChar32 zeroWidthSpaceCharacter = 0;
    141141#endif
    142     auto* glyphPageCharacterZero = glyphPage(GlyphPage::pageNumberForCodePoint('0'));
    143     auto* glyphPageSpace = glyphPage(GlyphPage::pageNumberForCodePoint(space));
    144142
    145143    if (glyphPageZeroWidthSpace)
    146144        m_zeroWidthSpaceGlyph = glyphPageZeroWidthSpace->glyphDataForCharacter(zeroWidthSpaceCharacter).glyph;
    147145
    148     // Nasty hack to determine if we should round or ceil space widths.
    149     // If the font is monospace or fake monospace we ceil to ensure that
    150     // every character and the space are the same width. Otherwise we round.
    151     if (glyphPageSpace)
    152         m_spaceGlyph = glyphPageSpace->glyphDataForCharacter(space).glyph;
    153     if (glyphPageCharacterZero)
    154         m_zeroGlyph = glyphPageCharacterZero->glyphDataForCharacter('0').glyph;
     146    if (auto* page = glyphPage(GlyphPage::pageNumberForCodePoint(space)))
     147        m_spaceGlyph = page->glyphDataForCharacter(space).glyph;
    155148
    156149    // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE.
     
    160153        m_zeroWidthSpaceGlyph = 0;
    161154
    162     float width = widthForGlyph(m_spaceGlyph);
    163     m_spaceWidth = width;
    164     m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph));
     155    // widthForGlyph depends on m_zeroWidthSpaceGlyph having the correct value.
     156    // Therefore all calls to widthForGlyph must happen after this point.
     157
     158    Glyph zeroGlyph = { 0 };
     159    if (auto* page = glyphPage(GlyphPage::pageNumberForCodePoint('0')))
     160        zeroGlyph = page->glyphDataForCharacter('0').glyph;
     161    m_fontMetrics.setZeroWidth(widthForGlyph(zeroGlyph));
     162
     163    // Use the width of the CJK water ideogram (U+6C34) as the
     164    // approximated width of ideograms in the font, as mentioned in
     165    // https://www.w3.org/TR/css-values-4/#ic. This is currently only used
     166    // to support the ic unit. If the width is not available, falls back to
     167    // 1em as specified.
     168    if (auto* page = glyphPage(GlyphPage::pageNumberForCodePoint(cjkWater))) {
     169        auto glyph = page->glyphDataForCharacter(cjkWater).glyph;
     170        m_fontMetrics.setIdeogramWidth(widthForGlyph(glyph));
     171    } else
     172        m_fontMetrics.setIdeogramWidth(platformData().size());
     173
     174    m_spaceWidth = widthForGlyph(m_spaceGlyph);
    165175    auto amountToAdjustLineGap = std::min(m_fontMetrics.floatLineGap(), 0.0f);
    166176    m_fontMetrics.setLineGap(m_fontMetrics.floatLineGap() - amountToAdjustLineGap);
    167177    m_fontMetrics.setLineSpacing(m_fontMetrics.floatLineSpacing() - amountToAdjustLineGap);
    168178    determinePitch();
    169     m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
     179    // Nasty hack to determine if we should round or ceil space widths.
     180    // If the font is monospace or fake monospace we ceil to ensure that
     181    // every character and the space are the same width. Otherwise we round.
     182    m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(m_spaceWidth) : roundf(m_spaceWidth);
    170183}
    171184
  • trunk/Source/WebCore/platform/graphics/Font.h

    r281687 r283279  
    136136    bool isTextOrientationFallback() const { return m_isTextOrientationFallback; }
    137137
    138     FontMetrics& fontMetrics() { return m_fontMetrics; }
    139138    const FontMetrics& fontMetrics() const { return m_fontMetrics; }
    140139    float sizePerUnit() const { return platformData().size() / (fontMetrics().unitsPerEm() ? fontMetrics().unitsPerEm() : 1); }
     
    154153
    155154    float spaceWidth() const { return m_spaceWidth; }
    156     float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
    157     void setSpaceWidths(float spaceWidth)
    158     {
    159         m_spaceWidth = spaceWidth;
    160         m_adjustedSpaceWidth = spaceWidth;
    161     }
    162155
    163156    float syntheticBoldOffset() const { return m_syntheticBoldOffset; }
    164157
    165158    Glyph spaceGlyph() const { return m_spaceGlyph; }
    166     void setSpaceGlyph(Glyph spaceGlyph) { m_spaceGlyph = spaceGlyph; }
    167159    Glyph zeroWidthSpaceGlyph() const { return m_zeroWidthSpaceGlyph; }
    168     void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spaceGlyph; }
    169160    bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; }
    170     Glyph zeroGlyph() const { return m_zeroGlyph; }
    171     void setZeroGlyph(Glyph zeroGlyph) { m_zeroGlyph = zeroGlyph; }
    172161
    173162    GlyphData glyphDataForCharacter(UChar32) const;
     
    328317
    329318    Glyph m_spaceGlyph { 0 };
    330     Glyph m_zeroGlyph { 0 };
    331319    Glyph m_zeroWidthSpaceGlyph { 0 };
    332320
  • trunk/Source/WebCore/platform/graphics/FontMetrics.h

    r252927 r283279  
    123123    void setZeroWidth(float zeroWidth) { m_zeroWidth = zeroWidth; }
    124124
     125    float ideogramWidth() const { return m_ideogramWidth; }
     126    void setIdeogramWidth(float ideogramWidth) { m_ideogramWidth = ideogramWidth; }
     127
    125128    float underlinePosition() const { return m_underlinePosition; }
    126129    void setUnderlinePosition(float underlinePosition) { m_underlinePosition = underlinePosition; }
     
    147150        m_xHeight = 0;
    148151        m_zeroWidth = 0;
     152        m_ideogramWidth = 0;
    149153        m_underlinePosition = 0;
    150154        m_underlineThickness = 0;
     
    167171
    168172    float m_zeroWidth { 0 };
     173    float m_ideogramWidth { 0 };
    169174    float m_xHeight { 0 };
    170175    float m_underlinePosition { 0 };
Note: See TracChangeset for help on using the changeset viewer.