Ignore:
Timestamp:
May 14, 2016, 12:18:34 PM (9 years ago)
Author:
[email protected]
Message:

Support ArrayBufferViews in the CSS Font Loading API
https://bugs.webkit.org/show_bug.cgi?id=157694
<rdar://problem/25554267>

Source/WebCore:

This patch adds a new mode to CSSFontFaceSource for immediate (ArrayBuffer) data.
Then, FontFace can simply be hooked up to this new mode.

Reviewed by Darin Adler.

Test: fast/text/css-font-loading-arraybuffer.html

  • css/CSSFontFaceSource.cpp:

(WebCore::CSSFontFaceSource::CSSFontFaceSource):
(WebCore::CSSFontFaceSource::font):

  • css/CSSFontFaceSource.h:
  • css/FontFace.cpp:

(WebCore::FontFace::create):

  • loader/cache/CachedFont.cpp:

(WebCore::CachedFont::ensureCustomFontData):
(WebCore::CachedFont::createCustomFontData):
(WebCore::CachedFont::createFont):
(WebCore::CachedFont::platformDataFromCustomData):

  • loader/cache/CachedFont.h:

LayoutTests:

Reviewed by Darin Adler.

  • fast/text/css-font-loading-arraybuffer-expected.txt: Added.
  • fast/text/css-font-loading-arraybuffer.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSFontFaceSource.cpp

    r199830 r200921  
    3535#include "Font.h"
    3636#include "FontCache.h"
     37#include "FontCustomPlatformData.h"
    3738#include "FontDescription.h"
    38 
    39 #include "FontCustomPlatformData.h"
    4039#include "SVGToOTFFontConversion.h"
    4140
     
    7069}
    7170
    72 CSSFontFaceSource::CSSFontFaceSource(CSSFontFace& owner, const String& familyNameOrURI, CachedFont* font, SVGFontFaceElement* fontFace)
     71CSSFontFaceSource::CSSFontFaceSource(CSSFontFace& owner, const String& familyNameOrURI, CachedFont* font, SVGFontFaceElement* fontFace, RefPtr<JSC::ArrayBufferView>&& arrayBufferView)
    7372    : m_familyNameOrURI(familyNameOrURI)
    7473    , m_font(font)
    7574    , m_face(owner)
     75    , m_immediateSource(WTFMove(arrayBufferView))
    7676#if ENABLE(SVG_FONTS)
    7777    , m_svgFontFaceElement(fontFace)
     
    138138
    139139    if (!m_font && !fontFaceElement) {
     140        if (m_immediateSource) {
     141            if (!m_immediateFontCustomPlatformData) {
     142                bool wrapping;
     143                RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<const char*>(m_immediateSource->baseAddress()), m_immediateSource->byteLength());
     144                ASSERT(buffer);
     145                m_immediateFontCustomPlatformData = CachedFont::createCustomFontData(*buffer, wrapping);
     146            } if (!m_immediateFontCustomPlatformData)
     147                return nullptr;
     148            return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings), true);
     149        }
     150
    140151        // We're local. Just return a Font from the normal cache.
    141152        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
Note: See TracChangeset for help on using the changeset viewer.