Allow ports specific text track menu
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 20:13:36 +0000 (20:13 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 20:13:36 +0000 (20:13 +0000)
commit714cbc9cf6987b5306b446deca611c9b9e00c246
tree8bb370f3b318c378cefe2fd8e7a7039631bf82b7
parentb759d0877cbec4fc7f96cfee15b7c0453583e3ee
Allow ports specific text track menu
https://bugs.webkit.org/show_bug.cgi?id=112800

Reviewed by Dean Jackson.

Source/WebCore:

No new tests, existing tests updated for changes.

* English.lproj/Localizable.strings: Add localizable strings for text track names.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): userPrefersCaptions -> shouldShowCaptions.
(WebCore::HTMLMediaElement::setSelectedTextTrack): toggleTrackAtIndex -> setSelectedTextTrack.
(WebCore::HTMLMediaElement::userPrefersCaptions): userPrefersCaptions -> shouldShowCaptions.
(WebCore::HTMLMediaElement::userIsInterestedInThisTrackKind): Get preferences from CaptionUserPreferences
    instead of from Settings.
(WebCore::HTMLMediaElement::setSelectedTextTrack): Renamed from toggleTrackAtIndex. Now takes
    a TextTrack* instead of an int.
(WebCore::HTMLMediaElement::captionPreferencesChanged): Don't force a recalculation unless
    captions are enabled/disabled to avoid unnecessary thrash.
* html/HTMLMediaElement.h:

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::defaultEventHandler): Use the menu to track
    map instead of just the track index.
(WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Build and configure the
    menu from the menu to track map.
(WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu): Start with a list
    of tracks already sorted according to platform specific rules. Build a menu to track map
    so tracks are retained while the menu is visible.
* html/shadow/MediaControlElements.h:

* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::textTrackPreferencesChanged): Call closedCaptionTracksChanged so the
    track menu will be rebuilt before it is shown again.

* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::containsOnlyForcedSubtitles): New, passthrough to the private track.
(WebCore::InbandTextTrack::isMainProgramContent): Ditto.
(WebCore::InbandTextTrack::isEasyToRead): Ditto.
* html/track/InbandTextTrack.h:
* html/track/TextTrack.h:

* html/track/TextTrackList.cpp:
(WebCore::TextTrackList::contains): New.
* html/track/TextTrackList.h:

* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::CaptionUserPreferences): Pull in from .h ditto.
(WebCore::CaptionUserPreferences::~CaptionUserPreferences): Ditto.
(WebCore::CaptionUserPreferences::shouldShowCaptions): Renamed from userPrefersCaptions.
(WebCore::CaptionUserPreferences::setShouldShowCaptions): New.
(WebCore::CaptionUserPreferences::userPrefersCaptions): Ditto.
(WebCore::CaptionUserPreferences::setUserPrefersCaptions): Ditto.
(WebCore::CaptionUserPreferences::userPrefersSubtitles): Ditto.
(WebCore::CaptionUserPreferences::setUserPrefersSubtitles): Ditto.
(WebCore::CaptionUserPreferences::userPrefersTextDescriptions): Ditto.
(WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions): Ditto.
(WebCore::CaptionUserPreferences::displayNameForTrack): Ditto.
(WebCore::CaptionUserPreferences::sortedTrackListForMenu): Ditto.
* page/CaptionUserPreferences.h:

* page/CaptionUserPreferencesMac.h:
* page/CaptionUserPreferencesMac.mm:
(WebCore::CaptionUserPreferencesMac::shouldShowCaptions): Renamed from userPrefersCaptions.
(WebCore::CaptionUserPreferencesMac::userPrefersCaptions): New.
(WebCore::CaptionUserPreferences::userPrefersSubtitles): Ditto.
(WebCore::trackDisplayName): Update logic used to build track title.
(WebCore::CaptionUserPreferencesMac::displayNameForTrack): Call trackDisplayName.
(WebCore::textTrackCompare): Text track title sort comparison function.
(WebCore::CaptionUserPreferencesMac::sortedTrackListForMenu): New. Sort the list of tracks
    according to title, language, and user preferences.

* platform/Language.cpp:
(WebCore::displayNameForLanguageLocale): Don't leak the CFLocale.

* platform/LocalizedStrings.cpp:
(WebCore::textTrackCountryAndLanguageMenuItemText): New.
(WebCore::textTrackLanguageMenuItemText): Ditto.
(WebCore::closedCaptionTrackMenuItemText): Ditto.
(WebCore::sdhTrackMenuItemText): Ditto.
(WebCore::easyReaderTrackMenuItemText): Ditto.
* platform/LocalizedStrings.h:

* platform/graphics/InbandTextTrackPrivate.h:
* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
(WebCore::InbandTextTrackPrivateAVFObjC::containsOnlyForcedSubtitles): New, return AVFoundation property.
(WebCore::InbandTextTrackPrivateAVFObjC::isMainProgramContent): Ditto.
(WebCore::InbandTextTrackPrivateAVFObjC::isEasyToRead): Ditto.

* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setShouldDisplayTrackKind): Set setting via CaptionUserPreferences
    instead of from Settings.
(WebCore::InternalSettings::shouldDisplayTrackKind): Get setting from CaptionUserPreferences
    instead of from Settings.

Source/WebKit:

* WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: Add new exports.
* win/WebKit.vcproj/WebKitExports.def.in: Ditto.

LayoutTests:

* media/track/track-user-preferences-expected.txt:
* media/track/track-user-preferences.html:
* media/video-controls-captions-trackmenu-localized.html:
* media/video-controls-captions-trackmenu-sorted.html:
* media/video-controls-captions-trackmenu.html:
* platform/mac/media/video-controls-captions-trackmenu-expected.txt:
* platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt:
* platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
36 files changed:
LayoutTests/ChangeLog
LayoutTests/media/track/track-user-preferences-expected.txt
LayoutTests/media/track/track-user-preferences.html
LayoutTests/media/video-controls-captions-trackmenu-localized.html
LayoutTests/media/video-controls-captions-trackmenu-sorted.html
LayoutTests/media/video-controls-captions-trackmenu.html
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-expected.txt
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControlElements.h
Source/WebCore/html/shadow/MediaControls.cpp
Source/WebCore/html/track/InbandTextTrack.cpp
Source/WebCore/html/track/InbandTextTrack.h
Source/WebCore/html/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h
Source/WebCore/html/track/TextTrackList.cpp
Source/WebCore/html/track/TextTrackList.h
Source/WebCore/page/CaptionUserPreferences.cpp
Source/WebCore/page/CaptionUserPreferences.h
Source/WebCore/page/CaptionUserPreferencesMac.h
Source/WebCore/page/CaptionUserPreferencesMac.mm
Source/WebCore/platform/Language.cpp
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/platform/graphics/InbandTextTrackPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm
Source/WebCore/testing/InternalSettings.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in
Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in