Diff
Modified: trunk/Source/WebCore/ChangeLog (254201 => 254202)
--- trunk/Source/WebCore/ChangeLog 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebCore/ChangeLog 2020-01-08 16:33:18 UTC (rev 254202)
@@ -1,3 +1,48 @@
+2020-01-08 Wenson Hsieh <[email protected]>
+
+ Add support for encoding WebCore::Font over IPC for DisplayList::DrawGlyphs
+ https://bugs.webkit.org/show_bug.cgi?id=205830
+ <rdar://problem/57347719>
+
+ Reviewed by Dean Jackson.
+
+ Add support for encoding Fonts. In the case where the Font is installed, we use platform encoders to send across
+ the font descriptor, and reconstruct the font using this descriptor on the receiving end (see the existing
+ implementations of encodeFontInternal and decodeFontInternal). In the case where the Font is not installed, we
+ instead send the font face data over (plumbed across from the CachedFont), and reconstruct the platform font
+ data from the raw font data on the receiving end.
+
+ This allows us to render web fonts in the GPU process through the `DrawGlyphs` display list item.
+
+ * css/CSSFontFace.cpp:
+ (WebCore::CSSFontFace::font):
+ * css/CSSFontFaceSource.h:
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::setFontFaceData):
+
+ Add a way to set font face data used to create the Font. This data comes from a CachedFont's data buffer, and is
+ used to serialize FontHandles when building display list items.
+
+ (WebCore::FontHandle::FontHandle):
+
+ Add a serializable wrapper class that contains a nullable Font. The encoder/decoders for FontHandle are
+ implemented in WebKit2.
+
+ * platform/graphics/Font.h:
+ (WebCore::Font::fontFaceData const):
+ * platform/graphics/displaylists/DisplayListItems.cpp:
+ (WebCore::DisplayList::DrawGlyphs::DrawGlyphs):
+
+ Finish implementing the encode/decode methods for DrawGlyphs, by sending the Font data over via FontHandle.
+
+ * platform/graphics/displaylists/DisplayListItems.h:
+ (WebCore::DisplayList::DrawGlyphs::create):
+ (WebCore::DisplayList::DrawGlyphs::encode const):
+ (WebCore::DisplayList::DrawGlyphs::decode):
+
+ When decoding `DrawGlyphs`, avoid having to rebuild the glyph Vector by adding (and using) new DrawGlyphs
+ constructors that take `Vector&&`s.
+
2020-01-08 Antoine Quint <[email protected]>
[Web Animations] Stop creating CSS Animations for <noscript> elements
Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (254201 => 254202)
--- trunk/Source/WebCore/css/CSSFontFace.cpp 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp 2020-01-08 16:33:18 UTC (rev 254202)
@@ -35,6 +35,7 @@
#include "CSSUnicodeRangeValue.h"
#include "CSSValue.h"
#include "CSSValueList.h"
+#include "CachedFont.h"
#include "Document.h"
#include "Font.h"
#include "FontCache.h"
@@ -41,6 +42,7 @@
#include "FontDescription.h"
#include "FontFace.h"
#include "Settings.h"
+#include "SharedBuffer.h"
#include "StyleBuilderConverter.h"
#include "StyleProperties.h"
#include "StyleRule.h"
@@ -673,8 +675,11 @@
return Font::create(FontCache::singleton().lastResortFallbackFont(fontDescription)->platformData(), Font::Origin::Local, Font::Interstitial::Yes, visibility);
}
case CSSFontFaceSource::Status::Success:
- if (RefPtr<Font> result = source->font(fontDescription, syntheticBold, syntheticItalic, m_featureSettings, m_fontSelectionCapabilities))
+ if (auto result = source->font(fontDescription, syntheticBold, syntheticItalic, m_featureSettings, m_fontSelectionCapabilities)) {
+ auto* cachedFont = source->cachedFont();
+ result->setFontFaceData(cachedFont ? cachedFont->resourceBuffer() : nullptr);
return result;
+ }
break;
case CSSFontFaceSource::Status::Failure:
break;
Modified: trunk/Source/WebCore/css/CSSFontFaceSource.h (254201 => 254202)
--- trunk/Source/WebCore/css/CSSFontFaceSource.h 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.h 2020-01-08 16:33:18 UTC (rev 254202)
@@ -72,6 +72,7 @@
void load(CSSFontSelector*);
RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ CachedFont* cachedFont() const { return m_font.get(); }
bool requiresExternalResource() const { return m_font; }
#if ENABLE(SVG_FONTS)
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (254201 => 254202)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2020-01-08 16:33:18 UTC (rev 254202)
@@ -33,10 +33,13 @@
#if PLATFORM(COCOA)
#include <pal/spi/cocoa/CoreTextSPI.h>
#endif
+#include "CachedFont.h"
#include "CharacterProperties.h"
#include "FontCache.h"
#include "FontCascade.h"
+#include "FontCustomPlatformData.h"
#include "OpenTypeMathData.h"
+#include "SharedBuffer.h"
#include <wtf/MathExtras.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/text/AtomStringHash.h>
@@ -705,4 +708,18 @@
return *m_glyphPathMap.existingMetricsForGlyph(glyph);
}
+void Font::setFontFaceData(RefPtr<SharedBuffer>&& fontFaceData)
+{
+ m_fontFaceData = WTFMove(fontFaceData);
+}
+
+FontHandle::FontHandle(Ref<SharedBuffer>&& fontFaceData, Font::Origin origin, float fontSize, bool syntheticBold, bool syntheticItalic)
+{
+ bool wrapping;
+ auto customFontData = CachedFont::createCustomFontData(fontFaceData.get(), { }, wrapping);
+ FontDescription description;
+ description.setComputedSize(fontSize);
+ font = Font::create(CachedFont::platformDataFromCustomData(*customFontData, description, syntheticBold, syntheticItalic, { }, { }), origin);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/Font.h (254201 => 254202)
--- trunk/Source/WebCore/platform/graphics/Font.h 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2020-01-08 16:33:18 UTC (rev 254202)
@@ -218,8 +218,11 @@
static float ascentConsideringMacAscentHack(const WCHAR*, float ascent, float descent);
#endif
+ SharedBuffer* fontFaceData() const { return m_fontFaceData.get(); }
+ void setFontFaceData(RefPtr<SharedBuffer>&&);
+
private:
- Font(const FontPlatformData&, Origin, Interstitial, Visibility, OrientationFallback);
+ WEBCORE_EXPORT Font(const FontPlatformData&, Origin, Interstitial, Visibility, OrientationFallback);
void platformInit();
void platformGlyphInit();
@@ -291,6 +294,8 @@
mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
#endif
+ RefPtr<SharedBuffer> m_fontFaceData;
+
Glyph m_spaceGlyph { 0 };
Glyph m_zeroGlyph { 0 };
Glyph m_zeroWidthSpaceGlyph { 0 };
@@ -321,6 +326,14 @@
#endif
};
+class FontHandle {
+public:
+ FontHandle() = default;
+ WEBCORE_EXPORT FontHandle(Ref<SharedBuffer>&& fontFaceData, Font::Origin, float fontSize, bool syntheticBold, bool syntheticItalic);
+
+ RefPtr<Font> font;
+};
+
#if PLATFORM(IOS_FAMILY)
bool fontFamilyShouldNotBeUsedForArabic(CFStringRef);
#endif
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (254201 => 254202)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-01-08 16:33:18 UTC (rev 254202)
@@ -512,6 +512,18 @@
return ts;
}
+DrawGlyphs::DrawGlyphs(const Font& font, Vector<GlyphBufferGlyph, 128>&& glyphs, Vector<GlyphBufferAdvance, 128>&& advances, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode smoothingMode)
+ : DrawingItem(ItemType::DrawGlyphs)
+ , m_font(const_cast<Font&>(font))
+ , m_glyphs(WTFMove(glyphs))
+ , m_advances(WTFMove(advances))
+ , m_blockLocation(blockLocation)
+ , m_localAnchor(localAnchor)
+ , m_smoothingMode(smoothingMode)
+{
+ computeBounds();
+}
+
DrawGlyphs::DrawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode smoothingMode)
: DrawingItem(ItemType::DrawGlyphs)
, m_font(const_cast<Font&>(font))
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (254201 => 254202)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2020-01-08 16:33:18 UTC (rev 254202)
@@ -1057,6 +1057,11 @@
return adoptRef(*new DrawGlyphs(font, glyphs, advances, count, blockLocation, localAnchor, smoothingMode));
}
+ static Ref<DrawGlyphs> create(const Font& font, Vector<GlyphBufferGlyph, 128>&& glyphs, Vector<GlyphBufferAdvance, 128>&& advances, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode smoothingMode)
+ {
+ return adoptRef(*new DrawGlyphs(font, WTFMove(glyphs), WTFMove(advances), blockLocation, localAnchor, smoothingMode));
+ }
+
WEBCORE_EXPORT virtual ~DrawGlyphs();
const FloatPoint& blockLocation() const { return m_blockLocation; }
@@ -1072,7 +1077,8 @@
template<class Decoder> static Optional<Ref<DrawGlyphs>> decode(Decoder&);
private:
- WEBCORE_EXPORT DrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode);
+ DrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode);
+ WEBCORE_EXPORT DrawGlyphs(const Font&, Vector<GlyphBufferGlyph, 128>&&, Vector<GlyphBufferAdvance, 128>&&, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode);
void computeBounds();
@@ -1094,7 +1100,9 @@
template<class Encoder>
void DrawGlyphs::encode(Encoder& encoder) const
{
- // FIXME: Add font data to the encoder.
+ FontHandle handle;
+ handle.font = m_font.ptr();
+ encoder << handle;
encoder << m_glyphs;
encoder << m_advances;
encoder << m_blockLocation;
@@ -1105,6 +1113,11 @@
template<class Decoder>
Optional<Ref<DrawGlyphs>> DrawGlyphs::decode(Decoder& decoder)
{
+ Optional<FontHandle> handle;
+ decoder >> handle;
+ if (!handle || !handle->font)
+ return WTF::nullopt;
+
Optional<Vector<GlyphBufferGlyph, 128>> glyphs;
decoder >> glyphs;
if (!glyphs)
@@ -1133,8 +1146,7 @@
if (!smoothingMode)
return WTF::nullopt;
- // FIXME: Create and return a DrawGlyphs once we're able to decode font data.
- return WTF::nullopt;
+ return DrawGlyphs::create(handle->font.releaseNonNull(), WTFMove(*glyphs), WTFMove(*advances), *blockLocation, *localAnchor, *smoothingMode);
}
class DrawImage : public DrawingItem {
Modified: trunk/Source/WebKit/ChangeLog (254201 => 254202)
--- trunk/Source/WebKit/ChangeLog 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebKit/ChangeLog 2020-01-08 16:33:18 UTC (rev 254202)
@@ -1,3 +1,31 @@
+2020-01-08 Wenson Hsieh <[email protected]>
+
+ Add support for encoding WebCore::Font over IPC for DisplayList::DrawGlyphs
+ https://bugs.webkit.org/show_bug.cgi?id=205830
+ <rdar://problem/57347719>
+
+ Reviewed by Dean Jackson.
+
+ Add basic support for encoding and decoding a FontHandle.
+
+ * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+ (IPC::ArgumentCoder<FontHandle>::encodePlatformData):
+ (IPC::ArgumentCoder<FontHandle>::decodePlatformData):
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<FontHandle>::encode):
+ (IPC::ArgumentCoder<FontHandle>::decode):
+
+ When encoding a Font on Cocoa platforms, send across the font face data (if present); otherwise, fall back to
+ sending the font descriptor for the UIFont or NSFont (as is the case for installed fonts).
+
+ * Shared/WebCoreArgumentCoders.h:
+ * Shared/curl/WebCoreArgumentCodersCurl.cpp:
+ (IPC::ArgumentCoder<FontHandle>::encodePlatformData):
+ (IPC::ArgumentCoder<FontHandle>::decodePlatformData):
+ * Shared/soup/WebCoreArgumentCodersSoup.cpp:
+ (IPC::ArgumentCoder<FontHandle>::encodePlatformData):
+ (IPC::ArgumentCoder<FontHandle>::decodePlatformData):
+
2020-01-08 Milan Crha <[email protected]>
[GTK] Editing: Allow line breaks in lists
Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (254201 => 254202)
--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2020-01-08 16:33:18 UTC (rev 254202)
@@ -28,6 +28,7 @@
#import "ArgumentCodersCocoa.h"
#import <WebCore/DictionaryPopupInfo.h>
+#import <WebCore/Font.h>
#import <WebCore/FontAttributes.h>
#if ENABLE(APPLE_PAY)
@@ -472,4 +473,36 @@
return attributes;
}
+#if PLATFORM(IOS_FAMILY)
+#define CocoaFont UIFont
+#else
+#define CocoaFont NSFont
+#endif
+
+void ArgumentCoder<FontHandle>::encodePlatformData(Encoder& encoder, const FontHandle& handle)
+{
+ auto ctFont = handle.font && !handle.font->fontFaceData() ? handle.font->getCTFont() : nil;
+ encoder << !!ctFont;
+ if (ctFont)
+ encoder << (__bridge CocoaFont *)ctFont;
+}
+
+bool ArgumentCoder<FontHandle>::decodePlatformData(Decoder& decoder, FontHandle& handle)
+{
+ bool hasPlatformFont;
+ if (!decoder.decode(hasPlatformFont))
+ return false;
+
+ if (!hasPlatformFont)
+ return true;
+
+ RetainPtr<CocoaFont> font;
+ if (!IPC::decode(decoder, font))
+ return false;
+
+ auto previousValue = handle.font;
+ handle.font = Font::create({ (__bridge CTFontRef)font.get(), static_cast<float>([font pointSize]) });
+ return true;
+}
+
} // namespace IPC
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (254201 => 254202)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2020-01-08 16:33:18 UTC (rev 254202)
@@ -48,6 +48,7 @@
#include <WebCore/FileChooser.h>
#include <WebCore/FilterOperation.h>
#include <WebCore/FilterOperations.h>
+#include <WebCore/Font.h>
#include <WebCore/FontAttributes.h>
#include <WebCore/GraphicsContext.h>
#include <WebCore/GraphicsLayer.h>
@@ -1125,6 +1126,71 @@
return decodeOptionalNativeImage(decoder, imageHandle.image);
}
+void ArgumentCoder<FontHandle>::encode(Encoder& encoder, const FontHandle& handle)
+{
+ encoder << !!handle.font;
+ if (!handle.font)
+ return;
+
+ auto* fontFaceData = handle.font->fontFaceData();
+ encoder << !!fontFaceData;
+ if (fontFaceData) {
+ encodeSharedBuffer(encoder, fontFaceData);
+ auto& data = ""
+ encoder << data.size();
+ encoder << data.syntheticBold();
+ encoder << data.syntheticOblique();
+ }
+
+ encodePlatformData(encoder, handle);
+}
+
+bool ArgumentCoder<FontHandle>::decode(Decoder& decoder, FontHandle& handle)
+{
+ Optional<bool> hasFont;
+ decoder >> hasFont;
+ if (!hasFont.hasValue())
+ return false;
+
+ if (!hasFont.value())
+ return true;
+
+ Optional<bool> hasFontFaceData;
+ decoder >> hasFontFaceData;
+ if (!hasFontFaceData.hasValue())
+ return false;
+
+ if (hasFontFaceData.value()) {
+ RefPtr<SharedBuffer> fontFaceData;
+ if (!decodeSharedBuffer(decoder, fontFaceData))
+ return false;
+
+ if (!fontFaceData)
+ return false;
+
+ Optional<float> fontSize;
+ decoder >> fontSize;
+ if (!fontSize)
+ return false;
+
+ Optional<bool> syntheticBold;
+ decoder >> syntheticBold;
+ if (!syntheticBold)
+ return false;
+
+ Optional<bool> syntheticItalic;
+ decoder >> syntheticItalic;
+ if (!syntheticItalic)
+ return false;
+
+ FontDescription description;
+ description.setComputedSize(*fontSize);
+ handle = { fontFaceData.releaseNonNull(), Font::Origin::Remote, *fontSize, *syntheticBold, *syntheticItalic };
+ }
+
+ return decodePlatformData(decoder, handle);
+}
+
void ArgumentCoder<Cursor>::encode(Encoder& encoder, const Cursor& cursor)
{
encoder.encodeEnum(cursor.type());
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (254201 => 254202)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2020-01-08 16:33:18 UTC (rev 254202)
@@ -80,6 +80,7 @@
class FloatRoundedRect;
class FloatSize;
class FixedPositionViewportConstraints;
+class FontHandle;
class HTTPHeaderMap;
class ImageHandle;
class IntPoint;
@@ -379,6 +380,13 @@
static bool decode(Decoder&, WebCore::Cursor&);
};
+template<> struct ArgumentCoder<WebCore::FontHandle> {
+ static void encode(Encoder&, const WebCore::FontHandle&);
+ static bool decode(Decoder&, WebCore::FontHandle&);
+ static void encodePlatformData(Encoder&, const WebCore::FontHandle&);
+ static bool decodePlatformData(Decoder&, WebCore::FontHandle&);
+};
+
template<> struct ArgumentCoder<WebCore::ImageHandle> {
static void encode(Encoder&, const WebCore::ImageHandle&);
static bool decode(Decoder&, WebCore::ImageHandle&);
Modified: trunk/Source/WebKit/Shared/curl/WebCoreArgumentCodersCurl.cpp (254201 => 254202)
--- trunk/Source/WebKit/Shared/curl/WebCoreArgumentCodersCurl.cpp 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebKit/Shared/curl/WebCoreArgumentCodersCurl.cpp 2020-01-08 16:33:18 UTC (rev 254202)
@@ -30,6 +30,7 @@
#include <WebCore/CertificateInfo.h>
#include <WebCore/CurlProxySettings.h>
#include <WebCore/DictionaryPopupInfo.h>
+#include <WebCore/Font.h>
#include <WebCore/FontAttributes.h>
#include <WebCore/ProtectionSpace.h>
#include <WebCore/ResourceError.h>
@@ -234,4 +235,15 @@
return false;
}
+void ArgumentCoder<FontHandle>::encodePlatformData(Encoder&, const FontHandle&)
+{
+ ASSERT_NOT_REACHED();
}
+
+bool ArgumentCoder<FontHandle>::decodePlatformData(Decoder&, FontHandle&)
+{
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+}
Modified: trunk/Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp (254201 => 254202)
--- trunk/Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp 2020-01-08 16:30:39 UTC (rev 254201)
+++ trunk/Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp 2020-01-08 16:33:18 UTC (rev 254202)
@@ -31,6 +31,7 @@
#include <WebCore/CertificateInfo.h>
#include <WebCore/DictionaryPopupInfo.h>
+#include <WebCore/Font.h>
#include <WebCore/FontAttributes.h>
#include <WebCore/ResourceError.h>
#include <WebCore/ResourceRequest.h>
@@ -251,5 +252,16 @@
return false;
}
+void ArgumentCoder<FontHandle>::encodePlatformData(Encoder&, const FontHandle&)
+{
+ ASSERT_NOT_REACHED();
}
+bool ArgumentCoder<FontHandle>::decodePlatformData(Decoder&, FontHandle&)
+{
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+}
+