Bug 115043

Summary: [Mac] forced subtitle track should change when audio track language changes
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, dino, esprehn+autocc, jer.noble
Priority: P2 Keywords: InRadar, PlatformOnly
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch none

Description Eric Carlson 2013-04-23 09:11:44 PDT
Because forced subtitles are always shown in the same language as the primary audio track, the forced track should change when the primary audio track changes to a different language.
Comment 1 Eric Carlson 2013-04-23 09:12:07 PDT
<rdar://problem/13716530>
Comment 2 Eric Carlson 2013-04-23 09:28:53 PDT
Created attachment 199246 [details]
Proposed patch
Comment 3 Jer Noble 2013-04-23 10:34:41 PDT
Comment on attachment 199246 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=199246&action=review

> Source/WebCore/ChangeLog:16
> +        (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): Take parameter toa allow

Nit: toa -> to

> Source/WebCore/html/HTMLMediaElement.cpp:3244
> +    if (trackToEnable && m_captionDisplayMode != CaptionUserPreferences::AlwaysOn && !defaultTrack && trackToEnable != fallbackTrack)

Can we move the "trackToEnable" checks together?  They all seem equally cheap (i.e., pointer comparisons).  Also, should this be an else-if?

> Source/WebCore/html/HTMLMediaElement.h:557
> +    enum ReconfigureMode {
> +        Immediately,
> +        AfterDelay,
> +    };
> +    void markCaptionAndSubtitleTracksAsUnconfigured(ReconfigureMode);

Ooh, good use of a boolean enum!

> Source/WebCore/page/CaptionUserPreferencesMac.mm:630
> +    if ((trackHasOnlyForcedSubtitles && displayMode != ForcedOnly) || (displayMode == ForcedOnly && !trackHasOnlyForcedSubtitles))

Why is the trackHasOnlyForcedSubtitles check order reversed?  I mean, if you want to go all funhouse-mirror, it should be:

if ((trackHasOnlyForcedSubtitles && displayMode != ForcedOnly) || (ForcedOnly == displayMode && !trackHasOnlyForcedSubtitles))

:-D

Or, this could just be re-written as:

if (trackHasOnlyForcedSubtitles == (displayMode != ForcedOnly))

But if that's "too clever by half", I'd just move things around to make the two halves more parallel:

if ((trackHasOnlyForcedSubtitles && displayMode != ForcedOnly) 
    || (!trackHasOnlyForcedSubtitles && displayMode == ForcedOnly))
Comment 4 Eric Carlson 2013-04-23 16:34:44 PDT
http://trac.webkit.org/changeset/149005