Commit 4ef7e2a7 authored by eric.carlson@apple.com's avatar eric.carlson@apple.com
Browse files

[Mac] Do not assume MediaAccessibility framework is installed

https://bugs.webkit.org/show_bug.cgi?id=109365

Reviewed by Sam Weinig.

* page/CaptionUserPreferencesMac.h:
* page/CaptionUserPreferencesMac.mm:
(WebCore::CaptionUserPreferencesMac::userPrefersCaptions): Call the base class if the framework
    is not available.
(WebCore::CaptionUserPreferencesMac::setUserPrefersCaptions): Ditto.
(WebCore::CaptionUserPreferencesMac::userHasCaptionPreferences): Ditto.
(WebCore::CaptionUserPreferencesMac::registerForCaptionPreferencesChangedCallbacks): Ditto.
(WebCore::CaptionUserPreferencesMac::unregisterForCaptionPreferencesChangedCallbacks): Ditto.
(WebCore::CaptionUserPreferencesMac::captionsStyleSheetOverride): Ditto.
(WebCore::CaptionUserPreferencesMac::captionFontSizeScale): Ditto.
(WebCore::CaptionUserPreferencesMac::setPreferredLanguage): Ditto.
(WebCore::CaptionUserPreferencesMac::preferredLanguages): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142383 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3b5179d2
2013-02-09 Eric Carlson <eric.carlson@apple.com>
[Mac] Do not assume MediaAccessibility framework is installed
https://bugs.webkit.org/show_bug.cgi?id=109365
Reviewed by Sam Weinig.
* page/CaptionUserPreferencesMac.h:
* page/CaptionUserPreferencesMac.mm:
(WebCore::CaptionUserPreferencesMac::userPrefersCaptions): Call the base class if the framework
is not available.
(WebCore::CaptionUserPreferencesMac::setUserPrefersCaptions): Ditto.
(WebCore::CaptionUserPreferencesMac::userHasCaptionPreferences): Ditto.
(WebCore::CaptionUserPreferencesMac::registerForCaptionPreferencesChangedCallbacks): Ditto.
(WebCore::CaptionUserPreferencesMac::unregisterForCaptionPreferencesChangedCallbacks): Ditto.
(WebCore::CaptionUserPreferencesMac::captionsStyleSheetOverride): Ditto.
(WebCore::CaptionUserPreferencesMac::captionFontSizeScale): Ditto.
(WebCore::CaptionUserPreferencesMac::setPreferredLanguage): Ditto.
(WebCore::CaptionUserPreferencesMac::preferredLanguages): Ditto.
2013-02-09 Dominic Mazzoni <dmazzoni@google.com>
 
AX: move isIgnored caching to AXObject
......@@ -43,7 +43,7 @@ public:
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
virtual bool userPrefersCaptions() const OVERRIDE;
virtual void setUserPrefersCaptions(bool) OVERRIDE;
virtual bool userHasCaptionPreferences() const OVERRIDE { return true; }
virtual bool userHasCaptionPreferences() const OVERRIDE;
virtual float captionFontSizeScale(bool&) const OVERRIDE;
virtual String captionsStyleSheetOverride() const OVERRIDE;
virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE;
......
......@@ -102,16 +102,37 @@ CaptionUserPreferencesMac::~CaptionUserPreferencesMac()
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
bool CaptionUserPreferencesMac::userPrefersCaptions() const
{
if (!MediaAccessibilityLibrary())
return CaptionUserPreferences::userPrefersCaptions();
return MACaptionAppearanceGetShowCaptions(kMACaptionAppearanceDomainUser);
}
void CaptionUserPreferencesMac::setUserPrefersCaptions(bool preference)
{
if (!MediaAccessibilityLibrary()) {
CaptionUserPreferences::setUserPrefersCaptions(preference);
return;
}
MACaptionAppearanceSetShowCaptions(kMACaptionAppearanceDomainUser, preference);
}
bool CaptionUserPreferencesMac::userHasCaptionPreferences() const
{
if (!MediaAccessibilityLibrary())
return CaptionUserPreferences::userHasCaptionPreferences();
return !MediaAccessibilityLibrary();
}
void CaptionUserPreferencesMac::registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener)
{
if (!MediaAccessibilityLibrary()) {
CaptionUserPreferences::registerForCaptionPreferencesChangedCallbacks(listener);
return;
}
ASSERT(!m_captionPreferenceChangeListeners.contains(listener));
if (!kMAXCaptionAppearanceSettingsChangedNotification)
......@@ -128,6 +149,11 @@ void CaptionUserPreferencesMac::registerForCaptionPreferencesChangedCallbacks(Ca
void CaptionUserPreferencesMac::unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener)
{
if (!MediaAccessibilityLibrary()) {
CaptionUserPreferences::unregisterForCaptionPreferencesChangedCallbacks(listener);
return;
}
if (kMAXCaptionAppearanceSettingsChangedNotification)
m_captionPreferenceChangeListeners.remove(listener);
}
......@@ -332,6 +358,9 @@ String CaptionUserPreferencesMac::captionsDefaultFontCSS() const
String CaptionUserPreferencesMac::captionsStyleSheetOverride() const
{
if (!MediaAccessibilityLibrary())
return CaptionUserPreferences::captionsStyleSheetOverride();
StringBuilder captionsOverrideStyleSheet;
String background = captionsBackgroundCSS();
......@@ -374,6 +403,9 @@ String CaptionUserPreferencesMac::captionsStyleSheetOverride() const
float CaptionUserPreferencesMac::captionFontSizeScale(bool& important) const
{
if (!MediaAccessibilityLibrary())
return CaptionUserPreferences::captionFontSizeScale(important);
MACaptionAppearanceBehavior behavior;
CGFloat characterScale = CaptionUserPreferences::captionFontSizeScale(important);
CGFloat scaleAdjustment = MACaptionAppearanceGetRelativeCharacterSize(kMACaptionAppearanceDomainUser, &behavior);
......@@ -417,6 +449,11 @@ void CaptionUserPreferencesMac::updateCaptionStyleSheetOveride()
void CaptionUserPreferencesMac::setPreferredLanguage(String language) const
{
if (!MediaAccessibilityLibrary()) {
CaptionUserPreferences::setPreferredLanguage(language);
return;
}
MACaptionAppearanceAddSelectedLanguage(kMACaptionAppearanceDomainUser, language.createCFString().get());
}
......@@ -426,6 +463,9 @@ Vector<String> CaptionUserPreferencesMac::preferredLanguages() const
if (!override.isEmpty())
return override;
if (!MediaAccessibilityLibrary())
return CaptionUserPreferences::preferredLanguages();
RetainPtr<CFArrayRef> languages(AdoptCF, MACaptionAppearanceCopySelectedLanguages(kMACaptionAppearanceDomainUser));
CFIndex languageCount = CFArrayGetCount(languages.get());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment