- Revision
- 138282
- Author
- d...@apple.com
- Date
- 2012-12-20 12:10:53 -0800 (Thu, 20 Dec 2012)
Log Message
Follow WebVTT line breaking rules
https://bugs.webkit.org/show_bug.cgi?id=105496
Reviewed by Eric Carlson.
Source/WebCore:
WebVTT requires that captions never overflow their containers. In other
words, that it is ok to break within words rather than hide content.
Implement this by using CSS's word-break property.
Test: media/track/track-word-breaking.html
* css/mediaControls.css:
(video::-webkit-media-text-track-container): Add word-break.
* css/mediaControlsQuickTime.css: Drive-by cleanup to make sure selection doesn't happen.
(audio::-webkit-media-controls-closed-captions-container, video::-webkit-media-controls-closed-captions-container):
(audio::-webkit-media-controls-closed-captions-track-list, video::-webkit-media-controls-closed-captions-track-list):
LayoutTests:
Test that captions do emergency line breaking. Since we can't
rely on text dimensions, the test simply compares a caption that
will be on one line to a caption with a single huge word, that must
break at least twice. If the bounding rectangle of the second caption
is bigger than the first, we know we broke.
* media/track/captions-webvtt/long-word.vtt: Added.
* media/track/track-word-breaking-expected.txt: Added.
* media/track/track-word-breaking.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (138281 => 138282)
--- trunk/LayoutTests/ChangeLog 2012-12-20 20:07:32 UTC (rev 138281)
+++ trunk/LayoutTests/ChangeLog 2012-12-20 20:10:53 UTC (rev 138282)
@@ -1,3 +1,20 @@
+2012-12-19 Dean Jackson <d...@apple.com>
+
+ Follow WebVTT line breaking rules
+ https://bugs.webkit.org/show_bug.cgi?id=105496
+
+ Reviewed by Eric Carlson.
+
+ Test that captions do emergency line breaking. Since we can't
+ rely on text dimensions, the test simply compares a caption that
+ will be on one line to a caption with a single huge word, that must
+ break at least twice. If the bounding rectangle of the second caption
+ is bigger than the first, we know we broke.
+
+ * media/track/captions-webvtt/long-word.vtt: Added.
+ * media/track/track-word-breaking-expected.txt: Added.
+ * media/track/track-word-breaking.html: Added.
+
2012-12-20 James Simonsen <simon...@chromium.org>
[Resource Timing] 304 responses should show up in the timing buffer
Added: trunk/LayoutTests/media/track/captions-webvtt/long-word.vtt (0 => 138282)
--- trunk/LayoutTests/media/track/captions-webvtt/long-word.vtt (rev 0)
+++ trunk/LayoutTests/media/track/captions-webvtt/long-word.vtt 2012-12-20 20:10:53 UTC (rev 138282)
@@ -0,0 +1,9 @@
+WEBVTT
+
+1
+00:00:00.000 --> 00:00:02.000
+first caption
+
+2
+00:00:02.000 --> 00:01:00.000
+mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Added: trunk/LayoutTests/media/track/track-word-breaking-expected.txt (0 => 138282)
--- trunk/LayoutTests/media/track/track-word-breaking-expected.txt (rev 0)
+++ trunk/LayoutTests/media/track/track-word-breaking-expected.txt 2012-12-20 20:10:53 UTC (rev 138282)
@@ -0,0 +1,7 @@
+Test that line breaks are forced in captions.
+EVENT(canplaythrough)
+Single line caption height recorded.
+EVENT(seeked)
+Second caption was more than twice as tall as first caption. OK
+END OF TEST
+
Property changes on: trunk/LayoutTests/media/track/track-word-breaking-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/media/track/track-word-breaking.html (0 => 138282)
--- trunk/LayoutTests/media/track/track-word-breaking.html (rev 0)
+++ trunk/LayoutTests/media/track/track-word-breaking.html 2012-12-20 20:10:53 UTC (rev 138282)
@@ -0,0 +1,41 @@
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script>
+
+ var singleLineRect;
+
+ function testUnbreakableLine()
+ {
+ var multiLineRect = textTrackDisplayElement(video).firstChild.firstChild.getBoundingClientRect();
+ var ratio = multiLineRect.height / singleLineRect.height;
+ logResult(ratio > 2, "Second caption was more than twice as tall as first caption.")
+ endTest();
+ }
+
+ function testSingleLine()
+ {
+ singleLineRect = textTrackDisplayElement(video).firstChild.firstChild.getBoundingClientRect();
+ consoleWrite("Single line caption height recorded.");
+ video.currentTime = 3;
+ }
+
+ function loaded()
+ {
+ consoleWrite('Test that line breaks are forced in captions.');
+ findMediaElement();
+ waitForEvent('canplaythrough', testSingleLine);
+ waitForEvent('seeked', testUnbreakableLine);
+ video.src = "" '../content/test');
+ }
+
+ </script>
+ </head>
+ <body _onload_="loaded()">
+ <video controls >
+ <track src="" kind="captions" default>
+ </video>
+ </body>
+</html>
Property changes on: trunk/LayoutTests/media/track/track-word-breaking.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (138281 => 138282)
--- trunk/Source/WebCore/ChangeLog 2012-12-20 20:07:32 UTC (rev 138281)
+++ trunk/Source/WebCore/ChangeLog 2012-12-20 20:10:53 UTC (rev 138282)
@@ -1,3 +1,22 @@
+2012-12-19 Dean Jackson <d...@apple.com>
+
+ Follow WebVTT line breaking rules
+ https://bugs.webkit.org/show_bug.cgi?id=105496
+
+ Reviewed by Eric Carlson.
+
+ WebVTT requires that captions never overflow their containers. In other
+ words, that it is ok to break within words rather than hide content.
+ Implement this by using CSS's word-break property.
+
+ Test: media/track/track-word-breaking.html
+
+ * css/mediaControls.css:
+ (video::-webkit-media-text-track-container): Add word-break.
+ * css/mediaControlsQuickTime.css: Drive-by cleanup to make sure selection doesn't happen.
+ (audio::-webkit-media-controls-closed-captions-container, video::-webkit-media-controls-closed-captions-container):
+ (audio::-webkit-media-controls-closed-captions-track-list, video::-webkit-media-controls-closed-captions-track-list):
+
2012-12-20 James Simonsen <simon...@chromium.org>
[Resource Timing] 304 responses should show up in the timing buffer
Modified: trunk/Source/WebCore/css/mediaControls.css (138281 => 138282)
--- trunk/Source/WebCore/css/mediaControls.css 2012-12-20 20:07:32 UTC (rev 138281)
+++ trunk/Source/WebCore/css/mediaControls.css 2012-12-20 20:10:53 UTC (rev 138282)
@@ -233,6 +233,7 @@
text-decoration: none;
pointer-events: none;
-webkit-user-select: none;
+ word-break: break-word;
-webkit-box-flex: 1;
}
Modified: trunk/Source/WebCore/css/mediaControlsQuickTime.css (138281 => 138282)
--- trunk/Source/WebCore/css/mediaControlsQuickTime.css 2012-12-20 20:07:32 UTC (rev 138281)
+++ trunk/Source/WebCore/css/mediaControlsQuickTime.css 2012-12-20 20:10:53 UTC (rev 138282)
@@ -252,6 +252,7 @@
background-color: rgba(0, 0, 0, 0.85);
border: 1px solid rgb(66, 66, 66);
border-radius: 8px;
+ cursor: default;
}
audio::-webkit-media-controls-closed-captions-track-list, video::-webkit-media-controls-closed-captions-track-list {
@@ -268,6 +269,7 @@
font-family: "Helvetica Bold", "Helvetica";
font-weight: bold;
font-size: 9pt;
+ -webkit-user-select: none;
}
audio::-webkit-media-controls-closed-captions-track-list h3,