2009-11-19 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Nov 2009 18:14:01 +0000 (18:14 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Nov 2009 18:14:01 +0000 (18:14 +0000)
        Reviewed by Dan Bernstein.

        <rdar://problem/7035231>
        Support closed caption in <video> element

        Test: media/media-captions.html

        * WebCore.base.exp:
        * accessibility/AccessibilityMediaControls.cpp:
        (WebCore::AccessibilityMediaControl::controlTypeName):
            Define ShowClosedCaptionsButton and HideClosedCaptionsButton.

        * css/CSSPrimitiveValueMappings.h:
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
            Add MediaToggleClosedCaptionsButtonPart.

        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::extractPseudoType):
            Define and match mediaControlsToggleClosedCaptionsButton.

        * css/CSSSelector.h:
        (WebCore::CSSSelector::):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
            Define and match PseudoMediaControlsToggleClosedCaptions.

        * css/CSSValueKeywords.in:
            Define and use media-toggle-closed-captions-button.

        * css/mediaControls.css:
        * css/mediaControlsQuickTime.css:
            Add webkit-media-controls-toggle-closed-captions-button.

        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::HTMLMediaElement):
            Initialize m_closedCaptionsVisible.
        (WebCore::HTMLMediaElement::loadInternal):
            Set m_closedCaptionsVisible to false.
        (WebCore::HTMLMediaElement::hasClosedCaptions):
        (WebCore::HTMLMediaElement::closedCaptionsVisible):
        (WebCore::HTMLMediaElement::setClosedCaptionsVisible):
            New, captions internal methods.
        (WebCore::HTMLMediaElement::setWebkitClosedCaptionsVisible):
        (WebCore::HTMLMediaElement::webkitClosedCaptionsVisible):
        (WebCore::HTMLMediaElement::webkitHasClosedCaptions):
            New, captions DOM API.

        * html/HTMLMediaElement.h:
        * html/HTMLMediaElement.idl:
            Declare methods needed for captions API.

        * platform/ThemeTypes.h:
            Add MediaToggleClosedCaptionsButtonPart.

        * platform/android/LocalizedStringsAndroid.cpp:
        (WebCore::localizedMediaControlElementString):
        (WebCore::localizedMediaControlElementHelpText):
        (WebCore::localizedMediaTimeDescription):
            Add empty implmentations.

        * platform/graphics/MediaPlayer.cpp:
        (WebCore::NullMediaPlayerPrivate::hasClosedCaptions):
        (WebCore::NullMediaPlayerPrivate::setClosedCaptionsVisible):
            New, empty implementations of media engine closed caption functions.
        (WebCore::MediaPlayer::hasClosedCaptions):
        (WebCore::MediaPlayer::setClosedCaptionsVisible):
            New, call media engine closed caption functions.

        * platform/graphics/MediaPlayer.h:
        * platform/graphics/MediaPlayerPrivate.h:
        (WebCore::MediaPlayerPrivateInterface::hasClosedCaptions):
        (WebCore::MediaPlayerPrivateInterface::setClosedCaptionsVisible):
            Declare new media engine methods.

        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivate::hasClosedCaptions):
        (WebCore::MediaPlayerPrivate::setClosedCaptionsVisible):
            New, QTKit implementation of closed caption methods.

        * platform/gtk/LocalizedStringsGtk.cpp:
        (WebCore::localizedMediaControlElementString):
        (WebCore::localizedMediaControlElementHelpText):
            Add help text for ShowClosedCaptionsButton and HideClosedCaptionsButton.

        * platform/mac/WebCoreSystemInterface.h:
        * platform/mac/WebCoreSystemInterface.mm:
            Declare and initialize wkQTMovieHasClosedCaptions and wkQTMovieSetShowClosedCaptions.

        * rendering/MediaControlElements.cpp:
        (WebCore::MediaControlInputElement::MediaControlInputElement):
            Deal with MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON.
        (WebCore::MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsButtonElement):
        (WebCore::MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler):
        (WebCore::MediaControlToggleClosedCaptionsButtonElement::updateDisplayType):
            New, implement the closed caption toggle button,

        * rendering/MediaControlElements.h:
            Define MediaShowClosedCaptionsButton and MediaHideClosedCaptionsButton,
            declare MediaControlToggleClosedCaptionsButtonElement.

        * rendering/RenderMedia.cpp:
        (WebCore::RenderMedia::styleDidChange):
        (WebCore::RenderMedia::createToggleClosedCaptionsButton):
        (WebCore::RenderMedia::createStatusDisplay):
        (WebCore::RenderMedia::updateControls):
        (WebCore::RenderMedia::forwardEvent):
        * rendering/RenderMedia.h:
            Deal with m_toggleClosedCaptionsButton.

        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::paint):
            Deal with MediaToggleClosedCaptionsButtonPart.

        * rendering/RenderTheme.h:
        * rendering/RenderThemeMac.h:
            Declare paintMediaToggleClosedCaptionsButton.

        * rendering/RenderThemeMac.mm:
        (WebCore::RenderThemeMac::paintMediaToggleClosedCaptionsButton):
            New.
        (WebCore::RenderThemeMac::shouldRenderMediaControlPart):
            Don't render captions toggle button unless we are using the new theme, the
            movie has captions, and the movie is in a <video> element since we currently
            rely on QTKit to render the captions.

        * rendering/style/RenderStyleConstants.h:
            Define MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON.

2009-11-19  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/7035231>
        Support closed caption in <video> element

        * media/media-captions-expected.txt: Added.
        * media/media-captions.html: Added.
        * media/content/counting-captioned.mov: Added.

        * platform/gtk/Skipped:
        * platform/mac-leopard/Skipped:
        * platform/mac-tiger/Skipped:
        * platform/win/Skipped:
            Skipped on platforms that don't support closed captions yet.

2009-11-19  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/7035231>
        Support closed caption in <video> element

        * English.lproj/Localizable.strings:
            Add strings for toggle captions button.

2009-11-19  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/7035231>
        Support closed caption in <video> element

        * WebCoreSupport/WebSystemInterface.m:
        (InitWebCoreSystemInterface):
            Add QTMovieHasClosedCaptions and QTMovieSetShowClosedCaptions.

        * WebCoreSupport/WebViewFactory.mm:
        (-[WebViewFactory localizedMediaControlElementString:]):
        (-[WebViewFactory localizedMediaControlElementHelpText:]):
            Add accessibility help strings for media controller closed caption button.

2009-11-19  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/7035231>
        Support closed caption in <video> element

        * WebCoreLocalizedStrings.cpp:
        (WebCore::localizedMediaControlElementString):
        (WebCore::localizedMediaControlElementHelpText):
            Add accessibility help strings for media controller closed caption button.

2009-11-19  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/7035231>
        Support closed caption in <video> element

        * WebKitSystemInterface.h:
            Add prototypes for WKQTMovieHasClosedCaptions and WKQTMovieSetShowClosedCaptions,
            define WKMediaUIPartToggleClosedCaptionsButton.

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

52 files changed:
LayoutTests/ChangeLog
LayoutTests/media/content/counting-captioned.mov [new file with mode: 0644]
LayoutTests/media/media-captions-expected.txt [new file with mode: 0644]
LayoutTests/media/media-captions.html [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac-leopard/Skipped
LayoutTests/platform/mac-tiger/Skipped
LayoutTests/platform/win/Skipped
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/accessibility/AccessibilityMediaControls.cpp
WebCore/css/CSSPrimitiveValueMappings.h
WebCore/css/CSSSelector.cpp
WebCore/css/CSSSelector.h
WebCore/css/CSSStyleSelector.cpp
WebCore/css/CSSValueKeywords.in
WebCore/css/mediaControls.css
WebCore/css/mediaControlsQuickTime.css
WebCore/html/HTMLMediaElement.cpp
WebCore/html/HTMLMediaElement.h
WebCore/html/HTMLMediaElement.idl
WebCore/platform/ThemeTypes.h
WebCore/platform/android/LocalizedStringsAndroid.cpp
WebCore/platform/graphics/MediaPlayer.cpp
WebCore/platform/graphics/MediaPlayer.h
WebCore/platform/graphics/MediaPlayerPrivate.h
WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
WebCore/platform/gtk/LocalizedStringsGtk.cpp
WebCore/platform/mac/WebCoreSystemInterface.h
WebCore/platform/mac/WebCoreSystemInterface.mm
WebCore/rendering/MediaControlElements.cpp
WebCore/rendering/MediaControlElements.h
WebCore/rendering/RenderMedia.cpp
WebCore/rendering/RenderMedia.h
WebCore/rendering/RenderTheme.cpp
WebCore/rendering/RenderTheme.h
WebCore/rendering/RenderThemeMac.h
WebCore/rendering/RenderThemeMac.mm
WebCore/rendering/style/RenderStyleConstants.h
WebKit/ChangeLog
WebKit/English.lproj/Localizable.strings
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebSystemInterface.m
WebKit/mac/WebCoreSupport/WebViewFactory.mm
WebKit/win/ChangeLog
WebKit/win/WebCoreLocalizedStrings.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a
WebKitLibraries/libWebKitSystemInterfaceTiger.a

index 4933b85f2586dc9e654be22abea414ea2b584cb6..7d901abf13cde643e866bb9ec68df0785b14791a 100644 (file)
@@ -1,3 +1,20 @@
+2009-11-19  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/7035231>
+        Support closed caption in <video> element
+
+        * media/media-captions-expected.txt: Added.
+        * media/media-captions.html: Added.
+        * media/content/counting-captioned.mov: Added.
+
+        * platform/gtk/Skipped:
+        * platform/mac-leopard/Skipped:
+        * platform/mac-tiger/Skipped:
+        * platform/win/Skipped:
+            Skipped on platforms that don't support closed captions yet.
+
 2009-11-19  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Gustavo Noronha Silva.
diff --git a/LayoutTests/media/content/counting-captioned.mov b/LayoutTests/media/content/counting-captioned.mov
new file mode 100644 (file)
index 0000000..92c4b13
Binary files /dev/null and b/LayoutTests/media/content/counting-captioned.mov differ
diff --git a/LayoutTests/media/media-captions-expected.txt b/LayoutTests/media/media-captions-expected.txt
new file mode 100644 (file)
index 0000000..1a9a8d5
--- /dev/null
@@ -0,0 +1,26 @@
+Test media element close caption API.
+
+Test before movie is open:
+EXPECTED (mediaElement.webkitHasClosedCaptions == 'false') OK
+EXPECTED (mediaElement.webkitClosedCaptionsVisible == 'false') OK
+
+Loading "content/test.wav". Audio-only file without captions.
+EVENT(loadstart)
+EVENT(durationchange)
+EVENT(loadedmetadata)
+EXPECTED (mediaElement.webkitHasClosedCaptions == 'false') OK
+EXPECTED (mediaElement.webkitClosedCaptionsVisible == 'false') OK
+*** enabling captions
+EXPECTED (mediaElement.webkitClosedCaptionsVisible == 'false') OK
+
+Loading "content/counting-captioned.mov". QuickTime movie with captions..
+EVENT(loadstart)
+EVENT(durationchange)
+EVENT(loadedmetadata)
+EXPECTED (mediaElement.webkitHasClosedCaptions == 'true') OK
+EXPECTED (mediaElement.webkitClosedCaptionsVisible == 'false') OK
+*** enabling captions
+EXPECTED (mediaElement.webkitClosedCaptionsVisible == 'true') OK
+
+END OF TEST
+
diff --git a/LayoutTests/media/media-captions.html b/LayoutTests/media/media-captions.html
new file mode 100644 (file)
index 0000000..b2f4565
--- /dev/null
@@ -0,0 +1,97 @@
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+        <title>closed caption API test</title>
+
+        <script src=video-test.js></script>
+        <script src=media-fullscreen.js></script>
+
+        <script>
+            var movieInfo = 
+            {
+                current : -1,
+                movies : 
+                [ 
+                    {
+                        url : "content/test.wav", 
+                        description : "Audio-only file without captions", 
+                        hasCaptions : false,
+                    },
+                    {
+                        url : "content/counting-captioned.mov", 
+                        description : "QuickTime movie with captions.", 
+                        hasCaptions : true,
+                    },
+                ]
+            };
+
+
+            function canplaythrough()
+            {
+                var movie = movieInfo.movies[movieInfo.current];
+            
+                testExpected("mediaElement.webkitHasClosedCaptions", movie.hasCaptions);
+                testExpected("mediaElement.webkitClosedCaptionsVisible", false);
+                
+                // Try to enable captions, they should only be enabled after if the movie has captions.
+                consoleWrite("*** enabling captions");
+                mediaElement.webkitClosedCaptionsVisible = true;
+                testExpected("mediaElement.webkitClosedCaptionsVisible", movie.hasCaptions);
+
+                openNextMovie();
+            }
+            
+            function openNextMovie()
+            {
+                consoleWrite("");
+
+                movieInfo.current++;
+                if (movieInfo.current >= movieInfo.movies.length)
+                {
+                    endTest();
+                    return;
+                }
+
+                var url = movieInfo.movies[movieInfo.current].url;
+                video.src = url;
+                var desc = "<b>Loading</b> <em>\""+ url + "\"</em>" + 
+                            ". " + movieInfo.movies[movieInfo.current].description + ".</em>";
+                consoleWrite(desc);
+                if (movieInfo.current > 0)
+                    video.load();
+            }
+            
+            function start()
+            {
+                findMediaElement();
+
+                waitForEvent("error");
+                waitForEvent("loadstart");
+                waitForEvent("waiting");
+                waitForEvent("ratechange");
+                waitForEvent("durationchange");
+                waitForEvent("pause");
+                waitForEvent("play");
+                waitForEvent("playing");
+
+                waitForEvent('loadedmetadata', canplaythrough);
+
+                consoleWrite("<b>Test before movie is open:</b>");
+                testExpected("mediaElement.webkitHasClosedCaptions", false);
+                testExpected("mediaElement.webkitClosedCaptionsVisible", false);
+            
+                openNextMovie();
+            }
+
+        </script>
+
+    </head>
+
+    <body onload="start()">
+
+        <video controls></video>
+
+        <p>Test media element close caption API.</p>
+
+    </body>
+</html>
index e5d238bab2387cf3b7b26ea32a54bd3880458f98..ca250d5a5a2fb540386800809093f478d894c3df 100644 (file)
@@ -3612,6 +3612,8 @@ media/video-volume-slider.html
 # Tests requiring fullscreen <video> support
 media/media-fullscreen-inline.html
 media/media-fullscreen-not-in-document.html
+# Requires media engine closed caption support
+media/media-captions.html
 
 # Tests in plugins/ directory
 #   These tests require ObjC plugin, do not bother trying to get them to work
index 05bf9d37183ddfba6ce15a917808457ea3fe8b7d..88e4dc9c055dae83f8e2b989e23b0deb34915669 100644 (file)
@@ -25,5 +25,8 @@ transforms/3d
 media/media-fullscreen-inline.html
 media/media-fullscreen-not-in-document.html
 
+# Requires media engine closed caption support
+media/media-captions.html
+
 # Tests of accessibility functionality not supported on Leopard
 accessibility/aria-list-and-listitem.html
index 29e9ff6f9183c783bac9f9ab309010158549f34a..60ad5a9e4f9221eb6bb3f6e8b1980abdce5940da 100644 (file)
@@ -67,6 +67,9 @@ http/tests/loading/redirect-with-no-location-crash.html
 media/media-fullscreen-inline.html
 media/media-fullscreen-not-in-document.html
 
+# Requires media engine closed caption support
+media/media-captions.html
+
 # Tests of accessibility functionality not supported on Tiger
 accessibility/aria-list-and-listitem.html
 
index bcf93fbecba5ba20efef074a303e301eb20c63d3..5ea99820399f6448937f19ac5f9fd3b89893ed9d 100644 (file)
@@ -55,6 +55,9 @@ media/video-volume-slider.html
 media/media-fullscreen-inline.html
 media/media-fullscreen-not-in-document.html
 
+# Requires media engine closed caption support
+media/media-captions.html
+
 # <rdar://problem/5075790> Layout tests that depend on certain fonts don't match Mac results:
 #                          - Mac OS X and Windows do not have an Arabic font in common
 fast/text/international/bidi-AN-after-L.html
index d61ebc2fb05cfd363153c926cc9b06585b1336a6..32dc8357cd8e541ba4655ac551d82493227b0b35 100644 (file)
@@ -1,3 +1,134 @@
+2009-11-19  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/7035231>
+        Support closed caption in <video> element
+
+        Test: media/media-captions.html
+
+        * WebCore.base.exp:
+        * accessibility/AccessibilityMediaControls.cpp:
+        (WebCore::AccessibilityMediaControl::controlTypeName):
+            Define ShowClosedCaptionsButton and HideClosedCaptionsButton.
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+            Add MediaToggleClosedCaptionsButtonPart.
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::extractPseudoType):
+            Define and match mediaControlsToggleClosedCaptionsButton.
+
+        * css/CSSSelector.h:
+        (WebCore::CSSSelector::):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
+            Define and match PseudoMediaControlsToggleClosedCaptions.
+
+        * css/CSSValueKeywords.in:
+            Define and use media-toggle-closed-captions-button.
+
+        * css/mediaControls.css:
+        * css/mediaControlsQuickTime.css:
+            Add webkit-media-controls-toggle-closed-captions-button.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement): 
+            Initialize m_closedCaptionsVisible.
+        (WebCore::HTMLMediaElement::loadInternal): 
+            Set m_closedCaptionsVisible to false.
+        (WebCore::HTMLMediaElement::hasClosedCaptions): 
+        (WebCore::HTMLMediaElement::closedCaptionsVisible): 
+        (WebCore::HTMLMediaElement::setClosedCaptionsVisible): 
+            New, captions internal methods.
+        (WebCore::HTMLMediaElement::setWebkitClosedCaptionsVisible): 
+        (WebCore::HTMLMediaElement::webkitClosedCaptionsVisible): 
+        (WebCore::HTMLMediaElement::webkitHasClosedCaptions): 
+            New, captions DOM API.
+
+        * html/HTMLMediaElement.h:
+        * html/HTMLMediaElement.idl:
+            Declare methods needed for captions API.
+
+        * platform/ThemeTypes.h:
+            Add MediaToggleClosedCaptionsButtonPart.
+
+        * platform/android/LocalizedStringsAndroid.cpp:
+        (WebCore::localizedMediaControlElementString):
+        (WebCore::localizedMediaControlElementHelpText):
+        (WebCore::localizedMediaTimeDescription):
+            Add empty implmentations.
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::NullMediaPlayerPrivate::hasClosedCaptions):
+        (WebCore::NullMediaPlayerPrivate::setClosedCaptionsVisible):
+            New, empty implementations of media engine closed caption functions.
+        (WebCore::MediaPlayer::hasClosedCaptions):
+        (WebCore::MediaPlayer::setClosedCaptionsVisible):
+            New, call media engine closed caption functions.
+
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::hasClosedCaptions):
+        (WebCore::MediaPlayerPrivateInterface::setClosedCaptionsVisible):
+            Declare new media engine methods.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivate::hasClosedCaptions):
+        (WebCore::MediaPlayerPrivate::setClosedCaptionsVisible):
+            New, QTKit implementation of closed caption methods.
+
+        * platform/gtk/LocalizedStringsGtk.cpp:
+        (WebCore::localizedMediaControlElementString):
+        (WebCore::localizedMediaControlElementHelpText):
+            Add help text for ShowClosedCaptionsButton and HideClosedCaptionsButton.
+
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+            Declare and initialize wkQTMovieHasClosedCaptions and wkQTMovieSetShowClosedCaptions.
+
+        * rendering/MediaControlElements.cpp:
+        (WebCore::MediaControlInputElement::MediaControlInputElement):
+            Deal with MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON.
+        (WebCore::MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsButtonElement):
+        (WebCore::MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler):
+        (WebCore::MediaControlToggleClosedCaptionsButtonElement::updateDisplayType):
+            New, implement the closed caption toggle button,
+
+        * rendering/MediaControlElements.h:
+            Define MediaShowClosedCaptionsButton and MediaHideClosedCaptionsButton,
+            declare MediaControlToggleClosedCaptionsButtonElement.
+
+        * rendering/RenderMedia.cpp:
+        (WebCore::RenderMedia::styleDidChange):
+        (WebCore::RenderMedia::createToggleClosedCaptionsButton):
+        (WebCore::RenderMedia::createStatusDisplay):
+        (WebCore::RenderMedia::updateControls):
+        (WebCore::RenderMedia::forwardEvent):
+        * rendering/RenderMedia.h:
+            Deal with m_toggleClosedCaptionsButton.
+
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::paint):
+            Deal with MediaToggleClosedCaptionsButtonPart.
+
+        * rendering/RenderTheme.h:
+        * rendering/RenderThemeMac.h:
+            Declare paintMediaToggleClosedCaptionsButton.
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintMediaToggleClosedCaptionsButton):
+            New.
+        (WebCore::RenderThemeMac::shouldRenderMediaControlPart):
+            Don't render captions toggle button unless we are using the new theme, the
+            movie has captions, and the movie is in a <video> element since we currently
+            rely on QTKit to render the captions.
+
+        * rendering/style/RenderStyleConstants.h:
+            Define MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON.
+
 2009-11-19  Kevin Ollivier  <kevino@theolliviers.com>
 
         wx build fix. Add missing header.
index 7101c236eb40f222768b6c03886b63063f12c0da..d8b9932f51c056a9ff430afca17dc4f1d349fdbd 100644 (file)
@@ -1021,9 +1021,11 @@ _wkPopupMenu
 _wkQTIncludeOnlyModernMediaFileTypes
 _wkQTMovieDataRate
 _wkQTMovieGetType
+_wkQTMovieHasClosedCaptions
 _wkQTMovieMaxTimeLoaded
 _wkQTMovieMaxTimeLoadedChangeNotification
 _wkQTMovieMaxTimeSeekable
+_wkQTMovieSetShowClosedCaptions
 _wkQTMovieViewSetDrawSynchronously
 _wkSetCGFontRenderingMode
 _wkSetDragImage
index 7200de9ba4c8c66668dc52e2f45f988dbf5a3442..6151840f596b0a8727f6422ee7f8170b7cce2b18 100644 (file)
@@ -113,6 +113,8 @@ String AccessibilityMediaControl::controlTypeName() const
     DEFINE_STATIC_LOCAL(const String, mediaStatusDisplayName, ("StatusDisplay"));
     DEFINE_STATIC_LOCAL(const String, mediaCurrentTimeDisplay, ("CurrentTimeDisplay"));
     DEFINE_STATIC_LOCAL(const String, mediaTimeRemainingDisplay, ("TimeRemainingDisplay"));
+    DEFINE_STATIC_LOCAL(const String, mediaShowClosedCaptionsButtonName, ("ShowClosedCaptionsButton"));
+    DEFINE_STATIC_LOCAL(const String, mediaHideClosedCaptionsButtonName, ("HideClosedCaptionsButton"));
 
     switch (controlType()) {
     case MediaFullscreenButton:
@@ -139,6 +141,10 @@ String AccessibilityMediaControl::controlTypeName() const
         return mediaCurrentTimeDisplay;
     case MediaTimeRemainingDisplay:
         return mediaTimeRemainingDisplay;
+    case MediaShowClosedCaptionsButton:
+        return mediaShowClosedCaptionsButtonName;
+    case MediaHideClosedCaptionsButton:
+        return mediaHideClosedCaptionsButtonName;
 
     default:
         break;
@@ -187,6 +193,8 @@ AccessibilityRole AccessibilityMediaControl::roleValue() const
     case MediaReturnToRealtimeButton:
     case MediaUnMuteButton:
     case MediaPauseButton:
+    case MediaShowClosedCaptionsButton:
+    case MediaHideClosedCaptionsButton:
         return ButtonRole;
 
     case MediaStatusDisplay:
index b690b22eae547e21d86a8eb7e5210bdfe6ca3922..3c6097b4e429cedf670c1d5758f24f74a81c5876 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -230,6 +230,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
         case MediaReturnToRealtimeButtonPart:
             m_value.ident = CSSValueMediaReturnToRealtimeButton;
             break;
+        case MediaToggleClosedCaptionsButtonPart:
+            m_value.ident = CSSValueMediaToggleClosedCaptionsButton;
+            break;
         case MediaSliderPart:
             m_value.ident = CSSValueMediaSlider;
             break;
index 313528f821d50c52911595a790aae6211bc6e1de..ab2d22b3f50f902b314f36d6c09c75ba59311700 100644 (file)
@@ -116,6 +116,7 @@ void CSSSelector::extractPseudoType() const
     DEFINE_STATIC_LOCAL(AtomicString, mediaControlsSeekForwardButton, ("-webkit-media-controls-seek-forward-button"));
     DEFINE_STATIC_LOCAL(AtomicString, mediaControlsRewindButton, ("-webkit-media-controls-rewind-button"));
     DEFINE_STATIC_LOCAL(AtomicString, mediaControlsReturnToRealtimeButton, ("-webkit-media-controls-return-to-realtime-button"));
+    DEFINE_STATIC_LOCAL(AtomicString, mediaControlsToggleClosedCaptionsButton, ("-webkit-media-controls-toggle-closed-captions-button"));
     DEFINE_STATIC_LOCAL(AtomicString, mediaControlsStatusDisplay, ("-webkit-media-controls-status-display"));
     DEFINE_STATIC_LOCAL(AtomicString, mediaControlsFullscreenButton, ("-webkit-media-controls-fullscreen-button"));
     DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimelineContainer, ("-webkit-media-controls-timeline-container"));
@@ -271,6 +272,9 @@ void CSSSelector::extractPseudoType() const
     } else if (m_value == mediaControlsReturnToRealtimeButton) {
         m_pseudoType = PseudoMediaControlsReturnToRealtimeButton;
         element = true;
+    } else if (m_value == mediaControlsToggleClosedCaptionsButton) {
+        m_pseudoType = PseudoMediaControlsToggleClosedCaptions;
+        element = true;
     } else if (m_value == mediaControlsStatusDisplay) {
         m_pseudoType = PseudoMediaControlsStatusDisplay;
         element = true;
index 15da323cf442a17779533f7641ff112339809e5b..95a72e4f0d720eda2715d13019f2a99393d5be11 100644 (file)
@@ -174,6 +174,7 @@ namespace WebCore {
             PseudoMediaControlsVolumeSliderContainer,
             PseudoMediaControlsCurrentTimeDisplay,
             PseudoMediaControlsTimeRemainingDisplay,
+            PseudoMediaControlsToggleClosedCaptions,
             PseudoMediaControlsTimeline,
             PseudoMediaControlsVolumeSlider,
             PseudoMediaControlsSeekBackButton,
index 9de4928645ad265003351fba8f253f6a62ff5822..55aca965f52d8925b9b1b89c6e6702e5a819ea22 100644 (file)
@@ -2556,6 +2556,9 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
             case CSSSelector::PseudoMediaControlsReturnToRealtimeButton:
                 dynamicPseudo = MEDIA_CONTROLS_RETURN_TO_REALTIME_BUTTON;
                 return true;
+            case CSSSelector::PseudoMediaControlsToggleClosedCaptions:
+                dynamicPseudo = MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON;
+                return true;
             case CSSSelector::PseudoMediaControlsStatusDisplay:
                 dynamicPseudo = MEDIA_CONTROLS_STATUS_DISPLAY;
                 return true;
index ccd5b9d69ea924d79de43a966ced74b5d7311a16..1c35b23b582cc72294b0428889d7f1ae204bb49b 100644 (file)
@@ -511,6 +511,7 @@ media-seek-back-button
 media-seek-forward-button
 media-rewind-button
 media-return-to-realtime-button
+media-toggle-closed-captions-button
 media-slider
 media-sliderthumb
 media-volume-slider-container
index d0ec90d6d27bfaece32b5687045cea4b1efa6287..12ca14a5b9f7a7809b0a070d0135ef7b58add96d 100644 (file)
@@ -124,3 +124,7 @@ audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewin
 audio::-webkit-media-controls-return-to-realtime-button, video::-webkit-media-controls-return-to-realtime-button {
     display: none;
 }
+
+audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button {
+    display: none;
+}
index 5cf48ae636af82028f41281f8b3efd07b63116ed..965685de2ca3938c991b77238724a96676580e03 100644 (file)
@@ -132,7 +132,7 @@ audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-f
     height: 16px;
     margin-left: 7px;
     margin-right: 7px;
-    -webkit-box-ordinal-group: 3; /* At the very end */
+    -webkit-box-ordinal-group: 4; /* At the very end */
 }
 
 audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewind-button {
@@ -175,3 +175,13 @@ audio::-webkit-media-controls-status-display, video::-webkit-media-controls-stat
     text-indent: 0;
     text-decoration: none;
 }
+
+audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button {
+    -webkit-appearance: media-toggle-closed-captions-button;
+    display: -webkit-box;
+    width: 16px;
+    height: 16px;
+    margin-left: 7px;
+    margin-right: 7px;
+    -webkit-box-ordinal-group: 3; /* between mute and fullscreen */
+}
index 9cad25da61b6d61d459e93adb2e9024f4a740d5e..99e2f1ed93a1c4d44d6de2ed2d59e29c4a742d8c 100644 (file)
@@ -117,6 +117,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* doc)
     , m_pausedInternal(false)
     , m_sendProgressEvents(true)
     , m_isFullscreen(false)
+    , m_closedCaptionsVisible(false)
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     , m_needWidgetUpdate(false)
 #endif
@@ -482,6 +483,7 @@ void HTMLMediaElement::loadInternal()
     m_autoplaying = true;
     m_playedTimeRanges = TimeRanges::create();
     m_lastSeekTime = 0;
+    m_closedCaptionsVisible = false;
 
     // 6
     setPlaybackRate(defaultPlaybackRate());
@@ -1852,6 +1854,43 @@ bool HTMLMediaElement::webkitDisplayingFullscreen()
     return m_isFullscreen;
 }
 
+bool HTMLMediaElement::hasClosedCaptions() const
+{
+    return m_player && m_player->hasClosedCaptions();
+}
+
+bool HTMLMediaElement::closedCaptionsVisible() const
+{
+    return m_closedCaptionsVisible;
+}
+
+void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
+{
+    if (!m_player ||!hasClosedCaptions())
+        return;
+
+    m_closedCaptionsVisible = closedCaptionVisible;
+    m_player->setClosedCaptionsVisible(closedCaptionVisible);
+    if (renderer())
+        renderer()->updateFromElement();
+}
+
+void HTMLMediaElement::setWebkitClosedCaptionsVisible(bool visible)
+{
+    setClosedCaptionsVisible(visible);
+}
+
+bool HTMLMediaElement::webkitClosedCaptionsVisible() const
+{
+    return closedCaptionsVisible();
+}
+
+
+bool HTMLMediaElement::webkitHasClosedCaptions() const
+{
+    return hasClosedCaptions();
+}
+
 }
 
 #endif
index fb6b8ce899f87f78e3abf38a3644290e6e9a18f5..b86835914927597d4ca00f506e8c3110cefae43b 100644 (file)
@@ -137,7 +137,12 @@ public:
     void webkitExitFullScreen();
     bool webkitSupportsFullscreen();
     bool webkitDisplayingFullscreen();
-    
+
+// captions
+    bool webkitHasClosedCaptions() const;
+    bool webkitClosedCaptionsVisible() const;
+    void setWebkitClosedCaptionsVisible(bool);
+
 // controls
     bool controls() const;
     void setControls(bool);
@@ -168,6 +173,10 @@ public:
     void enterFullscreen();
     void exitFullscreen();
 
+    bool hasClosedCaptions() const;
+    bool closedCaptionsVisible() const;
+    void setClosedCaptionsVisible(bool);
+
 protected:
     float getTimeOffsetAttribute(const QualifiedName&, float valueOnError) const;
     void setTimeOffsetAttribute(const QualifiedName&, float value);
@@ -325,6 +334,7 @@ protected:
     bool m_sendProgressEvents : 1;
 
     bool m_isFullscreen : 1;
+    bool m_closedCaptionsVisible : 1;
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     bool m_needWidgetUpdate : 1;
index 20d3a2e00a7629afa5334d0702c7a93365ee26e2..e418a63aead7ff50c9751b506d4d9895d713b560 100644 (file)
@@ -86,5 +86,8 @@ interface [GenerateConstructor, Conditional=VIDEO] HTMLMediaElement : HTMLElemen
     void webkitEnterFullScreen()
         raises (DOMException);
     void webkitExitFullScreen();
+
+    readonly attribute boolean webkitHasClosedCaptions;
+    attribute boolean webkitClosedCaptionsVisible;
 };
 }
index e13231379fbe983b5eed84aa578d50d1c49740f7..439a3b11d7fade1d6b6e9b8dc39fb17aa830928a 100644 (file)
@@ -48,7 +48,7 @@ enum ControlPart {
     NoControlPart, CheckboxPart, RadioPart, PushButtonPart, SquareButtonPart, ButtonPart,
     ButtonBevelPart, DefaultButtonPart, ListButtonPart, ListboxPart, ListItemPart,
     MediaFullscreenButtonPart, MediaMuteButtonPart, MediaPlayButtonPart, MediaSeekBackButtonPart, 
-    MediaSeekForwardButtonPart, MediaRewindButtonPart, MediaReturnToRealtimeButtonPart,
+    MediaSeekForwardButtonPart, MediaRewindButtonPart, MediaReturnToRealtimeButtonPart, MediaToggleClosedCaptionsButtonPart,
     MediaSliderPart, MediaSliderThumbPart, MediaVolumeSliderContainerPart, MediaVolumeSliderPart, MediaVolumeSliderThumbPart,
     MediaControlsBackgroundPart, MediaCurrentTimePart, MediaTimeRemainingPart,
     MenulistPart, MenulistButtonPart, MenulistTextPart, MenulistTextFieldPart,
index d15fd1b6d6323c9efac1657d37b1dd905403d7a6..2fc880b0c6ea336362a37f72358ce3f489a0771b 100644 (file)
@@ -279,6 +279,24 @@ String mediaElementLiveBroadcastStateText()
     return String();
 }
 
+String localizedMediaControlElementString(const String& controlName)
+{
+    notImplemented();
+    return String();
+}
+
+String localizedMediaControlElementHelpText(const String& controlName)
+{
+    notImplemented();
+    return String();
+}
+
+String localizedMediaTimeDescription(const String& controlName)
+{
+    notImplemented();
+    return String();
+}
+
 String searchableIndexIntroduction()
 {
     notImplemented();
index 19f243256b8250a909122b5f69cd4b06aa5fd462..78d766378d1b1bcebb3a8e9381616146c125b112 100644 (file)
@@ -89,6 +89,9 @@ public:
 
     virtual void setVolume(float) { }
 
+    virtual bool hasClosedCaptions() const { return false; }
+    virtual void setClosedCaptionsVisible(bool) { };
+
     virtual MediaPlayer::NetworkState networkState() const { return MediaPlayer::Empty; }
     virtual MediaPlayer::ReadyState readyState() const { return MediaPlayer::HaveNothing; }
 
@@ -375,6 +378,16 @@ void MediaPlayer::setVolume(float volume)
     m_private->setVolume(volume);   
 }
 
+bool MediaPlayer::hasClosedCaptions() const
+{
+    return m_private->hasClosedCaptions();
+}
+
+void MediaPlayer::setClosedCaptionsVisible(bool closedCaptionsVisible)
+{
+    m_private->setClosedCaptionsVisible(closedCaptionsVisible);
+}
+
 float MediaPlayer::rate() const
 {
     return m_rate;
index 51165b548d0416fbd277732d05187b0be4113f2b..ec8ac33d858245137fc007cb1aa9e2c464469969 100644 (file)
@@ -180,7 +180,10 @@ public:
     
     float volume() const;
     void setVolume(float);
-    
+
+    bool hasClosedCaptions() const;
+    void setClosedCaptionsVisible(bool closedCaptionsVisible);
+
     int dataRate() const;
 
     bool autobuffer() const;    
index 86b350d766a3cc09c51a3ee2dfaa487546a887f1..03906bd72869f0c3de6b8fcb2eee60fcc102f052 100644 (file)
@@ -76,6 +76,9 @@ public:
 
     virtual void setVolume(float) = 0;
 
+    virtual bool hasClosedCaptions() const { return false; }    
+    virtual void setClosedCaptionsVisible(bool) { }
+
     virtual MediaPlayer::NetworkState networkState() const = 0;
     virtual MediaPlayer::ReadyState readyState() const = 0;
 
index 0a636269e04ce742297dbb2231d663f5c879358b..7aaf95df3128f1bde95bbfd9e3dbe6f607c2ce97 100644 (file)
@@ -101,6 +101,9 @@ private:
     void setVolume(float);
     void setPreservesPitch(bool);
 
+    bool hasClosedCaptions() const;
+    void setClosedCaptionsVisible(bool);
+
     void setEndTime(float time);
 
     int dataRate() const;
index 8525a90dad7b55212e3ead9771ff5f0b9df36054..ae1aceebda10f98e7cf738a7b5eee0625d9821d6 100644 (file)
@@ -746,6 +746,27 @@ void MediaPlayerPrivate::setVolume(float volume)
         [m_qtMovie.get() setVolume:volume];  
 }
 
+bool MediaPlayerPrivate::hasClosedCaptions() const
+{
+    if (!metaDataAvailable())
+        return false;
+    return wkQTMovieHasClosedCaptions(m_qtMovie.get());  
+}
+
+void MediaPlayerPrivate::setClosedCaptionsVisible(bool closedCaptionsVisible)
+{
+    if (metaDataAvailable()) {
+        wkQTMovieSetShowClosedCaptions(m_qtMovie.get(), closedCaptionsVisible);
+
+#if USE(ACCELERATED_COMPOSITING) && (!defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD))
+    if (closedCaptionsVisible && m_qtVideoLayer) {
+        // Captions will be rendered upsided down unless we flag the movie as flipped (again). See <rdar://7408440>.
+        [m_qtVideoLayer.get() setGeometryFlipped:YES];
+    }
+#endif
+    }
+}
+
 void MediaPlayerPrivate::setRate(float rate)
 {
     if (m_qtMovie)
index 1ffad83e94badfa64b086ff056684847480e90dc..93c75a3892f5c720b7fcd26b66a4d422cdc0fae9 100644 (file)
@@ -392,6 +392,10 @@ String localizedMediaControlElementString(const String& name)
         return String::fromUTF8(_("fast forward"));
     if (name == "SeekBackButton")
         return String::fromUTF8(_("fast reverse"));
+    if (name == "ShowClosedCaptionsButton")
+        return String::fromUTF8(_("show closed captions"));
+    if (name == "HideClosedCaptionsButton")
+        return String::fromUTF8(_("hide closed captions"));
 
     ASSERT_NOT_REACHED();
     return String();
@@ -431,6 +435,10 @@ String localizedMediaControlElementHelpText(const String& name)
         return String::fromUTF8(_("seek quickly forward"));
     if (name == "FullscreenButton")
         return String::fromUTF8(_("Play movie in fullscreen mode"));
+    if (name == "ShowClosedCaptionsButton")
+        return String::fromUTF8(_("start displaying closed captions"));
+    if (name == "HideClosedCaptionsButton")
+        return String::fromUTF8(_("stop displaying closed captions"));
 
     ASSERT_NOT_REACHED();
     return String();
index 3031e3d9c34d7f7c6a91faee678a6465165acc2f..285a8bfef62f8c7614a5a6c656afb93f4dbe23b3 100644 (file)
@@ -125,6 +125,8 @@ extern float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
 extern NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void);
 extern float (*wkQTMovieMaxTimeSeekable)(QTMovie*);
 extern int (*wkQTMovieGetType)(QTMovie* movie);
+extern BOOL (*wkQTMovieHasClosedCaptions)(QTMovie* movie);
+extern void (*wkQTMovieSetShowClosedCaptions)(QTMovie* movie, BOOL showClosedCaptions);
 extern void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
 extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
 extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
index 9e2f76f9599875ab6580179f2a07ee0fa2295298..2663b8d0f580593c44366da8a60bee6ea014e20c 100644 (file)
@@ -59,6 +59,8 @@ float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
 NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void);
 float (*wkQTMovieMaxTimeSeekable)(QTMovie*);
 int (*wkQTMovieGetType)(QTMovie* movie);
+BOOL (*wkQTMovieHasClosedCaptions)(QTMovie* movie);
+void (*wkQTMovieSetShowClosedCaptions)(QTMovie* movie, BOOL showClosedCaptions);
 void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
 void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
 void (*wkSetDragImage)(NSImage*, NSPoint offset);
index 78216fceef5cdf68c26b37f3a1a00129190e065d..9c567568985388936ce781ed5850773072013308 100644 (file)
@@ -348,6 +348,9 @@ MediaControlInputElement::MediaControlInputElement(Document* document, PseudoId
     case MEDIA_CONTROLS_VOLUME_SLIDER:
         m_displayType = MediaVolumeSlider;
         break;
+    case MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON:
+        m_displayType = MediaShowClosedCaptionsButton;
+        break;
     default:
         ASSERT_NOT_REACHED();
         break;
@@ -576,6 +579,29 @@ void MediaControlReturnToRealtimeButtonElement::defaultEventHandler(Event* event
 }
 
 
+// ----------------------------
+
+MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsButtonElement(Document* doc, HTMLMediaElement* element)
+    : MediaControlInputElement(doc, MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON, "button", element)
+{
+}
+
+void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* event)
+{
+    if (event->type() == eventNames().clickEvent) {
+        m_mediaElement->setClosedCaptionsVisible(!m_mediaElement->closedCaptionsVisible());
+        setChecked(m_mediaElement->closedCaptionsVisible());
+        event->setDefaultHandled();
+    }
+    HTMLInputElement::defaultEventHandler(event);
+}
+
+void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType()
+{
+    setDisplayType(m_mediaElement->closedCaptionsVisible() ? MediaHideClosedCaptionsButton : MediaShowClosedCaptionsButton);
+}
+
+
 // ----------------------------
 
 MediaControlTimelineElement::MediaControlTimelineElement(Document* document, HTMLMediaElement* element)
index 8b297733fd285ad7e6d282c397ea4b1173d3bd64..0ba4abaa110280c2487fc7e213887e22d9a33f50 100644 (file)
@@ -54,6 +54,8 @@ enum MediaControlElementType {
     MediaSliderThumb,
     MediaRewindButton,
     MediaReturnToRealtimeButton,
+    MediaShowClosedCaptionsButton,
+    MediaHideClosedCaptionsButton,
     MediaUnMuteButton,
     MediaPauseButton,
     MediaTimelineContainer,
@@ -221,6 +223,15 @@ public:
 
 // ----------------------------
 
+class MediaControlToggleClosedCaptionsButtonElement : public MediaControlInputElement {
+public:
+    MediaControlToggleClosedCaptionsButtonElement(Document*, HTMLMediaElement*);
+    virtual void defaultEventHandler(Event*);
+    virtual void updateDisplayType();
+};    
+
+// ----------------------------
+
 class MediaControlTimelineElement : public MediaControlInputElement {
 public:
     MediaControlTimelineElement(Document*, HTMLMediaElement*);
index 1d4da2338180c74b2e5563fcbd55000cf3cab3aa..987056635e4e23a77f6df98f20f9d0a2d4f71c58 100644 (file)
@@ -121,6 +121,8 @@ void RenderMedia::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
             m_rewindButton->updateStyle();
         if (m_returnToRealtimeButton)
             m_returnToRealtimeButton->updateStyle();
+        if (m_toggleClosedCaptionsButton)
+            m_toggleClosedCaptionsButton->updateStyle();
         if (m_statusDisplay)
             m_statusDisplay->updateStyle();
         if (m_timelineContainer)
@@ -223,6 +225,13 @@ void RenderMedia::createReturnToRealtimeButton()
     m_returnToRealtimeButton->attachToParent(m_panel.get());
 }
 
+void RenderMedia::createToggleClosedCaptionsButton()
+{
+    ASSERT(!m_toggleClosedCaptionsButton);
+    m_toggleClosedCaptionsButton = new MediaControlToggleClosedCaptionsButtonElement(document(), mediaElement());
+    m_toggleClosedCaptionsButton->attachToParent(m_panel.get());
+}
+
 void RenderMedia::createStatusDisplay()
 {
     ASSERT(!m_statusDisplay);
@@ -310,6 +319,7 @@ void RenderMedia::updateControls()
             m_volumeSliderContainer = 0;
             m_volumeSlider = 0;
             m_controlsShadowRoot = 0;
+            m_toggleClosedCaptionsButton = 0;
         }
         m_opacityAnimationTo = 1.0f;
         m_opacityAnimationTimer.stop();
@@ -324,6 +334,7 @@ void RenderMedia::updateControls()
             createRewindButton();
             createPlayButton();
             createReturnToRealtimeButton();
+            createToggleClosedCaptionsButton();
             createStatusDisplay();
             createTimelineContainer();
             if (m_timelineContainer) {
@@ -379,6 +390,8 @@ void RenderMedia::updateControls()
         m_rewindButton->update();
     if (m_returnToRealtimeButton)
         m_returnToRealtimeButton->update();
+    if (m_toggleClosedCaptionsButton)
+        m_toggleClosedCaptionsButton->update();
     if (m_statusDisplay)
         m_statusDisplay->update();
     if (m_fullscreenButton)
@@ -535,6 +548,9 @@ void RenderMedia::forwardEvent(Event* event)
         if (m_returnToRealtimeButton && m_returnToRealtimeButton->hitTest(point))
             m_returnToRealtimeButton->defaultEventHandler(event);
 
+       if (m_toggleClosedCaptionsButton && m_toggleClosedCaptionsButton->hitTest(point))
+            m_toggleClosedCaptionsButton->defaultEventHandler(event);
+
         if (m_timeline && m_timeline->hitTest(point))
             m_timeline->defaultEventHandler(event);
 
index 602cd2648ae62c2872069f91ae9b0abd34a30c67..066b83d059fcf72884d599db6f25cde3d02c2df2 100644 (file)
@@ -40,6 +40,7 @@ class MediaControlPlayButtonElement;
 class MediaControlSeekButtonElement;
 class MediaControlRewindButtonElement;
 class MediaControlReturnToRealtimeButtonElement;
+class MediaControlToggleClosedCaptionsButtonElement;
 class MediaControlTimelineElement;
 class MediaControlVolumeSliderElement;
 class MediaControlFullscreenButtonElement;
@@ -96,6 +97,7 @@ private:
     void createSeekForwardButton();
     void createRewindButton();
     void createReturnToRealtimeButton();
+    void createToggleClosedCaptionsButton();
     void createStatusDisplay();
     void createTimelineContainer();
     void createTimeline();
@@ -123,6 +125,7 @@ private:
     RefPtr<MediaControlSeekButtonElement> m_seekForwardButton;
     RefPtr<MediaControlRewindButtonElement> m_rewindButton;
     RefPtr<MediaControlReturnToRealtimeButtonElement> m_returnToRealtimeButton;
+    RefPtr<MediaControlToggleClosedCaptionsButtonElement> m_toggleClosedCaptionsButton;
     RefPtr<MediaControlTimelineElement> m_timeline;
     RefPtr<MediaControlVolumeSliderElement> m_volumeSlider;
     RefPtr<MediaControlFullscreenButtonElement> m_fullscreenButton;
index 81f9052dc4d4462fe3d61d89abce26db2c853741..e334e9d6ecd98d6864713ef29278e1decf55f1be 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * This file is part of the theme implementation for form controls in WebCore.
  *
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Computer, Inc.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -278,6 +278,8 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf
             return paintMediaRewindButton(o, paintInfo, r);
         case MediaReturnToRealtimeButtonPart:
             return paintMediaReturnToRealtimeButton(o, paintInfo, r);
+        case MediaToggleClosedCaptionsButtonPart:
+            return paintMediaToggleClosedCaptionsButton(o, paintInfo, r);
         case MediaSliderPart:
             return paintMediaSliderTrack(o, paintInfo, r);
         case MediaSliderThumbPart:
@@ -416,6 +418,8 @@ bool RenderTheme::shouldRenderMediaControlPart(ControlPart part, Element* e)
         return mediaElement->movieLoadType() == MediaPlayer::LiveStream;
     case MediaFullscreenButtonPart:
         return mediaElement->supportsFullscreen();
+    case MediaToggleClosedCaptionsButtonPart:
+        return mediaElement->hasClosedCaptions();
     default:
         return true;
     }
index 1b6a7e44e5548ff41664d1290e200a88af189d4e..a080670b388a059ef294323f1daee36d55179c02 100644 (file)
@@ -250,6 +250,7 @@ protected:
     virtual bool paintMediaVolumeSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
     virtual bool paintMediaRewindButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
     virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
+    virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
     virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
     virtual bool paintMediaCurrentTime(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
     virtual bool paintMediaTimeRemaining(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
index 1d68c630c9afa2f3f891591d3a043492bffaf535..48c6c42c2056fc7df8d22091c7a69a480f62454a 100644 (file)
@@ -126,6 +126,7 @@ protected:
     virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     virtual bool paintMediaRewindButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+    virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     virtual bool paintMediaCurrentTime(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     virtual bool paintMediaTimeRemaining(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
index d7c30e55e524f11259ddddab84520229b1ba1a29..410bb9bb9b99663d132013ca68e59d2a840d75d6 100644 (file)
@@ -1644,7 +1644,22 @@ bool RenderThemeMac::paintMediaReturnToRealtimeButton(RenderObject* o, const Ren
     return false;
 }
 
+bool RenderThemeMac::paintMediaToggleClosedCaptionsButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
+{
+    HTMLInputElement* node = static_cast<HTMLInputElement*>(o->node());
+    if (!node)
+        return false;
+    
+    MediaControlToggleClosedCaptionsButtonElement* btn = static_cast<MediaControlToggleClosedCaptionsButtonElement*>(node);
+    if (!btn)
+        return false;
+
+    LocalCurrentGraphicsContext localContext(paintInfo.context);
+    wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, getMediaUIPartStateFlags(node));
 
+    return false;
+}
 bool RenderThemeMac::paintMediaControlsBackground(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
     Node* node = o->node();
@@ -1690,12 +1705,20 @@ String RenderThemeMac::extraMediaControlsStyleSheet()
         return String();
 }
 
-bool RenderThemeMac::shouldRenderMediaControlPart(ControlPart part, Element* e)
+bool RenderThemeMac::shouldRenderMediaControlPart(ControlPart part, Element* element)
 {
     if (part == MediaFullscreenButtonPart)
         return mediaControllerTheme() == MediaControllerThemeQuickTime;
 
-    return RenderTheme::shouldRenderMediaControlPart(part, e);
+    if (part == MediaToggleClosedCaptionsButtonPart) {
+
+        // We rely on QTKit to render captions so don't enable the button unless it will be able to do so.
+        HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(element);
+        if (mediaControllerTheme() != MediaControllerThemeQuickTime || !element->hasTagName(videoTag) || !mediaElement->hasVideo())
+            return false;
+    }
+
+    return RenderTheme::shouldRenderMediaControlPart(part, element);
 }
 
 #endif // ENABLE(VIDEO)
index 38f245c5c104049bcefbfcb4c07d2091c037fab4..92cd3d547cf7d1fb79eb313b14e55ac93b8aa866 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  *
@@ -69,8 +69,9 @@ enum PseudoId {
     NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, SCROLLBAR, FILE_UPLOAD_BUTTON, INPUT_PLACEHOLDER,
     SLIDER_THUMB, SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL,
     MEDIA_CONTROLS_PLAY_BUTTON, MEDIA_CONTROLS_MUTE_BUTTON, MEDIA_CONTROLS_TIMELINE, MEDIA_CONTROLS_TIMELINE_CONTAINER,
-    MEDIA_CONTROLS_VOLUME_SLIDER, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, MEDIA_CONTROLS_SEEK_BACK_BUTTON,
-    MEDIA_CONTROLS_SEEK_FORWARD_BUTTON, MEDIA_CONTROLS_FULLSCREEN_BUTTON, MEDIA_CONTROLS_REWIND_BUTTON, MEDIA_CONTROLS_RETURN_TO_REALTIME_BUTTON,
+    MEDIA_CONTROLS_VOLUME_SLIDER, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, 
+    MEDIA_CONTROLS_SEEK_BACK_BUTTON, MEDIA_CONTROLS_SEEK_FORWARD_BUTTON, MEDIA_CONTROLS_FULLSCREEN_BUTTON, MEDIA_CONTROLS_REWIND_BUTTON, 
+    MEDIA_CONTROLS_RETURN_TO_REALTIME_BUTTON, MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON,
     MEDIA_CONTROLS_STATUS_DISPLAY, SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER,
     INPUT_LIST_BUTTON,
 
index 8b8987c1d52e3e97eb39be1d909c157de096dde1..ab9bc8204c4475895dba98f51570a619de706375 100644 (file)
@@ -1,3 +1,13 @@
+2009-11-19  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/7035231>
+        Support closed caption in <video> element
+
+        * English.lproj/Localizable.strings:
+            Add strings for toggle captions button.
+
 2009-11-18  Michelangelo De Simone  <micdesim@gmail.com>
 
         Reviewed by Darin Adler.
index 0c7d3395c27b30f618f135ec99d8f1cbf3e95760..cb3c3224fc4129766ef817293fc588910cc56605 100644 (file)
Binary files a/WebKit/English.lproj/Localizable.strings and b/WebKit/English.lproj/Localizable.strings differ
index ab999b6a88503b92cf51b0bf0b3397e46d7d265d..c80dabfb19312f171f6c40978ab2042556bc8fcd 100644 (file)
@@ -1,3 +1,19 @@
+2009-11-19  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/7035231>
+        Support closed caption in <video> element
+
+        * WebCoreSupport/WebSystemInterface.m:
+        (InitWebCoreSystemInterface):
+            Add QTMovieHasClosedCaptions and QTMovieSetShowClosedCaptions.
+
+        * WebCoreSupport/WebViewFactory.mm:
+        (-[WebViewFactory localizedMediaControlElementString:]):
+        (-[WebViewFactory localizedMediaControlElementHelpText:]):
+            Add accessibility help strings for media controller closed caption button.
+
 2009-11-18  Michelangelo De Simone  <micdesim@gmail.com>
 
         Reviewed by Darin Adler.
index 68293b311a7dadfcade0ed15f05e853a87b75781..56e01687a69d508b9f4c958843944fa2573374d6 100644 (file)
@@ -80,6 +80,8 @@ void InitWebCoreSystemInterface(void)
     INIT(QTMovieMaxTimeLoadedChangeNotification);
     INIT(QTMovieMaxTimeSeekable);
     INIT(QTMovieGetType);
+    INIT(QTMovieHasClosedCaptions);
+    INIT(QTMovieSetShowClosedCaptions);
     INIT(QTMovieViewSetDrawSynchronously);
 
 #ifndef BUILDING_ON_TIGER
index 7ba5075f6133862f3521df83f689133093a231c0..7ea9055c0cb905b276d6416a473d9df686ae086f 100644 (file)
         return UI_STRING("fast forward", "accessibility role description for fast forward button");
     if ([name isEqualToString:@"SeekBackButton"])
         return UI_STRING("fast reverse", "accessibility role description for fast reverse button");
+    if ([name isEqualToString:@"ShowClosedCaptionsButton"])
+        return UI_STRING("show closed captions", "accessibility role description for show closed captions button");
+    if ([name isEqualToString:@"HideClosedCaptionsButton"])
+        return UI_STRING("hide closed captions", "accessibility role description for hide closed captions button");
+
     ASSERT_NOT_REACHED();
     return @"";
 }
         return UI_STRING("seek quickly forward", "accessibility help text for fast forward button");
     if ([name isEqualToString:@"FullscreenButton"])
         return UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button");
+    if ([name isEqualToString:@"ShowClosedCaptionsButton"])
+        return UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button");
+    if ([name isEqualToString:@"HideClosedCaptionsButton"])
+        return UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button");
     ASSERT_NOT_REACHED();
     return @"";
 }
index 2c4db01c2f2a97f32f2363f5dc00023dcc1e7126..643e550dcaa3c6f6f715e15e45febbc5527fea39 100644 (file)
@@ -1,3 +1,15 @@
+2009-11-19  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/7035231>
+        Support closed caption in <video> element
+
+        * WebCoreLocalizedStrings.cpp:
+        (WebCore::localizedMediaControlElementString):
+        (WebCore::localizedMediaControlElementHelpText):
+            Add accessibility help strings for media controller closed caption button.
+
 2009-11-18  Michelangelo De Simone  <micdesim@gmail.com>
 
         Reviewed by Darin Adler.
index f4ee724d0594161b32bc24f1ecd56f36d0c67a27..9ee22db1d0390026b1d376cd46f76eb8d0d8757e 100644 (file)
@@ -151,6 +151,10 @@ String WebCore::localizedMediaControlElementString(const String& name)
         return String(LPCTSTR_UI_STRING("fast forward", "accessibility role description for fast forward button"));
     if (name == "SeekBackButton")
         return String(LPCTSTR_UI_STRING("fast reverse", "accessibility role description for fast reverse button"));
+    if (name == "ShowClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("show closed captions", "accessibility role description for show closed captions button"));
+    if (name == "HideClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("hide closed captions", "accessibility role description for hide closed captions button"));
 
     ASSERT_NOT_REACHED();
     return String();
@@ -190,6 +194,10 @@ String WebCore::localizedMediaControlElementHelpText(const String& name)
         return String(LPCTSTR_UI_STRING("seek quickly forward", "accessibility help text for fast forward button"));
     if (name == "FullscreenButton")
         return String(LPCTSTR_UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button"));
+    if (name == "ShowClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button"));
+    if (name == "HideClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button"));
 
     ASSERT_NOT_REACHED();
     return String();
index 0ecb4a65c244a88fc50bd13ef2cb5612ecbdd8ee..7bdd10ecbe73d583fce2ffa04d413d30b31772a9 100644 (file)
@@ -1,3 +1,14 @@
+2009-11-19  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/7035231>
+        Support closed caption in <video> element
+
+        * WebKitSystemInterface.h:
+            Add prototypes for WKQTMovieHasClosedCaptions and WKQTMovieSetShowClosedCaptions,
+            define WKMediaUIPartToggleClosedCaptionsButton.
+
 2009-11-13  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Dan Bernstein.
index 50b439ecae261398b07d2b4e32f9c2d12d657605..026af3a91f373d99b833834cc5b3ad9f385d998e 100644 (file)
@@ -188,6 +188,9 @@ typedef enum {
 
 int WKQTMovieGetType(QTMovie* movie);
 
+BOOL WKQTMovieHasClosedCaptions(QTMovie* movie);
+void WKQTMovieSetShowClosedCaptions(QTMovie* movie, BOOL showClosedCaptions);
+
 unsigned WKQTIncludeOnlyModernMediaFileTypes(void);
 int WKQTMovieDataRate(QTMovie* movie);
 float WKQTMovieMaxTimeLoaded(QTMovie* movie);
@@ -207,6 +210,7 @@ typedef enum {
     WKMediaUIPartSliderThumb,
     WKMediaUIPartRewindButton,
     WKMediaUIPartSeekToRealtimeButton,
+    WKMediaUIPartToggleClosedCaptionsButton,
     WKMediaUIPartUnMuteButton,
     WKMediaUIPartPauseButton,
     WKMediaUIPartBackground,
index c2b2c738370de3d50b14f7f8b63f54cf1a0e1f76..17446cc617976e7002382f715e654b9dbb089043 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index 9a9bcc8ddbc0c325c2582234a89725a18df77f2b..946ddf929b94aabee83e761e58f783aeb0c4ac5e 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ
index 06d20f4f023a66537c41f0215493c4c55f822964..d717b8564fd539ee3186020b5966a5eb5055425a 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceTiger.a and b/WebKitLibraries/libWebKitSystemInterfaceTiger.a differ