Subclass CachedFont for SVG fonts
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Nov 2014 20:04:38 +0000 (20:04 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Nov 2014 20:04:38 +0000 (20:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138686

Reviewed by Simon Fraser.

Re-landing due to flakey bots.

Source/WebCore:

CachedFont had many #if ENABLE(SVG_FONTS) scattered throughout it.
Splitting out this SVG-specific code into a subclass of CachedFont
cleans up the design.

No new tests because there is no behavior change.

* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::getFontData): There are two sections
in this function; one for SVG fonts and one for regular fonts.
I've moved these two sections into CachedFont and SVGCachedFont,
thereby simplifying this function.
(WebCore::CSSFontFaceSource::ensureFontData): Ditto.
(WebCore::CSSFontFaceSource::svgFontFaceElement): Moved to header.
(WebCore::CSSFontFaceSource::setSVGFontFaceElement): Ditto.
(WebCore::CSSFontFaceSource::isSVGFontFaceSource): Ditto.
* css/CSSFontFaceSource.h: Put functions that are simple enough to
be inlined here.
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::isSVGFontTarget): Convenience
function.
(WebCore::CSSFontFaceSrcValue::cachedFont): Pass through a boolean
from CSSFontSelector to CachedResourceHandle regarding if we should
be using SVGCachedFont instead of CachedFont.
* css/CSSFontFaceSrcValue.h: New convenience function.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule): Pass through a boolean
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResourceType): Update for new
CachedResource type
(WebCore::cachedResourcesForFrame): Ditto.
* loader/cache/CachedFont.cpp:
(WebCore::CachedFont::CachedFont):
(WebCore::CachedFont::ensureCustomFontData): Taken from
CSSFontFaceSource::getFontData()
(WebCore::CachedFont::getFontData): Ditto.
(WebCore::CachedFont::platformDataFromCustomData): Ditto.
(WebCore::CachedFont::ensureSVGFontData): Moved to SVGCachedFont.
(WebCore::CachedFont::getSVGFontById): Ditto.
* loader/cache/CachedFont.h:
* loader/cache/CachedResource.cpp:
(WebCore::defaultPriorityForResourceType): Update for new enum
type.
* loader/cache/CachedResource.h:
* loader/cache/CachedResourceLoader.cpp:
(WebCore::createResource): Takes new boolean.
(WebCore::CachedResourceLoader::requestFont): Ditto.
(WebCore::CachedResourceLoader::checkInsecureContent): Update for
new enum type
(WebCore::CachedResourceLoader::canRequest): Ditto.
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedSVGFont.cpp: Added.
(WebCore::CachedSVGFont::CachedSVGFont): Moved from
CSSFontFaceSource::getFontData() and CachedFont
(WebCore::CachedSVGFont::getFontData): Ditto.
(WebCore::CachedSVGFont::platformDataFromCustomData): Ditto.
(WebCore::CachedSVGFont::ensureCustomFontData): Ditto.
(WebCore::CachedSVGFont::getSVGFontById): Ditto.
(WebCore::CachedSVGFont::firstFontFace): Ditto.
* loader/cache/CachedSVGFont.h: Subclass CachedFont.
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::getStatistics): Update for new enum.
* svg/SVGFontFaceUriElement.cpp:
(WebCore::isSVGFontTarget): Convenience function.
(WebCore::SVGFontFaceUriElement::loadFont): Update for new
boolean.

Source/WebKit2:

Update for enum type.

* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::maximumBufferingTime):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176276 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSFontFaceSource.cpp
Source/WebCore/css/CSSFontFaceSource.h
Source/WebCore/css/CSSFontFaceSrcValue.cpp
Source/WebCore/css/CSSFontFaceSrcValue.h
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/loader/cache/CachedFont.cpp
Source/WebCore/loader/cache/CachedFont.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.h
Source/WebCore/loader/cache/CachedSVGFont.cpp [new file with mode: 0644]
Source/WebCore/loader/cache/CachedSVGFont.h [new file with mode: 0644]
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/svg/SVGFontFaceUriElement.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp

index bf5466be50f1409a4fe66c402d311bc40a746d08..ba457d9d4e50d731691697e12ae3dcac26e78353 100644 (file)
@@ -1842,6 +1842,7 @@ set(WebCore_SOURCES
     loader/archive/mhtml/MHTMLParser.cpp
 
     loader/cache/CachedCSSStyleSheet.cpp
     loader/archive/mhtml/MHTMLParser.cpp
 
     loader/cache/CachedCSSStyleSheet.cpp
+    loader/cache/CachedSVGFont.cpp
     loader/cache/CachedFont.cpp
     loader/cache/CachedImage.cpp
     loader/cache/CachedRawResource.cpp
     loader/cache/CachedFont.cpp
     loader/cache/CachedImage.cpp
     loader/cache/CachedRawResource.cpp
index 59a2021923ff70cee2a98d6b3f215e46b49b76b4..53d807376fec1271c3370be0f0ec06ffd9dfd765 100644 (file)
@@ -1,3 +1,82 @@
+2014-11-18  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Subclass CachedFont for SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=138686
+
+        Reviewed by Simon Fraser.
+
+        Re-landing due to flakey bots.
+
+        CachedFont had many #if ENABLE(SVG_FONTS) scattered throughout it.
+        Splitting out this SVG-specific code into a subclass of CachedFont
+        cleans up the design.
+
+        No new tests because there is no behavior change.
+
+        * CMakeLists.txt:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSFontFaceSource.cpp:
+        (WebCore::CSSFontFaceSource::getFontData): There are two sections
+        in this function; one for SVG fonts and one for regular fonts.
+        I've moved these two sections into CachedFont and SVGCachedFont,
+        thereby simplifying this function.
+        (WebCore::CSSFontFaceSource::ensureFontData): Ditto.
+        (WebCore::CSSFontFaceSource::svgFontFaceElement): Moved to header.
+        (WebCore::CSSFontFaceSource::setSVGFontFaceElement): Ditto.
+        (WebCore::CSSFontFaceSource::isSVGFontFaceSource): Ditto.
+        * css/CSSFontFaceSource.h: Put functions that are simple enough to
+        be inlined here.
+        * css/CSSFontFaceSrcValue.cpp:
+        (WebCore::CSSFontFaceSrcValue::isSVGFontTarget): Convenience
+        function.
+        (WebCore::CSSFontFaceSrcValue::cachedFont): Pass through a boolean
+        from CSSFontSelector to CachedResourceHandle regarding if we should
+        be using SVGCachedFont instead of CachedFont.
+        * css/CSSFontFaceSrcValue.h: New convenience function.
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule): Pass through a boolean
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::cachedResourceType): Update for new
+        CachedResource type
+        (WebCore::cachedResourcesForFrame): Ditto.
+        * loader/cache/CachedFont.cpp:
+        (WebCore::CachedFont::CachedFont):
+        (WebCore::CachedFont::ensureCustomFontData): Taken from
+        CSSFontFaceSource::getFontData()
+        (WebCore::CachedFont::getFontData): Ditto.
+        (WebCore::CachedFont::platformDataFromCustomData): Ditto.
+        (WebCore::CachedFont::ensureSVGFontData): Moved to SVGCachedFont.
+        (WebCore::CachedFont::getSVGFontById): Ditto.
+        * loader/cache/CachedFont.h:
+        * loader/cache/CachedResource.cpp:
+        (WebCore::defaultPriorityForResourceType): Update for new enum
+        type.
+        * loader/cache/CachedResource.h:
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::createResource): Takes new boolean.
+        (WebCore::CachedResourceLoader::requestFont): Ditto.
+        (WebCore::CachedResourceLoader::checkInsecureContent): Update for
+        new enum type
+        (WebCore::CachedResourceLoader::canRequest): Ditto.
+        * loader/cache/CachedResourceLoader.h:
+        * loader/cache/CachedSVGFont.cpp: Added.
+        (WebCore::CachedSVGFont::CachedSVGFont): Moved from
+        CSSFontFaceSource::getFontData() and CachedFont
+        (WebCore::CachedSVGFont::getFontData): Ditto.
+        (WebCore::CachedSVGFont::platformDataFromCustomData): Ditto.
+        (WebCore::CachedSVGFont::ensureCustomFontData): Ditto.
+        (WebCore::CachedSVGFont::getSVGFontById): Ditto.
+        (WebCore::CachedSVGFont::firstFontFace): Ditto.
+        * loader/cache/CachedSVGFont.h: Subclass CachedFont.
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::getStatistics): Update for new enum.
+        * svg/SVGFontFaceUriElement.cpp:
+        (WebCore::isSVGFontTarget): Convenience function.
+        (WebCore::SVGFontFaceUriElement::loadFont): Update for new
+        boolean.
+
 2014-11-18  Chris Dumez  <cdumez@apple.com>
 
         Update the Vector API to deal with unsigned types instead of size_t
 2014-11-18  Chris Dumez  <cdumez@apple.com>
 
         Update the Vector API to deal with unsigned types instead of size_t
index 565d59b92863ccef834cf31bdbbd986890ad3c08..b57f1482c22ff025b3fb2b2d238d59c4afd90d8c 100644 (file)
     <ClCompile Include="..\loader\archive\mhtml\MHTMLParser.cpp" />
     <ClCompile Include="..\loader\cache\CachedCSSStyleSheet.cpp" />
     <ClCompile Include="..\loader\cache\CachedFont.cpp" />
     <ClCompile Include="..\loader\archive\mhtml\MHTMLParser.cpp" />
     <ClCompile Include="..\loader\cache\CachedCSSStyleSheet.cpp" />
     <ClCompile Include="..\loader\cache\CachedFont.cpp" />
+    <ClCompile Include="..\loader\cache\CachedSVGFont.cpp" />
     <ClCompile Include="..\loader\cache\CachedImage.cpp" />
     <ClCompile Include="..\loader\cache\CachedRawResource.cpp" />
     <ClCompile Include="..\loader\cache\CachedResource.cpp" />
     <ClCompile Include="..\loader\cache\CachedImage.cpp" />
     <ClCompile Include="..\loader\cache\CachedRawResource.cpp" />
     <ClCompile Include="..\loader\cache\CachedResource.cpp" />
     <ClInclude Include="..\loader\archive\mhtml\MHTMLParser.h" />
     <ClInclude Include="..\loader\cache\CachedCSSStyleSheet.h" />
     <ClInclude Include="..\loader\cache\CachedFont.h" />
     <ClInclude Include="..\loader\archive\mhtml\MHTMLParser.h" />
     <ClInclude Include="..\loader\cache\CachedCSSStyleSheet.h" />
     <ClInclude Include="..\loader\cache\CachedFont.h" />
+    <ClInclude Include="..\loader\cache\CachedSVGFont.h" />
     <ClInclude Include="..\loader\cache\CachedImage.h" />
     <ClInclude Include="..\loader\cache\CachedRawResource.h" />
     <ClInclude Include="..\loader\cache\CachedRawResourceClient.h" />
     <ClInclude Include="..\loader\cache\CachedImage.h" />
     <ClInclude Include="..\loader\cache\CachedRawResource.h" />
     <ClInclude Include="..\loader\cache\CachedRawResourceClient.h" />
index b78f46f6b3f500484ff1a83ba3bb74a4507694d6..78750bc7eb30ef821c6507fa947ca40b872a8e2d 100644 (file)
     <ClCompile Include="..\loader\cache\CachedCSSStyleSheet.cpp">
       <Filter>loader\cache</Filter>
     </ClCompile>
     <ClCompile Include="..\loader\cache\CachedCSSStyleSheet.cpp">
       <Filter>loader\cache</Filter>
     </ClCompile>
+    <ClCompile Include="..\loader\cache\CachedSVGFont.cpp">
+      <Filter>loader\cache</Filter>
+    </ClCompile>
     <ClCompile Include="..\loader\cache\CachedFont.cpp">
       <Filter>loader\cache</Filter>
     </ClCompile>
     <ClCompile Include="..\loader\cache\CachedFont.cpp">
       <Filter>loader\cache</Filter>
     </ClCompile>
     <ClInclude Include="..\loader\cache\CachedCSSStyleSheet.h">
       <Filter>loader\cache</Filter>
     </ClInclude>
     <ClInclude Include="..\loader\cache\CachedCSSStyleSheet.h">
       <Filter>loader\cache</Filter>
     </ClInclude>
+    <ClInclude Include="..\loader\cache\CachedSVGFont.h">
+      <Filter>loader\cache</Filter>
+    </ClInclude>
     <ClInclude Include="..\loader\cache\CachedFont.h">
       <Filter>loader\cache</Filter>
     </ClInclude>
     <ClInclude Include="..\loader\cache\CachedFont.h">
       <Filter>loader\cache</Filter>
     </ClInclude>
index eeb9589e0b2d92df09e5563ee40082e7187244f4..9bbe885e67af1dd539f88a71040714956057b8b9 100644 (file)
                1AFE119A0CBFFCC4003017FA /* JSSQLResultSetRowList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFE11980CBFFCC4003017FA /* JSSQLResultSetRowList.h */; };
                1C010700192594DF008A4201 /* InlineTextBoxStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */; };
                1C010701192594DF008A4201 /* InlineTextBoxStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */; };
                1AFE119A0CBFFCC4003017FA /* JSSQLResultSetRowList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFE11980CBFFCC4003017FA /* JSSQLResultSetRowList.h */; };
                1C010700192594DF008A4201 /* InlineTextBoxStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */; };
                1C010701192594DF008A4201 /* InlineTextBoxStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */; };
+               1C0939EA1A13E12900B788E5 /* CachedSVGFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C0939E81A13E12900B788E5 /* CachedSVGFont.cpp */; };
+               1C0939EB1A13E12900B788E5 /* CachedSVGFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0939E91A13E12900B788E5 /* CachedSVGFont.h */; };
                1C11CCB50AA6093700DADB20 /* DOMNotation.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85CA96E80A9624E900690CCF /* DOMNotation.h */; };
                1C11CCB60AA6093700DADB20 /* DOMComment.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85089CD10A98C42700A275AA /* DOMComment.h */; };
                1C11CCB70AA6093700DADB20 /* DOMNamedNodeMap.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 8518DD760A9CF31B0091B7A6 /* DOMNamedNodeMap.h */; };
                1C11CCB50AA6093700DADB20 /* DOMNotation.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85CA96E80A9624E900690CCF /* DOMNotation.h */; };
                1C11CCB60AA6093700DADB20 /* DOMComment.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85089CD10A98C42700A275AA /* DOMComment.h */; };
                1C11CCB70AA6093700DADB20 /* DOMNamedNodeMap.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 8518DD760A9CF31B0091B7A6 /* DOMNamedNodeMap.h */; };
                1AFE11980CBFFCC4003017FA /* JSSQLResultSetRowList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLResultSetRowList.h; sourceTree = "<group>"; };
                1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextBoxStyle.cpp; sourceTree = "<group>"; };
                1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineTextBoxStyle.h; sourceTree = "<group>"; };
                1AFE11980CBFFCC4003017FA /* JSSQLResultSetRowList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLResultSetRowList.h; sourceTree = "<group>"; };
                1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextBoxStyle.cpp; sourceTree = "<group>"; };
                1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineTextBoxStyle.h; sourceTree = "<group>"; };
+               1C0939E81A13E12900B788E5 /* CachedSVGFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedSVGFont.cpp; sourceTree = "<group>"; };
+               1C0939E91A13E12900B788E5 /* CachedSVGFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGFont.h; sourceTree = "<group>"; };
                1C18DA56181AF6A500C4EF22 /* TextPainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextPainter.cpp; sourceTree = "<group>"; };
                1C18DA57181AF6A500C4EF22 /* TextPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPainter.h; sourceTree = "<group>"; };
                1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IOSurfacePool.cpp; path = ../cg/IOSurfacePool.cpp; sourceTree = "<group>"; };
                1C18DA56181AF6A500C4EF22 /* TextPainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextPainter.cpp; sourceTree = "<group>"; };
                1C18DA57181AF6A500C4EF22 /* TextPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPainter.h; sourceTree = "<group>"; };
                1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IOSurfacePool.cpp; path = ../cg/IOSurfacePool.cpp; sourceTree = "<group>"; };
                                E467680F1A0177F900B9E26B /* CacheValidation.h */,
                                BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */,
                                BCB16BFF0979C3BD00467741 /* MemoryCache.h */,
                                E467680F1A0177F900B9E26B /* CacheValidation.h */,
                                BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */,
                                BCB16BFF0979C3BD00467741 /* MemoryCache.h */,
+                               1C0939E81A13E12900B788E5 /* CachedSVGFont.cpp */,
+                               1C0939E91A13E12900B788E5 /* CachedSVGFont.h */,
                        );
                        path = cache;
                        sourceTree = "<group>";
                        );
                        path = cache;
                        sourceTree = "<group>";
                                B22279E90D00BF220071B782 /* SVGFEFuncRElement.h in Headers */,
                                B22279EC0D00BF220071B782 /* SVGFEGaussianBlurElement.h in Headers */,
                                B25599850D00D8BA00BB825C /* SVGFEImage.h in Headers */,
                                B22279E90D00BF220071B782 /* SVGFEFuncRElement.h in Headers */,
                                B22279EC0D00BF220071B782 /* SVGFEGaussianBlurElement.h in Headers */,
                                B25599850D00D8BA00BB825C /* SVGFEImage.h in Headers */,
+                               1C0939EB1A13E12900B788E5 /* CachedSVGFont.h in Headers */,
                                B22279EF0D00BF220071B782 /* SVGFEImageElement.h in Headers */,
                                B22279F20D00BF220071B782 /* SVGFELightElement.h in Headers */,
                                B22279F40D00BF220071B782 /* SVGFEMergeElement.h in Headers */,
                                B22279EF0D00BF220071B782 /* SVGFEImageElement.h in Headers */,
                                B22279F20D00BF220071B782 /* SVGFELightElement.h in Headers */,
                                B22279F40D00BF220071B782 /* SVGFEMergeElement.h in Headers */,
                                51327D6111A33A2B004F9D65 /* SinkDocument.cpp in Sources */,
                                49E911CC0EF86D47009D0CAF /* SkewTransformOperation.cpp in Sources */,
                                4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */,
                                51327D6111A33A2B004F9D65 /* SinkDocument.cpp in Sources */,
                                49E911CC0EF86D47009D0CAF /* SkewTransformOperation.cpp in Sources */,
                                4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */,
+                               1C0939EA1A13E12900B788E5 /* CachedSVGFont.cpp in Sources */,
                                4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */,
                                E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */,
                                E4AFD00D0DAF335500F5F55C /* SMILTimeContainer.cpp in Sources */,
                                4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */,
                                E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */,
                                E4AFD00D0DAF335500F5F55C /* SMILTimeContainer.cpp in Sources */,
index b60c85ca277509c27a82d984eb02fb89e872b3ea..dbea2d62d70456ef5330362bcb13f387fc9a11f3 100644 (file)
@@ -37,6 +37,7 @@
 #include "SimpleFontData.h"
 
 #if ENABLE(SVG_FONTS)
 #include "SimpleFontData.h"
 
 #if ENABLE(SVG_FONTS)
+#include "CachedSVGFont.h"
 #include "FontCustomPlatformData.h"
 #include "SVGFontData.h"
 #include "SVGFontElement.h"
 #include "FontCustomPlatformData.h"
 #include "SVGFontData.h"
 #include "SVGFontElement.h"
@@ -122,42 +123,11 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription&
     // If we are still loading, then we let the system pick a font.
     if (isLoaded()) {
         if (m_font) {
     // If we are still loading, then we let the system pick a font.
     if (isLoaded()) {
         if (m_font) {
-#if ENABLE(SVG_FONTS)
-            if (m_hasExternalSVGFont) {
-                // For SVG fonts parse the external SVG document, and extract the <font> element.
-                if (!m_font->ensureSVGFontData())
-                    return 0;
-
-                if (!m_externalSVGFontElement) {
-                    String fragmentIdentifier;
-                    size_t start = m_string.find('#');
-                    if (start != notFound)
-                        fragmentIdentifier = m_string.string().substring(start + 1);
-                    m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
-                }
-
-                if (!m_externalSVGFontElement)
-                    return 0;
-
-                if (auto firstFontFace = childrenOfType<SVGFontFaceElement>(*m_externalSVGFontElement).first()) {
-                    if (!m_svgFontFaceElement) {
-                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
-                        // Use the imported <font-face> tag as referencing font-face element for these cases.
-                        m_svgFontFaceElement = firstFontFace;
-                    }
-
-                    fontData = SimpleFontData::create(std::make_unique<SVGFontData>(firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
-                }
-            } else
-#endif
-            {
-                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
-                if (!m_font->ensureCustomFontData())
-                    return 0;
-
-                fontData = SimpleFontData::create(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic,
-                    fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false);
-            }
+            // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
+            if (!m_font->ensureCustomFontData(m_hasExternalSVGFont))
+                return nullptr;
+
+            fontData = m_font->getFontData(fontDescription, m_string, syntheticBold, syntheticItalic, m_hasExternalSVGFont);
         } else {
 #if ENABLE(SVG_FONTS)
             // In-Document SVG Fonts
         } else {
 #if ENABLE(SVG_FONTS)
             // In-Document SVG Fonts
@@ -179,23 +149,6 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription&
     return fontData.release();
 }
 
     return fontData.release();
 }
 
-#if ENABLE(SVG_FONTS)
-SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const
-{
-    return m_svgFontFaceElement.get();
-}
-
-void CSSFontFaceSource::setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element)
-{
-    m_svgFontFaceElement = element;
-}
-
-bool CSSFontFaceSource::isSVGFontFaceSource() const
-{
-    return m_svgFontFaceElement || m_hasExternalSVGFont;
-}
-#endif
-
 #if ENABLE(FONT_LOAD_EVENTS)
 bool CSSFontFaceSource::isDecodeError() const
 {
 #if ENABLE(FONT_LOAD_EVENTS)
 bool CSSFontFaceSource::isDecodeError() const
 {
@@ -208,11 +161,7 @@ bool CSSFontFaceSource::ensureFontData()
 {
     if (!m_font)
         return false;
 {
     if (!m_font)
         return false;
-#if ENABLE(SVG_FONTS)
-    if (m_hasExternalSVGFont)
-        return m_font->ensureSVGFontData();
-#endif
-    return m_font->ensureCustomFontData();
+    return m_font->ensureCustomFontData(m_hasExternalSVGFont);
 }
 #endif
 
 }
 #endif
 
index e80fc29db72e42e6ed4d2443bbf95748c929d038..6b164104735615de300b7556dd2f0d4c04063a6c 100644 (file)
 
 #include "CachedFontClient.h"
 #include "CachedResourceHandle.h"
 
 #include "CachedFontClient.h"
 #include "CachedResourceHandle.h"
+#include "SharedBuffer.h"
+#if ENABLE(SVG_FONTS)
+#include "SVGFontElement.h"
+#include "SVGFontFaceElement.h"
+#endif
 #include "Timer.h"
 #include <wtf/HashMap.h>
 #include <wtf/text/AtomicString.h>
 #include "Timer.h"
 #include <wtf/HashMap.h>
 #include <wtf/text/AtomicString.h>
@@ -39,10 +44,6 @@ class CSSFontFace;
 class CSSFontSelector;
 class FontDescription;
 class SimpleFontData;
 class CSSFontSelector;
 class FontDescription;
 class SimpleFontData;
-#if ENABLE(SVG_FONTS)
-class SVGFontElement;
-class SVGFontFaceElement;
-#endif
 
 class CSSFontFaceSource final : public CachedFontClient {
 public:
 
 class CSSFontFaceSource final : public CachedFontClient {
 public:
@@ -63,10 +64,10 @@ public:
     void pruneTable();
 
 #if ENABLE(SVG_FONTS)
     void pruneTable();
 
 #if ENABLE(SVG_FONTS)
-    SVGFontFaceElement* svgFontFaceElement() const;
-    void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement>);
-    bool isSVGFontFaceSource() const;
-    void setHasExternalSVGFont(bool value) { m_hasExternalSVGFont = value; }
+    SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement.get(); }
+    void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element) { m_svgFontFaceElement = element; }
+    bool isSVGFontFaceSource() const { return m_svgFontFaceElement || m_hasExternalSVGFont; }
+    void setHasExternalSVGFont() { m_hasExternalSVGFont = true; }
 #endif
 
 #if ENABLE(FONT_LOAD_EVENTS)
 #endif
 
 #if ENABLE(FONT_LOAD_EVENTS)
@@ -84,7 +85,6 @@ private:
 
 #if ENABLE(SVG_FONTS)
     RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
 
 #if ENABLE(SVG_FONTS)
     RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
-    RefPtr<SVGFontElement> m_externalSVGFontElement;
     bool m_hasExternalSVGFont;
 #endif
 };
     bool m_hasExternalSVGFont;
 #endif
 };
index 58aed2f9823c422b1e8d8e3f0f5ac5e813e4564e..4366e571035638f3046bad36722b3d9331bd3eb2 100644 (file)
@@ -43,6 +43,11 @@ bool CSSFontFaceSrcValue::isSVGFontFaceSrc() const
 {
     return equalIgnoringCase(m_format, "svg");
 }
 {
     return equalIgnoringCase(m_format, "svg");
 }
+
+bool CSSFontFaceSrcValue::isSVGFontTarget() const
+{
+    return isSVGFontFaceSrc() || svgFontFaceElement();
+}
 #endif
 
 bool CSSFontFaceSrcValue::isSupportedFormat() const
 #endif
 
 bool CSSFontFaceSrcValue::isSupportedFormat() const
@@ -93,12 +98,12 @@ bool CSSFontFaceSrcValue::hasFailedOrCanceledSubresources() const
     return m_cachedFont->loadFailedOrCanceled();
 }
 
     return m_cachedFont->loadFailedOrCanceled();
 }
 
-CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document)
+CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document, bool isSVG)
 {
     if (!m_cachedFont) {
         CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)));
         request.setInitiator(cachedResourceRequestInitiators().css);
 {
     if (!m_cachedFont) {
         CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)));
         request.setInitiator(cachedResourceRequestInitiators().css);
-        m_cachedFont = document->cachedResourceLoader()->requestFont(request);
+        m_cachedFont = document->cachedResourceLoader()->requestFont(request, isSVG);
     }
     return m_cachedFont.get();
 }
     }
     return m_cachedFont.get();
 }
index 61bd90933c500144fcf7f59ef244c55273a172b3..60ac87c0aba4f64b127938458e249d074336fcf5 100644 (file)
@@ -58,6 +58,7 @@ public:
 
 #if ENABLE(SVG_FONTS)
     bool isSVGFontFaceSrc() const;
 
 #if ENABLE(SVG_FONTS)
     bool isSVGFontFaceSrc() const;
+    bool isSVGFontTarget() const;
 
     SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement; }
     void setSVGFontFaceElement(SVGFontFaceElement* element) { m_svgFontFaceElement = element; }
 
     SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement; }
     void setSVGFontFaceElement(SVGFontFaceElement* element) { m_svgFontFaceElement = element; }
@@ -69,7 +70,7 @@ public:
 
     bool hasFailedOrCanceledSubresources() const;
 
 
     bool hasFailedOrCanceledSubresources() const;
 
-    CachedFont* cachedFont(Document*);
+    CachedFont* cachedFont(Document*, bool isSVG);
 
     bool equals(const CSSFontFaceSrcValue&) const;
 
 
     bool equals(const CSSFontFaceSrcValue&) const;
 
index 1150889e8722c3953bfd9ad7ad0acab34684d93a..1baaefc2504575993dbdda59378835ad09f9590c 100644 (file)
@@ -212,12 +212,12 @@ void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace* fontFaceRule)
             Settings* settings = m_document ? m_document->frame() ? &m_document->frame()->settings() : 0 : 0;
             bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
             if (allowDownloading && item.isSupportedFormat() && m_document) {
             Settings* settings = m_document ? m_document->frame() ? &m_document->frame()->settings() : 0 : 0;
             bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
             if (allowDownloading && item.isSupportedFormat() && m_document) {
-                CachedFont* cachedFont = item.cachedFont(m_document);
+                CachedFont* cachedFont = item.cachedFont(m_document, foundSVGFont);
                 if (cachedFont) {
                     source = std::make_unique<CSSFontFaceSource>(item.resource(), cachedFont);
 #if ENABLE(SVG_FONTS)
                     if (foundSVGFont)
                 if (cachedFont) {
                     source = std::make_unique<CSSFontFaceSource>(item.resource(), cachedFont);
 #if ENABLE(SVG_FONTS)
                     if (foundSVGFont)
-                        source->setHasExternalSVGFont(true);
+                        source->setHasExternalSVGFont();
 #endif
                 }
             }
 #endif
                 }
             }
index f9b2b213fa40efb5e4b37d71e93e8536f129f663..d7e018c06389dd357c8233e4c7960996b7bce12a 100644 (file)
@@ -297,6 +297,9 @@ InspectorPageAgent::ResourceType InspectorPageAgent::cachedResourceType(const Ca
     switch (cachedResource.type()) {
     case CachedResource::ImageResource:
         return InspectorPageAgent::ImageResource;
     switch (cachedResource.type()) {
     case CachedResource::ImageResource:
         return InspectorPageAgent::ImageResource;
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+#endif
     case CachedResource::FontResource:
         return InspectorPageAgent::FontResource;
     case CachedResource::CSSStyleSheet:
     case CachedResource::FontResource:
         return InspectorPageAgent::FontResource;
     case CachedResource::CSSStyleSheet:
@@ -454,6 +457,9 @@ static Vector<CachedResource*> cachedResourcesForFrame(Frame* frame)
         switch (cachedResource->type()) {
         case CachedResource::ImageResource:
             // Skip images that were not auto loaded (images disabled in the user agent).
         switch (cachedResource->type()) {
         case CachedResource::ImageResource:
             // Skip images that were not auto loaded (images disabled in the user agent).
+#if ENABLE(SVG_FONTS)
+        case CachedResource::SVGFontResource:
+#endif
         case CachedResource::FontResource:
             // Skip fonts that were referenced in CSS but never used/downloaded.
             if (cachedResource->stillNeedsLoad())
         case CachedResource::FontResource:
             // Skip fonts that were referenced in CSS but never used/downloaded.
             if (cachedResource->stillNeedsLoad())
index 1ef622e24bde6b594e38b7f4d51f926e2db96c55..2026e57ec1e2ba49e0e485a8b0cdfcc761261a4f 100644 (file)
@@ -31,6 +31,7 @@
 #include "CachedResourceClientWalker.h"
 #include "CachedResourceLoader.h"
 #include "FontCustomPlatformData.h"
 #include "CachedResourceClientWalker.h"
 #include "CachedResourceLoader.h"
 #include "FontCustomPlatformData.h"
+#include "FontDescription.h"
 #include "FontPlatformData.h"
 #include "MemoryCache.h"
 #include "SharedBuffer.h"
 #include "FontPlatformData.h"
 #include "MemoryCache.h"
 #include "SharedBuffer.h"
 #include "WOFFFileFormat.h"
 #include <wtf/Vector.h>
 
 #include "WOFFFileFormat.h"
 #include <wtf/Vector.h>
 
+#if ENABLE(SVG_OTF_CONVERTER)
+#include "SVGToOTFFontConversion.h"
+#endif
+
 #if ENABLE(SVG_FONTS)
 #include "NodeList.h"
 #include "SVGDocument.h"
 #if ENABLE(SVG_FONTS)
 #include "NodeList.h"
 #include "SVGDocument.h"
@@ -50,8 +55,8 @@
 
 namespace WebCore {
 
 
 namespace WebCore {
 
-CachedFont::CachedFont(const ResourceRequest& resourceRequest, SessionID sessionID)
-    : CachedResource(resourceRequest, FontResource, sessionID)
+CachedFont::CachedFont(const ResourceRequest& resourceRequest, SessionID sessionID, Type type)
+    : CachedResource(resourceRequest, type, sessionID)
     , m_loadInitiated(false)
     , m_hasCreatedFontDataWrappingResource(false)
 {
     , m_loadInitiated(false)
     , m_hasCreatedFontDataWrappingResource(false)
 {
@@ -91,7 +96,7 @@ void CachedFont::beginLoadIfNeeded(CachedResourceLoader* dl)
     }
 }
 
     }
 }
 
-bool CachedFont::ensureCustomFontData()
+bool CachedFont::ensureCustomFontData(bool)
 {
     if (!m_fontData && !errorOccurred() && !isLoading() && m_data) {
         RefPtr<SharedBuffer> buffer = m_data;
 {
     if (!m_fontData && !errorOccurred() && !isLoading() && m_data) {
         RefPtr<SharedBuffer> buffer = m_data;
@@ -118,46 +123,18 @@ bool CachedFont::ensureCustomFontData()
     return m_fontData.get();
 }
 
     return m_fontData.get();
 }
 
-FontPlatformData CachedFont::platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode renderingMode)
+PassRefPtr<SimpleFontData> CachedFont::getFontData(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, bool)
 {
 {
-#if ENABLE(SVG_FONTS)
-    if (m_externalSVGDocument)
-        return FontPlatformData(size, bold, italic);
-#endif
-    ASSERT(m_fontData);
-    return m_fontData->fontPlatformData(static_cast<int>(size), bold, italic, orientation, widthVariant, renderingMode);
+    return SimpleFontData::create(platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic,
+        fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false);
 }
 
 }
 
-#if ENABLE(SVG_FONTS)
-
-bool CachedFont::ensureSVGFontData()
-{
-    if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) {
-        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
-        RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
-        m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
-        if (decoder->sawError())
-            m_externalSVGDocument = nullptr;
-    }
-    return m_externalSVGDocument;
-}
-
-SVGFontElement* CachedFont::getSVGFontById(const String& fontName) const
+FontPlatformData CachedFont::platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode renderingMode)
 {
 {
-    auto elements = descendantsOfType<SVGFontElement>(*m_externalSVGDocument);
-
-    if (fontName.isEmpty())
-        return elements.first();
-
-    for (auto& element : elements) {
-        if (element.getIdAttribute() == fontName)
-            return &element;
-    }
-    return nullptr;
+    ASSERT(m_fontData);
+    return m_fontData->fontPlatformData(static_cast<int>(size), bold, italic, orientation, widthVariant, renderingMode);
 }
 
 }
 
-#endif
-
 void CachedFont::allClientsRemoved()
 {
     m_fontData = nullptr;
 void CachedFont::allClientsRemoved()
 {
     m_fontData = nullptr;
index 2a267cccb1511127755905c9e1747f18ec7beb6b..e5c55457845cb2a08016264a70fbcdf92f898eb6 100644 (file)
 #include "FontOrientation.h"
 #include "FontRenderingMode.h"
 #include "FontWidthVariant.h"
 #include "FontOrientation.h"
 #include "FontRenderingMode.h"
 #include "FontWidthVariant.h"
+#include "SimpleFontData.h"
 
 namespace WebCore {
 
 class CachedResourceLoader;
 
 namespace WebCore {
 
 class CachedResourceLoader;
+class FontDescription;
 class FontPlatformData;
 class SVGDocument;
 class SVGFontElement;
 struct FontCustomPlatformData;
 
 class FontPlatformData;
 class SVGDocument;
 class SVGFontElement;
 struct FontCustomPlatformData;
 
-class CachedFont final : public CachedResource {
+class CachedFont : public CachedResource {
 public:
 public:
-    CachedFont(const ResourceRequest&, SessionID);
+    CachedFont(const ResourceRequest&, SessionID, Type = FontResource);
     virtual ~CachedFont();
 
     void beginLoadIfNeeded(CachedResourceLoader* dl);
     virtual bool stillNeedsLoad() const override { return !m_loadInitiated; }
 
     virtual ~CachedFont();
 
     void beginLoadIfNeeded(CachedResourceLoader* dl);
     virtual bool stillNeedsLoad() const override { return !m_loadInitiated; }
 
-    bool ensureCustomFontData();
-    FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
+    virtual bool ensureCustomFontData(bool externalSVG);
+
+    virtual PassRefPtr<SimpleFontData> getFontData(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG);
 
 
-#if ENABLE(SVG_FONTS)
-    bool ensureSVGFontData();
-    SVGFontElement* getSVGFontById(const String&) const;
-#endif
+protected:
+    FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
 
 private:
     virtual void checkNotify() override;
 
 private:
     virtual void checkNotify() override;
@@ -71,10 +72,6 @@ private:
     bool m_loadInitiated;
     bool m_hasCreatedFontDataWrappingResource;
 
     bool m_loadInitiated;
     bool m_hasCreatedFontDataWrappingResource;
 
-#if ENABLE(SVG_FONTS)
-    RefPtr<SVGDocument> m_externalSVGDocument;
-#endif
-
     friend class MemoryCache;
 };
 
     friend class MemoryCache;
 };
 
index 4f5f5a4a453cec8ff6dc73151b65e3fb21e35cbe..61730177d526d08681d1125a58f8e833b009885c 100644 (file)
@@ -69,6 +69,9 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type
     case CachedResource::CSSStyleSheet:
         return ResourceLoadPriorityHigh;
     case CachedResource::Script:
     case CachedResource::CSSStyleSheet:
         return ResourceLoadPriorityHigh;
     case CachedResource::Script:
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+#endif
     case CachedResource::FontResource:
     case CachedResource::RawResource:
         return ResourceLoadPriorityMedium;
     case CachedResource::FontResource:
     case CachedResource::RawResource:
         return ResourceLoadPriorityMedium;
index d4c03f4de118cb7b21a234a606732c7877626c03..5a247d548508c1d9003b7abfe50e549a79a7cac8 100644 (file)
@@ -66,6 +66,9 @@ public:
         CSSStyleSheet,
         Script,
         FontResource,
         CSSStyleSheet,
         Script,
         FontResource,
+#if ENABLE(SVG_FONTS)
+        SVGFontResource,
+#endif
         RawResource,
         SVGDocumentResource
 #if ENABLE(XSLT)
         RawResource,
         SVGDocumentResource
 #if ENABLE(XSLT)
index ab590df3d26d510115390272b3d542b30af96744..68c022ff0ac7a46e93d7667574b2f32e0de06214 100644 (file)
@@ -33,6 +33,7 @@
 #include "CachedImage.h"
 #include "CachedRawResource.h"
 #include "CachedResourceRequest.h"
 #include "CachedImage.h"
 #include "CachedRawResource.h"
 #include "CachedResourceRequest.h"
+#include "CachedSVGFont.h"
 #include "CachedScript.h"
 #include "CachedXSLStyleSheet.h"
 #include "Chrome.h"
 #include "CachedScript.h"
 #include "CachedXSLStyleSheet.h"
 #include "Chrome.h"
@@ -84,6 +85,10 @@ static CachedResource* createResource(CachedResource::Type type, ResourceRequest
         return new CachedScript(request, charset, sessionID);
     case CachedResource::SVGDocumentResource:
         return new CachedSVGDocument(request, sessionID);
         return new CachedScript(request, charset, sessionID);
     case CachedResource::SVGDocumentResource:
         return new CachedSVGDocument(request, sessionID);
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+        return new CachedSVGFont(request, sessionID);
+#endif
     case CachedResource::FontResource:
         return new CachedFont(request, sessionID);
     case CachedResource::RawResource:
     case CachedResource::FontResource:
         return new CachedFont(request, sessionID);
     case CachedResource::RawResource:
@@ -175,8 +180,10 @@ CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou
     return downcast<CachedImage>(requestResource(CachedResource::ImageResource, request).get());
 }
 
     return downcast<CachedImage>(requestResource(CachedResource::ImageResource, request).get());
 }
 
-CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourceRequest& request)
+CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourceRequest& request, bool isSVG)
 {
 {
+    if (isSVG)
+        return downcast<CachedSVGFont>(requestResource(CachedResource::SVGFontResource, request).get());
     return downcast<CachedFont>(requestResource(CachedResource::FontResource, request).get());
 }
 
     return downcast<CachedFont>(requestResource(CachedResource::FontResource, request).get());
 }
 
@@ -274,6 +281,9 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const
 #endif
     case CachedResource::RawResource:
     case CachedResource::ImageResource:
 #endif
     case CachedResource::RawResource:
     case CachedResource::ImageResource:
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+#endif
     case CachedResource::FontResource: {
         // These resources can corrupt only the frame's pixels.
         if (Frame* f = frame()) {
     case CachedResource::FontResource: {
         // These resources can corrupt only the frame's pixels.
         if (Frame* f = frame()) {
@@ -314,6 +324,9 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url,
     case CachedResource::ImageResource:
     case CachedResource::CSSStyleSheet:
     case CachedResource::Script:
     case CachedResource::ImageResource:
     case CachedResource::CSSStyleSheet:
     case CachedResource::Script:
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+#endif
     case CachedResource::FontResource:
     case CachedResource::RawResource:
 #if ENABLE(LINK_PREFETCH)
     case CachedResource::FontResource:
     case CachedResource::RawResource:
 #if ENABLE(LINK_PREFETCH)
@@ -361,6 +374,9 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url,
         if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowImageFromSource(url))
             return false;
         break;
         if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowImageFromSource(url))
             return false;
         break;
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+#endif
     case CachedResource::FontResource: {
         if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowFontFromSource(url))
             return false;
     case CachedResource::FontResource: {
         if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowFontFromSource(url))
             return false;
index e4ed2feb9d4ab8c9a527edb5d96a492718120bf7..aeba2544f1f59ce6ad904326f120055152d27c55 100644 (file)
@@ -75,7 +75,7 @@ public:
     CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&);
     CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&);
     CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&);
     CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&);
     CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&);
     CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&);
-    CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&);
+    CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&, bool isSVG);
     CachedResourceHandle<CachedRawResource> requestRawResource(CachedResourceRequest&);
     CachedResourceHandle<CachedRawResource> requestMainResource(CachedResourceRequest&);
     CachedResourceHandle<CachedSVGDocument> requestSVGDocument(CachedResourceRequest&);
     CachedResourceHandle<CachedRawResource> requestRawResource(CachedResourceRequest&);
     CachedResourceHandle<CachedRawResource> requestMainResource(CachedResourceRequest&);
     CachedResourceHandle<CachedSVGDocument> requestSVGDocument(CachedResourceRequest&);
diff --git a/Source/WebCore/loader/cache/CachedSVGFont.cpp b/Source/WebCore/loader/cache/CachedSVGFont.cpp
new file mode 100644 (file)
index 0000000..812fbf6
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Torch Mobile, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "CachedSVGFont.h"
+
+#if ENABLE(SVG_FONTS)
+
+#include "FontDescription.h"
+#include "FontPlatformData.h"
+#include "SVGDocument.h"
+#include "SVGFontData.h"
+#include "SVGFontElement.h"
+#include "SVGFontFaceElement.h"
+#include "SharedBuffer.h"
+#include "TextResourceDecoder.h"
+#include "TypedElementDescendantIterator.h"
+
+namespace WebCore {
+
+CachedSVGFont::CachedSVGFont(const ResourceRequest& resourceRequest, SessionID sessionID)
+    : CachedFont(resourceRequest, sessionID, SVGFontResource)
+    , m_externalSVGFontElement(nullptr)
+{
+}
+
+PassRefPtr<SimpleFontData> CachedSVGFont::getFontData(const FontDescription& fontDescription, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG)
+{
+    if (!externalSVG)
+        return CachedFont::getFontData(fontDescription, remoteURI, syntheticBold, syntheticItalic, externalSVG);
+
+    if (SVGFontFaceElement* firstFontFace = this->firstFontFace(remoteURI))
+        return SimpleFontData::create(std::make_unique<SVGFontData>(firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
+    return nullptr;
+}
+
+FontPlatformData CachedSVGFont::platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode renderingMode)
+{
+    if (m_externalSVGDocument)
+        return FontPlatformData(size, bold, italic);
+    return CachedFont::platformDataFromCustomData(size, bold, italic, orientation, widthVariant, renderingMode);
+}
+
+bool CachedSVGFont::ensureCustomFontData(bool externalSVG)
+{
+    if (!externalSVG)
+        return CachedFont::ensureCustomFontData(externalSVG);
+
+    if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) {
+        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
+        RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
+        m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
+        if (decoder->sawError())
+            m_externalSVGDocument = nullptr;
+    }
+    return m_externalSVGDocument;
+}
+
+SVGFontElement* CachedSVGFont::getSVGFontById(const String& fontName) const
+{
+    auto elements = descendantsOfType<SVGFontElement>(*m_externalSVGDocument);
+
+    if (fontName.isEmpty())
+        return elements.first();
+
+    for (auto& element : elements) {
+        if (element.getIdAttribute() == fontName)
+            return &element;
+    }
+    return nullptr;
+}
+
+SVGFontFaceElement* CachedSVGFont::firstFontFace(const AtomicString& remoteURI)
+{
+    if (!m_externalSVGFontElement) {
+        String fragmentIdentifier;
+        size_t start = remoteURI.find('#');
+        if (start != notFound)
+            fragmentIdentifier = remoteURI.string().substring(start + 1);
+        m_externalSVGFontElement = getSVGFontById(fragmentIdentifier);
+    }
+
+    if (!m_externalSVGFontElement)
+        return nullptr;
+
+    if (auto* firstFontFace = childrenOfType<SVGFontFaceElement>(*m_externalSVGFontElement).first())
+        return firstFontFace;
+    return nullptr;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/loader/cache/CachedSVGFont.h b/Source/WebCore/loader/cache/CachedSVGFont.h
new file mode 100644 (file)
index 0000000..68c0cf3
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef CachedSVGFont_h
+#define CachedSVGFont_h
+
+#if ENABLE(SVG_FONTS)
+
+#include "CachedFont.h"
+
+namespace WebCore {
+
+class SVGFontFaceElement;
+
+class CachedSVGFont final : public CachedFont {
+public:
+    CachedSVGFont(const ResourceRequest&, SessionID);
+
+    virtual bool ensureCustomFontData(bool externalSVG) override;
+    
+    virtual PassRefPtr<SimpleFontData> getFontData(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG) override;
+
+private:
+    FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
+
+    SVGFontElement* getSVGFontById(const String&) const;
+
+    SVGFontFaceElement* firstFontFace(const AtomicString& remoteURI);
+
+    RefPtr<SVGDocument> m_externalSVGDocument;
+    SVGFontElement* m_externalSVGFontElement;
+};
+
+}
+
+SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedSVGFont, CachedResource::SVGFontResource)
+
+#endif
+
+#endif
index f9d0a3a4bb6148897eebc81a34f10a568c0f04cd..61af2ffd74be964aa40e6cb760fe9955d944365d 100644 (file)
@@ -823,6 +823,9 @@ MemoryCache::Statistics MemoryCache::getStatistics()
                 case CachedResource::XSLStyleSheet:
                     stats.xslStyleSheets.addResource(resource);
                     break;
                 case CachedResource::XSLStyleSheet:
                     stats.xslStyleSheets.addResource(resource);
                     break;
+#endif
+#if ENABLE(SVG_FONTS)
+                case CachedResource::SVGFontResource:
 #endif
                 case CachedResource::FontResource:
                     stats.fonts.addResource(resource);
 #endif
                 case CachedResource::FontResource:
                     stats.fonts.addResource(resource);
index 03fb3f49c03e63c9f6f1c02a284e118bc7409256..45b906d76520c3c60d5f8c44b38ec2af8d5b96c5 100644 (file)
@@ -88,6 +88,12 @@ Node::InsertionNotificationRequest SVGFontFaceUriElement::insertedInto(Container
     return SVGElement::insertedInto(rootParent);
 }
 
     return SVGElement::insertedInto(rootParent);
 }
 
+static bool isSVGFontTarget(const SVGFontFaceUriElement& element)
+{
+    Ref<CSSFontFaceSrcValue> srcValue(element.srcValue());
+    return srcValue->isSVGFontTarget();
+}
+
 void SVGFontFaceUriElement::loadFont()
 {
     if (m_cachedFont)
 void SVGFontFaceUriElement::loadFont()
 {
     if (m_cachedFont)
@@ -98,7 +104,7 @@ void SVGFontFaceUriElement::loadFont()
         CachedResourceLoader* cachedResourceLoader = document().cachedResourceLoader();
         CachedResourceRequest request(ResourceRequest(document().completeURL(href)));
         request.setInitiator(this);
         CachedResourceLoader* cachedResourceLoader = document().cachedResourceLoader();
         CachedResourceRequest request(ResourceRequest(document().completeURL(href)));
         request.setInitiator(this);
-        m_cachedFont = cachedResourceLoader->requestFont(request);
+        m_cachedFont = cachedResourceLoader->requestFont(request, isSVGFontTarget(*this));
         if (m_cachedFont) {
             m_cachedFont->addClient(this);
             m_cachedFont->beginLoadIfNeeded(cachedResourceLoader);
         if (m_cachedFont) {
             m_cachedFont->addClient(this);
             m_cachedFont->beginLoadIfNeeded(cachedResourceLoader);
index 7a1c302ddc668ebf8e8719054b20ac1ac37100a5..f2aeb2361ca4e7acd913bd48a27304b3e2c2d236 100644 (file)
@@ -1,3 +1,17 @@
+2014-11-18  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Subclass CachedFont for SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=138686
+
+        Reviewed by Simon Fraser.
+
+        Re-landing due to flakey bots.
+
+        Update for enum type.
+
+        * WebProcess/Network/WebResourceLoadScheduler.cpp:
+        (WebKit::maximumBufferingTime):
+
 2014-11-18  Chris Dumez  <cdumez@apple.com>
 
         Update the Vector API to deal with unsigned types instead of size_t
 2014-11-18  Chris Dumez  <cdumez@apple.com>
 
         Update the Vector API to deal with unsigned types instead of size_t
index 88cb064e107293d790965a074adc12cdac80d68f..ec90fe9c208aa2cdb700a7bcf33e0a790344458d 100644 (file)
@@ -92,6 +92,9 @@ static std::chrono::milliseconds maximumBufferingTime(CachedResource* resource)
     switch (resource->type()) {
     case CachedResource::CSSStyleSheet:
     case CachedResource::Script:
     switch (resource->type()) {
     case CachedResource::CSSStyleSheet:
     case CachedResource::Script:
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+#endif
     case CachedResource::FontResource:
         return std::chrono::milliseconds::max();
     case CachedResource::ImageResource:
     case CachedResource::FontResource:
         return std::chrono::milliseconds::max();
     case CachedResource::ImageResource: