Changeset 166364 in webkit
- Timestamp:
- Mar 27, 2014 11:06:21 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r166360 r166364 1950 1950 platform/graphics/filters/SourceGraphic.cpp 1951 1951 platform/graphics/filters/SpotLightSource.cpp 1952 1953 platform/graphics/opentype/OpenTypeMathData.cpp 1952 1954 1953 1955 platform/graphics/texmap/TextureMapper.cpp -
trunk/Source/WebCore/ChangeLog
r166362 r166364 1 2014-03-27 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 * WebCore.vcxproj/WebCore.vcxproj: ditto. 17 * WebCore.vcxproj/WebCore.vcxproj.filters: ditto. 18 * WebCore.xcodeproj/project.pbxproj: ditto. 19 * platform/graphics/FontCache.cpp: We add a FontCache::getMathData function to implement a cache for the math data. 20 We make the math and vertical data share the same key for the cache. 21 (WebCore::fontMathDataCacheInstance): 22 (WebCore::FontCache::getMathData): 23 (WebCore::fontVerticalDataCacheInstance): 24 * platform/graphics/FontCache.h: We declare FontCache::getMathData and FontFileKey on all platforms. 25 * platform/graphics/FontPlatformData.cpp: 26 (WebCore::FontPlatformData::openTypeTable): We implement openTypeTable() on Darwin platform. 27 * platform/graphics/FontPlatformData.h: We expose openTypeTable() on Darwin platform. 28 * platform/graphics/SimpleFontData.cpp: We initialize m_mathData from the font cache. 29 (WebCore::SimpleFontData::SimpleFontData): 30 * platform/graphics/SimpleFontData.h: We expose a mathData() function to access the MATH data. 31 * platform/graphics/opentype/OpenTypeMathData.cpp: Added. This is a new class that will be used to parse the data from the OpenType MATH table. 32 (WebCore::OpenTypeMathData::OpenTypeMathData): 33 * platform/graphics/opentype/OpenTypeMathData.h: Added. 34 (WebCore::OpenTypeMathData::create): 35 (WebCore::OpenTypeMathData::hasMathData): 36 1 37 2014-03-27 Brent Fulgham <bfulgham@apple.com> 2 38 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r166360 r166364 7950 7950 <ClCompile Include="..\platform\graphics\win\IntSizeWin.cpp" /> 7951 7951 <ClCompile Include="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.cpp" /> 7952 <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp" /> 7952 7953 <ClCompile Include="..\platform\graphics\opentype\OpenTypeUtilities.cpp" /> 7953 7954 <ClCompile Include="..\platform\graphics\opentype\OpenTypeVerticalData.cpp" /> … … 19374 19375 <ClInclude Include="..\platform\graphics\win\LocalWindowsContext.h" /> 19375 19376 <CustomBuildStep Include="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.h" /> 19377 <ClInclude Include="..\platform\graphics\opentype\OpenTypeMathData.h" /> 19376 19378 <ClInclude Include="..\platform\graphics\opentype\OpenTypeTypes.h" /> 19377 19379 <ClInclude Include="..\platform\graphics\opentype\OpenTypeUtilities.h" /> -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r166360 r166364 1477 1477 <Filter>platform\graphics\win</Filter> 1478 1478 </ClCompile> 1479 <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp"> 1480 <Filter>platform\graphics\win</Filter> 1481 </ClCompile> 1479 1482 <ClCompile Include="..\platform\graphics\opentype\OpenTypeUtilities.cpp"> 1480 1483 <Filter>platform\graphics\win</Filter> … … 8433 8436 </ClInclude> 8434 8437 <ClInclude Include="..\platform\graphics\win\LocalWindowsContext.h"> 8438 <Filter>platform\graphics\win</Filter> 8439 </ClInclude> 8440 <ClInclude Include="..\platform\graphics\opentype\OpenTypeMathData.h"> 8435 8441 <Filter>platform\graphics\win</Filter> 8436 8442 </ClInclude> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r166360 r166364 4594 4594 B2C3DA640D006CD600EF6F26 /* SimpleFontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */; }; 4595 4595 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, ); }; }; 4596 4598 B2C3DA660D006CD600EF6F26 /* FontDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C3DA550D006CD600EF6F26 /* FontDescription.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4597 4599 B2C3DA670D006CD600EF6F26 /* FontGlyphs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C3DA560D006CD600EF6F26 /* FontGlyphs.cpp */; }; … … 11845 11847 B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleFontData.cpp; sourceTree = "<group>"; }; 11846 11848 B2C3DA540D006CD600EF6F26 /* SimpleFontData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SimpleFontData.h; sourceTree = "<group>"; }; 11849 B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = opentype/OpenTypeMathData.cpp; sourceTree = "<group>"; }; 11850 B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = opentype/OpenTypeMathData.h; sourceTree = "<group>"; }; 11847 11851 B2C3DA550D006CD600EF6F26 /* FontDescription.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontDescription.h; sourceTree = "<group>"; }; 11848 11852 B2C3DA560D006CD600EF6F26 /* FontGlyphs.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FontGlyphs.cpp; sourceTree = "<group>"; }; … … 20137 20141 B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */, 20138 20142 B2C3DA540D006CD600EF6F26 /* SimpleFontData.h */, 20143 B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */, 20144 B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */, 20139 20145 CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */, 20140 20146 CDC61DA0180867D8004B913F /* SourceBufferPrivate.h */, … … 25480 25486 41D168EE10226E89009BC827 /* SharedWorkerThread.h in Headers */, 25481 25487 B2C3DA650D006CD600EF6F26 /* SimpleFontData.h in Headers */, 25488 B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */, 25482 25489 E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */, 25483 25490 E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */, … … 28844 28851 41D168ED10226E89009BC827 /* SharedWorkerThread.cpp in Sources */, 28845 28852 B2C3DA640D006CD600EF6F26 /* SimpleFontData.cpp in Sources */, 28853 B2D3DA640D006CD600EF6F27 /* OpenTypeMathData.cpp in Sources */, 28846 28854 163E88F7118A39D200ED9231 /* SimpleFontDataCoreText.cpp in Sources */, 28847 28855 37E65950163B10C200EB4574 /* SimpleFontDataIOS.mm in Sources */, -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r166179 r166364 35 35 #include "FontPlatformData.h" 36 36 #include "FontSelector.h" 37 #include "OpenTypeMathData.h" 37 38 #include "WebKitFontFamilyNames.h" 38 39 #include <wtf/HashMap.h> … … 267 268 } 268 269 269 #if ENABLE(OPENTYPE_VERTICAL) 270 struct FontVerticalDataCacheKeyHash { 270 struct FontFileCacheKeyHash { 271 271 static unsigned hash(const FontCache::FontFileKey& fontFileKey) 272 272 { … … 282 282 }; 283 283 284 struct Font VerticalDataCacheKeyTraits : WTF::GenericHashTraits<FontCache::FontFileKey> {284 struct FontFileCacheKeyTraits : WTF::GenericHashTraits<FontCache::FontFileKey> { 285 285 static const bool emptyValueIsZero = true; 286 286 static const bool needsDestruction = true; … … 300 300 }; 301 301 302 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, FontVerticalDataCacheKeyHash, FontVerticalDataCacheKeyTraits> FontVerticalDataCache; 303 304 FontVerticalDataCache& fontVerticalDataCacheInstance() 302 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeMathData>, FontFileCacheKeyHash, FontFileCacheKeyTraits> FontMathDataCache; 303 304 static FontMathDataCache& fontMathDataCacheInstance() 305 { 306 static NeverDestroyed<FontMathDataCache> fontMathDataCache; 307 return fontMathDataCache; 308 } 309 310 PassRefPtr<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) 325 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, FontFileCacheKeyHash, FontFileCacheKeyTraits> FontVerticalDataCache; 326 327 static FontVerticalDataCache& fontVerticalDataCacheInstance() 305 328 { 306 329 static NeverDestroyed<FontVerticalDataCache> fontVerticalDataCache; -
trunk/Source/WebCore/platform/graphics/FontCache.h
r166179 r166364 55 55 class FontData; 56 56 class FontSelector; 57 class OpenTypeMathData; 57 58 class OpenTypeVerticalData; 58 59 class SimpleFontData; … … 152 153 #endif 153 154 155 typedef AtomicString FontFileKey; 156 PassRefPtr<OpenTypeMathData> getMathData(const FontFileKey&, const FontPlatformData&); 154 157 #if ENABLE(OPENTYPE_VERTICAL) 155 typedef AtomicString FontFileKey;156 158 PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const FontPlatformData&); 157 159 #endif -
trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp
r166179 r166364 27 27 #include <wtf/text/StringHash.h> 28 28 #include <wtf/text/WTFString.h> 29 30 #if OS(DARWIN) && USE(CG) 31 #include "SharedBuffer.h" 32 #include <CoreGraphics/CGFont.h> 33 #endif 29 34 30 35 namespace WebCore { … … 170 175 } 171 176 177 #if OS(DARWIN) && USE(CG) 178 PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const 179 { 180 if (CFDataRef data = CGFontCopyTableForTag(cgFont(), table)) 181 return SharedBuffer::wrapCFData(data); 182 183 return nullptr; 172 184 } 185 #endif 186 187 } -
trunk/Source/WebCore/platform/graphics/FontPlatformData.h
r166179 r166364 217 217 } 218 218 219 #if PLATFORM(WIN) && (USE(CG) || USE(CAIRO))219 #if (OS(DARWIN) && USE(CG)) || (PLATFORM(WIN) && (USE(CG) || USE(CAIRO))) 220 220 PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const; 221 221 #endif -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r166179 r166364 33 33 #include "Font.h" 34 34 #include "FontCache.h" 35 #include "OpenTypeMathData.h" 35 36 #include <wtf/MathExtras.h> 36 37 … … 53 54 , m_isTextOrientationFallback(isTextOrientationFallback) 54 55 , m_isBrokenIdeographFallback(false) 56 , m_mathData(nullptr) 55 57 #if ENABLE(OPENTYPE_VERTICAL) 56 58 , m_verticalData(0) … … 61 63 platformGlyphInit(); 62 64 platformCharWidthInit(); 65 66 bool tryMathData = false; 67 #if PLATFORM(WIN) && (USE(CG) || USE(CAIRO)) 68 tryMathData = platformData.hfont(); 69 #elif OS(DARWIN) && USE(CG) 70 tryMathData = platformData.font(); 71 #elif USE(FREETYPE) 72 tryMathData = platformData.hash(); 73 #endif 74 if (tryMathData) 75 m_mathData = fontCache()->getMathData(String::number(platformData.hash()), platformData); 76 63 77 #if ENABLE(OPENTYPE_VERTICAL) 64 78 if (platformData.orientation() == Vertical && !isTextOrientationFallback) { … … 77 91 , m_isTextOrientationFallback(false) 78 92 , m_isBrokenIdeographFallback(false) 93 , m_mathData(nullptr) 79 94 #if ENABLE(OPENTYPE_VERTICAL) 80 95 , m_verticalData(0) -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r166179 r166364 33 33 #include "GlyphMetricsMap.h" 34 34 #include "GlyphPageTreeNode.h" 35 #include "OpenTypeMathData.h" 35 36 #if ENABLE(OPENTYPE_VERTICAL) 36 37 #include "OpenTypeVerticalData.h" … … 93 94 94 95 const FontPlatformData& platformData() const { return m_platformData; } 96 const OpenTypeMathData* mathData() const { return m_mathData ? m_mathData.get() : nullptr; } 95 97 #if ENABLE(OPENTYPE_VERTICAL) 96 98 const OpenTypeVerticalData* verticalData() const { return m_verticalData.get(); } … … 260 262 bool m_isTextOrientationFallback; 261 263 bool m_isBrokenIdeographFallback; 264 RefPtr<OpenTypeMathData> m_mathData; 262 265 #if ENABLE(OPENTYPE_VERTICAL) 263 266 RefPtr<OpenTypeVerticalData> m_verticalData;
Note: See TracChangeset
for help on using the changeset viewer.