1. 27 Mar, 2013 1 commit
    • eric.carlson@apple.com's avatar
      [Mac] webkitClosedCaptionsVisible doesn't work · 92907e15
      eric.carlson@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=113417
      
      Reviewed by Jer Noble.
      
      Source/WebCore: 
      
      Test: media/track/track-in-band-legacy-api.html
      
      * html/HTMLMediaElement.cpp:
      (WebCore::HTMLMediaElement::HTMLMediaElement): Delete m_disableCaptions, it is no longer used.
      (WebCore::HTMLMediaElement::configureTextTrackGroup): Pass this to textTrackSelectionScore.
      (WebCore::HTMLMediaElement::setClosedCaptionsVisible):  Delete m_disableCaptions, it is no longer used.
      * html/HTMLMediaElement.h: Ditto.
      
      * page/CaptionUserPreferences.cpp:
      (WebCore::CaptionUserPreferences::textTrackSelectionScore): Add an HTMLMediaElement parameter.
      * page/CaptionUserPreferences.h:
      
      * page/CaptionUserPreferencesMac.h:
      * page/CaptionUserPreferencesMac.mm:
      (WebCore::CaptionUserPreferencesMac::textTrackSelectionScore): Return a score if the media element
          is showing captions, even if the preference says captions are disabled.
      
      LayoutTests: 
      
      * media/track/track-in-band-legacy-api-expected.txt: Added.
      * media/track/track-in-band-legacy-api.html: Added.
      
      * platform/chromium/TestExpectations: Skip new test.
      * platform/efl/TestExpectations: Ditto.
      * platform/gtk/TestExpectations: Ditto.
      * platform/mac/TestExpectations: Ditto.
      * platform/qt/TestExpectations: Ditto.
      * platform/win/TestExpectations: Ditto.
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      92907e15
  2. 22 Mar, 2013 1 commit
    • eric.carlson@apple.com's avatar
      Cleanup text track selection logic · d4e6f18f
      eric.carlson@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=113062
      
      Reviewed by Jer Noble.
      
      No new tests, covered by existing tests.
      
      * html/HTMLMediaElement.cpp:
      (WebCore::HTMLMediaElement::userIsInterestedInThisTrackKind): Remove.
      (WebCore::HTMLMediaElement::configureTextTrackGroup): Don't look at track attributes directly,
          use captionPreferences->textTrackSelectionScore to calculate track rank.
      (WebCore::HTMLMediaElement::setClosedCaptionsVisible): Set m_processingPreferenceChange here
          instead of in captionPreferencesChanged.
      (WebCore::HTMLMediaElement::captionPreferencesChanged): Don't suppress calls to setClosedCaptionsVisible,
          existing code already makes sure we don't do unnecessary work.
      * html/HTMLMediaElement.h:
      
      * html/shadow/MediaControlElements.cpp:
      (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Drive by cleanup, don't
          process inactive cues.
      
      * html/shadow/MediaControlsApple.cpp:
      (WebCore::MediaControlsApple::changedClosedCaptionsVisibility): Call resetTrackListMenu instead
          of updateDisplay so we only mark the menu as needing a recalculation and do the work when
          it is displayed.
      
      * page/CaptionUserPreferences.cpp:
      (WebCore::CaptionUserPreferences::shouldShowCaptions): When in testing mode, return true if
          the caption or subtitle preference has been set.
      (WebCore::CaptionUserPreferences::setShouldShowCaptions): In testing mode, clear the caption
          and subtitle preference when passed false.
      (WebCore::CaptionUserPreferences::textTrackSelectionScore): Calculate the track score based on
          track type preference and preferred language.
      (WebCore::CaptionUserPreferences::textTrackLanguageSelectionScore): Score a track according to
          the language presence and position in the preferred languages list.
      * page/CaptionUserPreferences.h:
      
      * page/CaptionUserPreferencesMac.h:
      * page/CaptionUserPreferencesMac.mm:
      (WebCore::CaptionUserPreferencesMac::textTrackSelectionScore): Calculate track language score 
          according to user preferences.
      
      * platform/Language.cpp:
      (WebCore::indexOfBestMatchingLanguageInList): Repurposed the static bestMatchingLanguage
          function to return the location of a language in a Vector.
      (WebCore::preferredLanguageFromList): Removed.
      * platform/Language.h:
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      d4e6f18f
  3. 20 Mar, 2013 1 commit
    • eric.carlson@apple.com's avatar
      Allow ports specific text track menu · 62bb7dc9
      eric.carlson@apple.com authored
      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: http://svn.webkit.org/repository/webkit/trunk@146380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      62bb7dc9
  4. 14 Mar, 2013 1 commit
    • jer.noble@apple.com's avatar
      Crash in DumpRenderTree at com.apple.WebCore:... · c3419e02
      jer.noble@apple.com authored
      Crash in DumpRenderTree at com.apple.WebCore: WebCore::CaptionUserPreferences::captionPreferencesChanged + 185
      https://bugs.webkit.org/show_bug.cgi?id=112051
      
      Reviewed by Eric Carlson.
      
      No new tests; fixes a crash during media/video-controls-captions-trackmenu.html.
      
      Instead of relying on a registration system which can fail when an element's document does not have a page,
      Elements will register for captionPreferencesChanged() notifications directly with their owning Document.
      CaptionUserPreferences, in turn, will notify all Documents in its PageGroup, rather than only directly
      registered listeners.
      
      * dom/Document.cpp:
      (WebCore::Document::registerForCaptionPreferencesChangedCallbacks): Added. Notify the CaptionUserPreferences that someone
          is interested in captionPreferencesChanged notfications.
      (WebCore::Document::unregisterForCaptionPreferencesChangedCallbacks): Added.
      (WebCore::Document::captionPreferencesChanged): Added. Pass to all registered elements.
      * dom/Document.h:
      * dom/Element.h:
      (WebCore::Element::captionPreferencesChanged): Added. Empty; intended
          to be overridden by subclasses.
      * history/CachedPage.cpp:
      (WebCore::CachedPage::CachedPage): Initialize m_needsCaptionPreferenceChanged member.
      (WebCore::CachedPage::restore): Call captionPreferencesChanged() if necessary.
      * history/CachedPage.h:
      (WebCore::CachedPage::markForCaptionPreferencesChanged): Set the m_needsCaptionPreferenceChanged member.
      * history/PageCache.cpp:
      (WebCore::PageCache::markPagesForCaptionPreferencesChanged): Pass to every CachedPage.
      * history/PageCache.h:
      * html/HTMLMediaElement.cpp:
      (WebCore::HTMLMediaElement::HTMLMediaElement): Register with the Document.
      (WebCore::HTMLMediaElement::~HTMLMediaElement): Unregister with same.
      (WebCore::HTMLMediaElement::attach): Remove previous registration call.
      * html/HTMLMediaElement.h:
      * page/CaptionUserPreferences.cpp:
      (WebCore::CaptionUserPreferences::captionPreferencesChanged): Pass to the
          PageGroup.
      * page/CaptionUserPreferences.h:
      (WebCore::CaptionUserPreferences::setInterestedInCaptionPreferenceChanges):
          Empty; intended to be overridden by subclasses.
      * page/CaptionUserPreferencesMac.h:
      * page/CaptionUserPreferencesMac.mm:
      (WebCore::CaptionUserPreferencesMac::setInterestedInCaptionPreferenceChanges):
          Renamed from registerForPreferencesChangedCallbacks().
      (WebCore::CaptionUserPreferencesMac::captionPreferencesChanged):
          Replace call to havePreferenceChangeListeners() with m_listeningForPreferenceChanges.
      * page/Page.cpp:
      (WebCore::Page::captionPreferencesChanged):
          Pass to every contained Document.
      * page/Page.h:
      * page/CaptionUserPreferences.cpp:
      (WebCore::CaptionUserPreferences::captionPreferencesChanged): Pass to the PageGroup.
      * page/CaptionUserPreferences.h:
      * page/PageGroup.cpp:
      (WebCore::PageGroup::captionPreferencesChanged): Pass to every page, as well as pages in the PageCache.
      * page/PageGroup.h:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145826 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      c3419e02
  5. 13 Feb, 2013 1 commit
    • eric.carlson@apple.com's avatar
      [Mac] Caption menu should have only one item selected · 70109507
      eric.carlson@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=109730
      
      Reviewed by Dean Jackson.
      
      Source/WebCore: 
      
      No new tests, media/track/track-user-preferences.html was modified to test the changes.
      
      * CMakeLists.txt: Add CaptionUserPreferences.cpp.
      * GNUmakefile.list.am: Ditto.
      * Target.pri: Ditto.
      * WebCore.gypi: Ditto.
      * WebCore.vcproj/WebCore.vcproj: Ditto.
      * WebCore.vcxproj/WebCore.vcxproj: Ditto.
      * WebCore.xcodeproj/project.pbxproj: Ditto.
      
      * html/HTMLMediaElement.cpp:
      (WebCore::HTMLMediaElement::HTMLMediaElement): Initialize m_processingPreferenceChange.
      (WebCore::HTMLMediaElement::configureTextTrackGroup): Only end up with one selected track when
          called because of a preferences change.
      (WebCore::HTMLMediaElement::captionPreferencesChanged): Call setClosedCaptionsVisible instead
          of calling markCaptionAndSubtitleTracksAsUnconfigured directly.
      (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): Process all tracks, 
          not just track elements.
      * html/HTMLMediaElement.h:
      
      * page/CaptionUserPreferences.cpp: Added so the functionality can be tested in DRT.
      (WebCore::CaptionUserPreferences::registerForPreferencesChangedCallbacks):
      (WebCore::CaptionUserPreferences::unregisterForPreferencesChangedCallbacks):
      (WebCore::CaptionUserPreferences::setUserPrefersCaptions):
      (WebCore::CaptionUserPreferences::captionPreferencesChanged):
      (WebCore::CaptionUserPreferences::preferredLanguages):
      (WebCore::CaptionUserPreferences::setPreferredLanguage):
      (WebCore::CaptionUserPreferences::displayNameForTrack):
      * page/CaptionUserPreferences.h:
      
      * page/CaptionUserPreferencesMac.h:
      * page/CaptionUserPreferencesMac.mm:
      (WebCore::CaptionUserPreferencesMac::registerForPreferencesChangedCallbacks): Moved some logic
          to base class.
      (WebCore::CaptionUserPreferencesMac::captionPreferencesChanged): Ditto.
      
      LayoutTests: 
      
      * media/track/track-user-preferences-expected.txt:
      * media/track/track-user-preferences.html: Update test to check for reactions to preferences.
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      70109507