haikuwebkit/Source/WebCore/workers/WorkerFontLoadRequest.h

84 lines
3.3 KiB
C
Raw Permalink Normal View History

Implement FontFace in Workers for OffscreenCanvas https://bugs.webkit.org/show_bug.cgi?id=224178 <rdar://problem/76529024> Reviewed by Darin Adler. LayoutTests/imported/w3c: FontFace is now available for Workers, rebaseline related tests. * web-platform-tests/css/css-font-loading/fontfaceset-load-css-wide-keywords-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.center.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.left.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.right.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.hanging.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.ideographic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fontface.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.basic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.actualBoundingBox.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.advances.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.baselines.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.width.basic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.width.empty.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.width.space.worker-expected.txt: Source/WebCore: To comply with spec and complete the OffscreenCanvas implementation, FontFace needs to be made available on WorkerGlobalScope. This patch makes it available and fixes crashes using it due to accessing main-thread only singletons. No new tests, rebaselined existing tests. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Add new files WorkerFontLoadRequest.cpp, WorkerFontLoadRequest.h * css/CSSFontFace.cpp: (WebCore::CSSFontFace::fontCacheFallingBackToSingleton): (WebCore::CSSFontFace::font): * css/CSSFontFace.h: Use the ScriptExecutionContext's FontCache if possible when loading fonts. * css/CSSFontFaceSet.cpp: (WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered): (WebCore::CSSFontFaceSet::matchingFacesExcludingPreinstalledFonts): Use the correct CSSValuePool and FontCache in ensureLocalFontFacesForFamilyRegistered. Also clarify a vaguely-named variable. * css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::CSSFontFaceSource): Use FontLoadRequest::isPending instead of making assumptions about the request state on construction. * css/FontFace.cpp: (WebCore::FontFace::create): (WebCore::FontFace::display const): * css/FontFace.h: * css/FontFace.idl: Construct with a ScriptExecutionContext instead of a Document and make available for Workers. * css/FontFaceSet.idl: Expose to Workers. * loader/FontLoadRequest.h: (WebCore::FontLoadRequest::isWorkerFontLoadRequest const): Add isPending function and new type WorkerFontLoadRequest. * loader/cache/CachedFont.cpp: (WebCore::CachedFont::createCustomFontData): Use convertWOFFToSfntIfNecessary(). * loader/cache/CachedFontLoadRequest.h: Implement FontLoadRequest::isPending. * platform/graphics/Font.cpp: (WebCore::Font::create): (WebCore::Font::Font): (WebCore::Font::systemFallbackFontForCharacter const): * platform/graphics/Font.h: Add an optional FontCache parameter for use with vertical font data retrieval and add a FontCache parameter to systemFallbackFontForCharacter instead of using the singleton. * platform/graphics/FontCache.cpp: (WebCore::FontCache::fontForPlatformData): Pass FontCache parameter when creating fonts. * platform/graphics/FontCache.h: (WebCore::FontCache::fontCacheFallingBackToSingleton): * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::update const): * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: (WebCore::FontCascade::fontForCombiningCharacterSequence const): Rename fontCacheFallbackToSingleton -> fontCacheFallingBackToSingleton * platform/graphics/FontCascadeFonts.cpp: (WebCore::FontCascadeFonts::realizeFallbackRangesAt): (WebCore::FontCascadeFonts::glyphDataForSystemFallback): Use familyNamesData instead of familyNames and pass the FontCache parameter when calling glyphDataForSystemFallback to make this safe to use in a Worker. * platform/graphics/FontTaggedSettings.h: Add missing wtf/Hasher.h include. * platform/graphics/WOFFFileFormat.cpp: (WebCore::convertWOFFToSfntIfNecessary): * platform/graphics/WOFFFileFormat.h: Add utility function to convert WOFF fonts on non-Cocoa platforms. * workers/WorkerFontLoadRequest.cpp: Added. (WebCore::WorkerFontLoadRequest::WorkerFontLoadRequest): (WebCore::WorkerFontLoadRequest::load): (WebCore::WorkerFontLoadRequest::ensureCustomFontData): (WebCore::WorkerFontLoadRequest::createFont): (WebCore::WorkerFontLoadRequest::setClient): (WebCore::WorkerFontLoadRequest::didReceiveResponse): (WebCore::WorkerFontLoadRequest::didReceiveData): (WebCore::WorkerFontLoadRequest::didFinishLoading): (WebCore::WorkerFontLoadRequest::didFail): * workers/WorkerFontLoadRequest.h: Added. Implement FontLoadRequest for Workers. * workers/WorkerGlobalScope.cpp: (WebCore::WorkerGlobalScope::fonts): (WebCore::WorkerGlobalScope::fontLoadRequest): (WebCore::WorkerGlobalScope::beginLoadingFontSoon): * workers/WorkerGlobalScope.h: Implement ScriptExecutionContext font-loading related functions. * workers/WorkerGlobalScope.idl: Include FontFaceSource. Canonical link: https://commits.webkit.org/236910@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276450 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 18:44:49 +00:00
/*
* Copyright (C) 2021 Metrological Group B.V.
* Copyright (C) 2021 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "FontLoadRequest.h"
#include "ResourceLoaderOptions.h"
#include "ThreadableLoaderClient.h"
#include <wtf/URL.h>
#include <wtf/WeakPtr.h>
namespace WebCore {
class ScriptExecutionContext;
class SharedBuffer;
class WorkerGlobalScope;
struct FontCustomPlatformData;
class WorkerFontLoadRequest : public FontLoadRequest, public ThreadableLoaderClient {
WTF_MAKE_FAST_ALLOCATED;
public:
WorkerFontLoadRequest(URL&&, LoadedFromOpaqueSource);
~WorkerFontLoadRequest() = default;
void load(WorkerGlobalScope&);
private:
const URL& url() const final { return m_url; }
bool isPending() const final { return !m_isLoading && !m_errorOccurred && !m_data; }
bool isLoading() const final { return m_isLoading; }
bool errorOccurred() const final { return m_errorOccurred; }
bool ensureCustomFontData(const AtomString& remoteURI) final;
RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities) final;
void setClient(FontLoadRequestClient*) final;
bool isWorkerFontLoadRequest() const final { return true; }
void didReceiveResponse(unsigned long identifier, const ResourceResponse&) final;
Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer https://bugs.webkit.org/show_bug.cgi?id=226623 Reviewed by Darin Adler. Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer. Also have SharedBuffer::data() return a `const uint8_t*` instead of `const char*`. This is our preferred type to store bytes. Source/WebCore: * Modules/fetch/FetchBody.cpp: (WebCore::FetchBody::consumeFormData): * Modules/fetch/FetchBodyConsumer.cpp: (WebCore::packageFormData): (WebCore::resolveWithTypeAndData): * Modules/highlight/AppHighlight.h: (WebCore::AppHighlight::encode const): * Modules/indexeddb/IDBGetResult.cpp: (WebCore::IDBGetResult::dataFromBuffer): * Modules/indexeddb/server/IDBSerialization.cpp: (WebCore::serializeIDBKeyData): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::RTCDataChannel::didReceiveRawData): * Modules/mediastream/RTCDataChannel.h: * Modules/mediastream/RTCDataChannelRemoteHandler.cpp: (WebCore::RTCDataChannelRemoteHandler::didReceiveRawData): (WebCore::RTCDataChannelRemoteHandler::sendRawData): * Modules/mediastream/RTCDataChannelRemoteHandler.h: * Modules/mediastream/RTCDataChannelRemoteSource.h: (WebCore::RTCDataChannelRemoteSource::sendRawData): * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp: (WebCore::LibWebRTCDataChannelHandler::sendRawData): (WebCore::LibWebRTCDataChannelHandler::OnMessage): * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: * css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::load): * fileapi/Blob.cpp: (WebCore::Blob::Blob): * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::processMessages): * fileapi/NetworkSendQueue.h: * inspector/NetworkResourcesData.cpp: (WebCore::NetworkResourcesData::ResourceData::appendData): (WebCore::NetworkResourcesData::maybeAddResourceData): * inspector/NetworkResourcesData.h: * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::didReceiveData): * inspector/agents/InspectorPageAgent.cpp: (WebCore::decodeBuffer): (WebCore::InspectorPageAgent::dataContent): * inspector/agents/InspectorPageAgent.h: * loader/ContentFilter.cpp: (WebCore::ContentFilter::deliverResourceData): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::continueAfterContentPolicy): (WebCore::DocumentLoader::maybeCreateArchive): (WebCore::DocumentLoader::maybeFinishLoadingMultipartContent): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::didFinishLoading): (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadResourceSynchronously): * loader/NetscapePlugInStreamLoader.cpp: (WebCore::NetscapePlugInStreamLoader::didReceiveDataOrBuffer): * loader/NetscapePlugInStreamLoader.h: * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didReceiveDataOrBuffer): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didReceiveDataOrBuffer): * loader/TextResourceDecoder.h: (WebCore::TextResourceDecoder::decode): (WebCore::TextResourceDecoder::decodeAndFlush): * loader/TextTrackLoader.cpp: (WebCore::TextTrackLoader::processNewCueData): * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::didFinishLoadingManifest): * loader/appcache/ApplicationCacheStorage.cpp: (WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory): * loader/archive/mhtml/MHTMLArchive.cpp: (WebCore::MHTMLArchive::generateMHTMLData): * loader/archive/mhtml/MHTMLParser.cpp: (WebCore::MHTMLParser::parseNextPart): * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::updateBuffer): (WebCore::CachedRawResource::finishLoading): (WebCore::CachedRawResource::didAddClient): * loader/cache/CachedSVGFont.cpp: (WebCore::CachedSVGFont::ensureCustomFontData): * platform/SharedBuffer.cpp: (WebCore::SharedBuffer::SharedBuffer): (WebCore::SharedBuffer::create): (WebCore::SharedBuffer::combineIntoOneSegment const): (WebCore::SharedBuffer::data const): (WebCore::SharedBuffer::tryCreateArrayBuffer const): (WebCore::SharedBuffer::append): (WebCore::SharedBuffer::DataSegment::data const): (WebCore::SharedBuffer::DataSegment::size const): (WebCore::SharedBufferDataView::data const): (WebCore::utf8Buffer): * platform/SharedBuffer.h: * platform/encryptedmedia/clearkey/CDMClearKey.cpp: (WebCore::extractKeyidsLocationFromCencInitData): (WebCore::extractKeyidsFromCencInitData): * platform/graphics/Model.h: (WebCore::Model::encode const): * platform/graphics/displaylists/DisplayListItemBuffer.cpp: (WebCore::DisplayList::ItemBuffer::append): * platform/graphics/gstreamer/eme/CDMThunder.cpp: (WebCore::CDMInstanceThunder::setServerCertificate): (WebCore::ParsedResponseMessage::ParsedResponseMessage): (WebCore::CDMInstanceSessionThunder::errorCallback): (WebCore::CDMInstanceSessionThunder::requestLicense): (WebCore::CDMInstanceSessionThunder::updateLicense): (WebCore::CDMInstanceSessionThunder::loadSession): * platform/graphics/opentype/OpenTypeTypes.h: (WebCore::OpenType::TableBase::isValidEnd): * platform/mediastream/RTCDataChannelHandler.h: * platform/mediastream/RTCDataChannelHandlerClient.h: * platform/mediastream/RTCDataChannelRemoteSourceConnection.h: * platform/mock/RTCDataChannelHandlerMock.cpp: (WebCore::RTCDataChannelHandlerMock::sendRawData): * platform/mock/RTCDataChannelHandlerMock.h: * platform/network/FormData.cpp: (WebCore::FormData::asSharedBuffer const): * platform/network/ResourceHandleClient.cpp: (WebCore::ResourceHandleClient::didReceiveBuffer): * platform/network/cocoa/RangeResponseGenerator.mm: (WebCore::RangeResponseGenerator::giveResponseToTaskIfBytesInRangeReceived): * platform/text/TextEncoding.h: (WebCore::TextEncoding::decode const): * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::dataChanged): * xml/XSLTProcessorLibxslt.cpp: (WebCore::docLoaderFunc): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::OffsetBuffer::OffsetBuffer): Source/WebKit: * Platform/IPC/SharedBufferCopy.h: (IPC::SharedBufferCopy::data const): * PluginProcess/PluginControllerProxy.cpp: (WebKit::PluginControllerProxy::streamDidReceiveData): (WebKit::PluginControllerProxy::manualStreamDidReceiveData): * Shared/PersistencyUtils.cpp: (WebKit::writeToDisk): * Shared/WebCoreArgumentCoders.cpp: (IPC::tryConvertToShareableResourceHandle): * UIProcess/WebURLSchemeTask.cpp: (WebKit::WebURLSchemeTask::didComplete): * WebProcess/Network/WebResourceLoader.cpp: (WebKit::WebResourceLoader::didReceiveData): * WebProcess/Network/WebSocketChannel.cpp: (WebKit::WebSocketChannel::createMessageQueue): * WebProcess/Network/webrtc/RTCDataChannelRemoteManager.cpp: (WebKit::RTCDataChannelRemoteManager::sendData): (WebKit::RTCDataChannelRemoteManager::receiveData): (WebKit::RTCDataChannelRemoteManager::RemoteSourceConnection::didReceiveRawData): * WebProcess/Network/webrtc/RTCDataChannelRemoteManager.h: * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp: (WebKit::parsePostBuffer): * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: (WebKit::NetscapePlugin::streamDidReceiveData): (WebKit::NetscapePlugin::manualStreamDidReceiveData): * WebProcess/Plugins/Netscape/NetscapePlugin.h: * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp: (WebKit::NetscapePluginStream::didReceiveData): (WebKit::NetscapePluginStream::sendJavaScriptStream): (WebKit::NetscapePluginStream::deliverData): (WebKit::NetscapePluginStream::deliverDataToFile): * WebProcess/Plugins/Netscape/NetscapePluginStream.h: * WebProcess/Plugins/PDF/PDFPlugin.h: * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didReceiveData): (WebKit::PDFPlugin::streamDidReceiveData): (WebKit::PDFPlugin::manualStreamDidReceiveData): * WebProcess/Plugins/Plugin.h: * WebProcess/Plugins/PluginProxy.cpp: (WebKit::PluginProxy::streamDidReceiveData): (WebKit::PluginProxy::manualStreamDidReceiveData): * WebProcess/Plugins/PluginProxy.h: * WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::Stream::didReceiveData): (WebKit::PluginView::manualLoadDidReceiveData): * WebProcess/Plugins/PluginView.h: * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::committedLoad): * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: (WebKit::WebPlatformStrategies::bufferForType): Source/WebKitLegacy/mac: * Plugins/Hosted/HostedNetscapePluginStream.h: * Plugins/Hosted/HostedNetscapePluginStream.mm: (WebKit::HostedNetscapePluginStream::didReceiveData): * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::evaluateJavaScript): * Plugins/Hosted/WebHostedNetscapePluginView.mm: (-[WebHostedNetscapePluginView pluginView:receivedData:]): * Plugins/WebNetscapePluginStream.h: * Plugins/WebNetscapePluginStream.mm: (WebNetscapePluginStream::didReceiveData): * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView pluginView:receivedData:]): (-[WebNetscapePluginView evaluateJavaScriptPluginRequest:]): Tools: * TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp: (TestWebKitAPI::TEST_F): (TestWebKitAPI::checkBuffer): Canonical link: https://commits.webkit.org/238515@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278516 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-05 01:16:43 +00:00
void didReceiveData(const uint8_t* data, int dataLength) final;
Implement FontFace in Workers for OffscreenCanvas https://bugs.webkit.org/show_bug.cgi?id=224178 <rdar://problem/76529024> Reviewed by Darin Adler. LayoutTests/imported/w3c: FontFace is now available for Workers, rebaseline related tests. * web-platform-tests/css/css-font-loading/fontfaceset-load-css-wide-keywords-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.center.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.left.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.right.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.hanging.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.ideographic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.fontface.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.basic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.actualBoundingBox.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.advances.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.baselines.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.width.basic.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.width.empty.worker-expected.txt: * web-platform-tests/html/canvas/offscreen/text/2d.text.measure.width.space.worker-expected.txt: Source/WebCore: To comply with spec and complete the OffscreenCanvas implementation, FontFace needs to be made available on WorkerGlobalScope. This patch makes it available and fixes crashes using it due to accessing main-thread only singletons. No new tests, rebaselined existing tests. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Add new files WorkerFontLoadRequest.cpp, WorkerFontLoadRequest.h * css/CSSFontFace.cpp: (WebCore::CSSFontFace::fontCacheFallingBackToSingleton): (WebCore::CSSFontFace::font): * css/CSSFontFace.h: Use the ScriptExecutionContext's FontCache if possible when loading fonts. * css/CSSFontFaceSet.cpp: (WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered): (WebCore::CSSFontFaceSet::matchingFacesExcludingPreinstalledFonts): Use the correct CSSValuePool and FontCache in ensureLocalFontFacesForFamilyRegistered. Also clarify a vaguely-named variable. * css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::CSSFontFaceSource): Use FontLoadRequest::isPending instead of making assumptions about the request state on construction. * css/FontFace.cpp: (WebCore::FontFace::create): (WebCore::FontFace::display const): * css/FontFace.h: * css/FontFace.idl: Construct with a ScriptExecutionContext instead of a Document and make available for Workers. * css/FontFaceSet.idl: Expose to Workers. * loader/FontLoadRequest.h: (WebCore::FontLoadRequest::isWorkerFontLoadRequest const): Add isPending function and new type WorkerFontLoadRequest. * loader/cache/CachedFont.cpp: (WebCore::CachedFont::createCustomFontData): Use convertWOFFToSfntIfNecessary(). * loader/cache/CachedFontLoadRequest.h: Implement FontLoadRequest::isPending. * platform/graphics/Font.cpp: (WebCore::Font::create): (WebCore::Font::Font): (WebCore::Font::systemFallbackFontForCharacter const): * platform/graphics/Font.h: Add an optional FontCache parameter for use with vertical font data retrieval and add a FontCache parameter to systemFallbackFontForCharacter instead of using the singleton. * platform/graphics/FontCache.cpp: (WebCore::FontCache::fontForPlatformData): Pass FontCache parameter when creating fonts. * platform/graphics/FontCache.h: (WebCore::FontCache::fontCacheFallingBackToSingleton): * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::update const): * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: (WebCore::FontCascade::fontForCombiningCharacterSequence const): Rename fontCacheFallbackToSingleton -> fontCacheFallingBackToSingleton * platform/graphics/FontCascadeFonts.cpp: (WebCore::FontCascadeFonts::realizeFallbackRangesAt): (WebCore::FontCascadeFonts::glyphDataForSystemFallback): Use familyNamesData instead of familyNames and pass the FontCache parameter when calling glyphDataForSystemFallback to make this safe to use in a Worker. * platform/graphics/FontTaggedSettings.h: Add missing wtf/Hasher.h include. * platform/graphics/WOFFFileFormat.cpp: (WebCore::convertWOFFToSfntIfNecessary): * platform/graphics/WOFFFileFormat.h: Add utility function to convert WOFF fonts on non-Cocoa platforms. * workers/WorkerFontLoadRequest.cpp: Added. (WebCore::WorkerFontLoadRequest::WorkerFontLoadRequest): (WebCore::WorkerFontLoadRequest::load): (WebCore::WorkerFontLoadRequest::ensureCustomFontData): (WebCore::WorkerFontLoadRequest::createFont): (WebCore::WorkerFontLoadRequest::setClient): (WebCore::WorkerFontLoadRequest::didReceiveResponse): (WebCore::WorkerFontLoadRequest::didReceiveData): (WebCore::WorkerFontLoadRequest::didFinishLoading): (WebCore::WorkerFontLoadRequest::didFail): * workers/WorkerFontLoadRequest.h: Added. Implement FontLoadRequest for Workers. * workers/WorkerGlobalScope.cpp: (WebCore::WorkerGlobalScope::fonts): (WebCore::WorkerGlobalScope::fontLoadRequest): (WebCore::WorkerGlobalScope::beginLoadingFontSoon): * workers/WorkerGlobalScope.h: Implement ScriptExecutionContext font-loading related functions. * workers/WorkerGlobalScope.idl: Include FontFaceSource. Canonical link: https://commits.webkit.org/236910@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276450 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 18:44:49 +00:00
void didFinishLoading(unsigned long identifier) final;
void didFail(const ResourceError&) final;
URL m_url;
LoadedFromOpaqueSource m_loadedFromOpaqueSource;
bool m_isLoading { false };
bool m_notifyOnClientSet { false };
bool m_errorOccurred { false };
FontLoadRequestClient* m_fontLoadRequestClient { nullptr };
WeakPtr<ScriptExecutionContext> m_context;
RefPtr<SharedBuffer> m_data;
std::unique_ptr<FontCustomPlatformData> m_fontCustomPlatformData;
};
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_FONTLOADREQUEST(WebCore::WorkerFontLoadRequest, isWorkerFontLoadRequest())