Changeset 166169 in webkit


Ignore:
Timestamp:
Mar 24, 2014 9:20:11 AM (10 years ago)
Author:
fred.wang@free.fr
Message:

Operator stretching: expose a math data API
https://bugs.webkit.org/show_bug.cgi?id=130572

Reviewed by Chris Fleizach.

We expose a new SimpleFontData API to give access to the data from the
OpenType MATH table using a font cache. The class OpenTypeMathData will
be implemented in bug 130324. On Darwin platform, we also implement the
missing FontPlatformData::openTypeTable function which will be necessary
to load the OpenType MATH table. The changes are intended to be used
for MathML operator stretching (bug 130322) so tests are not added yet.

  • CMakeLists.txt: add new OpenTypeMathData files.
  • GNUmakefile.list.am: ditto.
  • WebCore.vcxproj/WebCore.vcxproj: ditto.
  • WebCore.vcxproj/WebCore.vcxproj.filters: ditto.
  • WebCore.xcodeproj/project.pbxproj: ditto.
  • platform/graphics/FontCache.cpp: We add a FontCache::getMathData function to implement a cache for the math data.

We make the math and vertical data share the same key for the cache.
(WebCore::fontMathDataCacheInstance):
(WebCore::FontCache::getMathData):
(WebCore::fontVerticalDataCacheInstance):

  • platform/graphics/FontCache.h: We declare FontCache::getMathData and FontFileKey on all platforms.
  • platform/graphics/FontPlatformData.cpp:

(WebCore::FontPlatformData::openTypeTable): We implement openTypeTable() on Darwin platform.

  • platform/graphics/FontPlatformData.h: We expose openTypeTable() on Darwin platform.
  • platform/graphics/SimpleFontData.cpp: We initialize m_mathData from the font cache.

(WebCore::SimpleFontData::SimpleFontData):

  • platform/graphics/SimpleFontData.h: We expose a mathData() function to access the MATH data.
  • platform/graphics/opentype/OpenTypeMathData.cpp: Added. This is a new class that will be used to parse the data from the OpenType MATH table.

(WebCore::OpenTypeMathData::OpenTypeMathData):

  • platform/graphics/opentype/OpenTypeMathData.h: Added.

(WebCore::OpenTypeMathData::create):
(WebCore::OpenTypeMathData::hasMathData):

Location:
trunk/Source/WebCore
Files:
2 added
12 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r166157 r166169  
    19471947    platform/graphics/filters/SourceGraphic.cpp
    19481948    platform/graphics/filters/SpotLightSource.cpp
     1949
     1950    platform/graphics/opentype/OpenTypeMathData.cpp
    19491951
    19501952    platform/graphics/texmap/TextureMapper.cpp
  • trunk/Source/WebCore/ChangeLog

    r166168 r166169  
     12014-03-24  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Operator stretching: expose a math data API
     4        https://bugs.webkit.org/show_bug.cgi?id=130572
     5
     6        Reviewed by Chris Fleizach.
     7
     8        We expose a new SimpleFontData API to give access to the data from the
     9        OpenType MATH table using a font cache. The class OpenTypeMathData will
     10        be implemented in bug 130324. On Darwin platform, we also implement the
     11        missing FontPlatformData::openTypeTable function which will be necessary
     12        to load the OpenType MATH table. The changes are intended to be used
     13        for MathML operator stretching (bug 130322) so tests are not added yet.
     14
     15        * CMakeLists.txt: add new OpenTypeMathData files.
     16        * GNUmakefile.list.am: ditto.
     17        * WebCore.vcxproj/WebCore.vcxproj: ditto.
     18        * WebCore.vcxproj/WebCore.vcxproj.filters: ditto.
     19        * WebCore.xcodeproj/project.pbxproj: ditto.
     20        * platform/graphics/FontCache.cpp: We add a FontCache::getMathData function to implement a cache for the math data.
     21        We make the math and vertical data share the same key for the cache.
     22        (WebCore::fontMathDataCacheInstance):
     23        (WebCore::FontCache::getMathData):
     24        (WebCore::fontVerticalDataCacheInstance):
     25        * platform/graphics/FontCache.h: We declare FontCache::getMathData and FontFileKey on all platforms.
     26        * platform/graphics/FontPlatformData.cpp:
     27        (WebCore::FontPlatformData::openTypeTable): We implement openTypeTable() on Darwin platform.
     28        * platform/graphics/FontPlatformData.h: We expose openTypeTable() on Darwin platform.
     29        * platform/graphics/SimpleFontData.cpp: We initialize m_mathData from the font cache.
     30        (WebCore::SimpleFontData::SimpleFontData):
     31        * platform/graphics/SimpleFontData.h: We expose a mathData() function to access the MATH data.
     32        * platform/graphics/opentype/OpenTypeMathData.cpp: Added. This is a new class that will be used to parse the data from the OpenType MATH table.
     33        (WebCore::OpenTypeMathData::OpenTypeMathData):
     34        * platform/graphics/opentype/OpenTypeMathData.h: Added.
     35        (WebCore::OpenTypeMathData::create):
     36        (WebCore::OpenTypeMathData::hasMathData):
     37
    1382014-03-24  Jon Lee  <jonlee@apple.com>
    239
  • trunk/Source/WebCore/GNUmakefile.list.am

    r166157 r166169  
    53625362        Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp \
    53635363        Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.h \
     5364        Source/WebCore/platform/graphics/opentype/OpenTypeMathData.cpp \
     5365        Source/WebCore/platform/graphics/opentype/OpenTypeMathData.h \
    53645366        Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp \
    53655367        Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h \
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r166138 r166169  
    79467946    <ClCompile Include="..\platform\graphics\win\IntSizeWin.cpp" />
    79477947    <ClCompile Include="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.cpp" />
     7948    <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp" />
    79487949    <ClCompile Include="..\platform\graphics\opentype\OpenTypeUtilities.cpp" />
    79497950    <ClCompile Include="..\platform\graphics\opentype\OpenTypeVerticalData.cpp" />
     
    1930619307    <ClInclude Include="..\platform\graphics\win\LocalWindowsContext.h" />
    1930719308    <CustomBuildStep Include="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.h" />
     19309    <ClInclude Include="..\platform\graphics\opentype\OpenTypeMathData.h" />
    1930819310    <ClInclude Include="..\platform\graphics\opentype\OpenTypeTypes.h" />
    1930919311    <ClInclude Include="..\platform\graphics\opentype\OpenTypeUtilities.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r166138 r166169  
    14771477      <Filter>platform\graphics\win</Filter>
    14781478    </ClCompile>
     1479    <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp">
     1480      <Filter>platform\graphics\win</Filter>
     1481    </ClCompile>
    14791482    <ClCompile Include="..\platform\graphics\opentype\OpenTypeUtilities.cpp">
    14801483      <Filter>platform\graphics\win</Filter>
     
    84248427    </ClInclude>
    84258428    <ClInclude Include="..\platform\graphics\win\LocalWindowsContext.h">
     8429      <Filter>platform\graphics\win</Filter>
     8430    </ClInclude>
     8431    <ClInclude Include="..\platform\graphics\opentype\OpenTypeMathData.h">
    84268432      <Filter>platform\graphics\win</Filter>
    84278433    </ClInclude>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r166157 r166169  
    45944594                B2C3DA640D006CD600EF6F26 /* SimpleFontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */; };
    45954595                B2C3DA650D006CD600EF6F26 /* SimpleFontData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C3DA540D006CD600EF6F26 /* SimpleFontData.h */; settings = {ATTRIBUTES = (Private, ); }; };
     4596                B2D3DA640D006CD600EF6F27 /* OpenTypeMathData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */; };
     4597                B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    45964598                B2C3DA660D006CD600EF6F26 /* FontDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C3DA550D006CD600EF6F26 /* FontDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
    45974599                B2C3DA670D006CD600EF6F26 /* FontGlyphs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C3DA560D006CD600EF6F26 /* FontGlyphs.cpp */; };
     
    1183811840                B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleFontData.cpp; sourceTree = "<group>"; };
    1183911841                B2C3DA540D006CD600EF6F26 /* SimpleFontData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SimpleFontData.h; sourceTree = "<group>"; };
     11842                B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = opentype/OpenTypeMathData.cpp; sourceTree = "<group>"; };
     11843                B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = opentype/OpenTypeMathData.h; sourceTree = "<group>"; };
    1184011844                B2C3DA550D006CD600EF6F26 /* FontDescription.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontDescription.h; sourceTree = "<group>"; };
    1184111845                B2C3DA560D006CD600EF6F26 /* FontGlyphs.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FontGlyphs.cpp; sourceTree = "<group>"; };
     
    2012020124                                B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */,
    2012120125                                B2C3DA540D006CD600EF6F26 /* SimpleFontData.h */,
     20126                                B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */,
     20127                                B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */,
    2012220128                                CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */,
    2012320129                                CDC61DA0180867D8004B913F /* SourceBufferPrivate.h */,
     
    2545825464                                41D168EE10226E89009BC827 /* SharedWorkerThread.h in Headers */,
    2545925465                                B2C3DA650D006CD600EF6F26 /* SimpleFontData.h in Headers */,
     25466                                B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */,
    2546025467                                E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */,
    2546125468                                E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */,
     
    2881828825                                41D168ED10226E89009BC827 /* SharedWorkerThread.cpp in Sources */,
    2881928826                                B2C3DA640D006CD600EF6F26 /* SimpleFontData.cpp in Sources */,
     28827                                B2D3DA640D006CD600EF6F27 /* OpenTypeMathData.cpp in Sources */,
    2882028828                                163E88F7118A39D200ED9231 /* SimpleFontDataCoreText.cpp in Sources */,
    2882128829                                37E65950163B10C200EB4574 /* SimpleFontDataIOS.mm in Sources */,
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r165676 r166169  
    3535#include "FontPlatformData.h"
    3636#include "FontSelector.h"
     37#include "OpenTypeMathData.h"
    3738#include "WebKitFontFamilyNames.h"
    3839#include <wtf/HashMap.h>
     
    267268}
    268269
    269 #if ENABLE(OPENTYPE_VERTICAL)
    270 struct FontVerticalDataCacheKeyHash {
     270struct FontFileCacheKeyHash {
    271271    static unsigned hash(const FontCache::FontFileKey& fontFileKey)
    272272    {
     
    282282};
    283283
    284 struct FontVerticalDataCacheKeyTraits : WTF::GenericHashTraits<FontCache::FontFileKey> {
     284struct FontFileCacheKeyTraits : WTF::GenericHashTraits<FontCache::FontFileKey> {
    285285    static const bool emptyValueIsZero = true;
    286286    static const bool needsDestruction = true;
     
    300300};
    301301
    302 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, FontVerticalDataCacheKeyHash, FontVerticalDataCacheKeyTraits> FontVerticalDataCache;
    303 
    304 FontVerticalDataCache& fontVerticalDataCacheInstance()
     302typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeMathData>, FontFileCacheKeyHash, FontFileCacheKeyTraits> FontMathDataCache;
     303
     304static FontMathDataCache& fontMathDataCacheInstance()
     305{
     306    static NeverDestroyed<FontMathDataCache> fontMathDataCache;
     307    return fontMathDataCache;
     308}
     309
     310PassRefPtr<OpenTypeMathData> FontCache::getMathData(const FontFileKey& key, const FontPlatformData& fontData)
     311{
     312    FontMathDataCache& fontMathDataCache = fontMathDataCacheInstance();
     313    FontMathDataCache::iterator result = fontMathDataCache.find(key);
     314    if (result != fontMathDataCache.end())
     315        return result.get()->value;
     316
     317    RefPtr<OpenTypeMathData> mathData = OpenTypeMathData::create(fontData);
     318    if (!mathData->hasMathData())
     319        mathData.clear();
     320    fontMathDataCache.set(key, mathData);
     321    return mathData;
     322}
     323
     324#if ENABLE(OPENTYPE_VERTICAL)
     325typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, FontFileCacheKeyHash, FontFileCacheKeyTraits> FontVerticalDataCache;
     326
     327static FontVerticalDataCache& fontVerticalDataCacheInstance()
    305328{
    306329    static NeverDestroyed<FontVerticalDataCache> fontVerticalDataCache;
  • trunk/Source/WebCore/platform/graphics/FontCache.h

    r165676 r166169  
    5555class FontData;
    5656class FontSelector;
     57class OpenTypeMathData;
    5758class OpenTypeVerticalData;
    5859class SimpleFontData;
     
    152153#endif
    153154
     155    typedef AtomicString FontFileKey;
     156    PassRefPtr<OpenTypeMathData> getMathData(const FontFileKey&, const FontPlatformData&);
    154157#if ENABLE(OPENTYPE_VERTICAL)
    155     typedef AtomicString FontFileKey;
    156158    PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const FontPlatformData&);
    157159#endif
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp

    r161589 r166169  
    2727#include <wtf/text/StringHash.h>
    2828#include <wtf/text/WTFString.h>
     29
     30#if OS(DARWIN)
     31#include "SharedBuffer.h"
     32#include <CoreGraphics/CGFont.h>
     33#endif
    2934
    3035namespace WebCore {
     
    170175}
    171176
     177#if OS(DARWIN)
     178PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
     179{
     180    if (CFDataRef data = CGFontCopyTableForTag(cgFont(), table))
     181        return SharedBuffer::wrapCFData(data);
     182   
     183    return nullptr;
    172184}
     185#endif
     186
     187}
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r162451 r166169  
    217217    }
    218218
    219 #if PLATFORM(WIN) && (USE(CG) || USE(CAIRO))
     219#if OS(DARWIN) || (PLATFORM(WIN) && (USE(CG) || USE(CAIRO)))
    220220    PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
    221221#endif
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp

    r165676 r166169  
    3333#include "Font.h"
    3434#include "FontCache.h"
     35#include "OpenTypeMathData.h"
    3536#include <wtf/MathExtras.h>
    3637
     
    5354    , m_isTextOrientationFallback(isTextOrientationFallback)
    5455    , m_isBrokenIdeographFallback(false)
     56    , m_mathData(nullptr)
    5557#if ENABLE(OPENTYPE_VERTICAL)
    5658    , m_verticalData(0)
     
    6163    platformGlyphInit();
    6264    platformCharWidthInit();
     65    m_mathData = fontCache()->getMathData(String::number(platformData.hash()), platformData);
    6366#if ENABLE(OPENTYPE_VERTICAL)
    6467    if (platformData.orientation() == Vertical && !isTextOrientationFallback) {
     
    7780    , m_isTextOrientationFallback(false)
    7881    , m_isBrokenIdeographFallback(false)
     82    , m_mathData(nullptr)
    7983#if ENABLE(OPENTYPE_VERTICAL)
    8084    , m_verticalData(0)
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.h

    r163657 r166169  
    3333#include "GlyphMetricsMap.h"
    3434#include "GlyphPageTreeNode.h"
     35#include "OpenTypeMathData.h"
    3536#if ENABLE(OPENTYPE_VERTICAL)
    3637#include "OpenTypeVerticalData.h"
     
    9394
    9495    const FontPlatformData& platformData() const { return m_platformData; }
     96    const OpenTypeMathData* mathData() const { return m_mathData.get(); }
    9597#if ENABLE(OPENTYPE_VERTICAL)
    9698    const OpenTypeVerticalData* verticalData() const { return m_verticalData.get(); }
     
    260262    bool m_isTextOrientationFallback;
    261263    bool m_isBrokenIdeographFallback;
     264    RefPtr<OpenTypeMathData> m_mathData;
    262265#if ENABLE(OPENTYPE_VERTICAL)
    263266    RefPtr<OpenTypeVerticalData> m_verticalData;
Note: See TracChangeset for help on using the changeset viewer.