Title: [215461] trunk/Source/WebCore
Revision
215461
Author
[email protected]
Date
2017-04-18 09:15:32 -0700 (Tue, 18 Apr 2017)

Log Message

Add fallback fonts to video captions stylesheet.
https://bugs.webkit.org/show_bug.cgi?id=170495

Reviewed by Eric Carlson.

The kCTFontCascadeListAttribute key is used to obtain the cascade list for a font reference.

I have not added a test, since CaptionUserPreferences::testingMode() returns true when running tests,
preventing this code path from being executed.

* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):
* platform/spi/win/CoreTextSPIWin.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (215460 => 215461)


--- trunk/Source/WebCore/ChangeLog	2017-04-18 15:39:47 UTC (rev 215460)
+++ trunk/Source/WebCore/ChangeLog	2017-04-18 16:15:32 UTC (rev 215461)
@@ -1,3 +1,19 @@
+2017-04-18  Per Arne Vollan  <[email protected]>
+
+        Add fallback fonts to video captions stylesheet.
+        https://bugs.webkit.org/show_bug.cgi?id=170495
+
+        Reviewed by Eric Carlson.
+
+        The kCTFontCascadeListAttribute key is used to obtain the cascade list for a font reference.
+
+        I have not added a test, since CaptionUserPreferences::testingMode() returns true when running tests,
+        preventing this code path from being executed.
+
+        * page/CaptionUserPreferencesMediaAF.cpp:
+        (WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):
+        * platform/spi/win/CoreTextSPIWin.h:
+
 2017-04-18  Miguel Gomez  <[email protected]>
 
         [GTK+] Crash in WebCore::ImageFrame::ImageFrame()

Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (215460 => 215461)


--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2017-04-18 15:39:47 UTC (rev 215460)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2017-04-18 16:15:32 UTC (rev 215461)
@@ -32,6 +32,9 @@
 #include "CaptionUserPreferencesMediaAF.h"
 
 #include "AudioTrackList.h"
+#if PLATFORM(WIN)
+#include "CoreTextSPIWin.h"
+#endif
 #include "FloatConversion.h"
 #include "HTMLMediaElement.h"
 #include "URL.h"
@@ -78,14 +81,6 @@
 #define SOFT_LINK_AVF_FRAMEWORK_IMPORT(Lib, Fun, ReturnType, Arguments, Signature) SOFT_LINK_DLL_IMPORT(Lib, Fun, ReturnType, __cdecl, Arguments, Signature)
 #define SOFT_LINK_AVF_FRAMEWORK_IMPORT_OPTIONAL(Lib, Fun, ReturnType, Arguments) SOFT_LINK_DLL_IMPORT_OPTIONAL(Lib, Fun, ReturnType, __cdecl, Arguments)
 
-// CoreText only needs to be soft-linked on Windows.
-SOFT_LINK_AVF_FRAMEWORK(CoreText)
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(CoreText, CTFontDescriptorCopyAttribute,  CFTypeRef, (CTFontDescriptorRef descriptor, CFStringRef attribute), (descriptor, attribute));
-SOFT_LINK_AVF_POINTER(CoreText, kCTFontNameAttribute, CFStringRef)
-#define kCTFontNameAttribute getkCTFontNameAttribute()
-
-#define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute
-
 SOFT_LINK_AVF_FRAMEWORK(CoreMedia)
 SOFT_LINK_AVF_FRAMEWORK_IMPORT_OPTIONAL(CoreMedia, MTEnableCaption2015Behavior, Boolean, ())
 
@@ -424,7 +419,7 @@
     RetainPtr<CFTypeRef> name = adoptCF(CTFontDescriptorCopyAttribute(font.get(), kCTFontNameAttribute));
     if (!name)
         return emptyString();
-    
+
     StringBuilder builder;
     
     builder.append(getPropertyNameString(CSSPropertyFontFamily));
@@ -431,6 +426,23 @@
     builder.appendLiteral(": \"");
     builder.append(static_cast<CFStringRef>(name.get()));
     builder.append('"');
+
+    auto cascadeList = adoptCF(static_cast<CFArrayRef>(CTFontDescriptorCopyAttribute(font.get(), kCTFontCascadeListAttribute)));
+
+    if (cascadeList) {
+        for (CFIndex i = 0; i < CFArrayGetCount(cascadeList.get()); i++) {
+            auto fontCascade = static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(cascadeList.get(), i));
+            if (!fontCascade)
+                continue;
+            auto fontCascadeName = adoptCF(CTFontDescriptorCopyAttribute(fontCascade, kCTFontNameAttribute));
+            if (!fontCascadeName)
+                continue;
+            builder.append(", \"");
+            builder.append(static_cast<CFStringRef>(fontCascadeName.get()));
+            builder.append('"');
+        }
+    }
+    
     if (behavior == kMACaptionAppearanceBehaviorUseValue)
         builder.appendLiteral(" !important");
     builder.append(';');

Modified: trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h (215460 => 215461)


--- trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h	2017-04-18 15:39:47 UTC (rev 215460)
+++ trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h	2017-04-18 16:15:32 UTC (rev 215461)
@@ -37,6 +37,8 @@
 typedef FourCharCode CTFontTableTag;
 
 CT_EXPORT const CFStringRef kCTFontAttributeName;
+CT_EXPORT const CFStringRef kCTFontCascadeListAttribute;
+CT_EXPORT const CFStringRef kCTFontNameAttribute;
 CT_EXPORT const CFStringRef kCTForegroundColorFromContextAttributeName;
 CT_EXPORT const CFStringRef kCTStrokeWidthAttributeName;
 CT_EXPORT const CFStringRef kCTStrokeColorAttributeName;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to