[webkit-changes] [WebKit/WebKit] 7dff0d: [Cocoa] Add UnrealizedCoreTextFont to make it easi...
Myles C. Maxfield
noreply at github.com
Mon Feb 13 10:57:26 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7dff0d1ab2dd4d029978dfecbca85576759d81fb
https://github.com/WebKit/WebKit/commit/7dff0d1ab2dd4d029978dfecbca85576759d81fb
Author: Myles C. Maxfield <mmaxfield at apple.com>
Date: 2023-02-13 (Mon, 13 Feb 2023)
Changed paths:
M Source/WebCore/PlatformMac.cmake
M Source/WebCore/SourcesCocoa.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
A Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.cpp
A Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.h
M Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h
M Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.h
Log Message:
-----------
[Cocoa] Add UnrealizedCoreTextFont to make it easier to make CTFontDescriptor and CTFont transformations more deliberate
https://bugs.webkit.org/show_bug.cgi?id=252150
rdar://105378692
Reviewed by Alan Baradlay.
The solution to https://bugs.webkit.org/show_bug.cgi?id=247987 requires having explicit locations where we transform
a CTFontDescriptor into a CTFont.
Today, we ping-pong back and forth between CTFontDescriptors and CTFonts without much thought. Not only that, but we
also ping-pong between CTFontDescriptors and modified CTFontDescriptors sometimes too.
At the beginning of a font's lifetime (at the point it's looked up by WebKit), it usually begins life as a CTFontDescriptor.
(There is an exception where we fall off the end of the font-family list and ask the platform for _some_ font that supports
the character at hand; the result of that is a CTFont rather than a CTFontDescriptor.) This CTFontDescriptor (or CTFont)
needs to have a bunch of transformations applied to it before we can use it in web content: We need to set up the user-
installed-fonts state, the font features and font variations, the palettes, etc. Instead of handling each one of these
individually, by either modifying a CTFontDescriptor or modifying a CTFont, we should try to be more deliberate about when
the transformations take place, and to batch up all modifications so we can do all the modifications in one go.
This patch is the first step in a design where:
- UnrealizedCoreTextFont is a new class that holds either a CTFont or a CTFontDescriptor, and a CFMutableDictionary of
modifications to be made to it.
- It has a modify() function that takes a lambda that can modify the CFMutableDictionary. Because these modifications
never even hit Core Text, they are extremely lightweight.
- There's a modifyFromContext() which conceptually is like modify(), but is intended to take the place of what
preparePlatformFont() does now. It's intentionally unimplemented for now; a future patch will migrate code to it.
- Once WebCore is done modifying the CFMutableDictionary, there's a realize() function, which produces the final CTFont which
WebCore can directly use.
* Source/WebCore/PlatformMac.cmake:
* Source/WebCore/SourcesCocoa.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.cpp: Added.
(WebCore::getCGFloatValue):
(WebCore::UnrealizedCoreTextFont::getSize const):
(WebCore::UnrealizedCoreTextFont::realize const):
(WebCore::UnrealizedCoreTextFont::operator bool const):
(WebCore::modifyFromContext):
(WebCore::UnrealizedCoreTextFont::modifyFromContext):
* Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.h: Added.
(WebCore::UnrealizedCoreTextFont::UnrealizedCoreTextFont):
(WebCore::UnrealizedCoreTextFont::modify):
(WebCore::UnrealizedCoreTextFont::setSize):
* Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h:
* Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.h:
Canonical link: https://commits.webkit.org/260208@main
More information about the webkit-changes
mailing list