+2014-01-27 Andreas Kling <akling@apple.com>
+
+ Allow mmap encoded data replacement for WOFF fonts.
+ <https://webkit.org/b/127737>
+
+ We always have to convert WOFF fonts to SFNT format. This happens
+ in a separate buffer from the CachedFont's internal resource buffer.
+ Because of this, there's no need to protect the original buffer from
+ mmap replacement.
+
+ With this change, WOFF web fonts are no longer duplicated between
+ the network and web processes.
+
+ Reviewed by Brady Eidson.
+
+ * loader/cache/CachedFont.cpp:
+ (WebCore::CachedFont::CachedFont):
+ (WebCore::CachedFont::ensureCustomFontData):
+ (WebCore::CachedFont::mayTryReplaceEncodedData):
+ * loader/cache/CachedFont.h:
+
2014-01-27 David Hyatt <hyatt@apple.com>
[New Multicolumn] Add support for block progression axis and reverse direction
CachedFont::CachedFont(const ResourceRequest& resourceRequest)
: CachedResource(resourceRequest, FontResource)
, m_loadInitiated(false)
- , m_hasCreatedFontData(false)
+ , m_hasCreatedFontDataWrappingResource(false)
{
}
ASSERT(buffer);
RefPtr<SharedBuffer> sfntBuffer;
- if (isWOFF(buffer)) {
+
+ bool fontIsWOFF = isWOFF(buffer);
+ if (fontIsWOFF) {
Vector<char> sfnt;
if (convertWOFFToSfnt(buffer, sfnt)) {
sfntBuffer = SharedBuffer::adoptVector(sfnt);
m_fontData = buffer ? createFontCustomPlatformData(*buffer) : nullptr;
if (m_fontData)
- m_hasCreatedFontData = true;
+ m_hasCreatedFontDataWrappingResource = !fontIsWOFF;
else
setStatus(DecodeError);
}
bool CachedFont::mayTryReplaceEncodedData() const
{
- // If the FontCustomPlatformData has ever been constructed then it still might be in use somewhere.
+ // If a FontCustomPlatformData has ever been constructed to wrap the internal resource buffer then it still might be in use somewhere.
// That platform font object might directly reference the encoded data buffer behind this CachedFont,
// so replacing it is unsafe.
- return !m_hasCreatedFontData;
+ return !m_hasCreatedFontDataWrappingResource;
}
}
std::unique_ptr<FontCustomPlatformData> m_fontData;
bool m_loadInitiated;
- bool m_hasCreatedFontData;
+ bool m_hasCreatedFontDataWrappingResource;
#if ENABLE(SVG_FONTS)
RefPtr<SVGDocument> m_externalSVGDocument;