Update CaptionUserPreferences

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

Reviewed by Dean Jackson.

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateSizes): Mark font size as important
    when necessary.
* page/CaptionUserPreferences.h:
(WebCore::CaptionUserPreferences::setUserPrefersCaptions): New, allow a port to remember that
    the user has chosen to see captions.
(WebCore::CaptionUserPreferences::setPreferredLanguage): New, allow a port to remember the
    user's preferred caption language.
(WebCore::CaptionUserPreferences::preferredLanguages): New, return a Vector of the user's 
    preferred caption languages.
* page/CaptionUserPreferencesMac.h:
* page/CaptionUserPreferencesMac.mm:
* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferences):
(WebCore::PageGroup::captionFontSizeScale):
* page/PageGroup.h:
* platform/Language.cpp:
(WebCore::userPreferredLanguagesOverride): New, return the user preferred languages override
    used during testing.
* platform/Language.h:
* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
(WebCore::InbandTextTrackPrivateAVFObjC::kind):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 76fe919e
2013-02-04 Eric Carlson <eric.carlson@apple.com>
Update CaptionUserPreferences
https://bugs.webkit.org/show_bug.cgi?id=108783
Reviewed by Dean Jackson.
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateSizes): Mark font size as important
when necessary.
* page/CaptionUserPreferences.h:
(WebCore::CaptionUserPreferences::setUserPrefersCaptions): New, allow a port to remember that
the user has chosen to see captions.
(WebCore::CaptionUserPreferences::setPreferredLanguage): New, allow a port to remember the
user's preferred caption language.
(WebCore::CaptionUserPreferences::preferredLanguages): New, return a Vector of the user's
preferred caption languages.
* page/CaptionUserPreferencesMac.h:
* page/CaptionUserPreferencesMac.mm:
* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferences):
(WebCore::PageGroup::captionFontSizeScale):
* page/PageGroup.h:
* platform/Language.cpp:
(WebCore::userPreferredLanguagesOverride): New, return the user preferred languages override
used during testing.
* platform/Language.h:
* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
(WebCore::InbandTextTrackPrivateAVFObjC::kind):
2013-02-04 Tim Horton <timothy_horton@apple.com>
Allow TiledCoreAnimationDrawingArea overlay layers to become tiled
......@@ -1363,10 +1363,11 @@ void MediaControlTextTrackContainerElement::updateSizes()
float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
float fontSize = smallestDimension * (document()->page()->group().captionFontSizeScale());
bool important;
float fontSize = smallestDimension * (document()->page()->group().captionFontSizeScale(important));
if (fontSize != m_fontSize) {
m_fontSize = fontSize;
setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px", important);
}
}
......
......@@ -28,6 +28,7 @@
#if ENABLE(VIDEO_TRACK)
#include "Language.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/text/AtomicString.h>
......@@ -48,12 +49,16 @@ public:
virtual ~CaptionUserPreferences() { }
virtual bool userPrefersCaptions() const { return false; }
virtual void setUserPrefersCaptions(bool) { }
virtual bool userHasCaptionPreferences() const { return false; }
virtual float captionFontSizeScale() const { return 0.05f; }
virtual float captionFontSizeScale(bool& important) const { important = false; return 0.05f; }
virtual String captionsStyleSheetOverride() const { return emptyString(); }
virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { }
virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { }
virtual void setPreferredLanguage(String) const { }
virtual Vector<String> preferredLanguages() const { return platformUserPreferredLanguages(); }
PageGroup* pageGroup() { return m_pageGroup; }
protected:
......
......@@ -26,7 +26,7 @@
#ifndef CaptionUserPreferencesMac_h
#define CaptionUserPreferencesMac_h
#if ENABLE(VIDEO_TRACK)
#if ENABLE(VIDEO_TRACK) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
#include "CSSPropertyNames.h"
#include "CaptionUserPreferences.h"
......@@ -41,25 +41,31 @@ public:
virtual ~CaptionUserPreferencesMac();
virtual bool userPrefersCaptions() const OVERRIDE;
virtual bool userHasCaptionPreferences() const OVERRIDE;
virtual float captionFontSizeScale() const OVERRIDE;
virtual void setUserPrefersCaptions(bool) OVERRIDE;
virtual bool userHasCaptionPreferences() const OVERRIDE { return true; }
virtual float captionFontSizeScale(bool&) const OVERRIDE;
virtual String captionsStyleSheetOverride() const OVERRIDE;
virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE;
virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE;
virtual void setPreferredLanguage(String) const OVERRIDE;
virtual Vector<String> preferredLanguages() const OVERRIDE;
void captionPreferencesChanged();
private:
CaptionUserPreferencesMac(PageGroup*);
Color captionsWindowColor() const;
Color captionsBackgroundColor() const;
Color captionsTextColor() const;
String captionsDefaultFont() const;
String captionsWindowCSS() const;
String captionsBackgroundCSS() const;
String captionsTextColorCSS() const;
Color captionsTextColor(bool&) const;
String captionsDefaultFontCSS() const;
Color captionsEdgeColorForTextColor(const Color&) const;
String captionsTextEdgeStyle() const;
String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&) const;
String cssColorProperty(CSSPropertyID, const Color&) const;
String windowRoundedCornerRadiusCSS() const;
String captionsTextEdgeCSS() const;
String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&, bool) const;
String colorPropertyCSS(CSSPropertyID, const Color&, bool) const;
void updateCaptionStyleSheetOveride();
......
......@@ -39,7 +39,7 @@
#include "StorageNamespace.h"
#if ENABLE(VIDEO_TRACK)
#if PLATFORM(MAC)
#if PLATFORM(MAC) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
#include "CaptionUserPreferencesMac.h"
#else
#include "CaptionUserPreferences.h"
......@@ -420,7 +420,7 @@ void PageGroup::invalidatedInjectedStyleSheetCacheInAllFrames()
CaptionUserPreferences* PageGroup::captionPreferences()
{
if (!m_captionPreferences)
#if PLATFORM(MAC)
#if PLATFORM(MAC) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
m_captionPreferences = CaptionUserPreferencesMac::create(this);
#else
m_captionPreferences = CaptionUserPreferences::create(this);
......@@ -451,9 +451,9 @@ bool PageGroup::userHasCaptionPreferences()
return captionPreferences()->userPrefersCaptions();
}
float PageGroup::captionFontSizeScale()
float PageGroup::captionFontSizeScale(bool& important)
{
return captionPreferences()->captionFontSizeScale();
return captionPreferences()->captionFontSizeScale(important);
}
#endif
......
......@@ -111,7 +111,7 @@ namespace WebCore {
#if ENABLE(VIDEO_TRACK)
bool userPrefersCaptions();
bool userHasCaptionPreferences();
float captionFontSizeScale();
float captionFontSizeScale(bool&);
void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*);
void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*);
#endif
......
......@@ -76,6 +76,11 @@ static Vector<String>& preferredLanguagesOverride()
return override;
}
Vector<String> userPreferredLanguagesOverride()
{
return preferredLanguagesOverride();
}
void overrideUserPreferredLanguages(const Vector<String>& override)
{
preferredLanguagesOverride() = override;
......
......@@ -33,6 +33,7 @@ namespace WebCore {
String defaultLanguage();
Vector<String> userPreferredLanguages();
Vector<String> userPreferredLanguagesOverride();
void overrideUserPreferredLanguages(const Vector<String>&);
String preferredLanguageFromList(const Vector<String>&);
......
......@@ -60,14 +60,16 @@ SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicLegible, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaTypeSubtitle, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString *)
#define AVMetadataItem getAVMetadataItemClass()
#define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass()
#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
#define AVMetadataCommonKeyTitle getAVMetadataCommonKeyTitle()
#define AVMetadataKeySpaceCommon getAVMetadataKeySpaceCommon()
#define AVMediaTypeSubtitle getAVMediaTypeSubtitle()
#define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles()
#define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility()
#define AVMediaCharacteristicDescribesMusicAndSoundForAccessibility getAVMediaCharacteristicDescribesMusicAndSoundForAccessibility()
using namespace WebCore;
using namespace std;
......@@ -94,8 +96,17 @@ InbandTextTrackPrivate::Kind InbandTextTrackPrivateAVFObjC::kind() const
NSString *mediaType = [m_mediaSelectionOption mediaType];
if ([mediaType isEqualToString:AVMediaTypeClosedCaption])
return Captions;
if ([mediaType isEqualToString:AVMediaTypeSubtitle])
if ([mediaType isEqualToString:AVMediaTypeSubtitle]) {
// An "SDH" track is a subtitle track created for the deaf or hard-of-hearing. "captions" in WebVTT are
// "labeled as appropriate for the hard-of-hearing", so tag SDH sutitles as "captions".
if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
return Captions;
if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicDescribesMusicAndSoundForAccessibility])
return Captions;
return Subtitles;
}
return Captions;
}
......
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