[webkit-changes] [WebKit/WebKit] 443de8: @font-face src must serialize specified URLs, not ...

Darin Adler noreply at github.com
Sun Nov 6 23:15:02 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 443de8e8e9716b164f0a25da35e9235efd72d4dd
      https://github.com/WebKit/WebKit/commit/443de8e8e9716b164f0a25da35e9235efd72d4dd
  Author: Darin Adler <darin at apple.com>
  Date:   2022-11-06 (Sun, 06 Nov 2022)

  Changed paths:
    M LayoutTests/fast/css/font-face-src-parsing-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-family-src-quoted-expected.txt
    M Source/WebCore/css/CSSFontFace.cpp
    M Source/WebCore/css/CSSFontFaceSet.cpp
    M Source/WebCore/css/CSSFontFaceSet.h
    M Source/WebCore/css/CSSFontFaceSource.cpp
    M Source/WebCore/css/CSSFontFaceSource.h
    M Source/WebCore/css/CSSFontFaceSrcValue.cpp
    M Source/WebCore/css/CSSFontFaceSrcValue.h
    M Source/WebCore/css/CSSMarkup.cpp
    M Source/WebCore/css/CSSValue.cpp
    M Source/WebCore/css/CSSValue.h
    M Source/WebCore/css/FontFace.cpp
    M Source/WebCore/css/parser/CSSPropertyParser.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.h
    M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp
    M Source/WebCore/css/parser/CSSTokenizer.cpp
    M Source/WebCore/css/parser/CSSTokenizer.h
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/dom/ScriptExecutionContext.cpp
    M Source/WebCore/dom/ScriptExecutionContext.h
    M Source/WebCore/loader/FontLoadRequest.h
    M Source/WebCore/loader/cache/CachedFont.cpp
    M Source/WebCore/loader/cache/CachedFont.h
    M Source/WebCore/loader/cache/CachedFontLoadRequest.h
    M Source/WebCore/loader/cache/CachedSVGFont.cpp
    M Source/WebCore/loader/cache/CachedSVGFont.h
    M Source/WebCore/svg/SVGFontFaceElement.cpp
    M Source/WebCore/svg/SVGFontFaceNameElement.cpp
    M Source/WebCore/svg/SVGFontFaceNameElement.h
    M Source/WebCore/svg/SVGFontFaceSrcElement.cpp
    M Source/WebCore/svg/SVGFontFaceSrcElement.h
    M Source/WebCore/svg/SVGFontFaceUriElement.cpp
    M Source/WebCore/svg/SVGFontFaceUriElement.h
    M Source/WebCore/workers/WorkerFontLoadRequest.cpp
    M Source/WebCore/workers/WorkerFontLoadRequest.h
    M Source/WebCore/workers/WorkerGlobalScope.cpp
    M Source/WebCore/workers/WorkerGlobalScope.h

  Log Message:
  -----------
  @font-face src must serialize specified URLs, not URLs resolved against the base
https://bugs.webkit.org/show_bug.cgi?id=247547
rdar://problem/102012585

Reviewed by Sam Weinig.

* LayoutTests/fast/css/font-face-src-parsing-expected.txt: Updated to expect successful
parsing of all the values for src. The old code expected some to be skipped, and
they are not skipped any more.

* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-family-src-quoted-expected.txt:
Expect PASS.

* Source/WebCore/css/CSSFontFace.cpp:
(WebCore::CSSFontFace::appendSources): Updated since CSSFontFaceSrcLocalValue and
CSSFontFaceSrcResourceValue are now two separate classes and CSSFontFaceSource gets the URL from
the FontLoadRequest rather than taking a separate URL argument.

* Source/WebCore/css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered): Take AtomString.
(WebCore::CSSFontFaceSet::addToFacesLookupTable): Use AtomString.
* Source/WebCore/css/CSSFontFaceSet.h: Updated for above.

* Source/WebCore/css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::CSSFontFaceSource): Updated the argument name since this now takes
only a font face name, not a URL. Also, a font face name is *not* the same thing as a family name,
so don't call it a family name. Change argument types for things we take ownership of to the
appropriate owning type: AtomString and UniqueRef.
(WebCore::CSSFontFaceSource::opportunisticallyStartFontDataURLLoading): Check the length of URL
from the font request itself to decide if it's short enough, rather than using m_familyNameOrURI.
(WebCore::CSSFontFaceSource::fontLoaded): Removed the argument from ensureCustomFontData. We don't
need to pass the URL back to the object which supplied the URL in the first place.
(WebCore::CSSFontFaceSource::load): Updated for the name change of m_fontFaceName.
(WebCore::CSSFontFaceSource::font): Ditto. Also removed the argument from ensureCustomFontData
and createFont.

* Source/WebCore/css/CSSFontFaceSource.h: Changed the constructors: We don’t need to pass in a
URL along with a FontLoadRequest, which contains the URL. The font face name is not the
same thing as a family name, so let's not call it that.  Change argument types for things we take
ownership of to the appropriate owning type: AtomString and UniqueRef. There is not font face name
or URL when creating from an ArrayBufferView, so don't require the caller to pass a null one in.
Removed the familyNameOrURI function, which was unneeded. Replaced m_familyNameOrURI with
m_fontFaceName. Made m_fontRequest const to emphasize it's never changed after construction.

* Source/WebCore/css/CSSFontFaceSrcValue.cpp: Broke the CSSFontFaceSrcValue into two classes,
CSSFontFaceSrcLocalValue and CSSFontFaceSrcResourceValue. Otherwise this class would have mostly
been variant processing, since there are basically no data members in common.
(WebCore::CSSFontFaceSrcLocalValue::CSSFontFaceSrcLocalValue): Added.
(WebCore::CSSFontFaceSrcLocalValue::create): Added.
(WebCore::CSSFontFaceSrcLocalValue::svgFontFaceElement const): Added.
(WebCore::CSSFontFaceSrcLocalValue::setSVGFontFaceElement): Added.
(WebCore::CSSFontFaceSrcLocalValue::customCSSText const): Added.
(WebCore::CSSFontFaceSrcLocalValue::equals const): Added.
(WebCore::CSSFontFaceSrcResourceValue::CSSFontFaceSrcResourceValue): Added. Stores the location
as a ResolvedURL, the same way CSSImageValue does.
(WebCore::CSSFontFaceSrcResourceValue::create): Added.
(WebCore::CSSFontFaceSrcResourceValue::fontLoadRequest): Added. Besides what the old version
of this function did, this now checks if the format is one we can load and returns nullptr if not.
(WebCore::CSSFontFaceSrcResourceValue::customTraverseSubresources const): Added.
(WebCore::CSSFontFaceSrcResourceValue::customCSSText const): Added. Here is where the core of the
bug fix is: we serialize the specified URL string, not the resolved URL.
(WebCore::CSSFontFaceSrcResourceValue::equals const): Added.

* Source/WebCore/css/CSSFontFaceSrcValue.h: Broke the CSSFontFaceSrcValue class into two classes,
CSSFontFaceSrcLocalValue and CSSFontFaceSrcResourceValue. Removed unneeded functions resource,
format, isLocal, setFormat, isSupportedFormat, isSVGFontFaceSrc, abd isSVGFontTarget. Added
fontFaceName and isEmpty functions to CSSFontFaceSrcLocalValue. Changed CSSFontFaceSrcResourceValue
to take and store a ResolvedURL. Added isEmpty and isFormatSVG functions to
CSSFontFaceSrcResourceValue. Changed fontLoadRequest to take a ScriptExecutionContext& and also
removed the isSVG argument since CSSFontFaceSrcResourceValue itself is the where the answer to that
question comes from.

* Source/WebCore/css/CSSValue.cpp:
(WebCore::CSSValue::visitDerived): Updated for the two classes that replace CSSFontFaceSrcValue.
* Source/WebCore/css/CSSValue.h: Ditto.

* Source/WebCore/css/FontFace.cpp:
(WebCore::populateFontFaceWithArrayBuffer): Remove unneeded null URL string argument.

* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::consumePaintStroke): Updated to call consumeURL.
(WebCore::consumeNoneOrURI): Ditto.
(WebCore::consumePathOperation): Ditto.
(WebCore::consumeGridTrackRepeatFunction): Updated to use a rangee-based for loop.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeURLRaw): Renamed from consumeUrlAsStringView.
(WebCore::CSSPropertyParserHelpers::consumeURL): Renamed from consumeUrl.
(WebCore::CSSPropertyParserHelpers::consumeFilter): Updated to call consumeURL.
(WebCore::CSSPropertyParserHelpers::consumeImage): Ditto.
* Source/WebCore/css/parser/CSSPropertyParserHelpers.h: Updated for the name changes.

* Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp:
(WebCore::CSSPropertyParserHelpersWorkerSafe::consumeFontFaceSrcURI): Use the ResolvedURL
instead of immediately turning it into a string. Call the new
CSSFontFaceSrcResourceValue::create.
(WebCore::CSSPropertyParserHelpersWorkerSafe::consumeFontFaceSrcLocal): Call the new
CSSFontFaceSrcLocalValue::create.

* Source/WebCore/css/parser/CSSTokenizer.cpp:
(WebCore::CSSTokenizer::consumeIdentLikeToken): Use consumeURLToken.
(WebCore::CSSTokenizer::consumeURLToken): Renamed from consumeUrlToken.
* Source/WebCore/css/parser/CSSTokenizer.h: Updated for the name change.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::fontLoadRequest): Changed the URL argument to a const String&.
It was String& before by accident.
* Source/WebCore/dom/Document.h: Ditto.
* Source/WebCore/dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::fontLoadRequest): Ditto.
* Source/WebCore/dom/ScriptExecutionContext.h: Ditto.

* Source/WebCore/loader/FontLoadRequest.h: Took out the unnneded remoteURI arguments
from the ensureCustomFontData and createFont functions. These involve the font load
request passing the URI back to the object it came from, so they aren't needed.

* Source/WebCore/loader/cache/CachedFont.cpp:
(WebCore::CachedFont::ensureCustomFontData): Removed remoteURI argument.
(WebCore::CachedFont::createFont): Ditto.
* Source/WebCore/loader/cache/CachedFont.h: Ditto.
* Source/WebCore/loader/cache/CachedFontLoadRequest.h: Ditto.
* Source/WebCore/loader/cache/CachedSVGFont.cpp:
(WebCore::CachedSVGFont::createFont): Ditto.
(WebCore::CachedSVGFont::ensureCustomFontData): Ditto.
(WebCore::CachedSVGFont::maybeInitializeExternalSVGFontElement): Ditto.
The logic here got simpler becuase when we have an already-parsed URL instead of
just an atom string we can take advantage of member functions.
(WebCore::CachedSVGFont::firstFontFace): Ditto.
* Source/WebCore/loader/cache/CachedSVGFont.h: Ditto.

* Source/WebCore/svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::rebuildFontFace): Use CSSFontFaceSrcLocalValue::create,
a range-based for loop, and pass a reference instead of a pointer. Call createSrcValue.

* Source/WebCore/svg/SVGFontFaceNameElement.cpp:
(WebCore::SVGFontFaceNameElement::createSrcValue const): Renamed from srcValue, and return a
CSSFontFaceSrcLocalValue.
* Source/WebCore/svg/SVGFontFaceNameElement.h: Ditto.

* Source/WebCore/svg/SVGFontFaceSrcElement.cpp:
(WebCore::SVGFontFaceSrcElement::createSrcValue const): Renamed from srcValue, and updated to work
with the two different createSrcValue functions that now have different return types.

* Source/WebCore/svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::createSrcValue const): Renamed from srcValue, and return a
CSSFontFaceSrcResourceValue.
(WebCore::isSVGFontTarget): Check if the font is an SVG font without creating and destroying a
CSSFontFaceSrcValue, which is overkill since we can check the format attribute directly.
* Source/WebCore/svg/SVGFontFaceUriElement.h: Return a CSSFontFaceSrcResourceValue.

* Source/WebCore/workers/WorkerFontLoadRequest.cpp:
(WebCore::WorkerFontLoadRequest::ensureCustomFontData): Removed remoteURI argument.
(WebCore::WorkerFontLoadRequest::createFont): Ditto.
* Source/WebCore/workers/WorkerFontLoadRequest.h: Ditto.

* Source/WebCore/workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::fontLoadRequest): Changed the URL argument to a const String&.
It was String& before by accident.
* Source/WebCore/workers/WorkerGlobalScope.h: Ditto.

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




More information about the webkit-changes mailing list