| Differences between
and this patch
- a/Source/WebCore/ChangeLog +85 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-01-24  Myles C. Maxfield  <mmaxfield@apple.com>
2
3
        Modularize CSSFontFaceSource
4
        https://bugs.webkit.org/show_bug.cgi?id=153414
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        No new tests (OOPS!).
9
10
        * WebCore.xcodeproj/project.pbxproj:
11
        * css/ByteBasedFontFaceSource.cpp: Added.
12
        (WebCore::ByteBasedFontFaceSource::ByteBasedFontFaceSource):
13
        (WebCore::convertWOFF):
14
        (WebCore::getSVGFontById):
15
        (WebCore::convertSVGFont):
16
        (WebCore::ByteBasedFontFaceSource::bufferProvided):
17
        (WebCore::ByteBasedFontFaceSource::createFont):
18
        * css/ByteBasedFontFaceSource.h: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
19
        * css/CSSFontFaceSource.cpp:
20
        (WebCore::CSSFontFaceSource::fontLoaded):
21
        (WebCore::CSSFontFaceSource::font):
22
        (WebCore::CSSFontFaceSource::CSSFontFaceSource): Deleted.
23
        * css/CSSFontFaceSource.h:
24
        * css/CSSFontSelector.cpp:
25
        (WebCore::createFontFace):
26
        * css/CachedRemoteFontFaceSource.cpp: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
27
        (WebCore::CachedRemoteFontFaceSource::CachedRemoteFontFaceSource):
28
        (WebCore::CachedRemoteFontFaceSource::initiateLoad):
29
        (WebCore::CachedRemoteFontFaceSource::fontLoaded):
30
        * css/CachedRemoteFontFaceSource.h: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
31
        * css/FontFaceSource.cpp: Added.
32
        (WebCore::FontFaceSource::HashKey::HashKey):
33
        (WebCore::FontFaceSource::HashKey::isHashTableDeletedValue):
34
        (WebCore::FontFaceSource::HashKey::operator==):
35
        (WebCore::FontFaceSource::HashKey::operator!=):
36
        (WebCore::FontFaceSource::HashKey::hash):
37
        (WebCore::FontFaceSource::HashKey::equal):
38
        (WebCore::FontFaceSource::FontFaceSource):
39
        (WebCore::FontFaceSource::load):
40
        (WebCore::FontFaceSource::font):
41
        * css/FontFaceSource.h: Added.
42
        (WebCore::FontFaceSource::~FontFaceSource):
43
        (WebCore::FontFaceSource::state):
44
        (WebCore::FontFaceSource::owner):
45
        (WebCore::FontFaceSource::setState):
46
        (WebCore::FontFaceSource::shouldCache):
47
        * css/ImmediateFontFaceSource.h: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
48
        * css/InDocumentSVGFontFaceSource.cpp: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
49
        (WebCore::InDocumentSVGFontFaceSource::InDocumentSVGFontFaceSource):
50
        (WebCore::InDocumentSVGFontFaceSource::initiateLoad):
51
        * css/InDocumentSVGFontFaceSource.h: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
52
        * css/LocalFontFaceSource.cpp: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
53
        (WebCore::LocalFontFaceSource::LocalFontFaceSource):
54
        (WebCore::LocalFontFaceSource::initiateLoad):
55
        (WebCore::LocalFontFaceSource::createFont):
56
        * css/LocalFontFaceSource.h: Copied from Source/WebCore/loader/cache/CachedFontClient.h.
57
        * css/UncachedRemoteFontFaceSource.cpp: Added.
58
        (WebCore::UncachedRemoteFontFaceSource::Listener::Listener):
59
        (WebCore::UncachedRemoteFontFaceSource::Listener::handleEvent):
60
        (WebCore::UncachedRemoteFontFaceSource::Listener::operator==):
61
        (WebCore::UncachedRemoteFontFaceSource::UncachedRemoteFontFaceSource):
62
        (WebCore::UncachedRemoteFontFaceSource::initiateLoad):
63
        (WebCore::UncachedRemoteFontFaceSource::loadFinished):
64
        * css/UncachedRemoteFontFaceSource.h: Added.
65
        * loader/cache/CachedFont.cpp:
66
        (WebCore::CachedFont::didAddClient):
67
        (WebCore::CachedFont::ensureCustomFontData):
68
        (WebCore::CachedFont::createFont):
69
        (WebCore::CachedFont::checkNotify):
70
        * loader/cache/CachedFont.h:
71
        (WebCore::CachedFont::setHasCreatedFontDataWrappingResource):
72
        * loader/cache/CachedFontClient.h:
73
        (WebCore::CachedFontClient::fontLoaded):
74
        * loader/cache/CachedSVGFont.cpp:
75
        (WebCore::CachedSVGFont::createFont):
76
        (WebCore::CachedSVGFont::ensureCustomFontData):
77
        * loader/cache/CachedSVGFont.h:
78
        * platform/graphics/mac/FontCustomPlatformData.cpp:
79
        (WebCore::FontCustomPlatformData::fontPlatformData):
80
        * platform/network/HTTPParsers.cpp:
81
        (WebCore::isValidHTTPToken):
82
        * platform/text/TextFlags.h:
83
        (WebCore::FontVariantSettings::operator==):
84
        (WebCore::FontVariantSettings::hash):
85
1
2016-01-23  Wonchul Lee  <wonchul.lee@collabora.co.uk>
86
2016-01-23  Wonchul Lee  <wonchul.lee@collabora.co.uk>
2
87
3
        [GTK] Fix media controls displaying without controls attribute
88
        [GTK] Fix media controls displaying without controls attribute
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +52 lines
Lines 5869-5874 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
5869
		C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; };
5869
		C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; };
5870
		C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
5870
		C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
5871
		C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */; };
5871
		C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */; };
5872
		C2C73BD61C55671E00DF6B6B /* FontFaceSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C73BD41C55671E00DF6B6B /* FontFaceSource.cpp */; };
5873
		C2C73BD71C55671E00DF6B6B /* FontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C73BD51C55671E00DF6B6B /* FontFaceSource.h */; };
5874
		C2C73BDA1C5580DC00DF6B6B /* LocalFontFaceSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C73BD81C5580DC00DF6B6B /* LocalFontFaceSource.cpp */; };
5875
		C2C73BDB1C5580DC00DF6B6B /* LocalFontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C73BD91C5580DC00DF6B6B /* LocalFontFaceSource.h */; };
5876
		C2C73BDE1C558A3C00DF6B6B /* ByteBasedFontFaceSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C73BDC1C558A3B00DF6B6B /* ByteBasedFontFaceSource.cpp */; };
5877
		C2C73BDF1C558A3C00DF6B6B /* ByteBasedFontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C73BDD1C558A3B00DF6B6B /* ByteBasedFontFaceSource.h */; };
5878
		C2C73BE61C55A11800DF6B6B /* CachedRemoteFontFaceSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C73BE41C55A11800DF6B6B /* CachedRemoteFontFaceSource.cpp */; };
5879
		C2C73BE71C55A11800DF6B6B /* CachedRemoteFontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C73BE51C55A11800DF6B6B /* CachedRemoteFontFaceSource.h */; };
5880
		C2C73BEA1C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C73BE81C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.cpp */; };
5881
		C2C73BEB1C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C73BE91C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.h */; };
5882
		C2C73BEF1C55B01D00DF6B6B /* ImmediateFontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C73BED1C55B01C00DF6B6B /* ImmediateFontFaceSource.h */; };
5883
		C2C73BF21C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C73BF01C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.cpp */; };
5884
		C2C73BF31C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C73BF11C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.h */; };
5872
		C330A22313EC196B0000B45B /* ColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = C330A22113EC196B0000B45B /* ColorChooser.h */; settings = {ATTRIBUTES = (Private, ); }; };
5885
		C330A22313EC196B0000B45B /* ColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = C330A22113EC196B0000B45B /* ColorChooser.h */; settings = {ATTRIBUTES = (Private, ); }; };
5873
		C33EE5C414FB49610002095A /* BaseClickableWithKeyInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C33EE5C214FB49610002095A /* BaseClickableWithKeyInputType.cpp */; };
5886
		C33EE5C414FB49610002095A /* BaseClickableWithKeyInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C33EE5C214FB49610002095A /* BaseClickableWithKeyInputType.cpp */; };
5874
		C33EE5C514FB49610002095A /* BaseClickableWithKeyInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */; };
5887
		C33EE5C514FB49610002095A /* BaseClickableWithKeyInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */; };
Lines 13706-13711 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
13706
		C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontVariantBuilder.h; sourceTree = "<group>"; };
13719
		C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontVariantBuilder.h; sourceTree = "<group>"; };
13707
		C24685131A148E1800811792 /* CoreGraphicsSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreGraphicsSPI.h; sourceTree = "<group>"; };
13720
		C24685131A148E1800811792 /* CoreGraphicsSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreGraphicsSPI.h; sourceTree = "<group>"; };
13708
		C2C4CB1D161A131200D214DA /* WebSafeIncrementalSweeperIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSafeIncrementalSweeperIOS.h; sourceTree = "<group>"; };
13721
		C2C4CB1D161A131200D214DA /* WebSafeIncrementalSweeperIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSafeIncrementalSweeperIOS.h; sourceTree = "<group>"; };
13722
		C2C73BD41C55671E00DF6B6B /* FontFaceSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFaceSource.cpp; sourceTree = "<group>"; };
13723
		C2C73BD51C55671E00DF6B6B /* FontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFaceSource.h; sourceTree = "<group>"; };
13724
		C2C73BD81C5580DC00DF6B6B /* LocalFontFaceSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalFontFaceSource.cpp; sourceTree = "<group>"; };
13725
		C2C73BD91C5580DC00DF6B6B /* LocalFontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalFontFaceSource.h; sourceTree = "<group>"; };
13726
		C2C73BDC1C558A3B00DF6B6B /* ByteBasedFontFaceSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ByteBasedFontFaceSource.cpp; sourceTree = "<group>"; };
13727
		C2C73BDD1C558A3B00DF6B6B /* ByteBasedFontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteBasedFontFaceSource.h; sourceTree = "<group>"; };
13728
		C2C73BE41C55A11800DF6B6B /* CachedRemoteFontFaceSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedRemoteFontFaceSource.cpp; sourceTree = "<group>"; };
13729
		C2C73BE51C55A11800DF6B6B /* CachedRemoteFontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedRemoteFontFaceSource.h; sourceTree = "<group>"; };
13730
		C2C73BE81C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UncachedRemoteFontFaceSource.cpp; sourceTree = "<group>"; };
13731
		C2C73BE91C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UncachedRemoteFontFaceSource.h; sourceTree = "<group>"; };
13732
		C2C73BED1C55B01C00DF6B6B /* ImmediateFontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImmediateFontFaceSource.h; sourceTree = "<group>"; };
13733
		C2C73BF01C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InDocumentSVGFontFaceSource.cpp; sourceTree = "<group>"; };
13734
		C2C73BF11C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InDocumentSVGFontFaceSource.h; sourceTree = "<group>"; };
13709
		C330A22113EC196B0000B45B /* ColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooser.h; sourceTree = "<group>"; };
13735
		C330A22113EC196B0000B45B /* ColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooser.h; sourceTree = "<group>"; };
13710
		C33EE5C214FB49610002095A /* BaseClickableWithKeyInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseClickableWithKeyInputType.cpp; sourceTree = "<group>"; };
13736
		C33EE5C214FB49610002095A /* BaseClickableWithKeyInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseClickableWithKeyInputType.cpp; sourceTree = "<group>"; };
13711
		C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseClickableWithKeyInputType.h; sourceTree = "<group>"; };
13737
		C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseClickableWithKeyInputType.h; sourceTree = "<group>"; };
Lines 23513-23518 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
23513
				3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */,
23539
				3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */,
23514
				3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */,
23540
				3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */,
23515
				3F2B33E3165ABD3500E3987C /* WebKitCSSViewportRule.idl */,
23541
				3F2B33E3165ABD3500E3987C /* WebKitCSSViewportRule.idl */,
23542
				C2C73BD41C55671E00DF6B6B /* FontFaceSource.cpp */,
23543
				C2C73BD51C55671E00DF6B6B /* FontFaceSource.h */,
23544
				C2C73BD81C5580DC00DF6B6B /* LocalFontFaceSource.cpp */,
23545
				C2C73BD91C5580DC00DF6B6B /* LocalFontFaceSource.h */,
23546
				C2C73BDC1C558A3B00DF6B6B /* ByteBasedFontFaceSource.cpp */,
23547
				C2C73BDD1C558A3B00DF6B6B /* ByteBasedFontFaceSource.h */,
23548
				C2C73BE41C55A11800DF6B6B /* CachedRemoteFontFaceSource.cpp */,
23549
				C2C73BE51C55A11800DF6B6B /* CachedRemoteFontFaceSource.h */,
23550
				C2C73BE81C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.cpp */,
23551
				C2C73BE91C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.h */,
23552
				C2C73BED1C55B01C00DF6B6B /* ImmediateFontFaceSource.h */,
23553
				C2C73BF01C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.cpp */,
23554
				C2C73BF11C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.h */,
23516
			);
23555
			);
23517
			path = css;
23556
			path = css;
23518
			sourceTree = "<group>";
23557
			sourceTree = "<group>";
Lines 25525-25530 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
25525
				858015CE0ABCA75D0080588D /* DOMXPathException.h in Headers */,
25564
				858015CE0ABCA75D0080588D /* DOMXPathException.h in Headers */,
25526
				85E9E0A10AB3A0C700069CD0 /* DOMXPathExpression.h in Headers */,
25565
				85E9E0A10AB3A0C700069CD0 /* DOMXPathExpression.h in Headers */,
25527
				85E711DA0AC5D5350053270F /* DOMXPathExpressionInternal.h in Headers */,
25566
				85E711DA0AC5D5350053270F /* DOMXPathExpressionInternal.h in Headers */,
25567
				C2C73BEF1C55B01D00DF6B6B /* ImmediateFontFaceSource.h in Headers */,
25528
				85E9E0A40AB3A0C700069CD0 /* DOMXPathNSResolver.h in Headers */,
25568
				85E9E0A40AB3A0C700069CD0 /* DOMXPathNSResolver.h in Headers */,
25529
				85E9E0A50AB3A0C700069CD0 /* DOMXPathResult.h in Headers */,
25569
				85E9E0A50AB3A0C700069CD0 /* DOMXPathResult.h in Headers */,
25530
				85E711DB0AC5D5350053270F /* DOMXPathResultInternal.h in Headers */,
25570
				85E711DB0AC5D5350053270F /* DOMXPathResultInternal.h in Headers */,
Lines 26368-26373 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
26368
				8A9A588811E84F37008ACFD1 /* JSPerformanceTiming.h in Headers */,
26408
				8A9A588811E84F37008ACFD1 /* JSPerformanceTiming.h in Headers */,
26369
				FDEA6247152102FC00479DF0 /* JSPeriodicWave.h in Headers */,
26409
				FDEA6247152102FC00479DF0 /* JSPeriodicWave.h in Headers */,
26370
				93B70D6C09EB0C7C009D8468 /* JSPluginElementFunctions.h in Headers */,
26410
				93B70D6C09EB0C7C009D8468 /* JSPluginElementFunctions.h in Headers */,
26411
				C2C73BDF1C558A3C00DF6B6B /* ByteBasedFontFaceSource.h in Headers */,
26371
				5189F01E10B37BD900F3C739 /* JSPopStateEvent.h in Headers */,
26412
				5189F01E10B37BD900F3C739 /* JSPopStateEvent.h in Headers */,
26372
				598365DD1355F557001B185D /* JSPositionCallback.h in Headers */,
26413
				598365DD1355F557001B185D /* JSPositionCallback.h in Headers */,
26373
				FE80DA720E9C472F000D6F75 /* JSPositionError.h in Headers */,
26414
				FE80DA720E9C472F000D6F75 /* JSPositionError.h in Headers */,
Lines 26522-26527 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
26522
				B2FA3DBB0AB75A6F000E5AC4 /* JSSVGPathSegArcRel.h in Headers */,
26563
				B2FA3DBB0AB75A6F000E5AC4 /* JSSVGPathSegArcRel.h in Headers */,
26523
				B2FA3DBD0AB75A6F000E5AC4 /* JSSVGPathSegClosePath.h in Headers */,
26564
				B2FA3DBD0AB75A6F000E5AC4 /* JSSVGPathSegClosePath.h in Headers */,
26524
				B2FA3DBF0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicAbs.h in Headers */,
26565
				B2FA3DBF0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicAbs.h in Headers */,
26566
				C2C73BE71C55A11800DF6B6B /* CachedRemoteFontFaceSource.h in Headers */,
26525
				B2FA3DC10AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicRel.h in Headers */,
26567
				B2FA3DC10AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicRel.h in Headers */,
26526
				B2FA3DC30AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicSmoothAbs.h in Headers */,
26568
				B2FA3DC30AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicSmoothAbs.h in Headers */,
26527
				B2FA3DC50AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicSmoothRel.h in Headers */,
26569
				B2FA3DC50AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicSmoothRel.h in Headers */,
Lines 27137-27142 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec7
27137
				4A0FFAA61AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h in Headers */,
27179
				4A0FFAA61AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h in Headers */,
27138
				4A4F65741AA997F100E38CDD /* RealtimeMediaSourceSettings.h in Headers */,
27180
				4A4F65741AA997F100E38CDD /* RealtimeMediaSourceSettings.h in Headers */,
27139
				07C1C0E51BFB60ED00BD2256 /* RealtimeMediaSourceSupportedConstraints.h in Headers */,
27181
				07C1C0E51BFB60ED00BD2256 /* RealtimeMediaSourceSupportedConstraints.h in Headers */,
27182
				C2C73BEB1C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.h in Headers */,
27140
				BC4368E80C226E32005EFB5F /* Rect.h in Headers */,
27183
				BC4368E80C226E32005EFB5F /* Rect.h in Headers */,
27141
				FD45A958175D414C00C21EC8 /* RectangleShape.h in Headers */,
27184
				FD45A958175D414C00C21EC8 /* RectangleShape.h in Headers */,
27142
				9831AE4A154225C900FE2644 /* ReferrerPolicy.h in Headers */,
27185
				9831AE4A154225C900FE2644 /* ReferrerPolicy.h in Headers */,
Lines 27304-27309 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec8
27304
				934F713C0D5A6F1900018D69 /* ResourceErrorBase.h in Headers */,
27347
				934F713C0D5A6F1900018D69 /* ResourceErrorBase.h in Headers */,
27305
				514C76790CE923A1007EF3CD /* ResourceHandle.h in Headers */,
27348
				514C76790CE923A1007EF3CD /* ResourceHandle.h in Headers */,
27306
				26FAE4CD1852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.h in Headers */,
27349
				26FAE4CD1852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.h in Headers */,
27350
				C2C73BDB1C5580DC00DF6B6B /* LocalFontFaceSource.h in Headers */,
27307
				26C15CF71857E15E00F15C03 /* ResourceHandleCFURLConnectionDelegateWithOperationQueue.h in Headers */,
27351
				26C15CF71857E15E00F15C03 /* ResourceHandleCFURLConnectionDelegateWithOperationQueue.h in Headers */,
27308
				514C767A0CE923A1007EF3CD /* ResourceHandleClient.h in Headers */,
27352
				514C767A0CE923A1007EF3CD /* ResourceHandleClient.h in Headers */,
27309
				514C767B0CE923A1007EF3CD /* ResourceHandleInternal.h in Headers */,
27353
				514C767B0CE923A1007EF3CD /* ResourceHandleInternal.h in Headers */,
Lines 27490-27495 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec9
27490
				E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */,
27534
				E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */,
27491
				582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */,
27535
				582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */,
27492
				C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
27536
				C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
27537
				C2C73BF31C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.h in Headers */,
27493
				31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */,
27538
				31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */,
27494
				FD00D7A514A3F61900734011 /* SincResampler.h in Headers */,
27539
				FD00D7A514A3F61900734011 /* SincResampler.h in Headers */,
27495
				51327D6011A33A2B004F9D65 /* SinkDocument.h in Headers */,
27540
				51327D6011A33A2B004F9D65 /* SinkDocument.h in Headers */,
Lines 28100-28105 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec10
28100
				E180810F16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.h in Headers */,
28145
				E180810F16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.h in Headers */,
28101
				E152551516FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h in Headers */,
28146
				E152551516FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h in Headers */,
28102
				93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */,
28147
				93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */,
28148
				C2C73BD71C55671E00DF6B6B /* FontFaceSource.h in Headers */,
28103
				A14832C7187F66C800DA63A6 /* WebCoreThread.h in Headers */,
28149
				A14832C7187F66C800DA63A6 /* WebCoreThread.h in Headers */,
28104
				A14832C9187F676B00DA63A6 /* WebCoreThreadInternal.h in Headers */,
28150
				A14832C9187F676B00DA63A6 /* WebCoreThreadInternal.h in Headers */,
28105
				A14832CA187F678000DA63A6 /* WebCoreThreadMessage.h in Headers */,
28151
				A14832CA187F678000DA63A6 /* WebCoreThreadMessage.h in Headers */,
Lines 28709-28714 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec11
28709
				1A569CF70D7E2B82007C3983 /* c_class.cpp in Sources */,
28755
				1A569CF70D7E2B82007C3983 /* c_class.cpp in Sources */,
28710
				1A569CF90D7E2B82007C3983 /* c_instance.cpp in Sources */,
28756
				1A569CF90D7E2B82007C3983 /* c_instance.cpp in Sources */,
28711
				1A569CFB0D7E2B82007C3983 /* c_runtime.cpp in Sources */,
28757
				1A569CFB0D7E2B82007C3983 /* c_runtime.cpp in Sources */,
28758
				C2C73BDA1C5580DC00DF6B6B /* LocalFontFaceSource.cpp in Sources */,
28712
				1A569CFD0D7E2B82007C3983 /* c_utility.cpp in Sources */,
28759
				1A569CFD0D7E2B82007C3983 /* c_utility.cpp in Sources */,
28713
				BCB16C190979C3BD00467741 /* CachedCSSStyleSheet.cpp in Sources */,
28760
				BCB16C190979C3BD00467741 /* CachedCSSStyleSheet.cpp in Sources */,
28714
				BC64B4CB0CB4295D005F2B62 /* CachedFont.cpp in Sources */,
28761
				BC64B4CB0CB4295D005F2B62 /* CachedFont.cpp in Sources */,
Lines 29199-29204 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec12
29199
				31611E620E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm in Sources */,
29246
				31611E620E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm in Sources */,
29200
				3F2B33EC165AF15600E3987C /* DOMWebKitCSSViewportRule.mm in Sources */,
29247
				3F2B33EC165AF15600E3987C /* DOMWebKitCSSViewportRule.mm in Sources */,
29201
				8A195933147EA16E00D1EA61 /* DOMWebKitNamedFlow.mm in Sources */,
29248
				8A195933147EA16E00D1EA61 /* DOMWebKitNamedFlow.mm in Sources */,
29249
				C2C73BE61C55A11800DF6B6B /* CachedRemoteFontFaceSource.cpp in Sources */,
29202
				31C0FF4D0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm in Sources */,
29250
				31C0FF4D0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm in Sources */,
29203
				85C7F5E80AAFBAFB004014DD /* DOMWheelEvent.mm in Sources */,
29251
				85C7F5E80AAFBAFB004014DD /* DOMWheelEvent.mm in Sources */,
29204
				1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
29252
				1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
Lines 29353-29358 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec13
29353
				085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */,
29401
				085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */,
29354
				A8136D390973A8E700D74463 /* FormDataList.cpp in Sources */,
29402
				A8136D390973A8E700D74463 /* FormDataList.cpp in Sources */,
29355
				7EE6846612D26E3800E79415 /* FormDataStreamCFNet.cpp in Sources */,
29403
				7EE6846612D26E3800E79415 /* FormDataStreamCFNet.cpp in Sources */,
29404
				C2C73BD61C55671E00DF6B6B /* FontFaceSource.cpp in Sources */,
29356
				514C764F0CE9234E007EF3CD /* FormDataStreamMac.mm in Sources */,
29405
				514C764F0CE9234E007EF3CD /* FormDataStreamMac.mm in Sources */,
29357
				656D373B0ADBA5DE00A4554D /* FormState.cpp in Sources */,
29406
				656D373B0ADBA5DE00A4554D /* FormState.cpp in Sources */,
29358
				41885B9411B6FDA6003383BB /* FormSubmission.cpp in Sources */,
29407
				41885B9411B6FDA6003383BB /* FormSubmission.cpp in Sources */,
Lines 30129-30134 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec14
30129
				1AD2316E0CD269E700C1F194 /* JSSQLTransactionCustom.cpp in Sources */,
30178
				1AD2316E0CD269E700C1F194 /* JSSQLTransactionCustom.cpp in Sources */,
30130
				B59DD6A211902A52007E9684 /* JSSQLTransactionErrorCallback.cpp in Sources */,
30179
				B59DD6A211902A52007E9684 /* JSSQLTransactionErrorCallback.cpp in Sources */,
30131
				51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */,
30180
				51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */,
30181
				C2C73BF21C55C35C00DF6B6B /* InDocumentSVGFontFaceSource.cpp in Sources */,
30132
				51D0C5160DAA90B7003B3831 /* JSStorageCustom.cpp in Sources */,
30182
				51D0C5160DAA90B7003B3831 /* JSStorageCustom.cpp in Sources */,
30133
				51E0BAEA0DA55D4A00A9E417 /* JSStorageEvent.cpp in Sources */,
30183
				51E0BAEA0DA55D4A00A9E417 /* JSStorageEvent.cpp in Sources */,
30134
				0FF50269102BA9430066F39A /* JSStyleMedia.cpp in Sources */,
30184
				0FF50269102BA9430066F39A /* JSStyleMedia.cpp in Sources */,
Lines 30572-30577 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec15
30572
				F55B3DC51251F12D003EF269 /* MonthInputType.cpp in Sources */,
30622
				F55B3DC51251F12D003EF269 /* MonthInputType.cpp in Sources */,
30573
				85031B450A44EFC700F992E0 /* MouseEvent.cpp in Sources */,
30623
				85031B450A44EFC700F992E0 /* MouseEvent.cpp in Sources */,
30574
				93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */,
30624
				93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */,
30625
				C2C73BDE1C558A3C00DF6B6B /* ByteBasedFontFaceSource.cpp in Sources */,
30575
				85031B470A44EFC700F992E0 /* MouseRelatedEvent.cpp in Sources */,
30626
				85031B470A44EFC700F992E0 /* MouseRelatedEvent.cpp in Sources */,
30576
				93309DFB099E64920056E581 /* MoveSelectionCommand.cpp in Sources */,
30627
				93309DFB099E64920056E581 /* MoveSelectionCommand.cpp in Sources */,
30577
				FDB1700514A2BAB200A2B5D9 /* MultiChannelResampler.cpp in Sources */,
30628
				FDB1700514A2BAB200A2B5D9 /* MultiChannelResampler.cpp in Sources */,
Lines 30839-30844 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec16
30839
				1479FAEF109AE37500DED655 /* RenderRubyBase.cpp in Sources */,
30890
				1479FAEF109AE37500DED655 /* RenderRubyBase.cpp in Sources */,
30840
				1479FAF1109AE37500DED655 /* RenderRubyRun.cpp in Sources */,
30891
				1479FAF1109AE37500DED655 /* RenderRubyRun.cpp in Sources */,
30841
				1479FAF3109AE37500DED655 /* RenderRubyText.cpp in Sources */,
30892
				1479FAF3109AE37500DED655 /* RenderRubyText.cpp in Sources */,
30893
				C2C73BEA1C55A26E00DF6B6B /* UncachedRemoteFontFaceSource.cpp in Sources */,
30842
				BC3BE9930E9C1C7C00835588 /* RenderScrollbar.cpp in Sources */,
30894
				BC3BE9930E9C1C7C00835588 /* RenderScrollbar.cpp in Sources */,
30843
				BC3BE9AB0E9C242000835588 /* RenderScrollbarPart.cpp in Sources */,
30895
				BC3BE9AB0E9C242000835588 /* RenderScrollbarPart.cpp in Sources */,
30844
				BC3BE9A50E9C239600835588 /* RenderScrollbarTheme.cpp in Sources */,
30896
				BC3BE9A50E9C239600835588 /* RenderScrollbarTheme.cpp in Sources */,
- a/Source/WebCore/css/ByteBasedFontFaceSource.cpp +163 lines
Line 0 a/Source/WebCore/css/ByteBasedFontFaceSource.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "ByteBasedFontFaceSource.h"
28
29
#include "SVGDocument.h"
30
#include "SVGFontElement.h"
31
#include "SVGToOTFFontConversion.h"
32
#include "SharedBuffer.h"
33
#include "TypedElementDescendantIterator.h"
34
35
#include <runtime/ArrayBuffer.h>
36
37
namespace WebCore {
38
39
ByteBasedFontFaceSource::ByteBasedFontFaceSource(CSSFontFace& owner, const AtomicString& remoteURI, bool performConversion)
40
    : FontFaceSource(owner)
41
    , m_remoteURI(remoteURI)
42
    , m_performConversion(performConversion)
43
{
44
}
45
46
enum class WOFFConversionStatus {
47
    Unnecessary,
48
    Success,
49
    Failure
50
};
51
52
static WOFFConversionStatus convertWOFF(SharedBuffer& buffer, Vector<char>& result)
53
{
54
#if PLATFORM(COCOA)
55
    UNUSED_PARAM(buffer);
56
    UNUSED_PARAM(result);
57
    return WOFFConversionStatus::Unnecessary;
58
#else
59
    if (!isWOFF(&buffer))
60
        return Nullopt;
61
    if (!convertWOFFToSfnt(&buffer, result))
62
        return WOFFConversionStatus::Failure;
63
    result = WTF::move(convertedFont);
64
    return WOFFConversionStatus::Success;
65
#endif
66
}
67
68
static SVGFontElement* getSVGFontById(SVGDocument& externalSVGDocument, const String& fontName)
69
{
70
    auto elements = descendantsOfType<SVGFontElement>(externalSVGDocument);
71
72
    if (fontName.isEmpty())
73
        return elements.first();
74
75
    for (auto& element : elements) {
76
        if (element.getIdAttribute() == fontName)
77
            return &element;
78
    }
79
    return nullptr;
80
}
81
82
static Optional<Vector<char>> convertSVGFont(SharedBuffer& buffer, const AtomicString& remoteURI)
83
{
84
    RefPtr<SVGDocument> externalSVGDocument = SVGDocument::create(nullptr, URL());
85
    RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
86
    externalSVGDocument->setContent(decoder->decodeAndFlush(buffer.data(), buffer.size()));
87
    if (decoder->sawError())
88
        return Nullopt;
89
90
    String fragmentIdentifier;
91
    size_t start = remoteURI.find('#');
92
    if (start != notFound)
93
        fragmentIdentifier = remoteURI.string().substring(start + 1);
94
    SVGFontElement* externalSVGFontElement = getSVGFontById(*externalSVGDocument, fragmentIdentifier);
95
    if (!externalSVGFontElement)
96
        return Nullopt;
97
98
    return convertSVGToOTFFont(*externalSVGFontElement);
99
}
100
101
void ByteBasedFontFaceSource::bufferProvided(JSC::ArrayBuffer& arrayBuffer)
102
{
103
    RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<const char*>(arrayBuffer.data()), arrayBuffer.byteLength());
104
    if (!buffer) {
105
        setState(State::Failed);
106
        return;
107
    }
108
109
    bufferProvided(*buffer);
110
}
111
112
bool ByteBasedFontFaceSource::bufferProvided(SharedBuffer& buffer)
113
{
114
    ASSERT(state() == State::Loading);
115
    bool wrapping = true;
116
    RefPtr<SharedBuffer> active = &buffer;
117
118
    if (m_performConversion) {
119
        // Step 1: Try to convert WOFF to SFNT.
120
        Vector<char> sfnt;
121
        switch (convertWOFF(buffer, sfnt)) {
122
        case WOFFConversionStatus::Unnecessary:
123
            break;
124
        case WOFFConversionStatus::Success:
125
            wrapping = false;
126
            active = SharedBuffer::adoptVector(sfnt);
127
            break;
128
        case WOFFConversionStatus::Failure:
129
            setState(State::Failed);
130
            return false;
131
        }
132
133
        // Step 2: Try to convert SVG to OTF.
134
        if (auto otf = convertSVGFont(*active, m_remoteURI)) {
135
            wrapping = false;
136
            active = SharedBuffer::adoptVector(otf.value());
137
        }
138
    }
139
140
    m_fontCustomPlatformData = createFontCustomPlatformData(*active);
141
    if (!m_fontCustomPlatformData) {
142
        setState(State::Failed);
143
        return false;
144
    }
145
146
    // Finally!!
147
    setState(State::Succeeded);
148
149
    return wrapping;
150
}
151
152
RefPtr<Font> ByteBasedFontFaceSource::createFont(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
153
{
154
#if PLATFORM(COCOA)
155
    return Font::create(m_fontCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings), true, false);
156
#else
157
    UNUSED_PARAM(fontFaceFeatures);
158
    UNUSED_PARAM(fontFaceVariantSettings);
159
    return Font::create(m_fontCustomPlatformData->fontPlatformData(fontDescription, bold, italic), true, false);
160
#endif
161
}
162
163
}
- a/Source/WebCore/css/ByteBasedFontFaceSource.h +57 lines
Line 0 a/Source/WebCore/css/ByteBasedFontFaceSource.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef ByteBasedFontFaceSource_h
27
#define ByteBasedFontFaceSource_h
28
29
#include "FontCustomPlatformData.h"
30
#include "FontFaceSource.h"
31
32
namespace JSC {
33
class ArrayBuffer;
34
}
35
36
namespace WebCore {
37
38
class ByteBasedFontFaceSource : public FontFaceSource {
39
public:
40
    ByteBasedFontFaceSource(CSSFontFace& owner, const AtomicString& remoteURI = AtomicString(), bool performConversion = true);
41
42
protected:
43
    void bufferProvided(JSC::ArrayBuffer&);
44
    // Return value is whether or not I added a reference to the argument.
45
    bool bufferProvided(SharedBuffer&);
46
47
private:
48
    virtual RefPtr<Font> createFont(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, const FontVariantSettings&) override;
49
50
    std::unique_ptr<FontCustomPlatformData> m_fontCustomPlatformData;
51
    AtomicString m_remoteURI;
52
    bool m_performConversion;
53
};
54
55
}
56
57
#endif
- a/Source/WebCore/css/CSSFontFaceSource.cpp -10 / +3 lines
Lines 57-65 CSSFontFaceSource::CSSFontFaceSource(const String& str, CachedFont* font) a/Source/WebCore/css/CSSFontFaceSource.cpp_sec1
57
    : m_string(str)
57
    : m_string(str)
58
    , m_font(font)
58
    , m_font(font)
59
    , m_face(0)
59
    , m_face(0)
60
#if ENABLE(SVG_FONTS)
61
    , m_hasExternalSVGFont(false)
62
#endif
63
{
60
{
64
    if (m_font)
61
    if (m_font)
65
        m_font->addClient(this);
62
        m_font->addClient(this);
Lines 87-93 bool CSSFontFaceSource::isValid() const a/Source/WebCore/css/CSSFontFaceSource.cpp_sec2
87
    return true;
84
    return true;
88
}
85
}
89
86
90
void CSSFontFaceSource::fontLoaded(CachedFont*)
87
void CSSFontFaceSource::fontLoaded(CachedFont&)
91
{
88
{
92
    pruneTable();
89
    pruneTable();
93
    if (m_face)
90
    if (m_face)
Lines 119-132 RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, boo a/Source/WebCore/css/CSSFontFaceSource.cpp_sec3
119
116
120
    if (!m_font || m_font->isLoaded()) {
117
    if (!m_font || m_font->isLoaded()) {
121
        if (m_font) {
118
        if (m_font) {
122
            bool hasExternalSVGFont = false;
119
            if (!m_font->ensureCustomFontData(m_string))
123
#if ENABLE(SVG_FONTS)
124
            hasExternalSVGFont = m_hasExternalSVGFont;
125
#endif
126
            if (!m_font->ensureCustomFontData(hasExternalSVGFont, m_string))
127
                return nullptr;
120
                return nullptr;
128
121
129
            font = m_font->createFont(fontDescription, m_string, syntheticBold, syntheticItalic, hasExternalSVGFont, fontFaceFeatures, fontFaceVariantSettings);
122
            font = m_font->createFont(fontDescription, m_string, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings);
130
        } else {
123
        } else {
131
#if ENABLE(SVG_FONTS)
124
#if ENABLE(SVG_FONTS)
132
            // In-Document SVG Fonts
125
            // In-Document SVG Fonts
- a/Source/WebCore/css/CSSFontFaceSource.h -12 / +3 lines
Lines 28-33 a/Source/WebCore/css/CSSFontFaceSource.h_sec1
28
28
29
#include "CachedFontClient.h"
29
#include "CachedFontClient.h"
30
#include "CachedResourceHandle.h"
30
#include "CachedResourceHandle.h"
31
#include "CachedSVGFont.h"
31
#include "SharedBuffer.h"
32
#include "SharedBuffer.h"
32
#if ENABLE(SVG_FONTS)
33
#if ENABLE(SVG_FONTS)
33
#include "SVGFontElement.h"
34
#include "SVGFontElement.h"
Lines 39-45 a/Source/WebCore/css/CSSFontFaceSource.h_sec2
39
40
40
namespace WebCore {
41
namespace WebCore {
41
42
42
class CachedFont;
43
class CSSFontFace;
43
class CSSFontFace;
44
class CSSFontSelector;
44
class CSSFontSelector;
45
class Font;
45
class Font;
Lines 59-65 public: a/Source/WebCore/css/CSSFontFaceSource.h_sec3
59
59
60
    void setFontFace(CSSFontFace* face) { m_face = face; }
60
    void setFontFace(CSSFontFace* face) { m_face = face; }
61
61
62
    virtual void fontLoaded(CachedFont*) override;
62
    virtual void fontLoaded(CachedFont&) override;
63
63
64
    RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*, const FontFeatureSettings&, const FontVariantSettings&);
64
    RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*, const FontFeatureSettings&, const FontVariantSettings&);
65
65
Lines 68-85 public: a/Source/WebCore/css/CSSFontFaceSource.h_sec4
68
#if ENABLE(SVG_FONTS)
68
#if ENABLE(SVG_FONTS)
69
    SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement.get(); }
69
    SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement.get(); }
70
    void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element) { m_svgFontFaceElement = element; }
70
    void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element) { m_svgFontFaceElement = element; }
71
    bool isSVGFontFaceSource() const { return m_svgFontFaceElement || m_hasExternalSVGFont; }
71
    bool isSVGFontFaceSource() const { return m_svgFontFaceElement || is<CachedSVGFont>(m_font.get()); }
72
    void setHasExternalSVGFont() { m_hasExternalSVGFont = true; }
73
#endif
74
75
#if ENABLE(FONT_LOAD_EVENTS)
76
    bool isDecodeError() const;
77
    bool ensureFontData();
78
#endif
72
#endif
79
73
80
private:
74
private:
81
    void startLoadingTimerFired();
82
83
    AtomicString m_string; // URI for remote, built-in font name for local.
75
    AtomicString m_string; // URI for remote, built-in font name for local.
84
    CachedResourceHandle<CachedFont> m_font; // For remote fonts, a pointer to our cached resource.
76
    CachedResourceHandle<CachedFont> m_font; // For remote fonts, a pointer to our cached resource.
85
    CSSFontFace* m_face; // Our owning font face.
77
    CSSFontFace* m_face; // Our owning font face.
Lines 91-97 private: a/Source/WebCore/css/CSSFontFaceSource.h_sec5
91
83
92
#if ENABLE(SVG_FONTS) || ENABLE(SVG_OTF_CONVERTER)
84
#if ENABLE(SVG_FONTS) || ENABLE(SVG_OTF_CONVERTER)
93
    RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
85
    RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
94
    bool m_hasExternalSVGFont;
95
#endif
86
#endif
96
};
87
};
97
88
- a/Source/WebCore/css/CSSFontSelector.cpp -9 / +2 lines
Lines 180-197 static Ref<CSSFontFace> createFontFace(CSSValueList& srcList, FontTraitsMask tra a/Source/WebCore/css/CSSFontSelector.cpp_sec1
180
            Settings* settings = document ? document->settings() : nullptr;
180
            Settings* settings = document ? document->settings() : nullptr;
181
            bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
181
            bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
182
            if (allowDownloading && item.isSupportedFormat() && document) {
182
            if (allowDownloading && item.isSupportedFormat() && document) {
183
                CachedFont* cachedFont = item.cachedFont(document, foundSVGFont, isInitiatingElementInUserAgentShadowTree);
183
                if (CachedFont* cachedFont = item.cachedFont(document, foundSVGFont, isInitiatingElementInUserAgentShadowTree))
184
                if (cachedFont) {
185
                    source = std::make_unique<CSSFontFaceSource>(item.resource(), cachedFont);
184
                    source = std::make_unique<CSSFontFaceSource>(item.resource(), cachedFont);
186
#if ENABLE(SVG_FONTS)
187
                    if (foundSVGFont)
188
                        source->setHasExternalSVGFont();
189
#endif
190
                }
191
            }
185
            }
192
        } else {
186
        } else
193
            source = std::make_unique<CSSFontFaceSource>(item.resource());
187
            source = std::make_unique<CSSFontFaceSource>(item.resource());
194
        }
195
188
196
        if (source) {
189
        if (source) {
197
#if ENABLE(SVG_FONTS)
190
#if ENABLE(SVG_FONTS)
- a/Source/WebCore/css/CachedRemoteFontFaceSource.cpp +62 lines
Line 0 a/Source/WebCore/css/CachedRemoteFontFaceSource.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "CachedRemoteFontFaceSource.h"
28
29
#include "CSSFontFace.h"
30
#include "CSSFontSelector.h"
31
#include "CachedFont.h"
32
33
namespace WebCore {
34
35
CachedRemoteFontFaceSource::CachedRemoteFontFaceSource(CSSFontFace& owner, CSSFontSelector& fontSelector, CachedFont& cachedFont, AtomicString remoteURI)
36
    : ByteBasedFontFaceSource(owner, remoteURI)
37
    , m_fontSelector(fontSelector)
38
    , m_cachedFont(cachedFont)
39
{
40
}
41
42
void CachedRemoteFontFaceSource::initiateLoad()
43
{
44
    // Kick off the load. Do it soon rather than now, because we may be in the middle of layout,
45
    // and the loader may invoke arbitrary delegate or event handler code.
46
    m_fontSelector.beginLoadingFontSoon(&m_cachedFont);
47
}
48
49
void CachedRemoteFontFaceSource::fontLoaded(CachedFont& font)
50
{
51
    ASSERT_UNUSED(font, &font == &m_cachedFont);
52
    ASSERT(!m_cachedFont.isLoading());
53
54
    if (m_cachedFont.errorOccurred() || !m_cachedFont.resourceBuffer()) {
55
        setState(State::Failed);
56
        return;
57
    }
58
59
    m_cachedFont.setHasCreatedFontDataWrappingResource(bufferProvided(*m_cachedFont.resourceBuffer()));
60
}
61
62
}
- a/Source/WebCore/css/CachedRemoteFontFaceSource.h +53 lines
Line 0 a/Source/WebCore/css/CachedRemoteFontFaceSource.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef CachedRemoteFontFaceSource_h
27
#define CachedRemoteFontFaceSource_h
28
29
#include "ByteBasedFontFaceSource.h"
30
#include "CachedFontClient.h"
31
32
namespace WebCore {
33
34
class CachedFont;
35
class CSSFontSelector;
36
37
class CachedRemoteFontFaceSource final : public ByteBasedFontFaceSource, public CachedFontClient {
38
public:
39
    CachedRemoteFontFaceSource(CSSFontFace& owner, CSSFontSelector&, CachedFont&, AtomicString remoteURI);
40
41
private:
42
    virtual void initiateLoad() override;
43
44
    // CachedFontClient
45
    virtual void fontLoaded(CachedFont&) override;
46
47
    CSSFontSelector& m_fontSelector;
48
    CachedFont& m_cachedFont;
49
};
50
51
}
52
53
#endif
- a/Source/WebCore/css/FontFaceSource.cpp +130 lines
Line 0 a/Source/WebCore/css/FontFaceSource.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "FontFaceSource.h"
28
29
#include "FontDescription.h"
30
#include "TextFlags.h"
31
32
namespace WebCore {
33
34
FontFaceSource::HashKey::HashKey()
35
{
36
}
37
38
FontFaceSource::HashKey::HashKey(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatureSettings, const FontVariantSettings& fontFaceVariantSettings)
39
    : m_size(fontDescription.computedPixelSize() + 1) // We don't want to collide with an empty cache entry.
40
    , m_widthVariant(fontDescription.widthVariant())
41
    , m_orientation(fontDescription.orientation())
42
    , m_syntheticBold(syntheticBold)
43
    , m_syntheticItalic(syntheticItalic)
44
    , m_textRenderingMode(fontDescription.textRenderingMode())
45
    , m_descriptionFeatureSettings(fontDescription.featureSettings())
46
    , m_fontFaceFeatureSettings(fontFaceFeatureSettings)
47
    , m_descriptionVariantSettings(fontDescription.variantSettings())
48
    , m_fontFaceVariantSettings(fontFaceVariantSettings)
49
{
50
    ASSERT(m_size > 0 && m_size < cHashTableDeletedSize);
51
}
52
53
FontFaceSource::HashKey::HashKey(WTF::HashTableDeletedValueType)
54
    : m_size(cHashTableDeletedSize)
55
{
56
}
57
58
bool FontFaceSource::HashKey::isHashTableDeletedValue() const
59
{
60
    return m_size == cHashTableDeletedSize;
61
}
62
63
bool FontFaceSource::HashKey::operator==(const HashKey& other) const
64
{
65
    return m_size == other.m_size
66
        && m_widthVariant == other.m_widthVariant
67
        && m_orientation == other.m_orientation
68
        && m_syntheticBold == other.m_syntheticBold
69
        && m_syntheticItalic == other.m_syntheticItalic
70
        && m_textRenderingMode == other.m_textRenderingMode
71
        && m_descriptionFeatureSettings == other.m_descriptionFeatureSettings
72
        && m_fontFaceFeatureSettings == other.m_fontFaceFeatureSettings
73
        && m_descriptionVariantSettings == other.m_descriptionVariantSettings
74
        && m_fontFaceVariantSettings == other.m_fontFaceVariantSettings;
75
}
76
77
bool FontFaceSource::HashKey::operator!=(const HashKey& other) const
78
{
79
    return !(*this == other);
80
}
81
82
unsigned FontFaceSource::HashKey::hash(const HashKey& key)
83
{
84
    IntegerHasher hasher;
85
    hasher.add(key.m_size);
86
    hasher.add(key.m_widthVariant);
87
    hasher.add(key.m_orientation);
88
    hasher.add(key.m_syntheticBold);
89
    hasher.add(key.m_syntheticItalic);
90
    hasher.add(key.m_textRenderingMode);
91
    hasher.add(key.m_descriptionFeatureSettings.hash());
92
    hasher.add(key.m_fontFaceFeatureSettings.hash());
93
    hasher.add(key.m_descriptionVariantSettings.hash());
94
    hasher.add(key.m_fontFaceVariantSettings.hash());
95
    return hasher.hash();
96
}
97
98
bool FontFaceSource::HashKey::equal(const HashKey& a, const HashKey& b)
99
{
100
    return a == b;
101
}
102
103
const unsigned FontFaceSource::HashKey::cHashTableDeletedSize = 0xFFFFFFFFU;
104
105
FontFaceSource::FontFaceSource(CSSFontFace& owner)
106
    : m_owner(owner)
107
{
108
}
109
110
void FontFaceSource::load()
111
{
112
    ASSERT(m_state == State::Pending);
113
    setState(State::Loading);
114
    initiateLoad();
115
}
116
117
RefPtr<Font> FontFaceSource::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatureSettings, const FontVariantSettings& fontFaceVariantSettings)
118
{
119
    ASSERT(m_state == State::Succeeded);
120
    if (!shouldCache())
121
        return createFont(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatureSettings, fontFaceVariantSettings);
122
123
    HashKey hashKey(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatureSettings, fontFaceVariantSettings);
124
    auto addResult = m_cache.add(hashKey, nullptr);
125
    if (addResult.isNewEntry)
126
        addResult.iterator->value = createFont(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatureSettings, fontFaceVariantSettings);
127
    return addResult.iterator->value;
128
}
129
130
}
- a/Source/WebCore/css/FontFaceSource.h +118 lines
Line 0 a/Source/WebCore/css/FontFaceSource.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef FontFaceSource_h
27
#define FontFaceSource_h
28
29
#include "Font.h"
30
#include "FontFeatureSettings.h"
31
32
namespace WebCore {
33
34
class CSSFontFace;
35
class Font;
36
class FontDescription;
37
class FontFeatureSettings;
38
struct FontVariantSettings;
39
40
// This class represents a single clause of a src: attribute inside an @font-face block.
41
class FontFaceSource {
42
    WTF_MAKE_FAST_ALLOCATED;
43
public:
44
    FontFaceSource(CSSFontFace& owner);
45
    virtual ~FontFaceSource() { }
46
47
    //                      -> Succeeded
48
    //                    /
49
    // Pending -> Loading
50
    //                    \
51
    //                      -> Failed
52
    enum class State {
53
        Pending,
54
        Loading,
55
        Failed,
56
        Succeeded
57
    };
58
    State state() const { return m_state; }
59
60
    // State transition from Pending to Loading
61
    void load();
62
63
    // Subclasses handle the transition from Loading to Failed/Succeeded.
64
65
    // Only valid when state is Succeeded
66
    RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatureSettings, const FontVariantSettings& fontFaceVariantSettings);
67
68
protected:
69
    CSSFontFace& owner() const { return m_owner; }
70
    void setState(State state) { m_state = state; }
71
72
private:
73
    // Among the many arguments to font(), this key is only sensitive to the pieces that are actually used when creating a Font.
74
    // Other values are expected (indeed, encouraged) to collide for performance.
75
    class HashKey {
76
    public:
77
        HashKey();
78
        HashKey(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatureSettings, const FontVariantSettings& fontFaceVariantSettings);
79
80
        explicit HashKey(WTF::HashTableDeletedValueType);
81
82
        bool isHashTableDeletedValue() const;
83
84
        bool operator==(const HashKey& other) const;
85
        bool operator!=(const HashKey& other) const;
86
87
        static unsigned hash(const HashKey&);
88
        static bool equal(const HashKey&, const HashKey&);
89
90
        static const bool safeToCompareToEmptyOrDeleted = true;
91
92
    private:
93
        static const unsigned cHashTableDeletedSize;
94
95
        unsigned m_size { 0 };
96
        FontWidthVariant m_widthVariant { RegularWidth };
97
        FontOrientation m_orientation { Horizontal };
98
        bool m_syntheticBold { false };
99
        bool m_syntheticItalic { false };
100
        TextRenderingMode m_textRenderingMode { AutoTextRendering };
101
        FontFeatureSettings m_descriptionFeatureSettings;
102
        FontFeatureSettings m_fontFaceFeatureSettings;
103
        FontVariantSettings m_descriptionVariantSettings;
104
        FontVariantSettings m_fontFaceVariantSettings;
105
    };
106
107
    virtual bool shouldCache() const { return true; }
108
    virtual void initiateLoad() = 0;
109
    virtual RefPtr<Font> createFont(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatureSettings, const FontVariantSettings& fontFaceVariantSettings) = 0;
110
111
    CSSFontFace& m_owner;
112
    HashMap<HashKey, RefPtr<Font>, HashKey, WTF::SimpleClassHashTraits<HashKey>> m_cache;
113
    State m_state { State::Pending };
114
};
115
116
}
117
118
#endif
- a/Source/WebCore/css/ImmediateFontFaceSource.h +53 lines
Line 0 a/Source/WebCore/css/ImmediateFontFaceSource.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef ImmediateFontFaceSource_h
27
#define ImmediateFontFaceSource_h
28
29
#include "ByteBasedFontFaceSource.h"
30
31
namespace WebCore {
32
33
class ImmediateFontFaceSource final : public ByteBasedFontFaceSource {
34
public:
35
    ImmediateFontFaceSource(CSSFontFace& owner, JSC::ArrayBuffer& data)
36
        : ByteBasedFontFaceSource(owner)
37
    {
38
        setState(State::Loading);
39
        bufferProvided(data);
40
    }
41
42
private:
43
    virtual void initiateLoad() override
44
    {
45
        ASSERT_NOT_REACHED();
46
    }
47
};
48
49
}
50
51
#endif
52
53
- a/Source/WebCore/css/InDocumentSVGFontFaceSource.cpp +60 lines
Line 0 a/Source/WebCore/css/InDocumentSVGFontFaceSource.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "InDocumentSVGFontFaceSource.h"
28
29
#include "SVGFontElement.h"
30
#include "SVGFontFaceElement.h"
31
#include "SVGToOTFFontConversion.h"
32
#include "SharedBuffer.h"
33
34
namespace WebCore {
35
36
InDocumentSVGFontFaceSource::InDocumentSVGFontFaceSource(CSSFontFace& owner, SVGFontFaceElement& fontFace, const AtomicString& remoteURI)
37
    : ByteBasedFontFaceSource(owner, remoteURI, false)
38
    , m_svgFontFaceElement(fontFace)
39
{
40
}
41
42
void InDocumentSVGFontFaceSource::initiateLoad()
43
{
44
    if (!m_svgFontFaceElement->parentNode() || !is<SVGFontElement>(m_svgFontFaceElement->parentNode())) {
45
        setState(State::Failed);
46
        return;
47
    }
48
49
    SVGFontElement& fontElement = downcast<SVGFontElement>(*m_svgFontFaceElement->parentNode());
50
51
    if (auto otfFont = convertSVGToOTFFont(fontElement)) {
52
        RefPtr<SharedBuffer> buffer = SharedBuffer::adoptVector(otfFont.value());
53
        bufferProvided(*buffer);
54
        return;
55
    }
56
57
    setState(State::Failed);
58
}
59
60
}
- a/Source/WebCore/css/InDocumentSVGFontFaceSource.h +49 lines
Line 0 a/Source/WebCore/css/InDocumentSVGFontFaceSource.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef InDocumentSVGFontFaceSource_h
27
#define InDocumentSVGFontFaceSource_h
28
29
#include "ByteBasedFontFaceSource.h"
30
31
namespace WebCore {
32
33
class SVGFontFaceElement;
34
35
class InDocumentSVGFontFaceSource final : public ByteBasedFontFaceSource {
36
public:
37
    InDocumentSVGFontFaceSource(CSSFontFace& owner, SVGFontFaceElement&, const AtomicString& remoteURI);
38
39
private:
40
    virtual void initiateLoad() override;
41
42
    Ref<SVGFontFaceElement> m_svgFontFaceElement;
43
};
44
45
}
46
47
#endif
48
49
- a/Source/WebCore/css/LocalFontFaceSource.cpp +54 lines
Line 0 a/Source/WebCore/css/LocalFontFaceSource.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "LocalFontFaceSource.h"
28
29
#include "FontCache.h"
30
31
namespace WebCore {
32
33
LocalFontFaceSource::LocalFontFaceSource(CSSFontFace& owner, const String& familyName)
34
    : FontFaceSource(owner)
35
    , m_familyName(familyName)
36
{
37
}
38
39
void LocalFontFaceSource::initiateLoad()
40
{
41
    setState(State::Succeeded);
42
}
43
44
RefPtr<Font> LocalFontFaceSource::createFont(const FontDescription& fontDescription, bool, bool, const FontFeatureSettings&, const FontVariantSettings&)
45
{
46
    // The @font-face block's bold/italic style may disagree with our own knowledge of the real traits of a preinstalled font.
47
    // In this situation, we should consider the real traits of the preinstalled font when determining if we should apply synthetic bold/italic.
48
    // Luckily, FontCache automatically does this for us, so we simply disregard the @font-face block's bold/italic style.
49
50
    // FIXME: This local font face needs to apply the @font-face's font feature properties.
51
    return FontCache::singleton().fontForFamily(fontDescription, m_familyName, true);
52
}
53
54
}
- a/Source/WebCore/css/LocalFontFaceSource.h +52 lines
Line 0 a/Source/WebCore/css/LocalFontFaceSource.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef LocalFontFaceSource_h
27
#define LocalFontFaceSource_h
28
29
#include "FontFaceSource.h"
30
31
namespace WebCore {
32
33
// This class represents an entry of "src: local(xyz)" in an @font-face block.
34
class LocalFontFaceSource final : public FontFaceSource {
35
public:
36
    LocalFontFaceSource(CSSFontFace& owner, const String& familyName);
37
38
private:
39
    // We internally use FontCache, which is sensitive to more pieces of the FontDescription than our cache is sensitive to, so the FontFaceSource's cache would yield false hits.
40
    // Luckily, FontCache internally caches fonts, so we are still on a fast path.
41
    virtual bool shouldCache() const override { return false; }
42
43
    virtual void initiateLoad() override;
44
45
    virtual RefPtr<Font> createFont(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatureSettings, const FontVariantSettings& fontFaceVariantSettings) override;
46
47
    String m_familyName;
48
};
49
50
}
51
52
#endif
- a/Source/WebCore/css/UncachedRemoteFontFaceSource.cpp +95 lines
Line 0 a/Source/WebCore/css/UncachedRemoteFontFaceSource.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "UncachedRemoteFontFaceSource.h"
28
29
#include "CSSFontFace.h"
30
#include "Event.h"
31
32
namespace WebCore {
33
34
UncachedRemoteFontFaceSource::Listener::Listener(WeakPtr<UncachedRemoteFontFaceSource>&& owner)
35
    : EventListener(EventListener::CPPEventListenerType)
36
    , m_owner(WTFMove(owner))
37
{
38
}
39
40
void UncachedRemoteFontFaceSource::Listener::handleEvent(ScriptExecutionContext*, Event* event)
41
{
42
    if (!m_owner)
43
        return;
44
45
    m_owner->loadFinished(event && event->type() == eventNames().successEvent);
46
}
47
48
bool UncachedRemoteFontFaceSource::Listener::operator==(const EventListener& other)
49
{
50
    return this == &other;
51
}
52
53
UncachedRemoteFontFaceSource::UncachedRemoteFontFaceSource(CSSFontFace& owner, ScriptExecutionContext& scriptExecutionContext, const URL& url)
54
    : ByteBasedFontFaceSource(owner, url.string())
55
    , m_factory(this)
56
    , m_xmlHttpRequest(XMLHttpRequest::create(scriptExecutionContext))
57
    , m_listener(Listener::create(m_factory.createWeakPtr()))
58
    , m_url(url)
59
{
60
    m_xmlHttpRequest->addEventListener(eventNames().successEvent, m_listener.copyRef(), false);
61
    m_xmlHttpRequest->addEventListener(eventNames().errorEvent, m_listener.copyRef(), false);
62
    m_xmlHttpRequest->addEventListener(eventNames().abortEvent, m_listener.copyRef(), false);
63
}
64
65
void UncachedRemoteFontFaceSource::initiateLoad()
66
{
67
    ExceptionCode ec = 0;
68
    m_xmlHttpRequest->open(String("GET", String::ConstructFromLiteral), m_url, ec);
69
    if (ec) {
70
        setState(State::Failed);
71
        return;
72
    }
73
    m_xmlHttpRequest->setResponseType(String("arraybuffer", String::ConstructFromLiteral), ec);
74
    if (ec) {
75
        setState(State::Failed);
76
        return;
77
    }
78
    m_xmlHttpRequest->send(ec);
79
    if (ec) {
80
        setState(State::Failed);
81
        return;
82
    }
83
}
84
85
void UncachedRemoteFontFaceSource::loadFinished(bool success)
86
{
87
    if (!success || !m_xmlHttpRequest->responseArrayBuffer()) {
88
        setState(State::Failed);
89
        return;
90
    }
91
92
    bufferProvided(*m_xmlHttpRequest->responseArrayBuffer());
93
}
94
95
}
- a/Source/WebCore/css/UncachedRemoteFontFaceSource.h +72 lines
Line 0 a/Source/WebCore/css/UncachedRemoteFontFaceSource.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef UncachedRemoteFontFaceSource_h
27
#define UncachedRemoteFontFaceSource_h
28
29
#include "ByteBasedFontFaceSource.h"
30
#include "EventListener.h"
31
#include "XMLHttpRequest.h"
32
#include <wtf/WeakPtr.h>
33
34
namespace WebCore {
35
36
class scriptExecutionContext;
37
class URL;
38
39
class UncachedRemoteFontFaceSource final : public ByteBasedFontFaceSource {
40
public:
41
    UncachedRemoteFontFaceSource(CSSFontFace& owner, ScriptExecutionContext&, const URL&);
42
43
private:
44
    // This is a separate class becasue it needs to be RefCounted, but we don't want our FontFaceSources to be RefCounted.
45
    class Listener : public EventListener {
46
    public:
47
        static Ref<Listener> create(WeakPtr<UncachedRemoteFontFaceSource>&& owner) { return adoptRef(*new Listener(WTFMove(owner))); }
48
        bool success() const { return m_success; }
49
50
    private:
51
        Listener(WeakPtr<UncachedRemoteFontFaceSource>&& owner);
52
53
        virtual void handleEvent(ScriptExecutionContext*, Event*) override;
54
        virtual bool operator==(const EventListener& other) override;
55
56
        WeakPtr<UncachedRemoteFontFaceSource> m_owner;
57
        bool m_success { false };
58
    };
59
60
    virtual void initiateLoad() override;
61
62
    void loadFinished(bool success);
63
64
    WeakPtrFactory<UncachedRemoteFontFaceSource> m_factory;
65
    Ref<XMLHttpRequest> m_xmlHttpRequest;
66
    Ref<Listener> m_listener;
67
    URL m_url;
68
};
69
70
}
71
72
#endif
- a/Source/WebCore/loader/cache/CachedFont.cpp -4 / +4 lines
Lines 73-79 void CachedFont::didAddClient(CachedResourceClient* c) a/Source/WebCore/loader/cache/CachedFont.cpp_sec1
73
{
73
{
74
    ASSERT(c->resourceClientType() == CachedFontClient::expectedType());
74
    ASSERT(c->resourceClientType() == CachedFontClient::expectedType());
75
    if (!isLoading())
75
    if (!isLoading())
76
        static_cast<CachedFontClient*>(c)->fontLoaded(this);
76
        static_cast<CachedFontClient*>(c)->fontLoaded(*this);
77
}
77
}
78
78
79
void CachedFont::finishLoading(SharedBuffer* data)
79
void CachedFont::finishLoading(SharedBuffer* data)
Lines 92-98 void CachedFont::beginLoadIfNeeded(CachedResourceLoader& loader) a/Source/WebCore/loader/cache/CachedFont.cpp_sec2
92
    }
92
    }
93
}
93
}
94
94
95
bool CachedFont::ensureCustomFontData(bool, const AtomicString&)
95
bool CachedFont::ensureCustomFontData(const AtomicString&)
96
{
96
{
97
    return ensureCustomFontData(m_data.get());
97
    return ensureCustomFontData(m_data.get());
98
}
98
}
Lines 121-127 bool CachedFont::ensureCustomFontData(SharedBuffer* data) a/Source/WebCore/loader/cache/CachedFont.cpp_sec3
121
    return m_fontCustomPlatformData.get();
121
    return m_fontCustomPlatformData.get();
122
}
122
}
123
123
124
RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, bool, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
124
RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
125
{
125
{
126
    return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings), true, false);
126
    return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings), true, false);
127
}
127
}
Lines 150-156 void CachedFont::checkNotify() a/Source/WebCore/loader/cache/CachedFont.cpp_sec4
150
    
150
    
151
    CachedResourceClientWalker<CachedFontClient> w(m_clients);
151
    CachedResourceClientWalker<CachedFontClient> w(m_clients);
152
    while (CachedFontClient* c = w.next())
152
    while (CachedFontClient* c = w.next())
153
         c->fontLoaded(this);
153
        c->fontLoaded(*this);
154
}
154
}
155
155
156
bool CachedFont::mayTryReplaceEncodedData() const
156
bool CachedFont::mayTryReplaceEncodedData() const
- a/Source/WebCore/loader/cache/CachedFont.h -2 / +4 lines
Lines 49-57 public: a/Source/WebCore/loader/cache/CachedFont.h_sec1
49
    void beginLoadIfNeeded(CachedResourceLoader&);
49
    void beginLoadIfNeeded(CachedResourceLoader&);
50
    virtual bool stillNeedsLoad() const override { return !m_loadInitiated; }
50
    virtual bool stillNeedsLoad() const override { return !m_loadInitiated; }
51
51
52
    virtual bool ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI);
52
    void setHasCreatedFontDataWrappingResource(bool hasCreatedFontDataWrappingResource) { hasCreatedFontDataWrappingResource = m_hasCreatedFontDataWrappingResource; }
53
53
54
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG, const FontFeatureSettings&, const FontVariantSettings&);
54
    virtual bool ensureCustomFontData(const AtomicString& remoteURI);
55
56
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, const FontVariantSettings&);
55
57
56
protected:
58
protected:
57
    FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&);
59
    FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&);
- a/Source/WebCore/loader/cache/CachedFontClient.h -1 / +1 lines
Lines 37-43 public: a/Source/WebCore/loader/cache/CachedFontClient.h_sec1
37
    virtual ~CachedFontClient() { }
37
    virtual ~CachedFontClient() { }
38
    static CachedResourceClientType expectedType() { return FontType; }
38
    static CachedResourceClientType expectedType() { return FontType; }
39
    virtual CachedResourceClientType resourceClientType() const override { return expectedType(); }
39
    virtual CachedResourceClientType resourceClientType() const override { return expectedType(); }
40
    virtual void fontLoaded(CachedFont*) { }
40
    virtual void fontLoaded(CachedFont&) { }
41
};
41
};
42
42
43
} // namespace WebCore
43
} // namespace WebCore
- a/Source/WebCore/loader/cache/CachedSVGFont.cpp -15 / +10 lines
Lines 51-65 CachedSVGFont::CachedSVGFont(const ResourceRequest& resourceRequest, SessionID s a/Source/WebCore/loader/cache/CachedSVGFont.cpp_sec1
51
{
51
{
52
}
52
}
53
53
54
RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
54
RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
55
{
55
{
56
#if ENABLE(SVG_OTF_CONVERTER)
56
#if ENABLE(SVG_OTF_CONVERTER)
57
    if (!externalSVG || firstFontFace(remoteURI))
57
    if (firstFontFace(remoteURI))
58
        return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, externalSVG, fontFaceFeatures, fontFaceVariantSettings);
58
        return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings);
59
#else
59
#else
60
    if (!externalSVG)
60
    UNUSED_PARAM(fontFaceFeatures);
61
        return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, externalSVG, fontFaceFeatures, fontFaceVariantSettings);
61
    UNUSED_PARAM(fontFaceVariantSettings);
62
63
    if (SVGFontFaceElement* firstFontFace = this->firstFontFace(remoteURI))
62
    if (SVGFontFaceElement* firstFontFace = this->firstFontFace(remoteURI))
64
        return Font::create(std::make_unique<SVGFontData>(firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
63
        return Font::create(std::make_unique<SVGFontData>(firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
65
#endif
64
#endif
Lines 73-94 FontPlatformData CachedSVGFont::platformDataFromCustomData(const FontDescription a/Source/WebCore/loader/cache/CachedSVGFont.cpp_sec2
73
    return CachedFont::platformDataFromCustomData(fontDescription, bold, italic, fontFaceFeatures, fontFaceVariantSettings);
72
    return CachedFont::platformDataFromCustomData(fontDescription, bold, italic, fontFaceFeatures, fontFaceVariantSettings);
74
}
73
}
75
74
76
bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI)
75
bool CachedSVGFont::ensureCustomFontData(const AtomicString& remoteURI)
77
{
76
{
78
    if (!externalSVG)
79
        return CachedFont::ensureCustomFontData(externalSVG, remoteURI);
80
81
    if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) {
77
    if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) {
82
        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
78
        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
83
        RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
79
        RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
84
        m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
80
        m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
85
#if !ENABLE(SVG_OTF_CONVERTER)
86
        if (decoder->sawError())
87
            m_externalSVGDocument = nullptr;
88
#else
89
        if (decoder->sawError())
81
        if (decoder->sawError())
90
            m_externalSVGDocument = nullptr;
82
            m_externalSVGDocument = nullptr;
91
        else
83
#if ENABLE(SVG_OTF_CONVERTER)
84
        if (m_externalSVGDocument)
92
            maybeInitializeExternalSVGFontElement(remoteURI);
85
            maybeInitializeExternalSVGFontElement(remoteURI);
93
        if (!m_externalSVGFontElement)
86
        if (!m_externalSVGFontElement)
94
            return false;
87
            return false;
Lines 98-103 bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& r a/Source/WebCore/loader/cache/CachedSVGFont.cpp_sec3
98
            m_externalSVGDocument = nullptr;
91
            m_externalSVGDocument = nullptr;
99
            return false;
92
            return false;
100
        }
93
        }
94
#else
95
        UNUSED_PARAM(remoteURI);
101
#endif
96
#endif
102
    }
97
    }
103
98
- a/Source/WebCore/loader/cache/CachedSVGFont.h -2 / +2 lines
Lines 38-46 class CachedSVGFont final : public CachedFont { a/Source/WebCore/loader/cache/CachedSVGFont.h_sec1
38
public:
38
public:
39
    CachedSVGFont(const ResourceRequest&, SessionID);
39
    CachedSVGFont(const ResourceRequest&, SessionID);
40
40
41
    virtual bool ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI) override;
41
    virtual bool ensureCustomFontData(const AtomicString& remoteURI) override;
42
    
42
    
43
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG, const FontFeatureSettings&, const FontVariantSettings&) override;
43
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, const FontVariantSettings&) override;
44
44
45
private:
45
private:
46
    FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&);
46
    FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&);
- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp +1 lines
Lines 36-41 FontCustomPlatformData::~FontCustomPlatformData() a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp_sec1
36
36
37
FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
37
FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
38
{
38
{
39
    // This function must be consistent with FontFaceSource::HashKey.
39
    int size = fontDescription.computedPixelSize();
40
    int size = fontDescription.computedPixelSize();
40
    FontOrientation orientation = fontDescription.orientation();
41
    FontOrientation orientation = fontDescription.orientation();
41
    FontWidthVariant widthVariant = fontDescription.widthVariant();
42
    FontWidthVariant widthVariant = fontDescription.widthVariant();
- a/Source/WebCore/platform/network/HTTPParsers.cpp -2 / +2 lines
Lines 125-132 bool isValidHTTPToken(const String& value) a/Source/WebCore/platform/network/HTTPParsers.cpp_sec1
125
{
125
{
126
    if (value.isEmpty())
126
    if (value.isEmpty())
127
        return false;
127
        return false;
128
    for (unsigned i = 0; i < value.length(); ++i) {
128
    auto valueStringView = StringView(value);
129
        UChar c = value[i];
129
    for (UChar c : valueStringView.codeUnits()) {
130
        if (c <= 0x20 || c >= 0x7F
130
        if (c <= 0x20 || c >= 0x7F
131
            || c == '(' || c == ')' || c == '<' || c == '>' || c == '@'
131
            || c == '(' || c == ')' || c == '<' || c == '>' || c == '@'
132
            || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"'
132
            || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"'
- a/Source/WebCore/platform/text/TextFlags.h -1 / +24 lines
Lines 26-31 a/Source/WebCore/platform/text/TextFlags.h_sec1
26
#ifndef TextFlags_h
26
#ifndef TextFlags_h
27
#define TextFlags_h
27
#define TextFlags_h
28
28
29
#include <wtf/Hasher.h>
30
29
namespace WebCore {
31
namespace WebCore {
30
32
31
enum TextRenderingMode { AutoTextRendering, OptimizeSpeed, OptimizeLegibility, GeometricPrecision };
33
enum TextRenderingMode { AutoTextRendering, OptimizeSpeed, OptimizeLegibility, GeometricPrecision };
Lines 212-218 struct FontVariantSettings { a/Source/WebCore/platform/text/TextFlags.h_sec2
212
            && eastAsianRuby == FontVariantEastAsianRuby::Normal;
214
            && eastAsianRuby == FontVariantEastAsianRuby::Normal;
213
    }
215
    }
214
216
215
    bool operator==(const FontVariantSettings& other)
217
    bool operator==(const FontVariantSettings& other) const
216
    {
218
    {
217
        return commonLigatures == other.commonLigatures
219
        return commonLigatures == other.commonLigatures
218
            && discretionaryLigatures == other.discretionaryLigatures
220
            && discretionaryLigatures == other.discretionaryLigatures
Lines 231-236 struct FontVariantSettings { a/Source/WebCore/platform/text/TextFlags.h_sec3
231
            && eastAsianRuby == other.eastAsianRuby;
233
            && eastAsianRuby == other.eastAsianRuby;
232
    }
234
    }
233
235
236
    unsigned hash() const
237
    {
238
        IntegerHasher hasher;
239
        hasher.add(static_cast<unsigned>(commonLigatures));
240
        hasher.add(static_cast<unsigned>(discretionaryLigatures));
241
        hasher.add(static_cast<unsigned>(historicalLigatures));
242
        hasher.add(static_cast<unsigned>(contextualAlternates));
243
        hasher.add(static_cast<unsigned>(position));
244
        hasher.add(static_cast<unsigned>(caps));
245
        hasher.add(static_cast<unsigned>(numericFigure));
246
        hasher.add(static_cast<unsigned>(numericSpacing));
247
        hasher.add(static_cast<unsigned>(numericFraction));
248
        hasher.add(static_cast<unsigned>(commonLigatures));
249
        hasher.add(static_cast<unsigned>(numericSlashedZero));
250
        hasher.add(static_cast<unsigned>(alternates));
251
        hasher.add(static_cast<unsigned>(eastAsianVariant));
252
        hasher.add(static_cast<unsigned>(eastAsianWidth));
253
        hasher.add(static_cast<unsigned>(eastAsianRuby));
254
        return hasher.hash();
255
    }
256
234
    FontVariantLigatures commonLigatures;
257
    FontVariantLigatures commonLigatures;
235
    FontVariantLigatures discretionaryLigatures;
258
    FontVariantLigatures discretionaryLigatures;
236
    FontVariantLigatures historicalLigatures;
259
    FontVariantLigatures historicalLigatures;

Return to Bug 153414