Diff
Modified: trunk/Source/WebCore/ChangeLog (285551 => 285552)
--- trunk/Source/WebCore/ChangeLog 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/ChangeLog 2021-11-10 01:57:55 UTC (rev 285552)
@@ -1,3 +1,33 @@
+2021-11-09 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Migrate from CTFontCopyVariationAxes() to CTFontCopyVariationAxesInternal() if possible
+ https://bugs.webkit.org/show_bug.cgi?id=232690
+
+ Reviewed by Simon Fraser and Cameron McCormack.
+
+ CTFontCopyVariationAxesInternal() is faster than CTFontCopyVariationAxes(), but the strings
+ it provides are not localized. Luckily, we don't actually use the strings in the common case,
+ so we can migrate to CTFontCopyVariationAxesInternal() safely.
+
+ No new tests because there is no behavior change.
+
+ * Headers.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * inspector/agents/InspectorCSSAgent.cpp:
+ (WebCore::buildObjectForFont):
+ * platform/graphics/FontPlatformData.cpp:
+ (WebCore::FontPlatformData::variationAxes const):
+ * platform/graphics/FontPlatformData.h:
+ * platform/graphics/ShouldLocalizeAxisNames.h: Added.
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::variationAxes):
+ (WebCore::defaultVariationValues):
+ (WebCore::preparePlatformFont):
+ (WebCore::variationCapabilitiesForFontDescriptor):
+ * platform/graphics/cocoa/FontCacheCoreText.h:
+ * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+ (WebCore::FontPlatformData::variationAxes const):
+
2021-11-09 Dean Jackson <d...@apple.com>
[WebXR] three.js demos don't work
Modified: trunk/Source/WebCore/Headers.cmake (285551 => 285552)
--- trunk/Source/WebCore/Headers.cmake 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/Headers.cmake 2021-11-10 01:57:55 UTC (rev 285552)
@@ -1374,6 +1374,7 @@
platform/graphics/RenderingResourceIdentifier.h
platform/graphics/RenderingMode.h
platform/graphics/RoundedRect.h
+ platform/graphics/ShouldLocalizeAxisNames.h
platform/graphics/SourceBufferPrivate.h
platform/graphics/SourceBufferPrivateClient.h
platform/graphics/StringTruncator.h
Modified: trunk/Source/WebCore/PAL/ChangeLog (285551 => 285552)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-11-10 01:57:55 UTC (rev 285552)
@@ -1,3 +1,12 @@
+2021-11-09 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Migrate from CTFontCopyVariationAxes() to CTFontCopyVariationAxesInternal() if possible
+ https://bugs.webkit.org/show_bug.cgi?id=232690
+
+ Reviewed by Simon Fraser and Cameron McCormack.
+
+ * pal/spi/cf/CoreTextSPI.h:
+
2021-11-09 Devin Rousso <drou...@apple.com>
REGRESSION(r271735): PaymentShippingOption.selected ignored
Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CoreTextSPI.h (285551 => 285552)
--- trunk/Source/WebCore/PAL/pal/spi/cf/CoreTextSPI.h 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CoreTextSPI.h 2021-11-10 01:57:55 UTC (rev 285552)
@@ -169,6 +169,7 @@
CTFontRef CTFontCreateForCharactersWithLanguageAndOption(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CTFontFallbackOption, CFIndex *coveredLength);
CTFontRef CTFontCopyPhysicalFont(CTFontRef);
CTFontSymbolicTraits CTFontGetPhysicalSymbolicTraits(CTFontRef);
+CFArrayRef CTFontCopyVariationAxesInternal(CTFontRef);
extern const CFStringRef kCTUIFontTextStyleShortHeadline;
extern const CFStringRef kCTUIFontTextStyleShortBody;
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (285551 => 285552)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-10 01:57:55 UTC (rev 285552)
@@ -629,6 +629,7 @@
1C26671B26FA932F00117073 /* FontCreationContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C26671926FA7F2E00117073 /* FontCreationContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C4D0DD324D9F10D003D7498 /* GlyphBufferMembers.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 1C4DB02627339FE0007B0AD1 /* ShouldLocalizeAxisNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4DB02427339E5E007B0AD1 /* ShouldLocalizeAxisNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C5E1DA826F94B9000E07AF1 /* FontPaletteValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C6626111C6E7CA600AB527C /* FontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C66260F1C6E7CA600AB527C /* FontFace.h */; };
1C73A7132185757E004CCEA5 /* TextUnderlineOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7092,6 +7093,7 @@
1C43DE6A22AB4B8A001527D9 /* LocalCurrentTraitCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentTraitCollection.mm; sourceTree = "<group>"; };
1C4674FD26F4843600B61273 /* FontPalette.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontPalette.h; sourceTree = "<group>"; };
1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlyphBufferMembers.h; sourceTree = "<group>"; };
+ 1C4DB02427339E5E007B0AD1 /* ShouldLocalizeAxisNames.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShouldLocalizeAxisNames.h; sourceTree = "<group>"; };
1C50C49522C84F2400A6E4BE /* WHLSLStandardLibraryFunctionMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLStandardLibraryFunctionMap.cpp; sourceTree = "<group>"; };
1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontPaletteValues.h; sourceTree = "<group>"; };
1C66260E1C6E7CA600AB527C /* FontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFace.cpp; sourceTree = "<group>"; };
@@ -27990,6 +27992,7 @@
A73F95FD12C97BFE0031AAF9 /* RoundedRect.h */,
0F3DD44D12F5EA1B000D9190 /* ShadowBlur.cpp */,
0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */,
+ 1C4DB02427339E5E007B0AD1 /* ShouldLocalizeAxisNames.h */,
1DD127AC256E3A8700B227D7 /* SourceBufferPrivate.cpp */,
CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */,
CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */,
@@ -36009,6 +36012,7 @@
CD36C16B260A65CC00C8C529 /* SharedRoutingArbitrator.h in Headers */,
834DFAD01F7DAE5D00C2725B /* SharedStringHash.h in Headers */,
93309EA3099EB78C0056E581 /* SharedTimer.h in Headers */,
+ 1C4DB02627339FE0007B0AD1 /* ShouldLocalizeAxisNames.h in Headers */,
DF19E2AC24772BC1007BDACB /* ShouldRelaxThirdPartyCookieBlocking.h in Headers */,
8362E8C120CEF9CB00245886 /* ShouldTreatAsContinuingLoad.h in Headers */,
9316DDFB240C64B4009340AA /* SimpleRange.h in Headers */,
Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (285551 => 285552)
--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp 2021-11-10 01:57:55 UTC (rev 285552)
@@ -575,7 +575,7 @@
static Ref<Protocol::CSS::Font> buildObjectForFont(const Font& font)
{
auto resultVariationAxes = JSON::ArrayOf<Protocol::CSS::FontVariationAxis>::create();
- for (auto& variationAxis : font.platformData().variationAxes()) {
+ for (auto& variationAxis : font.platformData().variationAxes(ShouldLocalizeAxisNames::Yes)) {
auto axis = Protocol::CSS::FontVariationAxis::create()
.setTag(variationAxis.tag())
.setMinimumValue(variationAxis.minimumValue())
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp (285551 => 285552)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2021-11-10 01:57:55 UTC (rev 285552)
@@ -82,7 +82,7 @@
#endif
#if !PLATFORM(COCOA)
-Vector<FontPlatformData::FontVariationAxis> FontPlatformData::variationAxes() const
+Vector<FontPlatformData::FontVariationAxis> FontPlatformData::variationAxes(ShouldLocalizeAxisNames) const
{
// FIXME: <webkit.org/b/219614> Not implemented yet.
return { };
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (285551 => 285552)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2021-11-10 01:57:55 UTC (rev 285552)
@@ -25,6 +25,7 @@
#pragma once
#include "SharedBuffer.h"
+#include "ShouldLocalizeAxisNames.h"
#include "TextFlags.h"
#include <wtf/Forward.h>
#include <wtf/RetainPtr.h>
@@ -179,7 +180,7 @@
bool isForTextCombine() const { return widthVariant() != FontWidthVariant::RegularWidth; } // Keep in sync with callers of FontDescription::setWidthVariant().
String familyName() const;
- Vector<FontVariationAxis> variationAxes() const;
+ Vector<FontVariationAxis> variationAxes(ShouldLocalizeAxisNames) const;
#if USE(CAIRO)
cairo_scaled_font_t* scaledFont() const { return m_scaledFont.get(); }
Added: trunk/Source/WebCore/platform/graphics/ShouldLocalizeAxisNames.h (0 => 285552)
--- trunk/Source/WebCore/platform/graphics/ShouldLocalizeAxisNames.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ShouldLocalizeAxisNames.h 2021-11-10 01:57:55 UTC (rev 285552)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * 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 <cstdint>
+
+namespace WebCore {
+
+enum class ShouldLocalizeAxisNames : uint8_t {
+ No,
+ Yes
+};
+
+}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (285551 => 285552)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2021-11-10 01:57:55 UTC (rev 285552)
@@ -300,10 +300,25 @@
return CFStringGetLength(fontName) > 0 && CFStringGetCharacterAtIndex(fontName, 0) == '.';
}
-VariationDefaultsMap defaultVariationValues(CTFontRef font)
+static RetainPtr<CFArrayRef> variationAxes(CTFontRef font, ShouldLocalizeAxisNames shouldLocalizeAxisNames)
{
+#if defined(HAVE_CTFontCopyVariationAxesInternal) // This macro is defined inside CoreText, not WebKit.
+ if (shouldLocalizeAxisNames == ShouldLocalizeAxisNames::Yes)
+ return adoptCF(CTFontCopyVariationAxes(font));
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunguarded-availability-new"
+ return adoptCF(CTFontCopyVariationAxesInternal(font));
+#pragma clang diagnostic pop
+#else
+ UNUSED_PARAM(shouldLocalizeAxisNames);
+ return adoptCF(CTFontCopyVariationAxes(font));
+#endif
+}
+
+VariationDefaultsMap defaultVariationValues(CTFontRef font, ShouldLocalizeAxisNames shouldLocalizeAxisNames)
+{
VariationDefaultsMap result;
- auto axes = adoptCF(CTFontCopyVariationAxes(font));
+ auto axes = variationAxes(font, shouldLocalizeAxisNames);
if (!axes)
return result;
auto size = CFArrayGetCount(axes.get());
@@ -518,7 +533,7 @@
auto fontOpticalSizing = fontDescription.opticalSizing();
- auto defaultValues = defaultVariationValues(originalFont);
+ auto defaultValues = defaultVariationValues(originalFont, ShouldLocalizeAxisNames::No);
auto fontSelectionRequest = fontDescription.fontSelectionRequest();
auto fontStyleAxis = fontDescription.fontStyleAxis();
@@ -1021,7 +1036,7 @@
return result;
auto font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor, 0, nullptr));
- auto variations = adoptCF(CTFontCopyVariationAxes(font.get()));
+ auto variations = variationAxes(font.get(), ShouldLocalizeAxisNames::No);
if (!variations)
return result;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h (285551 => 285552)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2021-11-10 01:57:55 UTC (rev 285552)
@@ -29,6 +29,7 @@
#pragma once
#include "FontDescription.h"
+#include "ShouldLocalizeAxisNames.h"
#include <CoreText/CTFont.h>
@@ -72,5 +73,5 @@
void addAttributesForWebFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts);
RetainPtr<CFSetRef> installedFontMandatoryAttributes(AllowUserInstalledFonts);
-VariationDefaultsMap defaultVariationValues(CTFontRef);
+VariationDefaultsMap defaultVariationValues(CTFontRef, ShouldLocalizeAxisNames);
}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (285551 => 285552)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm 2021-11-10 01:39:23 UTC (rev 285551)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm 2021-11-10 01:57:55 UTC (rev 285552)
@@ -62,7 +62,7 @@
return nullptr;
}
-Vector<FontPlatformData::FontVariationAxis> FontPlatformData::variationAxes() const
+Vector<FontPlatformData::FontVariationAxis> FontPlatformData::variationAxes(ShouldLocalizeAxisNames shouldLocalizeAxisNames) const
{
auto platformFont = ctFont();
if (!platformFont)
@@ -69,7 +69,7 @@
return { };
Vector<FontVariationAxis> results;
- for (auto& [tag, values] : defaultVariationValues(platformFont))
+ for (auto& [tag, values] : defaultVariationValues(platformFont, shouldLocalizeAxisNames))
results.append(FontPlatformData::FontVariationAxis(values.axisName, String(tag.data(), tag.size()), values.defaultValue, values.minimumValue, values.maximumValue));
return results;