Not all subtitle tracks are SDH
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2013 21:29:12 +0000 (21:29 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2013 21:29:12 +0000 (21:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117738

Reviewed by Dean Jackson.

Source/WebCore:

No new tests, existing tests updated.

* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::isSDH): New.

* html/track/InbandTextTrack.h: Add isSDH override.
* html/track/TextTrack.h:

* page/CaptionUserPreferencesMac.mm:
(WebCore::trackDisplayName): Only add "SDH" label if a track claims to be SDH.

* platform/graphics/InbandTextTrackPrivate.h:
(WebCore::InbandTextTrackPrivate::isSDH): New.

* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
(WebCore::InbandTextTrackPrivateAVFObjC::isSDH): Return true if track has both "transcribes
    spoken dialog for accessibility" and "describes music and sound for accessibility"
    characteristics.

LayoutTests:

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

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/media/video-controls-captions-trackmenu-localized.html
LayoutTests/media/video-controls-captions-trackmenu-sorted.html
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/html/track/InbandTextTrack.cpp
Source/WebCore/html/track/InbandTextTrack.h
Source/WebCore/html/track/TextTrack.h
Source/WebCore/page/CaptionUserPreferencesMac.mm
Source/WebCore/platform/graphics/InbandTextTrackPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm

index 49ed3e3..3110b11 100644 (file)
@@ -1,3 +1,15 @@
+2013-06-18  Eric Carlson  <eric.carlson@apple.com>
+
+        Not all subtitle tracks are SDH
+        https://bugs.webkit.org/show_bug.cgi?id=117738
+
+        Reviewed by Dean Jackson.
+
+        * media/video-controls-captions-trackmenu-localized.html:
+        * media/video-controls-captions-trackmenu-sorted.html:
+        * platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt:
+        * platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt:
+
 2013-06-18  Dean Jackson  <dino@apple.com>
 
         Synthesized vertical italics on rotated glyphs are transformed incorrectly
index fa379ab..dad6942 100644 (file)
@@ -53,8 +53,8 @@
             testExpected("item.textContent", "Laugh Track (English-United States)");
 
             item = captionsEntries[4];
-            consoleWrite("<br>Fifth item in captions menu should be labelled 'Unknown SDH'");
-            testExpected("item.textContent", "Unknown SDH");
+            consoleWrite("<br>Fifth item in captions menu should be labelled 'Unknown'");
+            testExpected("item.textContent", "Unknown");
 
             endTest();
         }
index bc51bb9..6105371 100644 (file)
                     trackMenuItems = textTrackMenuItems();
                     testExpected("trackMenuItems[0].textContent", "Off");
                     testExpected("trackMenuItems[1].textContent", "Auto (Recommended)");
-                    testExpected("trackMenuItems[2].textContent", "u (English) SDH");
-                    testExpected("trackMenuItems[3].textContent", "y (English-Australia) SDH");
+                    testExpected("trackMenuItems[2].textContent", "u (English)");
+                    testExpected("trackMenuItems[3].textContent", "y (English-Australia)");
                     testExpected("trackMenuItems[4].textContent", "v (English)");
                     testExpected("trackMenuItems[5].textContent", "x (English-Australia)");
-                    testExpected("trackMenuItems[6].textContent", "w (Japanese) SDH");
+                    testExpected("trackMenuItems[6].textContent", "w (Japanese)");
                     testExpected("trackMenuItems[7].textContent", "z (Japanese)");
                     testExpected("video.textTracks.length", 6);
                     testExpected("trackMenuItems.length", 8);
index c4089e3..56014f5 100644 (file)
@@ -19,7 +19,7 @@ EXPECTED (item.textContent == 'English CC') OK
 Fourth item in captions menu should be labelled 'Laugh Track (English-United States)'
 EXPECTED (item.textContent == 'Laugh Track (English-United States)') OK
 
-Fifth item in captions menu should be labelled 'Unknown SDH'
-EXPECTED (item.textContent == 'Unknown SDH') OK
+Fifth item in captions menu should be labelled 'Unknown'
+EXPECTED (item.textContent == 'Unknown') OK
 END OF TEST
 
index 61ec95f..74328d1 100644 (file)
@@ -9,11 +9,11 @@ RUN(internals.setUserPreferredLanguages(['en']))
 RUN(internals.settings.setShouldDisplayTrackKind('Captions', true))
 EXPECTED (trackMenuItems[0].textContent == 'Off') OK
 EXPECTED (trackMenuItems[1].textContent == 'Auto (Recommended)') OK
-EXPECTED (trackMenuItems[2].textContent == 'u (English) SDH') OK
-EXPECTED (trackMenuItems[3].textContent == 'y (English-Australia) SDH') OK
+EXPECTED (trackMenuItems[2].textContent == 'u (English)') OK
+EXPECTED (trackMenuItems[3].textContent == 'y (English-Australia)') OK
 EXPECTED (trackMenuItems[4].textContent == 'v (English)') OK
 EXPECTED (trackMenuItems[5].textContent == 'x (English-Australia)') OK
-EXPECTED (trackMenuItems[6].textContent == 'w (Japanese) SDH') OK
+EXPECTED (trackMenuItems[6].textContent == 'w (Japanese)') OK
 EXPECTED (trackMenuItems[7].textContent == 'z (Japanese)') OK
 EXPECTED (video.textTracks.length == '6') OK
 EXPECTED (trackMenuItems.length == '8') OK
@@ -24,9 +24,9 @@ RUN(internals.settings.setShouldDisplayTrackKind('Captions', false))
 RUN(internals.settings.setShouldDisplayTrackKind('Subtitles', true))
 EXPECTED (trackMenuItems[0].textContent == 'Off') OK
 EXPECTED (trackMenuItems[1].textContent == 'Auto (Recommended)') OK
-EXPECTED (trackMenuItems[2].textContent == 'z (Japanese)'), OBSERVED 'w (Japanese) SDH' FAIL
+EXPECTED (trackMenuItems[2].textContent == 'z (Japanese)'), OBSERVED 'w (Japanese)' FAIL
 EXPECTED (trackMenuItems[3].textContent == 'v (English)'), OBSERVED 'z (Japanese)' FAIL
-EXPECTED (trackMenuItems[4].textContent == 'x (English-Australia)'), OBSERVED 'u (English) SDH' FAIL
+EXPECTED (trackMenuItems[4].textContent == 'x (English-Australia)'), OBSERVED 'u (English)' FAIL
 EXPECTED (video.textTracks.length == '6') OK
 EXPECTED (trackMenuItems.length == '5'), OBSERVED '8' FAIL
 
index 60355b9..4b083c0 100644 (file)
@@ -1,3 +1,30 @@
+2013-06-18  Eric Carlson  <eric.carlson@apple.com>
+
+        Not all subtitle tracks are SDH
+        https://bugs.webkit.org/show_bug.cgi?id=117738
+
+        Reviewed by Dean Jackson.
+
+        No new tests, existing tests updated.
+
+        * html/track/InbandTextTrack.cpp:
+        (WebCore::InbandTextTrack::isSDH): New.
+
+        * html/track/InbandTextTrack.h: Add isSDH override.
+        * html/track/TextTrack.h:
+
+        * page/CaptionUserPreferencesMac.mm:
+        (WebCore::trackDisplayName): Only add "SDH" label if a track claims to be SDH.
+
+        * platform/graphics/InbandTextTrackPrivate.h:
+        (WebCore::InbandTextTrackPrivate::isSDH): New.
+
+        * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
+        (WebCore::InbandTextTrackPrivateAVFObjC::isSDH): Return true if track has both "transcribes
+            spoken dialog for accessibility" and "describes music and sound for accessibility" 
+            characteristics.
+
 2013-06-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Simplify FormKeyGenerator::willDeleteForm
index 84b6f31..2e18ad6 100644 (file)
@@ -148,6 +148,14 @@ bool InbandTextTrack::isClosedCaptions() const
     return m_private->isClosedCaptions();
 }
 
+bool InbandTextTrack::isSDH() const
+{
+    if (!m_private)
+        return false;
+    
+    return m_private->isSDH();
+}
+
 bool InbandTextTrack::containsOnlyForcedSubtitles() const
 {
     if (!m_private)
index f029237..ea02799 100644 (file)
@@ -67,6 +67,7 @@ public:
     virtual ~InbandTextTrack();
 
     virtual bool isClosedCaptions() const OVERRIDE;
+    virtual bool isSDH() const OVERRIDE;
     virtual bool containsOnlyForcedSubtitles() const OVERRIDE;
     virtual bool isMainProgramContent() const OVERRIDE;
     virtual bool isEasyToRead() const OVERRIDE;
index e04e863..3e79bdf 100644 (file)
@@ -127,7 +127,7 @@ public:
     TextTrackType trackType() const { return m_trackType; }
 
     virtual bool isClosedCaptions() const { return false; }
-
+    virtual bool isSDH() const { return false; }
     virtual bool containsOnlyForcedSubtitles() const { return false; }
     virtual bool isMainProgramContent() const;
     virtual bool isEasyToRead() const { return false; }
index f790b44..952bd15 100644 (file)
@@ -587,13 +587,13 @@ static String trackDisplayName(TextTrack* track)
     if (track->isEasyToRead())
         return easyReaderTrackMenuItemText(displayName.toString());
     
-    if (track->kind() != track->captionsKeyword())
-        return displayName.toString();
-    
     if (track->isClosedCaptions())
         return closedCaptionTrackMenuItemText(displayName.toString());
-    
-    return sdhTrackMenuItemText(displayName.toString());
+
+    if (track->isSDH())
+        return sdhTrackMenuItemText(displayName.toString());
+
+    return displayName.toString();
 }
 
 String CaptionUserPreferencesMac::displayNameForTrack(TextTrack* track) const
index 4d41629..91066ea 100644 (file)
@@ -67,6 +67,7 @@ public:
     };
     virtual Kind kind() const { return Subtitles; }
     virtual bool isClosedCaptions() const { return false; }
+    virtual bool isSDH() const { return false; }
     virtual bool containsOnlyForcedSubtitles() const { return false; }
     virtual bool isMainProgramContent() const { return true; }
     virtual bool isEasyToRead() const { return false; }
index a94ca2f..0e5e6ca 100644 (file)
@@ -46,6 +46,7 @@ public:
 
     virtual InbandTextTrackPrivate::Kind kind() const OVERRIDE;
     virtual bool isClosedCaptions() const OVERRIDE;
+    virtual bool isSDH() const OVERRIDE;
     virtual bool containsOnlyForcedSubtitles() const OVERRIDE;
     virtual bool isMainProgramContent() const OVERRIDE;
     virtual bool isEasyToRead() const OVERRIDE;
index 0d29b2a..a6b373b 100644 (file)
@@ -126,6 +126,20 @@ bool InbandTextTrackPrivateAVFObjC::isClosedCaptions() const
     return [[m_mediaSelectionOption mediaType] isEqualToString:AVMediaTypeClosedCaption];
 }
 
+bool InbandTextTrackPrivateAVFObjC::isSDH() const
+{
+    if (!m_mediaSelectionOption)
+        return false;
+    
+    if (![[m_mediaSelectionOption mediaType] isEqualToString:AVMediaTypeSubtitle])
+        return false;
+
+    if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility] && [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicDescribesMusicAndSoundForAccessibility])
+        return true;
+
+    return false;
+}
+    
 bool InbandTextTrackPrivateAVFObjC::containsOnlyForcedSubtitles() const
 {
     if (!m_mediaSelectionOption)