[webkit-changes] [WebKit/WebKit] 30bf0f: font-face must accept ranges in reverse order, and...

Darin Adler noreply at github.com
Sun Oct 23 00:36:03 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 30bf0f961d694189c96d527c0a0c86fe3a656c5d
      https://github.com/WebKit/WebKit/commit/30bf0f961d694189c96d527c0a0c86fe3a656c5d
  Author: Darin Adler <darin at apple.com>
  Date:   2022-10-23 (Sun, 23 Oct 2022)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/fast/text/font-face-javascript-expected.txt
    M LayoutTests/fast/text/font-face-javascript.html
    M LayoutTests/fast/text/font-loading-font-display-expected.txt
    M LayoutTests/fast/text/font-loading-font-display.html
    M LayoutTests/fast/text/font-selection-font-face-parse-expected.txt
    M LayoutTests/fast/text/font-selection-font-face-parse.html
    M LayoutTests/fast/text/font-selection-font-loading-api-parse-expected.txt
    M LayoutTests/fast/text/font-selection-font-loading-api-parse.html
    M LayoutTests/fast/text/variations/font-loading-api-parse-ranges-expected.txt
    M LayoutTests/fast/text/variations/font-loading-api-parse-ranges.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-face-range-order-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/at-font-face-descriptors-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/at-font-face-font-matching-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-parse-numeric-stretch-style-weight-expected.txt
    R LayoutTests/platform/gtk/fast/text/font-selection-font-loading-api-parse-expected.txt
    R LayoutTests/platform/ios/fast/text/font-selection-font-face-parse-expected.txt
    R LayoutTests/platform/ios/fast/text/font-selection-font-loading-api-parse-expected.txt
    M LayoutTests/platform/mac/TestExpectations
    R LayoutTests/platform/mac/fast/text/font-selection-font-face-parse-expected.txt
    R LayoutTests/platform/mac/fast/text/font-selection-font-loading-api-parse-expected.txt
    R LayoutTests/platform/wpe/fast/text/font-selection-font-face-parse-expected.txt
    R LayoutTests/platform/wpe/fast/text/font-selection-font-loading-api-parse-expected.txt
    M Source/WebCore/css/CSSFontFace.cpp
    M Source/WebCore/css/CSSFontFace.h
    M Source/WebCore/css/CSSFontFaceSet.cpp
    M Source/WebCore/css/CSSFontFaceSet.h
    M Source/WebCore/css/CSSFontSelector.cpp
    M Source/WebCore/css/CSSFontSelector.h
    M Source/WebCore/css/CSSSegmentedFontFace.cpp
    M Source/WebCore/css/FontFace.cpp
    M Source/WebCore/css/FontFace.h
    M Source/WebCore/css/FontFace.idl
    M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp
    M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.h
    M Source/WebCore/platform/graphics/FontSelectionAlgorithm.h

  Log Message:
  -----------
  font-face must accept ranges in reverse order, and reverse them for *computed* style
https://bugs.webkit.org/show_bug.cgi?id=246585
rdar://problem/101210777

[ Mac ] imported/w3c/web-platform-tests/server-timing/service_worker_idl.html is flaky failing
https://bugs.webkit.org/show_bug.cgi?id=219907
rdar://problem/72351272

https://bugs.webkit.org/show_bug.cgi?id=244900
New Test(254036 at main): [ iOS macOS Debug ] 3X imported/w3c/web-platform-tests/dom/nodes/NodeList-static-length-getter-tampered-indexOf-(Layout tests) are constant timeouts
rdar://problem/99657326

Reviewed by Tim Nguyen.

The biggest change here is to store the specified values in CSSFontFace. The existing code was
not storing these values, and when querying it would return a computed value, but that is not
the same thing. We store the values either in the style properties of a StyleRuleFontFace if this
font face is connected to a CSS style rule, or in our own MutableStyleProperties object if it is
not connected.

When it comes to tests, many of the ones we wrote for WebKit were expecting the computed values,
but the web platform tests were expecting the specified values. The WebKit ones needed some
updating to expect the correct behavior.

* LayoutTests/fast/text/font-face-javascript-expected.txt:
* LayoutTests/fast/text/font-face-javascript.html: Updated to expect the style attribute to return
the specified style "oblique" rather than the computed style "italic".

* LayoutTests/fast/text/font-loading-font-display-expected.txt:
* LayoutTests/fast/text/font-loading-font-display.html: Updated to expect font-display to get set
to "auto" when we set the display attribute on a FontFace to "auto". The old code expected the
empty string, but a review of the specification makes it clear that was not correct.

* LayoutTests/fast/text/font-selection-font-face-parse-expected.txt:
* LayoutTests/fast/text/font-selection-font-face-parse.html: Updated since out of order ranges now
are parsed successfully. There was one test case each for fontWeight, fontStretch, and fontStyle
that was affected.

* LayoutTests/fast/text/font-selection-font-loading-api-parse-expected.txt:
* LayoutTests/fast/text/font-selection-font-loading-api-parse.html: Updated since the style
attribute now returns the specified style rather than the computed style. That means we get "400"
instead of "normal" and "700" instead of "bold", and other similar changes.

* LayoutTests/fast/text/variations/font-loading-api-parse-ranges-expected.txt:
* LayoutTests/fast/text/variations/font-loading-api-parse-ranges.html: Updated since out of order
ranges are now parsed successfully. There was one case each for weight, stretch, and style that
was affected.

* LayoutTests/TestExpectations: Removed expectation for simulcast-h264.html, which has been removed.

* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-face-range-order-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/at-font-face-descriptors-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/at-font-face-font-matching-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-parse-numeric-stretch-style-weight-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-style-parsing-expected.txt:
Updated expected results. These are mostly progressions. In a few cases we have a test that is
newly failing because we are now parsing font-face correctly and matching incorrectly. In those
cases the old version failed to parse so the test was saying PASS but that was a false negative.

* LayoutTests/platform/gtk/fast/text/font-selection-font-loading-api-parse-expected.txt: Removed.
* LayoutTests/platform/ios/fast/text/font-selection-font-face-parse-expected.txt: Removed.
* LayoutTests/platform/ios/fast/text/font-selection-font-loading-api-parse-expected.txt: Removed.
* LayoutTests/platform/mac/fast/text/font-selection-font-face-parse-expected.txt: Removed.
* LayoutTests/platform/mac/fast/text/font-selection-font-loading-api-parse-expected.txt: Removed.
* LayoutTests/platform/wpe/fast/text/font-selection-font-face-parse-expected.txt: Removed.
* LayoutTests/platform/wpe/fast/text/font-selection-font-loading-api-parse-expected.txt: Removed.

* LayoutTests/platform/mac/TestExpectations: Removed expectations for service_worker_idl.html and
NodeList-static-length-getter-tampered-indexOf-[1-3].html, which have been removed.

* Source/WebCore/css/CSSFontFace.cpp:
(WebCore::propertiesOrCSSConnection): Added. Helper for the below. Could have used a lambda, but then
the style checker would have gotten all confused.
(WebCore::CSSFontFace::CSSFontFace): Initialize m_propertiesOrCSSConnection.
(WebCore::CSSFontFace::properties): Added.
(WebCore::CSSFontFace::mutableProperties): Added.
(WebCore::CSSFontFace::cssConnection): Moved here from the header.
(WebCore::CSSFontFace::setFamilies): Changed argument type to CSSValueList. Use mutableProperties.
Removed unneeded boolean return value.
(WebCore::CSSFontFace::setWeight): Use mutableProperties. Set the weight in
m_fontSelectionCapabilities directly rather than using a helper function.
(WebCore::CSSFontFace::setStretch): Use mutableProperties. Set the stretch in
m_fontSelectionCapabilities directly rather than using a helper function.
(WebCore::CSSFontFace::setStyle): Use mutableProperties. Set the slope in
m_fontSelectionCapabilities directly rather than using a helper function.
(WebCore::CSSFontFace::setUnicodeRange): Changed argument type to CSSValueList. Use
mutableProperties. Removed unneeded boolean return value.
(WebCore::CSSFontFace::setFeatureSettings): Use mutableProperties. Renamed the
existing data member to m_parsedFeatureSettings.
(WebCore::CSSFontFace::setDisplay): Renamed from setLoadingBehavior to match the terminology in the
specification. Use mutableProperties. Changed the argument type to CSSPrimitiveValue.
(WebCore::CSSFontFace::family const): Added. Gets the property from the properties object. Moved
logic here, to work around the fact that we use a list, from FontFace::family.
(WebCore::CSSFontFace::style const): Ditto.
(WebCore::CSSFontFace::weight const): Ditto.
(WebCore::CSSFontFace::stretch const): Ditto.
(WebCore::CSSFontFace::unicodeRange const): Ditto.
(WebCore::CSSFontFace::featureSettings const): Ditto.
(WebCore::CSSFontFace::display const): Ditto.
(WebCore::CSSFontFace::families const): Just a simple getter, here so the header does not have
to include CSSValueList.h.

* Source/WebCore/css/CSSFontFace.h: Updated for the above. Removed the functions that returned
various computed properties, and instead have functions that return the specified properties
as strings since that is what FontFace needs for its interface. The only ones that return computed
properties that are kept are families, ranges, and fontSelectionCapabilities; they could probably
use names that make it clear they return computed values. Return a span instead of a vector from
the ranges function, a pointer instead of an optional pointer from the families function, and a
non-optional FontSelectionCapabilities from the fontSelectionCapabilities function. Added private
member functions named properties and mutableProperties and replaced m_cssConnection with a
private data member named m_propertiesOrCSSConnection. These store the specified property values
in the appropriate place whether or not a CSS connection exists.

* Source/WebCore/css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered): Added a comment.
(WebCore::CSSFontFaceSet::addToFacesLookupTable): Updated for the return type change of
CSSFontFace::families.
(WebCore::CSSFontFaceSet::remove): Ditto.
(WebCore::CSSFontFaceSet::fontFace): Updated to check the loading staus explicitly instead of
doing it implicitly with the optional status of fontSelectionCapabilities. This makes it more
explicit what this is doing, and perhaps might even lead us to discover the code is unneeded later.
Updated since fontSelectionCapabilities return type is no longer optional.

* Source/WebCore/css/CSSFontFaceSet.h: Added newly-needed forward declaration.

* Source/WebCore/css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule): Updated for changes to CSSFontFace::setFamilies,
CSSFontFace::setUnicodeRange, and CSSFontFace::setDisplay.

* Source/WebCore/css/CSSFontSelector.h: Removed unneeded forward declaration.

* Source/WebCore/css/CSSSegmentedFontFace.cpp:
(WebCore::CSSSegmentedFontFace::fontRanges): Updated for changes to CSSFontFace::ranges and
CSSFontFace::fontSelectionCapabilities.

* Source/WebCore/css/FontFace.cpp:
(WebCore::FontFace::setFamily): Updated for change to CSSFontFace::setFamilies.
(WebCore::FontFace::setStyle): Removed unneeded special case for empty string; the
CSSPropertyParserWorkerSafe::parseFontFaceStyle function fails to parse it.
(WebCore::FontFace::setWeight): Removed unneeded special case for empty string, since the
CSSPropertyParserWorkerSafe::parseFontFaceWeight function fails to parse it.
(WebCore::FontFace::setStretch): Removed unneeded special case for empty string, since the
CSSPropertyParserWorkerSafe::parseFontFaceStretch function fails to parse it.
(WebCore::FontFace::setUnicodeRange): Removed unneeded special case for empty string, since the
CSSPropertyParserWorkerSafe::parseFontFaceUnicodeRange function fails to parse it. Also updated
for change to CSSFontFace::setUnicodeRange.
(WebCore::FontFace::setFeatureSettings): Removed unneeded special case for empty string, since the
CSSPropertyParserWorkerSafe::parseFontFaceFeatureSettings function fails to parse it. Changed
the coding style to match the other surrounding functions.
(WebCore::FontFace::setDisplay): Removed unneeded special case for empty string, since the
CSSPropertyParserWorkerSafe::parseFontFaceDisplay function fails to parse it. Updated for the
change to CSSFontFace::setDisplay.
(WebCore::FontFace::family const): Instead of a computed value string, get the specified value
string by calling the function on the CSSFontFace.
(WebCore::FontFace::style const): Ditto.
(WebCore::FontFace::weight const): Ditto.
(WebCore::FontFace::stretch const): Ditto.
(WebCore::FontFace::unicodeRange const): Ditto.
(WebCore::FontFace::featureSettings const): Ditto.
(WebCore::FontFace::display const): Ditto.

* Source/WebCore/css/FontFace.h: Removed ScriptExecutionContext argument from display getter.
* Source/WebCore/css/FontFace.idl: Updated for the above.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.h:
(WebCore::CSSPropertyParserHelpers::isFontStyleAngleInRange): Updated to allow -90 and 90
degrees as specified.

* Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp:
(WebCore::CSSPropertyParserWorkerSafe::parseFontFaceUnicodeRange): Return CSSValueList.
(WebCore::CSSPropertyParserWorkerSafe::parseFontFaceDisplay): Return CSSPrimitiveValue.
(WebCore::CSSPropertyParserHelpersWorkerSafe::consumeFontStyleRange): Removed the check that the
two angles are in order. This is now handled as part of style computation instead.
(WebCore::CSSPropertyParserHelpersWorkerSafe::consumeFontWeightAbsoluteRange): Removed the check
that the two weights are in order. This is now handled as part of style computation instead.
(WebCore::CSSPropertyParserHelpersWorkerSafe::consumeFontStretchRange): Removed the check that the
two stretches are in order. This is now handled as part of style computation instead.

* Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.h: Updated the return types mentioned above.

* Source/WebCore/platform/graphics/FontSelectionAlgorithm.h: Change the FontSelectionRange
constructor to sort the two values so either can be the minimum and either can be the maximum.
This is the behavior the specification calls for. And it's required we do this sorting as part
of the computation process, rather than when parsing the specified values.

Canonical link: https://commits.webkit.org/255893@main




More information about the webkit-changes mailing list