Stop using string-based enumerations in TextTrack, and eliminate support for string...
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2016 06:05:57 +0000 (06:05 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2016 06:05:57 +0000 (06:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157253

Reviewed by Chris Dumez.

This was the most difficult case to convert from the old style of enumeration to enum class.
Afterward there is a bit of messy duplication, but it still seems like an improvement overall.

After this patch, I plan to change the rule for the name of the enumeration; instead of
living at the top level of the WebCore namespace, we will look for them inside the class for the
first interface defined in the same file along with the enumeration, and remove the name prefix,
if the interfaces's name is a prefix of the enumerations's name.

Once that's done, next step is to do something in the bindings for dictionaries. And adopt both the
enumeration and dictionary mechanisms more widely, and remove the old use of "dictionary" as a type name.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::removeSourceBuffer): Use enum values instead of keywords.
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::textTrackModeChanged): Ditto.

* bindings/js/JSTextTrackCustom.cpp:
(WebCore::JSTextTrack::setKind): Deleted.

* bindings/scripts/CodeGenerator.pm:
(IsStringBasedEnumType): Deleted.

* bindings/scripts/CodeGeneratorJS.pm:
(GetEnumerationImplementationContent): Removed IsStringBasedEnumType check.
(GenerateParametersCheck): Ditto.
(GenerateImplementation): Ditto.
(GetNativeType): Ditto.
(JSValueToNative): Ditto.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::loadInternal): Use enum values instead of keywords.
(WebCore::HTMLMediaElement::textTrackModeChanged): Ditto.
(WebCore::HTMLMediaElement::textTrackKindChanged): Ditto.
(WebCore::HTMLMediaElement::textTrackAddCues): Ditto.
(WebCore::HTMLMediaElement::textTrackAddCue): Ditto.
(WebCore::HTMLMediaElement::addTextTrack): Ditto.
(WebCore::HTMLMediaElement::configureTextTrackGroup): Ditto.
(WebCore::HTMLMediaElement::setSelectedTextTrack): Ditto.
(WebCore::HTMLMediaElement::configureTextTracks): Ditto.
(WebCore::HTMLMediaElement::hasClosedCaptions): Ditto.
(WebCore::HTMLMediaElement::configureTextTrackDisplay): Ditto.
(WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): Ditto.
(WebCore::toPlatform): Added helpers for the outOfBandTrackSources function.
(WebCore::HTMLMediaElement::outOfBandTrackSources): Removed unneeded fastHasAttribute
check since getNonEmptyURLAttribute already returns an empty URL when the attribute is
not present. Changed to use enum values instead of keywords.

* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::parseAttribute): Use new setKindKeywordIgnoringASCIICase
function rather than calling setKind and convertToASCIILowercase. Also use ensureTrack
instead of track since the latter is a cover that calls it and dumbs down the return type.
(WebCore::HTMLTrackElement::kind): Changed return type to const AtomicString& since
that's what we will have for kind keywords and because it matches what we normally have
for attribute getting fuctions. Also use ensureTrack.
(WebCore::HTMLTrackElement::setKind): Changed argument to AtomicString so we don't waste
time making a string and then destroying it before turning it into an AtomicString so it
can be an attribute value.
(WebCore::HTMLTrackElement::srclang): Changed return type to const AtomicString& as is
customary and efficient for attribute value convenience functions. Also use fastGetAttribute.
(WebCore::HTMLTrackElement::setSrclang): Deleted.
(WebCore::HTMLTrackElement::label): Ditto.
(WebCore::HTMLTrackElement::setLabel): Deleted.
(WebCore::HTMLTrackElement::setIsDefault): Deleted.
(WebCore::HTMLTrackElement::scheduleLoad): Use enum values instead of keywords.

* html/HTMLTrackElement.h: Use pragma once. Update for changes mentioned above.
Also mark things final instead of override as per our recent style discussion.

* html/HTMLTrackElement.idl: Use [Reflect] for srclang and label.

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Use enum value
instead of keyword.
(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Ditto.

* html/track/AudioTrack.cpp:
(WebCore::AudioTrack::AudioTrack): Use new base class MediaTrackBase.

* html/track/AudioTrack.h: Use pragma once. Make base class be MediaTrackBase instead
of TrackBase.

* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::setMode): Change argument type to enum instead of string.
(WebCore::toPrivate): Added. Helper for setModeInternal.
(WebCore::InbandTextTrack::setModeInternal): Change argument type to enum instead of string.
(WebCore::InbandTextTrack::updateKindFromPrivate): Use enum instead of string to call setKind.

* html/track/InbandTextTrack.h: Use pragma once. Use TextTrackMode for argument types.

* html/track/TextTrack.cpp:
(WebCore::captionsKeyword): Converted this to a non-member function since it is now
private to this file.
(WebCore::descriptionsKeyword): Ditto.
(WebCore::chaptersKeyword): Ditto.
(WebCore::metadataKeyword): Ditto.
(WebCore::forcedKeyword): Ditto.
(WebCore::TextTrack::disabledKeyword): Deleted.
(WebCore::TextTrack::hiddenKeyword): Deleted.
(WebCore::TextTrack::showingKeyword): Deleted.
(WebCore::TextTrack::TextTrack): Moved some initialization to be done in the header where
the data members are defined. Put the code that is the equivalent to setKindInternal here,
because it turns out it's not needed anywhere else. Over time we might change the types
involved and there's no need to have that be across multiple functions.
(WebCore::TextTrack::~TextTrack): Removed unneeded call to clearClient, right when the
object is about to be destroyed. Perhaps there was an illusion that the old call might
be a virtual function call that invokes the clearClient from a derived class, but that
doesn't work in a destructor, so this code was only clearing out the data member and
that does not need to be done.
(WebCore::TextTrack::isValidKind): Deleted.
(WebCore::TextTrack::enabled): Use enum value instead of keyword.
(WebCore::TextTrack::kindKeyword): Added. Function for callers who need a string, not the
enum value.
(WebCore::TextTrack::setKind): Take enum value instead of keyword. Also changed since
we store the kind in a data member in this class, not inherited.
(WebCore::TextTrack::setKindKeywordIgnoringASCIICase): Added. For HTMLTrackElement to use
when setting the kind attribute.
(WebCore::TextTrack::setMode): Take enum value instread of keyword. Also removed assertion
since the enum already makes it intrinsically clear what values are valid, unlike a string.
(WebCore::TextTrack::cues): Use enum value instead of keyword.
(WebCore::TextTrack::activeCues): Ditto.
(WebCore::TextTrack::addCue): Ditto.
(WebCore::TextTrack::ensureVTTRegionList): Changed return type to reference.
(WebCore::TextTrack::regions): Use enum value instead of keyword.
(WebCore::TextTrack::addRegion): Use reference.
(WebCore::TextTrack::cueDidChange): Ditto.
(WebCore::TextTrack::isRendered): Use enum values instead of keywords. Also write to be
a boolean expression instead of a couple different if statements.
(WebCore::TextTrack::ensureTextTrackCueList): Changed return type to reference.
(WebCore::TextTrack::isMainProgramContent): Use enum value instead of keyword.
(WebCore::TextTrack::containsOnlyForcedSubtitles): Ditto.

* html/track/TextTrack.h: Use pragma once. Removed unneeded include. Added enums for
TextTrackKind and TextTrackMode. Updated for changes to functions listed above.
Added m_mode and m_kind and initialized those data members and some others.

* html/track/TextTrack.idl: Tweaked formatting. Used ImplementedAs for the kind
attribute rather than using a CustomSetter. This preserves the strange behavior
where setting kind does nothing when !ENABLE(MEDIA_SOURCE). If we discover we don't
need that, then we won't need ImplementedAs any more either.

* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Use enum instad of keyword.
(WebCore::TextTrackCue::isActive): Ditto.

* html/track/TrackBase.cpp:
(WebCore::TrackBase::TrackBase): Removed unneeded initialization that is handled in
the data member definition in the header now.
(WebCore::MediaTrackBase::MediaTrackBase): Added. Calls through to TrackBase.
(WebCore::MediaTrackBase::setKind): Moved to MediaTrackBase from TrackBase, because
this isn't needed for text tracks.
(WebCore::MediaTrackBase::setKindInternal): Ditto.

* html/track/TrackBase.h: Use pragma once. Move kind, setKind, isValidKind, defaultKindKeyword,
setKindInternal, and m_kind all to a derived class, MediaTrackBase, since TextTrack doesn't need
any of those any more. Later we might adopt enumerations more and it's possible the need for
MediaTrackBase will go away.

* html/track/VideoTrack.cpp:
(WebCore::VideoTrack::VideoTrack): Updated to use MediaTrackBase.
(WebCore::VideoTrack::setLanguage): Ditto.

* html/track/VideoTrack.h: Use pragma once. Removed unneeded header include.
Derive from MediaTrackBase instead of TrackBase.

* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::sortedTrackListForMenu): Use enum values instead
of keywords.
(WebCore::CaptionUserPreferences::textTrackSelectionScore): Ditto.
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore): Ditto.
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu): Ditto. Also used
kindKeyword since we want a string for logging.
* platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
(WebPlaybackSessionModelMediaElement::updateLegibleOptions): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200317 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/bindings/js/JSTextTrackCustom.cpp
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/html/HTMLTrackElement.idl
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/track/AudioTrack.cpp
Source/WebCore/html/track/AudioTrack.h
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/TextTrack.idl
Source/WebCore/html/track/TextTrackCue.cpp
Source/WebCore/html/track/TrackBase.cpp
Source/WebCore/html/track/TrackBase.h
Source/WebCore/html/track/VideoTrack.cpp
Source/WebCore/html/track/VideoTrack.h
Source/WebCore/page/CaptionUserPreferences.cpp
Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm

index 081b519..14e1915 100644 (file)
@@ -1,3 +1,185 @@
+2016-05-01  Darin Adler  <darin@apple.com>
+
+        Stop using string-based enumerations in TextTrack, and eliminate support for string-based enumerations
+        https://bugs.webkit.org/show_bug.cgi?id=157253
+
+        Reviewed by Chris Dumez.
+
+        This was the most difficult case to convert from the old style of enumeration to enum class.
+        Afterward there is a bit of messy duplication, but it still seems like an improvement overall.
+
+        After this patch, I plan to change the rule for the name of the enumeration; instead of
+        living at the top level of the WebCore namespace, we will look for them inside the class for the
+        first interface defined in the same file along with the enumeration, and remove the name prefix,
+        if the interfaces's name is a prefix of the enumerations's name.
+
+        Once that's done, next step is to do something in the bindings for dictionaries. And adopt both the
+        enumeration and dictionary mechanisms more widely, and remove the old use of "dictionary" as a type name.
+
+        * Modules/mediasource/MediaSource.cpp:
+        (WebCore::MediaSource::removeSourceBuffer): Use enum values instead of keywords.
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::textTrackModeChanged): Ditto.
+
+        * bindings/js/JSTextTrackCustom.cpp:
+        (WebCore::JSTextTrack::setKind): Deleted.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (IsStringBasedEnumType): Deleted.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetEnumerationImplementationContent): Removed IsStringBasedEnumType check.
+        (GenerateParametersCheck): Ditto.
+        (GenerateImplementation): Ditto.
+        (GetNativeType): Ditto.
+        (JSValueToNative): Ditto.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::loadInternal): Use enum values instead of keywords.
+        (WebCore::HTMLMediaElement::textTrackModeChanged): Ditto.
+        (WebCore::HTMLMediaElement::textTrackKindChanged): Ditto.
+        (WebCore::HTMLMediaElement::textTrackAddCues): Ditto.
+        (WebCore::HTMLMediaElement::textTrackAddCue): Ditto.
+        (WebCore::HTMLMediaElement::addTextTrack): Ditto.
+        (WebCore::HTMLMediaElement::configureTextTrackGroup): Ditto.
+        (WebCore::HTMLMediaElement::setSelectedTextTrack): Ditto.
+        (WebCore::HTMLMediaElement::configureTextTracks): Ditto.
+        (WebCore::HTMLMediaElement::hasClosedCaptions): Ditto.
+        (WebCore::HTMLMediaElement::configureTextTrackDisplay): Ditto.
+        (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): Ditto.
+        (WebCore::toPlatform): Added helpers for the outOfBandTrackSources function.
+        (WebCore::HTMLMediaElement::outOfBandTrackSources): Removed unneeded fastHasAttribute
+        check since getNonEmptyURLAttribute already returns an empty URL when the attribute is
+        not present. Changed to use enum values instead of keywords.
+
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::parseAttribute): Use new setKindKeywordIgnoringASCIICase
+        function rather than calling setKind and convertToASCIILowercase. Also use ensureTrack
+        instead of track since the latter is a cover that calls it and dumbs down the return type.
+        (WebCore::HTMLTrackElement::kind): Changed return type to const AtomicString& since
+        that's what we will have for kind keywords and because it matches what we normally have
+        for attribute getting fuctions. Also use ensureTrack.
+        (WebCore::HTMLTrackElement::setKind): Changed argument to AtomicString so we don't waste
+        time making a string and then destroying it before turning it into an AtomicString so it
+        can be an attribute value.
+        (WebCore::HTMLTrackElement::srclang): Changed return type to const AtomicString& as is
+        customary and efficient for attribute value convenience functions. Also use fastGetAttribute.
+        (WebCore::HTMLTrackElement::setSrclang): Deleted.
+        (WebCore::HTMLTrackElement::label): Ditto.
+        (WebCore::HTMLTrackElement::setLabel): Deleted.
+        (WebCore::HTMLTrackElement::setIsDefault): Deleted.
+        (WebCore::HTMLTrackElement::scheduleLoad): Use enum values instead of keywords.
+
+        * html/HTMLTrackElement.h: Use pragma once. Update for changes mentioned above.
+        Also mark things final instead of override as per our recent style discussion.
+
+        * html/HTMLTrackElement.idl: Use [Reflect] for srclang and label.
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Use enum value
+        instead of keyword.
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Ditto.
+
+        * html/track/AudioTrack.cpp:
+        (WebCore::AudioTrack::AudioTrack): Use new base class MediaTrackBase.
+
+        * html/track/AudioTrack.h: Use pragma once. Make base class be MediaTrackBase instead
+        of TrackBase.
+
+        * html/track/InbandTextTrack.cpp:
+        (WebCore::InbandTextTrack::setMode): Change argument type to enum instead of string.
+        (WebCore::toPrivate): Added. Helper for setModeInternal.
+        (WebCore::InbandTextTrack::setModeInternal): Change argument type to enum instead of string.
+        (WebCore::InbandTextTrack::updateKindFromPrivate): Use enum instead of string to call setKind.
+
+        * html/track/InbandTextTrack.h: Use pragma once. Use TextTrackMode for argument types.
+
+        * html/track/TextTrack.cpp:
+        (WebCore::captionsKeyword): Converted this to a non-member function since it is now
+        private to this file.
+        (WebCore::descriptionsKeyword): Ditto.
+        (WebCore::chaptersKeyword): Ditto.
+        (WebCore::metadataKeyword): Ditto.
+        (WebCore::forcedKeyword): Ditto.
+        (WebCore::TextTrack::disabledKeyword): Deleted.
+        (WebCore::TextTrack::hiddenKeyword): Deleted.
+        (WebCore::TextTrack::showingKeyword): Deleted.
+        (WebCore::TextTrack::TextTrack): Moved some initialization to be done in the header where
+        the data members are defined. Put the code that is the equivalent to setKindInternal here,
+        because it turns out it's not needed anywhere else. Over time we might change the types
+        involved and there's no need to have that be across multiple functions.
+        (WebCore::TextTrack::~TextTrack): Removed unneeded call to clearClient, right when the
+        object is about to be destroyed. Perhaps there was an illusion that the old call might
+        be a virtual function call that invokes the clearClient from a derived class, but that
+        doesn't work in a destructor, so this code was only clearing out the data member and
+        that does not need to be done.
+        (WebCore::TextTrack::isValidKind): Deleted.
+        (WebCore::TextTrack::enabled): Use enum value instead of keyword.
+        (WebCore::TextTrack::kindKeyword): Added. Function for callers who need a string, not the
+        enum value.
+        (WebCore::TextTrack::setKind): Take enum value instead of keyword. Also changed since
+        we store the kind in a data member in this class, not inherited.
+        (WebCore::TextTrack::setKindKeywordIgnoringASCIICase): Added. For HTMLTrackElement to use
+        when setting the kind attribute.
+        (WebCore::TextTrack::setMode): Take enum value instread of keyword. Also removed assertion
+        since the enum already makes it intrinsically clear what values are valid, unlike a string.
+        (WebCore::TextTrack::cues): Use enum value instead of keyword.
+        (WebCore::TextTrack::activeCues): Ditto.
+        (WebCore::TextTrack::addCue): Ditto.
+        (WebCore::TextTrack::ensureVTTRegionList): Changed return type to reference.
+        (WebCore::TextTrack::regions): Use enum value instead of keyword.
+        (WebCore::TextTrack::addRegion): Use reference.
+        (WebCore::TextTrack::cueDidChange): Ditto.
+        (WebCore::TextTrack::isRendered): Use enum values instead of keywords. Also write to be
+        a boolean expression instead of a couple different if statements.
+        (WebCore::TextTrack::ensureTextTrackCueList): Changed return type to reference.
+        (WebCore::TextTrack::isMainProgramContent): Use enum value instead of keyword.
+        (WebCore::TextTrack::containsOnlyForcedSubtitles): Ditto.
+
+        * html/track/TextTrack.h: Use pragma once. Removed unneeded include. Added enums for
+        TextTrackKind and TextTrackMode. Updated for changes to functions listed above.
+        Added m_mode and m_kind and initialized those data members and some others.
+
+        * html/track/TextTrack.idl: Tweaked formatting. Used ImplementedAs for the kind
+        attribute rather than using a CustomSetter. This preserves the strange behavior
+        where setting kind does nothing when !ENABLE(MEDIA_SOURCE). If we discover we don't
+        need that, then we won't need ImplementedAs any more either.
+
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::dispatchEvent): Use enum instad of keyword.
+        (WebCore::TextTrackCue::isActive): Ditto.
+
+        * html/track/TrackBase.cpp:
+        (WebCore::TrackBase::TrackBase): Removed unneeded initialization that is handled in
+        the data member definition in the header now.
+        (WebCore::MediaTrackBase::MediaTrackBase): Added. Calls through to TrackBase.
+        (WebCore::MediaTrackBase::setKind): Moved to MediaTrackBase from TrackBase, because
+        this isn't needed for text tracks.
+        (WebCore::MediaTrackBase::setKindInternal): Ditto.
+
+        * html/track/TrackBase.h: Use pragma once. Move kind, setKind, isValidKind, defaultKindKeyword,
+        setKindInternal, and m_kind all to a derived class, MediaTrackBase, since TextTrack doesn't need
+        any of those any more. Later we might adopt enumerations more and it's possible the need for
+        MediaTrackBase will go away.
+
+        * html/track/VideoTrack.cpp:
+        (WebCore::VideoTrack::VideoTrack): Updated to use MediaTrackBase.
+        (WebCore::VideoTrack::setLanguage): Ditto.
+
+        * html/track/VideoTrack.h: Use pragma once. Removed unneeded header include.
+        Derive from MediaTrackBase instead of TrackBase.
+
+        * page/CaptionUserPreferences.cpp:
+        (WebCore::CaptionUserPreferences::sortedTrackListForMenu): Use enum values instead
+        of keywords.
+        (WebCore::CaptionUserPreferences::textTrackSelectionScore): Ditto.
+        * page/CaptionUserPreferencesMediaAF.cpp:
+        (WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore): Ditto.
+        (WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu): Ditto. Also used
+        kindKeyword since we want a string for logging.
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
+        (WebPlaybackSessionModelMediaElement::updateLegibleOptions): Ditto.
+
 2016-05-01  Chris Dumez  <cdumez@apple.com>
 
         Pass reference instead of pointer to IDL attribute setters if not nullable
index c1bd88b..1a09c3e 100644 (file)
@@ -671,7 +671,7 @@ void MediaSource::removeSourceBuffer(SourceBuffer& buffer, ExceptionCode& ec)
 
             // 9.3.2 If the mode attribute on the TextTrack object is set to "showing" or "hidden", then
             // set the removed enabled text track flag to true.
-            if (track->mode() == TextTrack::showingKeyword() || track->mode() == TextTrack::hiddenKeyword())
+            if (track->mode() == TextTrackMode::Showing || track->mode() == TextTrackMode::Hidden)
                 removedEnabledTextTrack = true;
 
             // 9.3.3 Remove the TextTrack object from the HTMLMediaElement textTracks list.
index b488b35..bc4922b 100644 (file)
@@ -1674,7 +1674,7 @@ void SourceBuffer::textTrackModeChanged(TextTrack* track)
     // 2.4.5 Changes to selected/enabled track state
     // If a text track mode becomes "disabled" and the SourceBuffer associated with this track is not
     // associated with any other enabled or selected track, then run the following steps:
-    if (track->mode() == TextTrack::disabledKeyword()
+    if (track->mode() == TextTrackMode::Disabled
         && (!m_videoTracks || !m_videoTracks->isAnyTrackEnabled())
         && (!m_audioTracks || !m_audioTracks->isAnyTrackEnabled())
         && (!m_textTracks || !m_textTracks->isAnyTrackEnabled())) {
index 7fce6ad..9448bae 100644 (file)
@@ -41,19 +41,6 @@ void JSTextTrack::visitAdditionalChildren(SlotVisitor& visitor)
     visitor.addOpaqueRoot(root(&wrapped()));
 }
 
-void JSTextTrack::setKind(ExecState& state, JSValue value)
-{
-#if ENABLE(MEDIA_SOURCE)
-    auto& string = value.toString(&state)->value(&state);
-    if (state.hadException())
-        return;
-    wrapped().setKind(string);
-#else
-    UNUSED_PARAM(state);
-    UNUSED_PARAM(value);
-#endif
-}
-
 void JSTextTrack::setLanguage(ExecState& state, JSValue value)
 {
 #if ENABLE(MEDIA_SOURCE)
index 13c64e3..00e3ff2 100644 (file)
@@ -129,14 +129,6 @@ my %svgTypeWithWritablePropertiesNeedingTearOff = (
     "SVGMatrix" => 1
 );
 
-# FIXME: Remove each enum from this hash as we convert it from the string-based
-# enumeration to using an actual enum class in the C++. Once that is done, we should
-# remove this hash and the function that calls it.
-my %stringBasedEnumerationHash = (
-    "TextTrackKind" => 1,
-    "TextTrackMode" => 1,
-);
-
 # Cache of IDL file pathnames.
 my $idlFiles;
 my $cachedInterfaces = {};
@@ -381,16 +373,6 @@ sub IsStringType
     return $type eq "DOMString";
 }
 
-sub IsStringBasedEnumType
-{
-    my $object = shift;
-    my $type = shift;
-
-    return 0 if !$object->IsEnumType($type);
-    return 1 if exists $stringBasedEnumerationHash{$type};
-    return 0;
-}
-
 sub IsEnumType
 {
     my $object = shift;
index 771851c..33a38d0 100644 (file)
@@ -838,7 +838,6 @@ sub GetEnumerationImplementationContent
     my $result = "";
     foreach my $enumeration (@$enumerations) {
         my $name = $enumeration->name;
-        next if $codeGenerator->IsStringBasedEnumType($name);
 
         my $className = GetEnumerationClassName($name);
 
@@ -2845,16 +2844,6 @@ sub GenerateImplementation
                 push(@implContent, "    if (UNLIKELY(state->hadException()))\n");
                 push(@implContent, "        return false;\n");
 
-                if ($codeGenerator->IsStringBasedEnumType($type)) {
-                    my @enumValues = $codeGenerator->ValidEnumValues($type);
-                    my @enumChecks = ();
-                    foreach my $enumValue (@enumValues) {
-                        push(@enumChecks, "nativeValue != \"$enumValue\"");
-                    }
-                    push (@implContent, "    if (" . join(" && ", @enumChecks) . ")\n");
-                    push (@implContent, "        return false;\n");
-                }
-
                 if ($codeGenerator->IsEnumType($type)) {
                     push (@implContent, "    if (UNLIKELY(!nativeValue))\n");
                     push (@implContent, "        return false;\n");
@@ -2908,7 +2897,7 @@ sub GenerateImplementation
                     my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
                     if ($codeGenerator->IsTypedArrayType($type) and not $type eq "ArrayBuffer") {
                         push(@arguments, "nativeValue.get()");
-                    } elsif ($codeGenerator->IsEnumType($type) and not $codeGenerator->IsStringBasedEnumType($type)) {
+                    } elsif ($codeGenerator->IsEnumType($type)) {
                         push(@arguments, "nativeValue.value()");
                     } else {
                         push(@arguments, $shouldPassByReference ? "*nativeValue" : "nativeValue");
@@ -3635,49 +3624,6 @@ sub GenerateParametersCheck
                 push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
                 push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
             }
-        } elsif ($codeGenerator->IsStringBasedEnumType($argType)) {
-            $implIncludes{"<runtime/Error.h>"} = 1;
-
-            my $exceptionCheck = sub {
-                my $indent = shift;
-                push(@$outputArray, $indent . "    if (UNLIKELY(state->hadException()))\n");
-                push(@$outputArray, $indent . "        return JSValue::encode(jsUndefined());\n");
-            };
-
-            my $enumValueCheck = sub {
-                my $indent = shift;
-                my @enumValues = $codeGenerator->ValidEnumValues($argType);
-                my @enumChecks = ();
-                my $enums = 0;
-                foreach my $enumValue (@enumValues) {
-                    push(@enumChecks, "${name} != \"$enumValue\"");
-                    if (!$enums) {
-                        $enums = "\\\"$enumValue\\\"";
-                    } else {
-                        $enums = $enums . ", \\\"" . $enumValue . "\\\"";
-                    }
-                }
-                push(@$outputArray, $indent . "    if (" . join(" && ", @enumChecks) . ")\n");
-                push(@$outputArray, $indent . "        return throwArgumentMustBeEnumError(*state, $argsIndex, \"$name\", \"$interfaceName\", $quotedFunctionName, \"$enums\");\n");
-            };
-
-            my $argValue = "state->argument($argsIndex)";
-            if ($parameter->isOptional && defined($parameter->default)) {
-                push(@$outputArray, "    String $name;\n");
-                push(@$outputArray, "    if (${argValue}.isUndefined())\n");
-                push(@$outputArray, "        $name = ASCIILiteral(" . $parameter->default . ");\n");
-                push(@$outputArray, "    else {\n");
-                push(@$outputArray, "        $name = state->uncheckedArgument($argsIndex).toWTFString(state);\n");
-                &$exceptionCheck("    ");
-                &$enumValueCheck("    ");
-                push(@$outputArray, "    }\n");
-            } else {
-                push(@$outputArray, "    // Keep pointer to the JSString in a local so we don't need to ref the String.\n");
-                push(@$outputArray, "    auto* ${name}String = ${argValue}.toString(state);\n");
-                push(@$outputArray, "    auto& $name = ${name}String->value(state);\n");
-                &$exceptionCheck("");
-                &$enumValueCheck("");
-            }
         } elsif ($codeGenerator->IsEnumType($argType)) {
             my $className = GetEnumerationClassName($argType);
             $implIncludes{"<runtime/Error.h>"} = 1;
@@ -4272,7 +4218,6 @@ sub GetNativeType
     my $arrayOrSequenceType = $codeGenerator->GetArrayOrSequenceType($type);
 
     return "Vector<" . GetNativeVectorInnerType($arrayOrSequenceType) . ">" if $arrayOrSequenceType;
-    return "String" if $codeGenerator->IsStringBasedEnumType($type);
     return "auto" if $codeGenerator->IsEnumType($type);
 
     # For all other types, the native type is a pointer with same type name as the IDL type.
@@ -4423,7 +4368,6 @@ sub JSValueToNative
     return "valueToDate(state, $value)" if $type eq "Date";
 
     return "to$type($value)" if $codeGenerator->IsTypedArrayType($type);
-    return "$value.toWTFString(state)" if $codeGenerator->IsStringBasedEnumType($type);
     return "parse" . GetEnumerationClassName($type) . "(*state, $value)" if $codeGenerator->IsEnumType($type);
 
     AddToImplIncludes("JS$type.h", $conditional);
index 920153c..a83ebb7 100644 (file)
@@ -1174,7 +1174,7 @@ void HTMLMediaElement::loadInternal()
         if (m_textTracks) {
             for (unsigned i = 0; i < m_textTracks->length(); ++i) {
                 TextTrack* track = m_textTracks->item(i);
-                if (track->mode() != TextTrack::disabledKeyword())
+                if (track->mode() != TextTrackMode::Disabled)
                     m_textTracksWhenResourceSelectionBegan.append(track);
             }
         }
@@ -1731,7 +1731,7 @@ void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
     // Mark this track as "configured" so configureTextTracks won't change the mode again.
     track->setHasBeenConfigured(true);
     
-    if (track->mode() != TextTrack::disabledKeyword() && trackIsLoaded)
+    if (track->mode() != TextTrackMode::Disabled && trackIsLoaded)
         textTrackAddCues(track, track->cues());
 
     configureTextTrackDisplay(AssumeTextTrackVisibilityChanged);
@@ -1755,8 +1755,8 @@ void HTMLMediaElement::videoTrackSelectedChanged(VideoTrack* track)
 
 void HTMLMediaElement::textTrackKindChanged(TextTrack* track)
 {
-    if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword() && track->mode() == TextTrack::showingKeyword())
-        track->setMode(TextTrack::hiddenKeyword());
+    if (track->kind() != TextTrackKind::Captions && track->kind() != TextTrackKind::Subtitles && track->mode() == TextTrackMode::Showing)
+        track->setMode(TextTrackMode::Hidden);
 }
 
 void HTMLMediaElement::beginIgnoringTrackDisplayUpdateRequests()
@@ -1774,7 +1774,7 @@ void HTMLMediaElement::endIgnoringTrackDisplayUpdateRequests()
 
 void HTMLMediaElement::textTrackAddCues(TextTrack* track, const TextTrackCueList* cues) 
 {
-    if (track->mode() == TextTrack::disabledKeyword())
+    if (track->mode() == TextTrackMode::Disabled)
         return;
 
     TrackDisplayUpdateScope scope(this);
@@ -1791,7 +1791,7 @@ void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* c
 
 void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtr<TextTrackCue> prpCue)
 {
-    if (track->mode() == TextTrack::disabledKeyword())
+    if (track->mode() == TextTrackMode::Disabled)
         return;
 
     RefPtr<TextTrackCue> cue = prpCue;
@@ -3664,7 +3664,7 @@ PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const S
     textTrack->setReadinessState(TextTrack::Loaded);
 
     // ... its text track mode to the text track hidden mode, and its text track list of cues to an empty list ...
-    textTrack->setMode(TextTrack::hiddenKeyword());
+    textTrack->setMode(TextTrackMode::Hidden);
 
     return textTrack.release();
 }
@@ -3792,11 +3792,11 @@ void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
     for (size_t i = 0; i < group.tracks.size(); ++i) {
         RefPtr<TextTrack> textTrack = group.tracks[i];
 
-        if (m_processingPreferenceChange && textTrack->mode() == TextTrack::showingKeyword())
+        if (m_processingPreferenceChange && textTrack->mode() == TextTrackMode::Showing)
             currentlyEnabledTracks.append(textTrack);
 
         int trackScore = captionPreferences ? captionPreferences->textTrackSelectionScore(textTrack.get(), this) : 0;
-        LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%p) -  '%s' track with language '%s' has score %i", this, textTrack->kind().string().utf8().data(), textTrack->language().string().utf8().data(), trackScore);
+        LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%p) -  '%s' track with language '%s' has score %i", this, textTrack->kindKeyword().string().utf8().data(), textTrack->language().string().utf8().data(), trackScore);
 
         if (trackScore) {
 
@@ -3861,12 +3861,12 @@ void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
         for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) {
             RefPtr<TextTrack> textTrack = currentlyEnabledTracks[i];
             if (textTrack != trackToEnable)
-                textTrack->setMode(TextTrack::disabledKeyword());
+                textTrack->setMode(TextTrackMode::Disabled);
         }
     }
 
     if (trackToEnable) {
-        trackToEnable->setMode(TextTrack::showingKeyword());
+        trackToEnable->setMode(TextTrackMode::Showing);
 
         // If user preferences indicate we should always display captions, make sure we reflect the
         // proper status via the webkitClosedCaptionsVisible API call:
@@ -3996,13 +3996,13 @@ void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect)
         for (int i = 0, length = trackList->length(); i < length; ++i) {
             TextTrack* track = trackList->item(i);
             if (!trackToSelect || track != trackToSelect)
-                track->setMode(TextTrack::disabledKeyword());
+                track->setMode(TextTrackMode::Disabled);
             else
-                track->setMode(TextTrack::showingKeyword());
+                track->setMode(TextTrackMode::Showing);
         }
     } else if (trackToSelect == TextTrack::captionMenuOffItem()) {
         for (int i = 0, length = trackList->length(); i < length; ++i)
-            trackList->item(i)->setMode(TextTrack::disabledKeyword());
+            trackList->item(i)->setMode(TextTrackMode::Disabled);
     }
 
     if (!document().page())
@@ -4039,20 +4039,20 @@ void HTMLMediaElement::configureTextTracks()
         if (!textTrack)
             continue;
 
-        String kind = textTrack->kind();
+        auto kind = textTrack->kind();
         TrackGroup* currentGroup;
-        if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captionsKeyword() || kind == TextTrack::forcedKeyword())
+        if (kind == TextTrackKind::Subtitles || kind == TextTrackKind::Captions || kind == TextTrackKind::Forced)
             currentGroup = &captionAndSubtitleTracks;
-        else if (kind == TextTrack::descriptionsKeyword())
+        else if (kind == TextTrackKind::Descriptions)
             currentGroup = &descriptionTracks;
-        else if (kind == TextTrack::chaptersKeyword())
+        else if (kind == TextTrackKind::Chapters)
             currentGroup = &chapterTracks;
-        else if (kind == TextTrack::metadataKeyword())
+        else if (kind == TextTrackKind::Metadata)
             currentGroup = &metadataTracks;
         else
             currentGroup = &otherTracks;
 
-        if (!currentGroup->visibleTrack && textTrack->mode() == TextTrack::showingKeyword())
+        if (!currentGroup->visibleTrack && textTrack->mode() == TextTrackMode::Showing)
             currentGroup->visibleTrack = textTrack;
         if (!currentGroup->defaultTrack && textTrack->isDefault())
             currentGroup->defaultTrack = textTrack;
@@ -5447,6 +5447,7 @@ PlatformLayer* HTMLMediaElement::platformLayer() const
 }
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+
 void HTMLMediaElement::setVideoFullscreenLayer(PlatformLayer* platformLayer)
 {
     m_videoFullscreenLayer = platformLayer;
@@ -5474,6 +5475,7 @@ void HTMLMediaElement::setVideoFullscreenGravity(MediaPlayer::VideoGravity gravi
     if (m_player)
         m_player->setVideoFullscreenGravity(gravity);
 }
+
 #endif
 
 bool HTMLMediaElement::hasClosedCaptions() const
@@ -5486,11 +5488,10 @@ bool HTMLMediaElement::hasClosedCaptions() const
         return false;
 
     for (unsigned i = 0; i < m_textTracks->length(); ++i) {
-        if (m_textTracks->item(i)->readinessState() == TextTrack::FailedToLoad)
+        auto& track = *m_textTracks->item(i);
+        if (track.readinessState() == TextTrack::FailedToLoad)
             continue;
-
-        if (m_textTracks->item(i)->kind() == TextTrack::captionsKeyword()
-            || m_textTracks->item(i)->kind() == TextTrack::subtitlesKeyword())
+        if (track.kind() == TextTrackKind::Captions || track.kind() == TextTrackKind::Subtitles)
             return true;
     }
 #endif
@@ -5757,7 +5758,7 @@ void HTMLMediaElement::configureTextTrackDisplay(TextTrackVisibilityCheckType ch
 
     bool haveVisibleTextTrack = false;
     for (unsigned i = 0; i < m_textTracks->length(); ++i) {
-        if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) {
+        if (m_textTracks->item(i)->mode() == TextTrackMode::Showing) {
             haveVisibleTextTrack = true;
             break;
         }
@@ -5831,12 +5832,10 @@ void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured(ReconfigureMod
     // captions and non-default tracks should be displayed based on language
     // preferences if the user has turned captions on).
     for (unsigned i = 0; i < m_textTracks->length(); ++i) {
-        
-        RefPtr<TextTrack> textTrack = m_textTracks->item(i);
-        String kind = textTrack->kind();
-
-        if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captionsKeyword())
-            textTrack->setHasBeenConfigured(false);
+        auto& track = *m_textTracks->item(i);
+        auto kind = track.kind();
+        if (kind == TextTrackKind::Subtitles || kind == TextTrackKind::Captions)
+            track.setHasBeenConfigured(false);
     }
 
     m_processingPreferenceChange = true;
@@ -6080,14 +6079,45 @@ String HTMLMediaElement::mediaPlayerUserAgent() const
 }
 
 #if ENABLE(AVF_CAPTIONS)
+
+static inline PlatformTextTrack::TrackKind toPlatform(TextTrackKind kind)
+{
+    switch (kind) {
+    case TextTrackKind::Captions:
+        return PlatformTextTrack::Caption;
+    case TextTrackKind::Chapters:
+        return PlatformTextTrack::Chapter;
+    case TextTrackKind::Descriptions:
+        return PlatformTextTrack::Description;
+    case TextTrackKind::Forced:
+        return PlatformTextTrack::Forced;
+    case TextTrackKind::Metadata:
+        return PlatformTextTrack::MetaData;
+    case TextTrackKind::Subtitles:
+        return PlatformTextTrack::Subtitle;
+    }
+    ASSERT_NOT_REACHED();
+    return PlatformTextTrack::Caption;
+}
+
+static inline PlatformTextTrack::TrackMode toPlatform(TextTrackMode mode)
+{
+    switch (mode) {
+    case TextTrackMode::Disabled:
+        return PlatformTextTrack::Disabled;
+    case TextTrackMode::Hidden:
+        return PlatformTextTrack::Hidden;
+    case TextTrackMode::Showing:
+        return PlatformTextTrack::Showing;
+    }
+    ASSERT_NOT_REACHED();
+    return PlatformTextTrack::Disabled;
+}
+
 Vector<RefPtr<PlatformTextTrack>> HTMLMediaElement::outOfBandTrackSources()
 {
     Vector<RefPtr<PlatformTextTrack>> outOfBandTrackSources;
     for (auto& trackElement : childrenOfType<HTMLTrackElement>(*this)) {
-        
-        if (!trackElement.fastHasAttribute(srcAttr))
-            continue;
-        
         URL url = trackElement.getNonEmptyURLAttribute(srcAttr);
         if (url.isEmpty())
             continue;
@@ -6095,33 +6125,28 @@ Vector<RefPtr<PlatformTextTrack>> HTMLMediaElement::outOfBandTrackSources()
         if (!document().contentSecurityPolicy()->allowMediaFromSource(url, trackElement.isInUserAgentShadowTree()))
             continue;
 
-        PlatformTextTrack::TrackKind platformKind = PlatformTextTrack::Caption;
-        if (trackElement.kind() == TextTrack::captionsKeyword())
-            platformKind = PlatformTextTrack::Caption;
-        else if (trackElement.kind() == TextTrack::subtitlesKeyword())
-            platformKind = PlatformTextTrack::Subtitle;
-        else if (trackElement.kind() == TextTrack::descriptionsKeyword())
-            platformKind = PlatformTextTrack::Description;
-        else if (trackElement.kind() == TextTrack::forcedKeyword())
-            platformKind = PlatformTextTrack::Forced;
-        else
+        auto& track = *trackElement.track();
+        auto kind = track.kind();
+
+        // FIXME: The switch statement below preserves existing behavior where we ignore chapters and metadata tracks.
+        // If we confirm this behavior is valuable, we should remove this comment. Otherwise, remove both comment and switch.
+        switch (kind) {
+        case TextTrackKind::Captions:
+        case TextTrackKind::Descriptions:
+        case TextTrackKind::Forced:
+        case TextTrackKind::Subtitles:
+            break;
+        case TextTrackKind::Chapters:
+        case TextTrackKind::Metadata:
             continue;
-        
-        const AtomicString& mode = trackElement.track()->mode();
-        
-        PlatformTextTrack::TrackMode platformMode = PlatformTextTrack::Disabled;
-        if (TextTrack::hiddenKeyword() == mode)
-            platformMode = PlatformTextTrack::Hidden;
-        else if (TextTrack::disabledKeyword() == mode)
-            platformMode = PlatformTextTrack::Disabled;
-        else if (TextTrack::showingKeyword() == mode)
-            platformMode = PlatformTextTrack::Showing;
-        
-        outOfBandTrackSources.append(PlatformTextTrack::createOutOfBand(trackElement.label(), trackElement.srclang(), url.string(), platformMode, platformKind, trackElement.track()->uniqueId(), trackElement.isDefault()));
+        }
+
+        outOfBandTrackSources.append(PlatformTextTrack::createOutOfBand(trackElement.label(), trackElement.srclang(), url.string(), toPlatform(track.mode()), toPlatform(kind), track.uniqueId(), trackElement.isDefault()));
     }
-    
+
     return outOfBandTrackSources;
 }
+
 #endif
 
 bool HTMLMediaElement::mediaPlayerNeedsSiteSpecificHacks() const
index fa77be7..454bc26 100644 (file)
@@ -102,46 +102,36 @@ void HTMLTrackElement::parseAttribute(const QualifiedName& name, const AtomicStr
         // 4.8.10.12.3 Sourcing out-of-band text tracks
         // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly...
         } else if (name == kindAttr)
-            track()->setKind(value.convertToASCIILowercase());
+            ensureTrack().setKindKeywordIgnoringASCIICase(value.string());
         else if (name == labelAttr)
-            track()->setLabel(value);
+            ensureTrack().setLabel(value);
         else if (name == srclangAttr)
-            track()->setLanguage(value);
+            ensureTrack().setLanguage(value);
         else if (name == defaultAttr)
-            track()->setIsDefault(!value.isNull());
+            ensureTrack().setIsDefault(!value.isNull());
     }
 
     HTMLElement::parseAttribute(name, value);
 }
 
-String HTMLTrackElement::kind()
+const AtomicString& HTMLTrackElement::kind()
 {
-    return track()->kind();
+    return ensureTrack().kindKeyword();
 }
 
-void HTMLTrackElement::setKind(const String& kind)
+void HTMLTrackElement::setKind(const AtomicString& kind)
 {
-    setAttribute(kindAttr, kind);
+    setAttributeWithoutSynchronization(kindAttr, kind);
 }
 
-String HTMLTrackElement::srclang() const
+const AtomicString& HTMLTrackElement::srclang() const
 {
-    return getAttribute(srclangAttr);
+    return fastGetAttribute(srclangAttr);
 }
 
-void HTMLTrackElement::setSrclang(const String& srclang)
+const AtomicString& HTMLTrackElement::label() const
 {
-    setAttribute(srclangAttr, srclang);
-}
-
-String HTMLTrackElement::label() const
-{
-    return getAttribute(labelAttr);
-}
-
-void HTMLTrackElement::setLabel(const String& label)
-{
-    setAttribute(labelAttr, label);
+    return fastGetAttribute(labelAttr);
 }
 
 bool HTMLTrackElement::isDefault() const
@@ -149,11 +139,6 @@ bool HTMLTrackElement::isDefault() const
     return fastHasAttribute(defaultAttr);
 }
 
-void HTMLTrackElement::setIsDefault(bool isDefault)
-{
-    setBooleanAttribute(defaultAttr, isDefault);
-}
-
 LoadableTextTrack& HTMLTrackElement::ensureTrack()
 {
     if (!m_track) {
@@ -189,7 +174,7 @@ void HTMLTrackElement::scheduleLoad()
         return;
 
     // 2. If the text track's text track mode is not set to one of hidden or showing, abort these steps.
-    if (ensureTrack().mode() != TextTrack::hiddenKeyword() && ensureTrack().mode() != TextTrack::showingKeyword())
+    if (ensureTrack().mode() != TextTrackMode::Hidden && ensureTrack().mode() != TextTrackMode::Showing)
         return;
 
     // 3. If the text track's track element does not have a media element as a parent, abort these steps.
index 6d152b4..d316d84 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef HTMLTrackElement_h
-#define HTMLTrackElement_h
+#pragma once
 
 #if ENABLE(VIDEO_TRACK)
+
 #include "HTMLElement.h"
 #include "LoadableTextTrack.h"
-#include "TextTrack.h"
 
 namespace WebCore {
 
@@ -39,17 +38,12 @@ class HTMLTrackElement final : public HTMLElement, public TextTrackClient {
 public:
     static Ref<HTMLTrackElement> create(const QualifiedName&, Document&);
 
-    String kind();
-    void setKind(const String&);
-
-    String srclang() const;
-    void setSrclang(const String&);
-
-    String label() const;
-    void setLabel(const String&);
+    const AtomicString& kind();
+    void setKind(const AtomicString&);
 
+    const AtomicString& srclang() const;
+    const AtomicString& label() const;
     bool isDefault() const;
-    void setIsDefault(bool);
 
     enum ReadyState { NONE = 0, LOADING = 1, LOADED = 2, TRACK_ERROR = 3 };
     ReadyState readyState();
@@ -68,24 +62,24 @@ private:
     HTMLTrackElement(const QualifiedName&, Document&);
     virtual ~HTMLTrackElement();
 
-    void parseAttribute(const QualifiedName&, const AtomicString&) override;
+    void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
-    void removedFrom(ContainerNode&) override;
+    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    void removedFrom(ContainerNode&) final;
 
-    bool isURLAttribute(const Attribute&) const override;
+    bool isURLAttribute(const Attribute&) const final;
 
     void loadTimerFired();
 
     HTMLMediaElement* mediaElement() const;
 
     // TextTrackClient
-    void textTrackModeChanged(TextTrack*) override;
-    void textTrackKindChanged(TextTrack*) override;
-    void textTrackAddCues(TextTrack*, const TextTrackCueList*) override;
-    void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) override;
-    void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>) override;
-    void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) override;
+    void textTrackModeChanged(TextTrack*) final;
+    void textTrackKindChanged(TextTrack*) final;
+    void textTrackAddCues(TextTrack*, const TextTrackCueList*) final;
+    void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) final;
+    void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>) final;
+    void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) final;
 
     LoadableTextTrack& ensureTrack();
     bool canLoadURL(const URL&);
@@ -97,4 +91,3 @@ private:
 }
 
 #endif
-#endif
index 023c706..01da9d9 100644 (file)
@@ -28,8 +28,8 @@
 ] interface HTMLTrackElement : HTMLElement {
     attribute DOMString kind;
     [Reflect, URL] attribute DOMString src;
-    attribute DOMString srclang;
-    attribute DOMString label;
+    [Reflect] attribute DOMString srclang;
+    [Reflect] attribute DOMString label;
     [Reflect] attribute boolean default;
 
     const unsigned short NONE = 0;
index 286f15a..d9c1f9d 100644 (file)
@@ -765,7 +765,7 @@ void MediaControlClosedCaptionsTrackListElement::updateDisplay()
             continue;
         }
 
-        if (displayMode != CaptionUserPreferences::Automatic && textTrack->mode() == TextTrack::showingKeyword()) {
+        if (displayMode != CaptionUserPreferences::Automatic && textTrack->mode() == TextTrackMode::Showing) {
             trackMenuItemSelected = true;
             trackItem->classList().add(selectedClassValue, ASSERT_NO_EXCEPTION);
         } else
@@ -1173,7 +1173,7 @@ void MediaControlTextTrackContainerElement::updateDisplay()
         LOG(Media, "MediaControlTextTrackContainerElement::updateDisplay(%p) - adding and positioning cue #%zu: \"%s\", start=%.2f, end=%.2f, line=%.2f", this, i, cue->text().utf8().data(), cue->startTime(), cue->endTime(), cue->line());
 
         RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize);
-        if (cue->track()->mode() == TextTrack::disabledKeyword())
+        if (cue->track()->mode() == TextTrackMode::Disabled)
             continue;
 
         VTTRegion* region = cue->track()->regions()->getRegionById(cue->regionId());
index a42e105..5af4761 100644 (file)
@@ -79,7 +79,7 @@ const AtomicString& AudioTrack::commentaryKeyword()
 }
 
 AudioTrack::AudioTrack(AudioTrackClient* client, PassRefPtr<AudioTrackPrivate> trackPrivate)
-    : TrackBase(TrackBase::AudioTrack, trackPrivate->id(), trackPrivate->label(), trackPrivate->language())
+    : MediaTrackBase(MediaTrackBase::AudioTrack, trackPrivate->id(), trackPrivate->label(), trackPrivate->language())
     , m_enabled(trackPrivate->enabled())
     , m_client(client)
     , m_private(trackPrivate)
index 08eaebf..2f39415 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef AudioTrack_h
-#define AudioTrack_h
-
-#include "PlatformExportMacros.h"
+#pragma once
 
 #if ENABLE(VIDEO_TRACK)
 
 #include "AudioTrackPrivate.h"
 #include "ExceptionCode.h"
+#include "PlatformExportMacros.h"
 #include "TrackBase.h"
-#include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -47,7 +44,7 @@ public:
     virtual void audioTrackEnabledChanged(AudioTrack*) = 0;
 };
 
-class AudioTrack final : public TrackBase, public AudioTrackPrivateClient {
+class AudioTrack final : public MediaTrackBase, public AudioTrackPrivateClient {
 public:
     static Ref<AudioTrack> create(AudioTrackClient* client, PassRefPtr<AudioTrackPrivate> trackPrivate)
     {
@@ -105,4 +102,3 @@ inline AudioTrack* toAudioTrack(TrackBase* track)
 } // namespace WebCore
 
 #endif
-#endif
index 875e7d8..3c10a44 100644 (file)
@@ -70,7 +70,7 @@ InbandTextTrack::InbandTextTrack(ScriptExecutionContext* context, TextTrackClien
 
 InbandTextTrack::~InbandTextTrack()
 {
-    m_private->setClient(0);
+    m_private->setClient(nullptr);
 }
 
 void InbandTextTrack::setPrivate(PassRefPtr<InbandTextTrackPrivate> trackPrivate)
@@ -81,7 +81,7 @@ void InbandTextTrack::setPrivate(PassRefPtr<InbandTextTrackPrivate> trackPrivate
     if (m_private == trackPrivate)
         return;
 
-    m_private->setClient(0);
+    m_private->setClient(nullptr);
     m_private = trackPrivate;
     m_private->setClient(this);
 
@@ -89,22 +89,29 @@ void InbandTextTrack::setPrivate(PassRefPtr<InbandTextTrackPrivate> trackPrivate
     updateKindFromPrivate();
 }
 
-void InbandTextTrack::setMode(const AtomicString& mode)
+void InbandTextTrack::setMode(TextTrackMode mode)
 {
     TextTrack::setMode(mode);
     setModeInternal(mode);
 }
 
-void InbandTextTrack::setModeInternal(const AtomicString& mode)
+static inline InbandTextTrackPrivate::Mode toPrivate(TextTrackMode mode)
 {
-    if (mode == TextTrack::disabledKeyword())
-        m_private->setMode(InbandTextTrackPrivate::Disabled);
-    else if (mode == TextTrack::hiddenKeyword())
-        m_private->setMode(InbandTextTrackPrivate::Hidden);
-    else if (mode == TextTrack::showingKeyword())
-        m_private->setMode(InbandTextTrackPrivate::Showing);
-    else
-        ASSERT_NOT_REACHED();
+    switch (mode) {
+    case TextTrackMode::Disabled:
+        return InbandTextTrackPrivate::Disabled;
+    case TextTrackMode::Hidden:
+        return InbandTextTrackPrivate::Hidden;
+    case TextTrackMode::Showing:
+        return InbandTextTrackPrivate::Showing;
+    }
+    ASSERT_NOT_REACHED();
+    return InbandTextTrackPrivate::Disabled;
+}
+
+void InbandTextTrack::setModeInternal(TextTrackMode mode)
+{
+    m_private->setMode(toPrivate(mode));
 }
 
 bool InbandTextTrack::isClosedCaptions() const
@@ -189,22 +196,22 @@ void InbandTextTrack::updateKindFromPrivate()
 {
     switch (m_private->kind()) {
     case InbandTextTrackPrivate::Subtitles:
-        setKind(TextTrack::subtitlesKeyword());
+        setKind(TextTrackKind::Subtitles);
         break;
     case InbandTextTrackPrivate::Captions:
-        setKind(TextTrack::captionsKeyword());
+        setKind(TextTrackKind::Captions);
         break;
     case InbandTextTrackPrivate::Descriptions:
-        setKind(TextTrack::descriptionsKeyword());
+        setKind(TextTrackKind::Descriptions);
         break;
     case InbandTextTrackPrivate::Chapters:
-        setKind(TextTrack::chaptersKeyword());
+        setKind(TextTrackKind::Chapters);
         break;
     case InbandTextTrackPrivate::Metadata:
-        setKind(TextTrack::metadataKeyword());
+        setKind(TextTrackKind::Metadata);
         break;
     case InbandTextTrackPrivate::Forced:
-        setKind(TextTrack::forcedKeyword());
+        setKind(TextTrackKind::Forced);
         break;
     case InbandTextTrackPrivate::None:
     default:
index 408bef0..a3aa010 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef InbandTextTrack_h
-#define InbandTextTrack_h
+#pragma once
 
 #if ENABLE(VIDEO_TRACK)
 
@@ -46,7 +45,7 @@ public:
     bool containsOnlyForcedSubtitles() const override;
     bool isMainProgramContent() const override;
     bool isEasyToRead() const override;
-    void setMode(const AtomicString&) override;
+    void setMode(TextTrackMode) override;
     size_t inbandTrackIndex();
 
     AtomicString inBandMetadataTrackDispatchType() const override;
@@ -56,7 +55,7 @@ public:
 protected:
     InbandTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
 
-    void setModeInternal(const AtomicString&);
+    void setModeInternal(TextTrackMode);
     void updateKindFromPrivate();
 
     RefPtr<InbandTextTrackPrivate> m_private;
@@ -94,5 +93,3 @@ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::InbandTextTrack)
 SPECIALIZE_TYPE_TRAITS_END()
 
 #endif // ENABLE(VIDEO_TRACK)
-
-#endif // InbandTextTrack_h
index 123d16c..a7d81be 100644 (file)
@@ -53,54 +53,36 @@ const AtomicString& TextTrack::subtitlesKeyword()
     return subtitles;
 }
 
-const AtomicString& TextTrack::captionsKeyword()
+static const AtomicString& captionsKeyword()
 {
     static NeverDestroyed<const AtomicString> captions("captions", AtomicString::ConstructFromLiteral);
     return captions;
 }
 
-const AtomicString& TextTrack::descriptionsKeyword()
+static const AtomicString& descriptionsKeyword()
 {
     static NeverDestroyed<const AtomicString> descriptions("descriptions", AtomicString::ConstructFromLiteral);
     return descriptions;
 }
 
-const AtomicString& TextTrack::chaptersKeyword()
+static const AtomicString& chaptersKeyword()
 {
     static NeverDestroyed<const AtomicString> chapters("chapters", AtomicString::ConstructFromLiteral);
     return chapters;
 }
 
-const AtomicString& TextTrack::metadataKeyword()
+static const AtomicString& metadataKeyword()
 {
     static NeverDestroyed<const AtomicString> metadata("metadata", AtomicString::ConstructFromLiteral);
     return metadata;
 }
     
-const AtomicString& TextTrack::forcedKeyword()
+static const AtomicString& forcedKeyword()
 {
     static NeverDestroyed<const AtomicString> forced("forced", AtomicString::ConstructFromLiteral);
     return forced;
 }
 
-const AtomicString& TextTrack::disabledKeyword()
-{
-    static NeverDestroyed<const AtomicString> open("disabled", AtomicString::ConstructFromLiteral);
-    return open;
-}
-
-const AtomicString& TextTrack::hiddenKeyword()
-{
-    static NeverDestroyed<const AtomicString> closed("hidden", AtomicString::ConstructFromLiteral);
-    return closed;
-}
-
-const AtomicString& TextTrack::showingKeyword()
-{
-    static NeverDestroyed<const AtomicString> ended("showing", AtomicString::ConstructFromLiteral);
-    return ended;
-}
-
 TextTrack* TextTrack::captionMenuOffItem()
 {
     static TextTrack& off = TextTrack::create(0, 0, "off menu item", "", "", "").leakRef();
@@ -115,18 +97,22 @@ TextTrack* TextTrack::captionMenuAutomaticItem()
 
 TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& id, const AtomicString& label, const AtomicString& language, TextTrackType type)
     : TrackBase(TrackBase::TextTrack, id, label, language)
-    , m_cues(0)
-    , m_regions(0)
     , m_scriptExecutionContext(context)
-    , m_mode(disabledKeyword().string())
     , m_client(client)
     , m_trackType(type)
-    , m_readinessState(NotLoaded)
     , m_trackIndex(invalidTrackIndex)
     , m_renderedTrackIndex(invalidTrackIndex)
-    , m_hasBeenConfigured(false)
 {
-    setKindInternal(kind);
+    if (kind == captionsKeyword())
+        m_kind = TextTrackKind::Captions;
+    else if (kind == chaptersKeyword())
+        m_kind = TextTrackKind::Chapters;
+    else if (kind == descriptionsKeyword())
+        m_kind = TextTrackKind::Descriptions;
+    else if (kind == forcedKeyword())
+        m_kind = TextTrackKind::Forced;
+    else if (kind == metadataKeyword())
+        m_kind = TextTrackKind::Metadata;
 }
 
 TextTrack::~TextTrack()
@@ -142,17 +128,11 @@ TextTrack::~TextTrack()
         for (size_t i = 0; i < m_regions->length(); ++i)
             m_regions->item(i)->setTrack(nullptr);
     }
-    clearClient();
-}
-
-bool TextTrack::isValidKind(const AtomicString& value) const
-{
-    return TextTrack::isValidKindKeyword(value);
 }
 
 bool TextTrack::enabled() const
 {
-    return m_mode != disabledKeyword();
+    return m_mode != TextTrackMode::Disabled;
 }
 
 bool TextTrack::isValidKindKeyword(const AtomicString& value)
@@ -173,20 +153,38 @@ bool TextTrack::isValidKindKeyword(const AtomicString& value)
     return false;
 }
 
-void TextTrack::setKind(const AtomicString& newKind)
+const AtomicString& TextTrack::kindKeyword() const
+{
+    switch (m_kind) {
+    case TextTrackKind::Captions:
+        return captionsKeyword();
+    case TextTrackKind::Chapters:
+        return chaptersKeyword();
+    case TextTrackKind::Descriptions:
+        return descriptionsKeyword();
+    case TextTrackKind::Forced:
+        return forcedKeyword();
+    case TextTrackKind::Metadata:
+        return metadataKeyword();
+    case TextTrackKind::Subtitles:
+        return subtitlesKeyword();
+    }
+    ASSERT_NOT_REACHED();
+    return subtitlesKeyword();
+}
+
+void TextTrack::setKind(TextTrackKind newKind)
 {
-    String oldKind = kind();
+    auto oldKind = m_kind;
 
-#if ENABLE(MEDIA_SOURCE)
     // 10.1 kind, on setting:
     // 1. If the value being assigned to this attribute does not match one of the text track kinds,
     // then abort these steps.
-    if (!isValidKindKeyword(newKind))
-        return;
 
     // 2. Update this attribute to the new value.
-    setKindInternal(newKind);
+    m_kind = newKind;
 
+#if ENABLE(MEDIA_SOURCE)
     // 3. If the sourceBuffer attribute on this track is not null, then queue a task to fire a simple
     // event named change at sourceBuffer.textTracks.
     if (m_sourceBuffer)
@@ -196,18 +194,38 @@ void TextTrack::setKind(const AtomicString& newKind)
     // the textTracks attribute on the HTMLMediaElement.
     if (mediaElement())
         mediaElement()->textTracks()->scheduleChangeEvent();
-#else
-    TrackBase::setKind(newKind);
 #endif
 
-    if (m_client && oldKind != kind())
+    if (m_client && oldKind != m_kind)
         m_client->textTrackKindChanged(this);
 }
 
-void TextTrack::setMode(const AtomicString& mode)
-{
-    ASSERT(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showingKeyword());
+void TextTrack::setKindKeywordIgnoringASCIICase(StringView keyword)
+{
+    if (equalLettersIgnoringASCIICase(keyword, "captions"))
+        setKind(TextTrackKind::Captions);
+    else if (equalLettersIgnoringASCIICase(keyword, "chapters"))
+        setKind(TextTrackKind::Chapters);
+    else if (equalLettersIgnoringASCIICase(keyword, "descriptions"))
+        setKind(TextTrackKind::Descriptions);
+    else if (equalLettersIgnoringASCIICase(keyword, "forced"))
+        setKind(TextTrackKind::Forced);
+    else if (equalLettersIgnoringASCIICase(keyword, "metadata"))
+        setKind(TextTrackKind::Metadata);
+    else if (equalLettersIgnoringASCIICase(keyword, "subtitles"))
+        setKind(TextTrackKind::Subtitles);
+#if !ENABLE(MEDIA_SOURCE)
+    // FIXME: This preserves the behavior of an older version of this code before refactoring.
+    // !ENABLE(MEDIA_SOURCE): unknown keywords all get turned into Subtitles.
+    // ENABLE(MEDIA_SOURCE): unknown keywords leave the old value for kind untouched.
+    // I am not sure that either of those is the correct behavior; should test and fix.
+    else
+        setKind(TextTrackKind::Subtitles);
+#endif
+}
 
+void TextTrack::setMode(TextTrackMode mode)
+{
     // On setting, if the new value isn't equal to what the attribute would currently
     // return, the new value must be processed as follows ...
     if (m_mode == mode)
@@ -215,10 +233,10 @@ void TextTrack::setMode(const AtomicString& mode)
 
     // If mode changes to disabled, remove this track's cues from the client
     // because they will no longer be accessible from the cues() function.
-    if (mode == disabledKeyword() && m_client && m_cues)
+    if (mode == TextTrackMode::Disabled && m_client && m_cues)
         m_client->textTrackRemoveCues(this, m_cues.get());
-         
-    if (mode != showingKeyword() && m_cues) {
+
+    if (mode != TextTrackMode::Showing && m_cues) {
         for (size_t i = 0; i < m_cues->length(); ++i) {
             TextTrackCue* cue = m_cues->item(i);
             if (cue->isRenderable())
@@ -239,9 +257,9 @@ TextTrackCueList* TextTrack::cues()
     // Otherwise, it must return null. When an object is returned, the
     // same object must be returned each time.
     // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-cues
-    if (m_mode != disabledKeyword())
-        return ensureTextTrackCueList();
-    return nullptr;
+    if (m_mode == TextTrackMode::Disabled)
+        return nullptr;
+    return &ensureTextTrackCueList();
 }
 
 void TextTrack::removeAllCues()
@@ -266,9 +284,9 @@ TextTrackCueList* TextTrack::activeCues() const
     // order. Otherwise, it must return null. When an object is returned, the
     // same object must be returned each time.
     // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecues
-    if (m_cues && m_mode != disabledKeyword())
-        return m_cues->activeCues();
-    return nullptr;
+    if (!m_cues || m_mode == TextTrackMode::Disabled)
+        return nullptr;
+    return m_cues->activeCues();
 }
 
 void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec)
@@ -284,7 +302,7 @@ void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec)
     // If a DataCue is added to a TextTrack via the addCue() method but the text track does not have its text
     // track kind set to metadata, throw a InvalidNodeTypeError exception and don't add the cue to the TextTrackList
     // of the TextTrack.
-    if (cue->cueType() == TextTrackCue::Data && kind() != metadataKeyword()) {
+    if (cue->cueType() == TextTrackCue::Data && m_kind != TextTrackKind::Metadata) {
         ec = INVALID_NODE_TYPE_ERR;
         return;
     }
@@ -305,7 +323,7 @@ void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec)
 
     // 2. Add cue to the method's TextTrack object's text track's text track list of cues.
     cue->setTrack(this);
-    ensureTextTrackCueList()->add(cue);
+    ensureTextTrackCueList().add(cue);
     
     if (m_client)
         m_client->textTrackAddCue(this, cue.get());
@@ -338,12 +356,12 @@ void TextTrack::removeCue(TextTrackCue* cue, ExceptionCode& ec)
         m_client->textTrackRemoveCue(this, cue);
 }
 
-VTTRegionList* TextTrack::ensureVTTRegionList()
+VTTRegionList& TextTrack::ensureVTTRegionList()
 {
     if (!m_regions)
         m_regions = VTTRegionList::create();
 
-    return m_regions.get();
+    return *m_regions;
 }
 
 VTTRegionList* TextTrack::regions()
@@ -354,10 +372,9 @@ VTTRegionList* TextTrack::regions()
     // the text track list of regions of the text track. Otherwise, it must
     // return null. When an object is returned, the same object must be returned
     // each time.
-    if (m_mode != disabledKeyword())
-        return ensureVTTRegionList();
-
-    return 0;
+    if (m_mode == TextTrackMode::Disabled)
+        return nullptr;
+    return &ensureVTTRegionList();
 }
 
 void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion)
@@ -366,7 +383,7 @@ void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion)
         return;
 
     RefPtr<VTTRegion> region = prpRegion;
-    VTTRegionList* regionList = ensureVTTRegionList();
+    VTTRegionList& regionList = ensureVTTRegionList();
 
     // 1. If the given region is in a text track list of regions, then remove
     // region from that text track list of regions.
@@ -378,7 +395,7 @@ void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion)
     // a region with the same identifier as region replace the values of that
     // region's width, height, anchor point, viewport anchor point and scroll
     // attributes with those of region.
-    VTTRegion* existingRegion = regionList->getRegionById(region->id());
+    VTTRegion* existingRegion = regionList.getRegionById(region->id());
     if (existingRegion) {
         existingRegion->updateParametersFromRegion(region.get());
         return;
@@ -387,7 +404,7 @@ void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion)
     // Otherwise: add region to the method's TextTrack object's text track
     // list of regions.
     region->setTrack(this);
-    regionList->add(region);
+    regionList.add(region);
 }
 
 void TextTrack::removeRegion(VTTRegion* region, ExceptionCode &ec)
@@ -426,7 +443,7 @@ void TextTrack::cueDidChange(TextTrackCue* cue)
         return;
 
     // Make sure the TextTrackCueList order is up-to-date.
-    ensureTextTrackCueList()->updateCueIndex(cue);
+    ensureTextTrackCueList().updateCueIndex(cue);
 
     // ... and add it back again.
     m_client->textTrackAddCue(this, cue);
@@ -450,21 +467,15 @@ void TextTrack::invalidateTrackIndex()
 
 bool TextTrack::isRendered()
 {
-    if (kind() != captionsKeyword() && kind() != subtitlesKeyword() && kind() != forcedKeyword())
-        return false;
-
-    if (m_mode != showingKeyword())
-        return false;
-
-    return true;
+    return (m_kind == TextTrackKind::Captions || m_kind == TextTrackKind::Subtitles || m_kind == TextTrackKind::Forced)
+        && m_mode == TextTrackMode::Showing;
 }
 
-TextTrackCueList* TextTrack::ensureTextTrackCueList()
+TextTrackCueList& TextTrack::ensureTextTrackCueList()
 {
     if (!m_cues)
         m_cues = TextTrackCueList::create();
-
-    return m_cues.get();
+    return *m_cues;
 }
 
 int TextTrack::trackIndexRelativeToRenderedTracks()
@@ -542,15 +553,16 @@ bool TextTrack::isMainProgramContent() const
     // directors commentary is not "main program" because it is not essential for the presentation. HTML5 doesn't have
     // a way to express this in a machine-reable form, it is typically done with the track label, so we assume that caption
     // tracks are main content and all other track types are not.
-    return kind() == captionsKeyword();
+    return m_kind == TextTrackKind::Captions;
 }
 
 bool TextTrack::containsOnlyForcedSubtitles() const
 {
-    return kind() == forcedKeyword();
+    return m_kind == TextTrackKind::Forced;
 }
 
 #if ENABLE(MEDIA_SOURCE)
+
 void TextTrack::setLanguage(const AtomicString& language)
 {
     // 11.1 language, on setting:
@@ -571,6 +583,7 @@ void TextTrack::setLanguage(const AtomicString& language)
     if (mediaElement())
         mediaElement()->textTracks()->scheduleChangeEvent();
 }
+
 #endif
 
 } // namespace WebCore
index 8454eac..5cb2490 100644 (file)
@@ -24,8 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TextTrack_h
-#define TextTrack_h
+#pragma once
 
 #if ENABLE(VIDEO_TRACK)
 
@@ -33,7 +32,6 @@
 #include "TextTrackCue.h"
 #include "TrackBase.h"
 #include "VTTCue.h"
-#include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -44,6 +42,9 @@ class TextTrackCueList;
 class VTTRegion;
 class VTTRegionList;
 
+enum class TextTrackKind { Subtitles, Captions, Descriptions, Chapters, Metadata, Forced };
+enum class TextTrackMode { Disabled, Hidden, Showing };
+
 class TextTrackClient {
 public:
     virtual ~TextTrackClient() { }
@@ -70,24 +71,25 @@ public:
     static TextTrack* captionMenuAutomaticItem();
 
     static const AtomicString& subtitlesKeyword();
-    static const AtomicString& captionsKeyword();
-    static const AtomicString& descriptionsKeyword();
-    static const AtomicString& chaptersKeyword();
-    static const AtomicString& metadataKeyword();
-    static const AtomicString& forcedKeyword();
-    const AtomicString& defaultKindKeyword() const override { return subtitlesKeyword(); }
     static bool isValidKindKeyword(const AtomicString&);
 
     static const AtomicString& disabledKeyword();
     static const AtomicString& hiddenKeyword();
     static const AtomicString& showingKeyword();
 
-    void setKind(const AtomicString&) override;
+    TextTrackKind kind() const;
+    void setKind(TextTrackKind);
+
+    TextTrackKind kindForBindings() const;
+    void setKindForBindings(TextTrackKind);
+
+    const AtomicString& kindKeyword() const;
+    void setKindKeywordIgnoringASCIICase(StringView);
 
     virtual AtomicString inBandMetadataTrackDispatchType() const { return emptyString(); }
 
-    AtomicString mode() const { return m_mode; }
-    virtual void setMode(const AtomicString&);
+    TextTrackMode mode() const;
+    virtual void setMode(TextTrackMode);
 
     enum ReadinessState { NotLoaded = 0, Loading = 1, Loaded = 2, FailedToLoad = 3 };
     ReadinessState readinessState() const { return m_readinessState; }
@@ -96,7 +98,7 @@ public:
     TextTrackCueList* cues();
     TextTrackCueList* activeCues() const;
 
-    void clearClient() override { m_client = 0; }
+    void clearClient() override { m_client = nullptr; }
     TextTrackClient* client() { return m_client; }
 
     void addCue(PassRefPtr<TextTrackCue>, ExceptionCode&);
@@ -151,26 +153,25 @@ protected:
     RefPtr<TextTrackCueList> m_cues;
 
 private:
-    bool isValidKind(const AtomicString&) const override;
-
     bool enabled() const override;
 
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
-    VTTRegionList* ensureVTTRegionList();
+    VTTRegionList& ensureVTTRegionList();
     RefPtr<VTTRegionList> m_regions;
 
-    TextTrackCueList* ensureTextTrackCueList();
+    TextTrackCueList& ensureTextTrackCueList();
 
     ScriptExecutionContext* m_scriptExecutionContext;
-    AtomicString m_mode;
+    TextTrackMode m_mode { TextTrackMode::Disabled };
+    TextTrackKind m_kind { TextTrackKind::Subtitles };
     TextTrackClient* m_client;
     TextTrackType m_trackType;
-    ReadinessState m_readinessState;
+    ReadinessState m_readinessState { NotLoaded };
     int m_trackIndex;
     int m_renderedTrackIndex;
-    bool m_hasBeenConfigured;
+    bool m_hasBeenConfigured { false };
 };
 
 inline TextTrack* toTextTrack(TrackBase* track)
@@ -179,7 +180,40 @@ inline TextTrack* toTextTrack(TrackBase* track)
     return static_cast<TextTrack*>(track);
 }
 
-} // namespace WebCore
+inline TextTrackMode TextTrack::mode() const
+{
+    return m_mode;
+}
+
+inline TextTrackKind TextTrack::kind() const
+{
+    return m_kind;
+}
+
+inline TextTrackKind TextTrack::kindForBindings() const
+{
+    return kind();
+}
+
+#if !ENABLE(MEDIA_SOURCE)
+
+inline void TextTrack::setKindForBindings(TextTrackKind)
+{
+    // FIXME: We are using kindForBindings only to implement this empty function, preserving the
+    // behavior of doing nothing when trying to set the kind, originally implemented in a custom setter.
+    // Once we no longer need this special case, we should remove kindForBindings and setKindForBindings.
+}
+
+#else
+
+inline void TextTrack::setKindForBindings(TextTrackKind kind)
+{
+    setKind(kind);
+}
 
 #endif
+
+
+} // namespace WebCore
+
 #endif
index ba1c161..bc16b3a 100644 (file)
@@ -23,8 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-enum TextTrackMode { "disabled",  "hidden",  "showing" };
-enum TextTrackKind { "subtitles",  "captions",  "descriptions",  "chapters", "metadata" };
+enum TextTrackMode { "disabled", "hidden", "showing" };
+enum TextTrackKind { "subtitles", "captions", "descriptions", "chapters", "metadata", "forced" };
 
 [
     Conditional=VIDEO_TRACK,
@@ -33,7 +33,7 @@ enum TextTrackKind { "subtitles",  "captions",  "descriptions",  "chapters", "me
     SkipVTableValidation,
 ] interface TextTrack : EventTarget {
     readonly attribute DOMString id;
-    [CustomSetter] attribute TextTrackKind kind;
+    [ImplementedAs=kindForBindings] attribute TextTrackKind kind;
     readonly attribute DOMString label;
     [CustomSetter] attribute DOMString language;
     readonly attribute DOMString inBandMetadataTrackDispatchType;
index a6b1dbb..42736fb 100644 (file)
@@ -193,7 +193,7 @@ void TextTrackCue::invalidateCueIndex()
 bool TextTrackCue::dispatchEvent(Event& event)
 {
     // When a TextTrack's mode is disabled: no cues are active, no events fired.
-    if (!track() || track()->mode() == TextTrack::disabledKeyword())
+    if (!track() || track()->mode() == TextTrackMode::Disabled)
         return false;
 
     return EventTarget::dispatchEvent(event);
@@ -201,7 +201,7 @@ bool TextTrackCue::dispatchEvent(Event& event)
 
 bool TextTrackCue::isActive()
 {
-    return m_isActive && track() && track()->mode() != TextTrack::disabledKeyword();
+    return m_isActive && track() && track()->mode() != TextTrackMode::Disabled;
 }
 
 void TextTrackCue::setIsActive(bool active)
index ff0b6ca..7dd8ddb 100644 (file)
 #include "config.h"
 #include "TrackBase.h"
 
-#include "HTMLMediaElement.h"
-
 #if ENABLE(VIDEO_TRACK)
 
+#include "HTMLMediaElement.h"
+
 namespace WebCore {
 
 static int s_uniqueId = 0;
 
 TrackBase::TrackBase(Type type, const AtomicString& id, const AtomicString& label, const AtomicString& language)
-    : m_mediaElement(0)
-#if ENABLE(MEDIA_SOURCE)
-    , m_sourceBuffer(0)
-#endif
-    , m_uniqueId(++s_uniqueId)
+    : m_uniqueId(++s_uniqueId)
     , m_id(id)
     , m_label(label)
     , m_language(language)
@@ -57,15 +53,18 @@ Element* TrackBase::element()
     return m_mediaElement;
 }
 
-void TrackBase::setKind(const AtomicString& kind)
+MediaTrackBase::MediaTrackBase(Type type, const AtomicString& id, const AtomicString& label, const AtomicString& language)
+    : TrackBase(type, id, label, language)
 {
-    setKindInternal(kind);
 }
 
-void TrackBase::setKindInternal(const AtomicString& kind)
+void MediaTrackBase::setKind(const AtomicString& kind)
 {
-    String oldKind = m_kind;
+    setKindInternal(kind);
+}
 
+void MediaTrackBase::setKindInternal(const AtomicString& kind)
+{
     if (isValidKind(kind))
         m_kind = kind;
     else
index 245988b..f75678f 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef TrackBase_h
-#define TrackBase_h
+#pragma once
 
 #if ENABLE(VIDEO_TRACK)
 
@@ -51,9 +50,6 @@ public:
     virtual AtomicString id() const { return m_id; }
     virtual void setId(const AtomicString& id) { m_id = id; }
 
-    AtomicString kind() const { return m_kind; }
-    virtual void setKind(const AtomicString&);
-
     AtomicString label() const { return m_label; }
     void setLabel(const AtomicString& label) { m_label = label; }
 
@@ -74,27 +70,37 @@ public:
 protected:
     TrackBase(Type, const AtomicString& id, const AtomicString& label, const AtomicString& language);
 
-    virtual bool isValidKind(const AtomicString&) const = 0;
-    virtual const AtomicString& defaultKindKeyword() const = 0;
-
-    void setKindInternal(const AtomicString&);
-
-    HTMLMediaElement* m_mediaElement;
+    HTMLMediaElement* m_mediaElement { nullptr };
 
 #if ENABLE(MEDIA_SOURCE)
-    SourceBuffer* m_sourceBuffer;
+    SourceBuffer* m_sourceBuffer { nullptr };
 #endif
 
 private:
     Type m_type;
     int m_uniqueId;
     AtomicString m_id;
-    AtomicString m_kind;
     AtomicString m_label;
     AtomicString m_language;
 };
 
+class MediaTrackBase : public TrackBase {
+public:
+    const AtomicString& kind() const { return m_kind; }
+    virtual void setKind(const AtomicString&);
+
+protected:
+    MediaTrackBase(Type, const AtomicString& id, const AtomicString& label, const AtomicString& language);
+
+    void setKindInternal(const AtomicString&);
+
+private:
+    virtual bool isValidKind(const AtomicString&) const = 0;
+    virtual const AtomicString& defaultKindKeyword() const = 0;
+
+    AtomicString m_kind;
+};
+
 } // namespace WebCore
 
 #endif
-#endif // TrackBase_h
index 7340938..be29688 100644 (file)
@@ -82,7 +82,7 @@ const AtomicString& VideoTrack::commentaryKeyword()
 }
 
 VideoTrack::VideoTrack(VideoTrackClient* client, PassRefPtr<VideoTrackPrivate> trackPrivate)
-    : TrackBase(TrackBase::VideoTrack, trackPrivate->id(), trackPrivate->label(), trackPrivate->language())
+    : MediaTrackBase(MediaTrackBase::VideoTrack, trackPrivate->id(), trackPrivate->label(), trackPrivate->language())
     , m_selected(trackPrivate->selected())
     , m_client(client)
     , m_private(trackPrivate)
@@ -208,7 +208,7 @@ void VideoTrack::setLanguage(const AtomicString& language)
     // FIXME(123926): Validate the BCP47-ness of langague.
 
     // 2. Update this attribute to the new value.
-    TrackBase::setLanguage(language);
+    MediaTrackBase::setLanguage(language);
 
     // 3. If the sourceBuffer attribute on this track is not null, then queue a task to fire a simple
     // event named change at sourceBuffer.videoTracks.
index 2743465..5c71f5f 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef VideoTrack_h
-#define VideoTrack_h
+#pragma once
 
 #if ENABLE(VIDEO_TRACK)
 
 #include "ExceptionCode.h"
 #include "TrackBase.h"
 #include "VideoTrackPrivate.h"
-#include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -46,7 +44,7 @@ public:
     virtual void videoTrackSelectedChanged(VideoTrack*) = 0;
 };
 
-class VideoTrack final : public TrackBase, public VideoTrackPrivateClient {
+class VideoTrack final : public MediaTrackBase, public VideoTrackPrivateClient {
 public:
     static Ref<VideoTrack> create(VideoTrackClient* client, PassRefPtr<VideoTrackPrivate> trackPrivate)
     {
@@ -113,4 +111,3 @@ inline VideoTrack* toVideoTrack(TrackBase* track)
 } // namespace WebCore
 
 #endif
-#endif
index 0e98c65..1d06c2d 100644 (file)
@@ -216,8 +216,8 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferences::sortedTrackListForMenu(TextTra
 
     for (unsigned i = 0, length = trackList->length(); i < length; ++i) {
         TextTrack* track = trackList->item(i);
-        const AtomicString& kind = track->kind();
-        if (kind == TextTrack::captionsKeyword() || kind == TextTrack::descriptionsKeyword() || kind == TextTrack::subtitlesKeyword())
+        auto kind = track->kind();
+        if (kind == TextTrackKind::Captions || kind == TextTrackKind::Descriptions || kind == TextTrackKind::Subtitles)
             tracksForMenu.append(track);
     }
 
@@ -265,7 +265,7 @@ Vector<RefPtr<AudioTrack>> CaptionUserPreferences::sortedTrackListForMenu(AudioT
 
 int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement*) const
 {
-    if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword())
+    if (track->kind() != TextTrackKind::Captions && track->kind() != TextTrackKind::Subtitles)
         return 0;
     
     if (!userPrefersSubtitles() && !userPrefersCaptions())
index 54fde98..3d116f9 100644 (file)
@@ -710,7 +710,7 @@ int CaptionUserPreferencesMediaAF::textTrackSelectionScore(TextTrack* track, HTM
     bool legacyOverride = mediaElement->webkitClosedCaptionsVisible();
     if (displayMode == AlwaysOn && (!userPrefersSubtitles() && !userPrefersCaptions() && !legacyOverride))
         return 0;
-    if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword() && track->kind() != TextTrack::forcedKeyword())
+    if (track->kind() != TextTrackKind::Captions && track->kind() != TextTrackKind::Subtitles && track->kind() != TextTrackKind::Forced)
         return 0;
     if (!track->isMainProgramContent())
         return 0;
@@ -771,7 +771,7 @@ int CaptionUserPreferencesMediaAF::textTrackSelectionScore(TextTrack* track, HTM
 
     if (userPrefersCaptions()) {
         // When the user prefers accessibility tracks, rank is SDH, then CC, then subtitles.
-        if (track->kind() == track->subtitlesKeyword())
+        if (track->kind() == TextTrackKind::Subtitles)
             trackScore = 1;
         else if (track->isClosedCaptions())
             trackScore = 2;
@@ -779,7 +779,7 @@ int CaptionUserPreferencesMediaAF::textTrackSelectionScore(TextTrack* track, HTM
             trackScore = 3;
     } else {
         // When the user prefers translation tracks, rank is subtitles, then SDH, then CC tracks.
-        if (track->kind() == track->subtitlesKeyword())
+        if (track->kind() == TextTrackKind::Subtitles)
             trackScore = 3;
         else if (!track->isClosedCaptions())
             trackScore = 2;
@@ -859,30 +859,30 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
         String language = displayNameForLanguageLocale(track->language());
 
         if (displayMode == Manual) {
-            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because selection mode is 'manual'", track->kind().string().utf8().data(), language.utf8().data());
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because selection mode is 'manual'", track->kindKeyword().string().utf8().data(), language.utf8().data());
             tracksForMenu.append(track);
             continue;
         }
 
-        const AtomicString& kind = track->kind();
-        if (kind != TextTrack::captionsKeyword() && kind != TextTrack::descriptionsKeyword() && kind != TextTrack::subtitlesKeyword())
+        auto kind = track->kind();
+        if (kind != TextTrackKind::Captions && kind != TextTrackKind::Descriptions && kind != TextTrackKind::Subtitles)
             continue;
 
         if (track->containsOnlyForcedSubtitles()) {
-            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it contains only forced subtitles", track->kind().string().utf8().data(), language.utf8().data());
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it contains only forced subtitles", track->kindKeyword().string().utf8().data(), language.utf8().data());
             continue;
         }
         
         if (track->isEasyToRead()) {
-            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is 'easy to read'", track->kind().string().utf8().data(), language.utf8().data());
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is 'easy to read'", track->kindKeyword().string().utf8().data(), language.utf8().data());
             if (!language.isEmpty())
                 languagesIncluded.add(language);
             tracksForMenu.append(track);
             continue;
         }
 
-        if (track->mode() == TextTrack::showingKeyword()) {
-            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is already visible", track->kind().string().utf8().data(), language.utf8().data());
+        if (track->mode() == TextTrackMode::Showing) {
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is already visible", track->kindKeyword().string().utf8().data(), language.utf8().data());
             if (!language.isEmpty())
                 languagesIncluded.add(language);
             tracksForMenu.append(track);
@@ -890,21 +890,21 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
         }
 
         if (!language.isEmpty() && track->isMainProgramContent()) {
-            bool isAccessibilityTrack = track->kind() == track->captionsKeyword();
+            bool isAccessibilityTrack = track->kind() == TextTrackKind::Captions;
             if (prefersAccessibilityTracks) {
                 // In the first pass, include only caption tracks if the user prefers accessibility tracks.
                 if (!isAccessibilityTrack && filterTrackList) {
-                    LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it is NOT an accessibility track", track->kind().string().utf8().data(), language.utf8().data());
+                    LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it is NOT an accessibility track", track->kindKeyword().string().utf8().data(), language.utf8().data());
                     continue;
                 }
             } else {
                 // In the first pass, only include the first non-CC or SDH track with each language if the user prefers translation tracks.
                 if (isAccessibilityTrack && filterTrackList) {
-                    LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it is an accessibility track", track->kind().string().utf8().data(), language.utf8().data());
+                    LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it is an accessibility track", track->kindKeyword().string().utf8().data(), language.utf8().data());
                     continue;
                 }
-                if (languagesIncluded.contains(language)  && filterTrackList) {
-                    LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it is not the first with this language", track->kind().string().utf8().data(), language.utf8().data());
+                if (languagesIncluded.contains(language) && filterTrackList) {
+                    LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it is not the first with this language", track->kindKeyword().string().utf8().data(), language.utf8().data());
                     continue;
                 }
             }
@@ -914,7 +914,7 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
             languagesIncluded.add(language);
         tracksForMenu.append(track);
 
-        LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s', is%s main program content", track->kind().string().utf8().data(), language.utf8().data(), track->isMainProgramContent() ? "" : " NOT");
+        LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s', is%s main program content", track->kindKeyword().string().utf8().data(), language.utf8().data(), track->isMainProgramContent() ? "" : " NOT");
     }
 
     // Now that we have filtered for the user's accessibility/translation preference, add  all tracks with a unique language without regard to track type.
@@ -925,8 +925,8 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
         if (tracksForMenu.contains(track))
             continue;
 
-        const AtomicString& kind = track->kind();
-        if (kind != TextTrack::captionsKeyword() && kind != TextTrack::descriptionsKeyword() && kind != TextTrack::subtitlesKeyword())
+        auto kind = track->kind();
+        if (kind != TextTrackKind::Captions && kind != TextTrackKind::Descriptions && kind != TextTrackKind::Subtitles)
             continue;
 
         // All candidates with no languge were added the first time through.
@@ -939,7 +939,7 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
         if (!languagesIncluded.contains(language) && track->isMainProgramContent()) {
             languagesIncluded.add(language);
             tracksForMenu.append(track);
-            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is the only track with this language", track->kind().string().utf8().data(), language.utf8().data());
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is the only track with this language", track->kindKeyword().string().utf8().data(), language.utf8().data());
         }
     }
 
index 48bdf94..754eb1e 100644 (file)
@@ -303,7 +303,7 @@ void WebPlaybackSessionModelMediaElement::updateLegibleOptions()
             trackMenuItemSelected = true;
         }
 
-        if (displayMode != MediaControlsHost::automaticKeyword() && track->mode() == TextTrack::showingKeyword()) {
+        if (displayMode != MediaControlsHost::automaticKeyword() && track->mode() == TextTrackMode::Showing) {
             selectedIndex = index;
             trackMenuItemSelected = true;
         }