Changeset 141790 in webkit
- Timestamp:
- Feb 4, 2013, 11:39:31 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r141789 r141790 1 2013-02-04 Eric Carlson <eric.carlson@apple.com> 2 3 Update CaptionUserPreferences 4 https://bugs.webkit.org/show_bug.cgi?id=108783 5 6 Reviewed by Dean Jackson. 7 8 * html/shadow/MediaControlElements.cpp: 9 (WebCore::MediaControlTextTrackContainerElement::updateSizes): Mark font size as important 10 when necessary. 11 * page/CaptionUserPreferences.h: 12 (WebCore::CaptionUserPreferences::setUserPrefersCaptions): New, allow a port to remember that 13 the user has chosen to see captions. 14 (WebCore::CaptionUserPreferences::setPreferredLanguage): New, allow a port to remember the 15 user's preferred caption language. 16 (WebCore::CaptionUserPreferences::preferredLanguages): New, return a Vector of the user's 17 preferred caption languages. 18 * page/CaptionUserPreferencesMac.h: 19 * page/CaptionUserPreferencesMac.mm: 20 * page/PageGroup.cpp: 21 (WebCore::PageGroup::captionPreferences): 22 (WebCore::PageGroup::captionFontSizeScale): 23 * page/PageGroup.h: 24 * platform/Language.cpp: 25 (WebCore::userPreferredLanguagesOverride): New, return the user preferred languages override 26 used during testing. 27 * platform/Language.h: 28 * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm: 29 (WebCore::InbandTextTrackPrivateAVFObjC::kind): 30 1 31 2013-02-04 Tim Horton <timothy_horton@apple.com> 2 32 -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r141066 r141790 1364 1364 float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width()); 1365 1365 1366 float fontSize = smallestDimension * (document()->page()->group().captionFontSizeScale()); 1366 bool important; 1367 float fontSize = smallestDimension * (document()->page()->group().captionFontSizeScale(important)); 1367 1368 if (fontSize != m_fontSize) { 1368 1369 m_fontSize = fontSize; 1369 setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px" );1370 setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px", important); 1370 1371 } 1371 1372 } -
trunk/Source/WebCore/page/CaptionUserPreferences.h
r132349 r141790 29 29 #if ENABLE(VIDEO_TRACK) 30 30 31 #include "Language.h" 31 32 #include <wtf/PassOwnPtr.h> 32 33 #include <wtf/text/AtomicString.h> … … 49 50 50 51 virtual bool userPrefersCaptions() const { return false; } 52 virtual void setUserPrefersCaptions(bool) { } 51 53 virtual bool userHasCaptionPreferences() const { return false; } 52 virtual float captionFontSizeScale( ) const {return 0.05f; }54 virtual float captionFontSizeScale(bool& important) const { important = false; return 0.05f; } 53 55 virtual String captionsStyleSheetOverride() const { return emptyString(); } 54 56 virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { } 55 57 virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { } 58 59 virtual void setPreferredLanguage(String) const { } 60 virtual Vector<String> preferredLanguages() const { return platformUserPreferredLanguages(); } 56 61 57 62 PageGroup* pageGroup() { return m_pageGroup; } -
trunk/Source/WebCore/page/CaptionUserPreferencesMac.h
r132349 r141790 27 27 #define CaptionUserPreferencesMac_h 28 28 29 #if ENABLE(VIDEO_TRACK) 29 #if ENABLE(VIDEO_TRACK) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 30 30 31 31 #include "CSSPropertyNames.h" … … 42 42 43 43 virtual bool userPrefersCaptions() const OVERRIDE; 44 virtual bool userHasCaptionPreferences() const OVERRIDE; 45 virtual float captionFontSizeScale() const OVERRIDE; 44 virtual void setUserPrefersCaptions(bool) OVERRIDE; 45 virtual bool userHasCaptionPreferences() const OVERRIDE { return true; } 46 virtual float captionFontSizeScale(bool&) const OVERRIDE; 46 47 virtual String captionsStyleSheetOverride() const OVERRIDE; 47 48 virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE; 48 49 virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE; 50 51 virtual void setPreferredLanguage(String) const OVERRIDE; 52 virtual Vector<String> preferredLanguages() const OVERRIDE; 49 53 50 54 void captionPreferencesChanged(); … … 53 57 CaptionUserPreferencesMac(PageGroup*); 54 58 55 Color captionsWindowColor() const; 56 Color captionsBackgroundColor() const; 57 Color captionsTextColor() const; 58 String captionsDefaultFont() const; 59 String captionsWindowCSS() const; 60 String captionsBackgroundCSS() const; 61 String captionsTextColorCSS() const; 62 Color captionsTextColor(bool&) const; 63 String captionsDefaultFontCSS() const; 59 64 Color captionsEdgeColorForTextColor(const Color&) const; 60 String captionsTextEdgeStyle() const; 61 String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&) const; 62 String cssColorProperty(CSSPropertyID, const Color&) const; 65 String windowRoundedCornerRadiusCSS() const; 66 String captionsTextEdgeCSS() const; 67 String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&, bool) const; 68 String colorPropertyCSS(CSSPropertyID, const Color&, bool) const; 63 69 64 70 void updateCaptionStyleSheetOveride(); -
trunk/Source/WebCore/page/CaptionUserPreferencesMac.mm
r138784 r141790 26 26 #import "config.h" 27 27 28 #if ENABLE(VIDEO_TRACK) 28 #if ENABLE(VIDEO_TRACK) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 29 29 30 30 #import "CaptionUserPreferencesMac.h" 31 31 32 32 #import "ColorMac.h" 33 #import "CoreText/CoreText.h" 33 34 #import "DOMWrapperWorld.h" 34 35 #import "FloatConversion.h" 35 36 #import "KURL.h" 37 #import "MediaAccessibility/MediaAccessibility.h" 36 38 #import "PageGroup.h" 39 #import "SoftLinking.h" 37 40 #import "TextTrackCue.h" 38 41 #import "UserStyleSheetTypes.h" 39 #import "WebCoreSystemInterface.h"40 42 #import <wtf/RetainPtr.h> 41 43 #import <wtf/text/StringBuilder.h> 42 44 45 SOFT_LINK_FRAMEWORK_OPTIONAL(MediaAccessibility) 46 47 SOFT_LINK(MediaAccessibility, MACaptionAppearanceGetShowCaptions, bool, (MACaptionAppearanceDomain domain), (domain)) 48 SOFT_LINK(MediaAccessibility, MACaptionAppearanceSetShowCaptions, void, (MACaptionAppearanceDomain domain, bool showCaptions), (domain, showCaptions)) 49 SOFT_LINK(MediaAccessibility, MACaptionAppearanceCopyForegroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 50 SOFT_LINK(MediaAccessibility, MACaptionAppearanceCopyBackgroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 51 SOFT_LINK(MediaAccessibility, MACaptionAppearanceCopyWindowColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 52 SOFT_LINK(MediaAccessibility, MACaptionAppearanceGetForegroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 53 SOFT_LINK(MediaAccessibility, MACaptionAppearanceGetBackgroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 54 SOFT_LINK(MediaAccessibility, MACaptionAppearanceGetWindowOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 55 SOFT_LINK(MediaAccessibility, MACaptionAppearanceGetWindowRoundedCornerRadius, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 56 SOFT_LINK(MediaAccessibility, MACaptionAppearanceCopyFontDescriptorForStyle, CTFontDescriptorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior, MACaptionAppearanceFontStyle fontStyle), (domain, behavior, fontStyle)) 57 SOFT_LINK(MediaAccessibility, MACaptionAppearanceGetRelativeCharacterSize, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 58 SOFT_LINK(MediaAccessibility, MACaptionAppearanceGetTextEdgeStyle, MACaptionAppearanceTextEdgeStyle, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior)) 59 SOFT_LINK(MediaAccessibility, MACaptionAppearanceAddSelectedLanguage, bool, (MACaptionAppearanceDomain domain, CFStringRef language), (domain, language)); 60 SOFT_LINK(MediaAccessibility, MACaptionAppearanceCopySelectedLanguages, CFArrayRef, (MACaptionAppearanceDomain domain), (domain)); 61 62 SOFT_LINK_POINTER(MediaAccessibility, kMAXCaptionAppearanceSettingsChangedNotification, CFStringRef) 63 #define kMAXCaptionAppearanceSettingsChangedNotification getkMAXCaptionAppearanceSettingsChangedNotification() 64 43 65 using namespace std; 44 66 … … 49 71 static_cast<CaptionUserPreferencesMac*>(observer)->captionPreferencesChanged(); 50 72 } 51 52 73 53 74 CaptionUserPreferencesMac::CaptionUserPreferencesMac(PageGroup* group) … … 59 80 CaptionUserPreferencesMac::~CaptionUserPreferencesMac() 60 81 { 61 if (wkCaptionAppearanceGetSettingsChangedNotification()) 62 CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, wkCaptionAppearanceGetSettingsChangedNotification(), NULL); 63 } 64 65 bool CaptionUserPreferencesMac::userHasCaptionPreferences() const 66 { 67 return wkCaptionAppearanceHasUserPreferences(); 82 if (kMAXCaptionAppearanceSettingsChangedNotification) 83 CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, kMAXCaptionAppearanceSettingsChangedNotification, NULL); 68 84 } 69 85 70 86 bool CaptionUserPreferencesMac::userPrefersCaptions() const 71 87 { 72 return wkCaptionAppearanceShowCaptionsWhenAvailable(); 88 return MACaptionAppearanceGetShowCaptions(kMACaptionAppearanceDomainUser); 89 } 90 91 void CaptionUserPreferencesMac::setUserPrefersCaptions(bool preference) 92 { 93 MACaptionAppearanceSetShowCaptions(kMACaptionAppearanceDomainUser, preference); 73 94 } 74 95 … … 77 98 ASSERT(!m_captionPreferenceChangeListeners.contains(listener)); 78 99 79 if (! wkCaptionAppearanceGetSettingsChangedNotification())100 if (!kMAXCaptionAppearanceSettingsChangedNotification) 80 101 return; 81 102 82 103 if (!m_listeningForPreferenceChanges) { 83 104 m_listeningForPreferenceChanges = true; 84 CFNotificationCenterAddObserver (CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, wkCaptionAppearanceGetSettingsChangedNotification(), NULL, CFNotificationSuspensionBehaviorCoalesce);105 CFNotificationCenterAddObserver (CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, NULL, CFNotificationSuspensionBehaviorCoalesce); 85 106 updateCaptionStyleSheetOveride(); 86 107 } … … 91 112 void CaptionUserPreferencesMac::unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener) 92 113 { 93 if ( wkCaptionAppearanceGetSettingsChangedNotification())114 if (kMAXCaptionAppearanceSettingsChangedNotification) 94 115 m_captionPreferenceChangeListeners.remove(listener); 95 116 } 96 117 97 Color CaptionUserPreferencesMac::captionsWindowColor() const 98 { 99 RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyWindowColor()); 118 String CaptionUserPreferencesMac::captionsWindowCSS() const 119 { 120 MACaptionAppearanceBehavior behavior; 121 RetainPtr<CGColorRef> color(AdoptCF, MACaptionAppearanceCopyWindowColor(kMACaptionAppearanceDomainUser, &behavior)); 122 100 123 Color windowColor(color.get()); 101 124 if (!windowColor.isValid()) 102 125 windowColor = Color::transparent; 103 104 CGFloat opacity; 105 if (wkCaptionAppearanceGetWindowOpacity(&opacity)) 106 return Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255)); 107 108 if (!color) 109 return Color(); 110 111 return windowColor; 112 } 113 114 Color CaptionUserPreferencesMac::captionsBackgroundColor() const 126 127 CGFloat opacity = MACaptionAppearanceGetWindowOpacity(kMACaptionAppearanceDomainUser, &behavior); 128 return colorPropertyCSS(CSSPropertyBackgroundColor, Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255)), behavior == kMACaptionAppearanceBehaviorUseValue); 129 } 130 131 String CaptionUserPreferencesMac::captionsBackgroundCSS() const 115 132 { 116 133 // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-past-nodes 117 134 // and webkit-media-text-track-future-nodes. 118 135 DEFINE_STATIC_LOCAL(Color, defaultBackgroundColor, (Color(0, 0, 0, 0.8 * 255))); 119 120 RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyBackgroundColor()); 136 137 MACaptionAppearanceBehavior behavior; 138 139 RetainPtr<CGColorRef> color(AdoptCF, MACaptionAppearanceCopyBackgroundColor(kMACaptionAppearanceDomainUser, &behavior)); 121 140 Color backgroundColor(color.get()); 122 if (!backgroundColor.isValid()) {141 if (!backgroundColor.isValid()) 123 142 backgroundColor = defaultBackgroundColor; 124 } 125 126 CGFloat opacity; 127 if (wkCaptionAppearanceGetBackgroundOpacity(&opacity)) 128 return Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255)); 129 130 if (!color) 131 return Color(); 132 133 return backgroundColor; 134 } 135 136 Color CaptionUserPreferencesMac::captionsTextColor() const 137 { 138 RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyForegroundColor()); 143 144 CGFloat opacity = MACaptionAppearanceGetBackgroundOpacity(kMACaptionAppearanceDomainUser, 0); 145 return colorPropertyCSS(CSSPropertyBackgroundColor, Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255)), behavior == kMACaptionAppearanceBehaviorUseValue); 146 } 147 148 Color CaptionUserPreferencesMac::captionsTextColor(bool& important) const 149 { 150 MACaptionAppearanceBehavior behavior; 151 RetainPtr<CGColorRef> color(AdoptCF, MACaptionAppearanceCopyForegroundColor(kMACaptionAppearanceDomainUser, &behavior)); 139 152 Color textColor(color.get()); 140 if (!textColor.isValid()) {153 if (!textColor.isValid()) 141 154 // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-container. 142 155 textColor = Color::white; 143 } 144 145 CGFloat opacity; 146 if (wkCaptionAppearanceGetForegroundOpacity(&opacity)) 147 return Color(textColor.red(), textColor.green(), textColor.blue(), static_cast<int>(opacity * 255)); 148 149 if (!color) 150 return Color(); 151 152 return textColor; 153 } 154 156 157 CGFloat opacity = MACaptionAppearanceGetForegroundOpacity(kMACaptionAppearanceDomainUser, &behavior); 158 important = behavior == kMACaptionAppearanceBehaviorUseValue; 159 return Color(textColor.red(), textColor.green(), textColor.blue(), static_cast<int>(opacity * 255)); 160 } 161 162 String CaptionUserPreferencesMac::captionsTextColorCSS() const 163 { 164 bool important; 165 Color textColor = captionsTextColor(important); 166 167 if (!textColor.isValid()) 168 return emptyString(); 169 170 return colorPropertyCSS(CSSPropertyColor, textColor, important); 171 } 172 173 String CaptionUserPreferencesMac::windowRoundedCornerRadiusCSS() const 174 { 175 MACaptionAppearanceBehavior behavior; 176 CGFloat radius = MACaptionAppearanceGetWindowRoundedCornerRadius(kMACaptionAppearanceDomainUser, &behavior); 177 if (!radius) 178 return emptyString(); 179 180 StringBuilder builder; 181 builder.append(getPropertyNameString(CSSPropertyBorderRadius)); 182 builder.append(':'); 183 builder.append(String::format("%.02f", radius)); 184 if (behavior == kMACaptionAppearanceBehaviorUseValue) 185 builder.append(" !important"); 186 builder.append(';'); 187 188 return builder.toString(); 189 } 190 155 191 Color CaptionUserPreferencesMac::captionsEdgeColorForTextColor(const Color& textColor) const 156 192 { … … 164 200 } 165 201 166 String CaptionUserPreferencesMac::cssPropertyWithTextEdgeColor(CSSPropertyID id, const String& value, const Color& textColor ) const202 String CaptionUserPreferencesMac::cssPropertyWithTextEdgeColor(CSSPropertyID id, const String& value, const Color& textColor, bool important) const 167 203 { 168 204 StringBuilder builder; … … 173 209 builder.append(' '); 174 210 builder.append(captionsEdgeColorForTextColor(textColor).serialized()); 211 if (important) 212 builder.append(" !important"); 175 213 builder.append(';'); 176 214 … … 178 216 } 179 217 180 String CaptionUserPreferencesMac::c ssColorProperty(CSSPropertyID id, const Color& color) const218 String CaptionUserPreferencesMac::colorPropertyCSS(CSSPropertyID id, const Color& color, bool important) const 181 219 { 182 220 StringBuilder builder; … … 185 223 builder.append(':'); 186 224 builder.append(color.serialized()); 225 if (important) 226 builder.append(" !important"); 187 227 builder.append(';'); 188 228 … … 190 230 } 191 231 192 String CaptionUserPreferencesMac::captionsTextEdge Style() const232 String CaptionUserPreferencesMac::captionsTextEdgeCSS() const 193 233 { 194 234 DEFINE_STATIC_LOCAL(const String, edgeStyleRaised, (" -.05em -.05em 0 ", String::ConstructFromLiteral)); … … 196 236 DEFINE_STATIC_LOCAL(const String, edgeStyleDropShadow, (" .075em .075em 0 ", String::ConstructFromLiteral)); 197 237 DEFINE_STATIC_LOCAL(const String, edgeStyleUniform, (" .03em ", String::ConstructFromLiteral)); 198 199 Color color = captionsTextColor(); 238 239 bool unused; 240 Color color = captionsTextColor(unused); 200 241 if (!color.isValid()) 201 242 color.setNamedColor("black"); 202 243 color = captionsEdgeColorForTextColor(color); 203 204 wkCaptionTextEdgeStyle textEdgeStyle = static_cast<wkCaptionTextEdgeStyle>(wkCaptionAppearanceGetTextEdgeStyle()); 244 245 MACaptionAppearanceBehavior behavior; 246 MACaptionAppearanceTextEdgeStyle textEdgeStyle = MACaptionAppearanceGetTextEdgeStyle(kMACaptionAppearanceDomainUser, &behavior); 205 247 switch (textEdgeStyle) { 206 case wkCaptionTextEdgeStyleUndefined:207 case wkCaptionTextEdgeStyleNone:248 case kMACaptionAppearanceTextEdgeStyleUndefined: 249 case kMACaptionAppearanceTextEdgeStyleNone: 208 250 return emptyString(); 209 251 210 case wkCaptionTextEdgeStyleRaised:211 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleRaised, color );212 case wkCaptionTextEdgeStyleDepressed:213 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDepressed, color );214 case wkCaptionTextEdgeStyleDropShadow:215 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color );216 case wkCaptionTextEdgeStyleUniform:217 return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color );252 case kMACaptionAppearanceTextEdgeStyleRaised: 253 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleRaised, color, behavior == kMACaptionAppearanceBehaviorUseValue); 254 case kMACaptionAppearanceTextEdgeStyleDepressed: 255 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDepressed, color, behavior == kMACaptionAppearanceBehaviorUseValue); 256 case kMACaptionAppearanceTextEdgeStyleDropShadow: 257 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color, behavior == kMACaptionAppearanceBehaviorUseValue); 258 case kMACaptionAppearanceTextEdgeStyleUniform: 259 return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color, behavior == kMACaptionAppearanceBehaviorUseValue); 218 260 219 case wkCaptionTextEdgeStyleMax:220 ASSERT_NOT_REACHED();221 261 default: 222 262 ASSERT_NOT_REACHED(); … … 227 267 } 228 268 229 String CaptionUserPreferencesMac::captionsDefaultFont() const 230 { 231 RetainPtr<CGFontRef> font(AdoptCF, wkCaptionAppearanceCopyFontForStyle(wkCaptionFontStyleDefault)); 269 String CaptionUserPreferencesMac::captionsDefaultFontCSS() const 270 { 271 MACaptionAppearanceBehavior behavior; 272 273 RetainPtr<CTFontDescriptorRef> font(AdoptCF, MACaptionAppearanceCopyFontDescriptorForStyle(kMACaptionAppearanceDomainUser, &behavior, kMACaptionAppearanceFontStyleDefault)); 232 274 if (!font) 233 275 return emptyString(); 234 235 RetainPtr<CF StringRef> name(AdoptCF, CGFontCopyPostScriptName(font.get()));276 277 RetainPtr<CFTypeRef> name(AdoptCF, CTFontDescriptorCopyAttribute(font.get(), kCTFontNameAttribute)); 236 278 if (!name) 237 279 return emptyString(); … … 241 283 builder.append(getPropertyNameString(CSSPropertyFontFamily)); 242 284 builder.append(": \""); 243 builder.append(name.get()); 244 builder.append("\";"); 285 builder.append(static_cast<CFStringRef>(name.get())); 286 builder.append('"'); 287 if (behavior == kMACaptionAppearanceBehaviorUseValue) 288 builder.append(" !important"); 289 builder.append(';'); 245 290 246 291 return builder.toString(); … … 250 295 { 251 296 StringBuilder captionsOverrideStyleSheet; 252 253 Color color = captionsBackgroundColor();254 if ( color.isValid()) {297 298 String background = captionsBackgroundCSS(); 299 if (!background.isEmpty()) { 255 300 captionsOverrideStyleSheet.append(" video::"); 256 301 captionsOverrideStyleSheet.append(TextTrackCue::allNodesShadowPseudoId()); 257 302 captionsOverrideStyleSheet.append('{'); 258 captionsOverrideStyleSheet.append( cssColorProperty(CSSPropertyBackgroundColor, color));303 captionsOverrideStyleSheet.append(background); 259 304 captionsOverrideStyleSheet.append('}'); 260 305 } 261 262 color = captionsWindowColor(); 263 if (color.isValid()) { 306 307 String windowColor = captionsWindowCSS(); 308 String windowCornerRadius = windowRoundedCornerRadiusCSS(); 309 String captionsColor = captionsTextColorCSS(); 310 String edgeStyle = captionsTextEdgeCSS(); 311 String fontName = captionsDefaultFontCSS(); 312 if (!captionsColor.isEmpty() || !windowColor.isEmpty() || !windowCornerRadius.isEmpty() || !edgeStyle.isEmpty() || !fontName.isEmpty()) { 264 313 captionsOverrideStyleSheet.append(" video::"); 265 314 captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId()); 266 315 captionsOverrideStyleSheet.append('{'); 267 captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyBackgroundColor, color)); 268 captionsOverrideStyleSheet.append('}'); 269 } 270 271 color = captionsTextColor(); 272 String edgeStyle = captionsTextEdgeStyle(); 273 String fontName = captionsDefaultFont(); 274 if (color.isValid() || !edgeStyle.isEmpty() || !fontName.isEmpty()) { 275 captionsOverrideStyleSheet.append(" video::"); 276 captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId()); 277 captionsOverrideStyleSheet.append('{'); 278 279 if (color.isValid()) 280 captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyColor, color)); 316 317 if (!windowColor.isEmpty()) 318 captionsOverrideStyleSheet.append(windowColor); 319 if (!windowCornerRadius.isEmpty()) 320 captionsOverrideStyleSheet.append(windowCornerRadius); 321 if (!captionsColor.isEmpty()) 322 captionsOverrideStyleSheet.append(captionsColor); 281 323 if (!edgeStyle.isEmpty()) 282 324 captionsOverrideStyleSheet.append(edgeStyle); 283 325 if (!fontName.isEmpty()) 284 326 captionsOverrideStyleSheet.append(fontName); 285 327 286 328 captionsOverrideStyleSheet.append('}'); 287 329 } 288 330 289 331 return captionsOverrideStyleSheet.toString(); 290 332 } 291 333 292 float CaptionUserPreferencesMac::captionFontSizeScale() const 293 { 294 CGFloat characterScale = CaptionUserPreferences::captionFontSizeScale(); 295 CGFloat scaleAdjustment; 296 297 if (!wkCaptionAppearanceGetRelativeCharacterSize(&scaleAdjustment)) 334 float CaptionUserPreferencesMac::captionFontSizeScale(bool& important) const 335 { 336 MACaptionAppearanceBehavior behavior; 337 CGFloat characterScale = CaptionUserPreferences::captionFontSizeScale(important); 338 CGFloat scaleAdjustment = MACaptionAppearanceGetRelativeCharacterSize(kMACaptionAppearanceDomainUser, &behavior); 339 340 if (!scaleAdjustment) 298 341 return characterScale; 299 342 343 important = behavior == kMACaptionAppearanceBehaviorUseValue; 300 344 #if defined(__LP64__) && __LP64__ 301 345 return narrowPrecisionToFloat(scaleAdjustment * characterScale); … … 323 367 pageGroup()->removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL); 324 368 325 if (!userHasCaptionPreferences())326 return;327 328 369 String captionsOverrideStyleSheet = captionsStyleSheetOverride(); 329 370 if (captionsOverrideStyleSheet.isEmpty()) … … 334 375 } 335 376 377 void CaptionUserPreferencesMac::setPreferredLanguage(String language) const 378 { 379 MACaptionAppearanceAddSelectedLanguage(kMACaptionAppearanceDomainUser, language.createCFString().get()); 380 } 381 382 Vector<String> CaptionUserPreferencesMac::preferredLanguages() const 383 { 384 Vector<String> override = userPreferredLanguagesOverride(); 385 if (!override.isEmpty()) 386 return override; 387 388 RetainPtr<CFArrayRef> languages(AdoptCF, MACaptionAppearanceCopySelectedLanguages(kMACaptionAppearanceDomainUser)); 389 CFIndex languageCount = CFArrayGetCount(languages.get()); 390 391 if (!languageCount) 392 return CaptionUserPreferences::preferredLanguages(); 393 394 Vector<String> userPreferredLanguages(languageCount); 395 for (CFIndex i = 0; i < languageCount; i++) 396 userPreferredLanguages.append(static_cast<CFStringRef>(CFArrayGetValueAtIndex(languages.get(), i))); 397 398 return userPreferredLanguages; 399 } 400 336 401 } 337 402 -
trunk/Source/WebCore/page/PageGroup.cpp
r136323 r141790 40 40 41 41 #if ENABLE(VIDEO_TRACK) 42 #if PLATFORM(MAC) 42 #if PLATFORM(MAC) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 43 43 #include "CaptionUserPreferencesMac.h" 44 44 #else … … 421 421 { 422 422 if (!m_captionPreferences) 423 #if PLATFORM(MAC) 423 #if PLATFORM(MAC) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 424 424 m_captionPreferences = CaptionUserPreferencesMac::create(this); 425 425 #else … … 452 452 } 453 453 454 float PageGroup::captionFontSizeScale( )455 { 456 return captionPreferences()->captionFontSizeScale( );454 float PageGroup::captionFontSizeScale(bool& important) 455 { 456 return captionPreferences()->captionFontSizeScale(important); 457 457 } 458 458 -
trunk/Source/WebCore/page/PageGroup.h
r136323 r141790 112 112 bool userPrefersCaptions(); 113 113 bool userHasCaptionPreferences(); 114 float captionFontSizeScale( );114 float captionFontSizeScale(bool&); 115 115 void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*); 116 116 void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*); -
trunk/Source/WebCore/platform/Language.cpp
r134507 r141790 75 75 DEFINE_STATIC_LOCAL(Vector<String>, override, ()); 76 76 return override; 77 } 78 79 Vector<String> userPreferredLanguagesOverride() 80 { 81 return preferredLanguagesOverride(); 77 82 } 78 83 -
trunk/Source/WebCore/platform/Language.h
r134507 r141790 34 34 String defaultLanguage(); 35 35 Vector<String> userPreferredLanguages(); 36 Vector<String> userPreferredLanguagesOverride(); 36 37 void overrideUserPreferredLanguages(const Vector<String>&); 37 38 String preferredLanguageFromList(const Vector<String>&); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm
r137161 r141790 61 61 SOFT_LINK_POINTER(AVFoundation, AVMetadataKeySpaceCommon, NSString *) 62 62 SOFT_LINK_POINTER(AVFoundation, AVMediaTypeSubtitle, NSString *) 63 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *) 63 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *) 64 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString *) 64 65 #define AVMetadataItem getAVMetadataItemClass() 65 66 #define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass() … … 68 69 #define AVMetadataKeySpaceCommon getAVMetadataKeySpaceCommon() 69 70 #define AVMediaTypeSubtitle getAVMediaTypeSubtitle() 70 #define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles() 71 #define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility() 72 #define AVMediaCharacteristicDescribesMusicAndSoundForAccessibility getAVMediaCharacteristicDescribesMusicAndSoundForAccessibility() 71 73 72 74 using namespace WebCore; … … 95 97 if ([mediaType isEqualToString:AVMediaTypeClosedCaption]) 96 98 return Captions; 97 if ([mediaType isEqualToString:AVMediaTypeSubtitle]) 99 if ([mediaType isEqualToString:AVMediaTypeSubtitle]) { 100 101 // An "SDH" track is a subtitle track created for the deaf or hard-of-hearing. "captions" in WebVTT are 102 // "labeled as appropriate for the hard-of-hearing", so tag SDH sutitles as "captions". 103 if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility]) 104 return Captions; 105 if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicDescribesMusicAndSoundForAccessibility]) 106 return Captions; 107 98 108 return Subtitles; 109 } 99 110 100 111 return Captions;
Note:
See TracChangeset
for help on using the changeset viewer.