Diff
Modified: trunk/Source/WebCore/ChangeLog (211802 => 211803)
--- trunk/Source/WebCore/ChangeLog 2017-02-07 10:53:54 UTC (rev 211802)
+++ trunk/Source/WebCore/ChangeLog 2017-02-07 13:09:06 UTC (rev 211803)
@@ -1,3 +1,20 @@
+2017-02-06 Per Arne Vollan <pvol...@apple.com>
+
+ Read stroke width of subtitles from MediaAccessibility framework.
+ https://bugs.webkit.org/show_bug.cgi?id=167871
+ <rdar://problem/29265906>
+
+ Reviewed by Brent Fulgham.
+
+ Read MACaptionFontAttributeStrokeWidth from CTFontDescriptorRef.
+
+ * page/CaptionUserPreferencesMediaAF.cpp:
+ (WebCore::CaptionUserPreferencesMediaAF::strokeWidth):
+ (WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS):
+ * page/CaptionUserPreferencesMediaAF.h:
+ * platform/cf/MediaAccessibilitySoftLink.cpp:
+ * platform/cf/MediaAccessibilitySoftLink.h:
+
2017-02-07 Antoine Quint <grao...@apple.com>
[Modern Media Controls] Improve handling of <video> with only audio tracks
Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (211802 => 211803)
--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp 2017-02-07 10:53:54 UTC (rev 211802)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp 2017-02-07 13:09:06 UTC (rev 211803)
@@ -386,12 +386,35 @@
return builder.toString();
}
+String CaptionUserPreferencesMediaAF::strokeWidth() const
+{
+ static NeverDestroyed<const String> strokeWidthDefault(ASCIILiteral(" .03em "));
+
+ if (!MACaptionFontAttributeStrokeWidth && !canLoad_MediaAccessibility_MACaptionFontAttributeStrokeWidth())
+ return strokeWidthDefault;
+
+ MACaptionAppearanceBehavior behavior;
+
+ auto font = adoptCF(MACaptionAppearanceCopyFontDescriptorForStyle(kMACaptionAppearanceDomainUser, &behavior, kMACaptionAppearanceFontStyleDefault));
+ if (!font)
+ return strokeWidthDefault;
+
+ auto strokeWidthAttribute = adoptCF(CTFontDescriptorCopyAttribute(font.get(), MACaptionFontAttributeStrokeWidth));
+ if (!strokeWidthAttribute)
+ return strokeWidthDefault;
+
+ int strokeWidth = 0;
+ if (!CFNumberGetValue(static_cast<CFNumberRef>(strokeWidthAttribute.get()), kCFNumberIntType, &strokeWidth))
+ return strokeWidthDefault;
+
+ return String::format(" %dpx ", strokeWidth);
+}
+
String CaptionUserPreferencesMediaAF::captionsTextEdgeCSS() const
{
static NeverDestroyed<const String> edgeStyleRaised(ASCIILiteral(" -.05em -.05em 0 "));
static NeverDestroyed<const String> edgeStyleDepressed(ASCIILiteral(" .05em .05em 0 "));
static NeverDestroyed<const String> edgeStyleDropShadow(ASCIILiteral(" .075em .075em 0 "));
- static NeverDestroyed<const String> edgeStyleUniform(ASCIILiteral(" .03em "));
bool unused;
Color color = captionsTextColor(unused);
@@ -413,8 +436,8 @@
case kMACaptionAppearanceTextEdgeStyleDropShadow:
return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color, behavior == kMACaptionAppearanceBehaviorUseValue);
case kMACaptionAppearanceTextEdgeStyleUniform:
- return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color, behavior == kMACaptionAppearanceBehaviorUseValue);
-
+ return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, strokeWidth(), color, behavior == kMACaptionAppearanceBehaviorUseValue);
+
default:
ASSERT_NOT_REACHED();
break;
Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h (211802 => 211803)
--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h 2017-02-07 10:53:54 UTC (rev 211802)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h 2017-02-07 13:09:06 UTC (rev 211803)
@@ -81,6 +81,7 @@
String captionsDefaultFontCSS() const;
Color captionsEdgeColorForTextColor(const Color&) const;
String windowRoundedCornerRadiusCSS() const;
+ String strokeWidth() const;
String captionsTextEdgeCSS() const;
String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&, bool) const;
String colorPropertyCSS(CSSPropertyID, const Color&, bool) const;
Modified: trunk/Source/WebCore/platform/cf/MediaAccessibilitySoftLink.cpp (211802 => 211803)
--- trunk/Source/WebCore/platform/cf/MediaAccessibilitySoftLink.cpp 2017-02-07 10:53:54 UTC (rev 211802)
+++ trunk/Source/WebCore/platform/cf/MediaAccessibilitySoftLink.cpp 2017-02-07 13:09:06 UTC (rev 211803)
@@ -56,5 +56,6 @@
SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaAccessibility, kMAXCaptionAppearanceSettingsChangedNotification, CFStringRef)
SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, MediaAccessibility, kMAAudibleMediaSettingsChangedNotification, CFStringRef)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, MediaAccessibility, MACaptionFontAttributeStrokeWidth, CFStringRef)
#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
Modified: trunk/Source/WebCore/platform/cf/MediaAccessibilitySoftLink.h (211802 => 211803)
--- trunk/Source/WebCore/platform/cf/MediaAccessibilitySoftLink.h 2017-02-07 10:53:54 UTC (rev 211802)
+++ trunk/Source/WebCore/platform/cf/MediaAccessibilitySoftLink.h 2017-02-07 13:09:06 UTC (rev 211803)
@@ -70,6 +70,8 @@
#define kMAXCaptionAppearanceSettingsChangedNotification get_MediaAccessibility_kMAXCaptionAppearanceSettingsChangedNotification()
SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, MediaAccessibility, kMAAudibleMediaSettingsChangedNotification, CFStringRef)
#define kMAAudibleMediaSettingsChangedNotification get_MediaAccessibility_kMAAudibleMediaSettingsChangedNotification()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, MediaAccessibility, MACaptionFontAttributeStrokeWidth, CFStringRef)
+#define MACaptionFontAttributeStrokeWidth get_MediaAccessibility_MACaptionFontAttributeStrokeWidth()
#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)