Display a TextTrackCue when snap-to-lines flag is set
authorvictor@rosedu.org <victor@rosedu.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 01:00:10 +0000 (01:00 +0000)
committervictor@rosedu.org <victor@rosedu.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 01:00:10 +0000 (01:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79751

Reviewed by Tony Chang.

Source/WebCore:

This patch implements rendering functionality for a given text track,
following closer the exact WebVTT specification. There are two new classes
which have been added in order to succesfully cover rendering when of a text
track cue.

RenderTextTrackCue handles the specific rendering algorithm required,
by checking for overlaps with other boxes that are in the same
container (these can be any other boxes, not necessarily other cues,
the video controls, for example).

TextTrackCueBox extends HTMLDivElement and is an intermediate layer
between the renderer class and the actual cue object. Its purpose is
to instantiate the particular renderer and cover all the default CSS
styling that needs to be applied to the cue.

The layout is done in two steps:
  - Step 1: Layout the TextTrackCue with default CSS properties set (this is
the TextTrackCueBox decorated with the respective CSS elements)
  - Step 2: RenderTextTrackCue adjusts the box position depending on the
parameters of the TextTrackCue object and the overlaps that may occur with
previously positioned cues.

Tests: media/track/track-cue-rendering-horizontal.html
       media/track/track-cue-rendering-vertical.html

* CMakeLists.txt: Updated to include RenderTextTrackCue.
* GNUmakefile.list.am: Updated to include RenderTextTrackCue.
* Target.pri: Updated to include RenderTextTrackCue.
* WebCore.gypi: Updated to include RenderTextTrackCue.
* WebCore.vcproj/WebCore.vcproj: Updated to include RenderTextTrackCue.
* WebCore.xcodeproj/project.pbxproj: Updated to include RenderTextTrackCue.
* css/mediaControls.css: Removed unreliable CSS.
(video::-webkit-media-text-track-display): Removed properties.
* html/shadow/MediaControlElements.cpp: Updated to not use the new class.
(RenderTextTrackContainerElement):
(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Simplified
the function by moving the check if track is rendered in TextTrack and used
the TextTrackCueBox for cues.
* html/track/TextTrack.cpp: Added a new method.
(WebCore::TextTrack::isRendered): Method that returns whether the track should
be rendered or not.
(WebCore):
* html/track/TextTrack.h: Added the isRendered method.
(TextTrack):
* html/track/TextTrackCue.cpp: Added several helper methods and
the TextTrackCueBox.
(WebCore):
(WebCore::TextTrackCueBox::TextTrackCueBox): The TextTrackCueBox extends
the HTMLDivElement and represents a bridge class between RenderTextTrackCue
and TextTrackCue. This is required as the layout is done in two steps, as
explained on top of the ChangeLog entry.
(WebCore::TextTrackCueBox::getCue): Returns the associated TextTrackCue object.
(WebCore::TextTrackCueBox::applyCSSProperties): Applies a part of the default CSS
properties, as defined by section 3.5.1 of the WebVTT specification.
(WebCore::TextTrackCueBox::shadowPseudoId): Moved the shadow pseudo id.
(WebCore::TextTrackCueBox::createRenderer): Creates the particular renderer.
(WebCore::TextTrackCue::TextTrackCue): Corrected the internal writing mode map.
(WebCore::TextTrackCue::calculateComputedLinePosition): Updated the compute line
position algorithm. This requires, however, a method to consider only rendered
tracks (and therefore will be addressed completely in subsequent changeset).
(WebCore::TextTrackCue::calculateDisplayParameters): Updated and corrected the
computed display parameters to match the current specification.
(WebCore::TextTrackCue::getDisplayTree): Update to use the TextTrackCueBox class
and moved CSS application to the respective class.
(WebCore::TextTrackCue::getPositionCoordinates): Added comment to specify in which
situation this method is used and change visibility to private.
(WebCore::TextTrackCue::getCSSWritingMode): Returns the CSS writing mode corresponding
to the cue writing mode.
(WebCore::TextTrackCue::getCSSSize): Returns the cue width / height (depending on the
writing direction.
(WebCore::TextTrackCue::getCSSPosition): Returns the default display position, that is
used in the first layout step.
* html/track/TextTrackCue.h:
(WebCore):
(TextTrackCueBox):
(WebCore::TextTrackCueBox::create): Initialization method.
(TextTrackCue):
(WebCore::TextTrackCue::getWritingDirection): Helper method to return the internal
values used to represent the writing direction.
* rendering/RenderTextTrackCue.cpp: Added.
(WebCore):
(WebCore::RenderTextTrackCue::RenderTextTrackCue):
(WebCore::RenderTextTrackCue::layout): The rendering steps, as mentioned in
the WebVTT rendering rules. Currently, this treats only the snap-to-lines set
case. It is implemented following closely the spec, and might be subject to
change as discussions on various bugs evolve.
(WebCore::RenderTextTrackCue::initializeLayoutParameters): Steps 1 - 7.
(WebCore::RenderTextTrackCue::placeBoxInDefaultPosition): Steps 8 - 10.
(WebCore::RenderTextTrackCue::isOutside): Inline method to check if the cue is outside.
(WebCore::RenderTextTrackCue::isOverlapping): Inline method to check if the cue overlaps other boxes.
(WebCore::RenderTextTrackCue::shouldSwitchDirection): Step 12.
(WebCore::RenderTextTrackCue::moveBoxesByStep): Step 13.
(WebCore::RenderTextTrackCue::switchDirection): Steps 15 - 18.
(WebCore::RenderTextTrackCue::repositionCueSnapToLinesSet): Cue repositioning
for text track cue when the snap to lines flag is set.
(WebCore::RenderTextTrackCue::repositionCueSnapToLinesNotSet): Cue repositioning
for text track cue when the snap to lines flag is not set. Not implemented yet.
* rendering/RenderTextTrackCue.h: Added.
(WebCore):
(RenderTextTrackCue): Rendering class, handling the display of cues.

LayoutTests:

Test cases covering snap-to-lines horizontal and vertical positioning of cues.

* media/track/captions-webvtt/captions-snap-to-lines-set.vtt: Added.
* media/track/track-cue-rendering-horizontal.html: Added.
* media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt: Updated.
* media/track/track-cue-rendering-vertical.html: Added.
* media/video-test.js: Updated to support pixel test dumps.
* platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.png: Added.
* platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.txt: Added.
* platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.png: Added.
* platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.txt: Added.
* platform/chromium/TestExpectations: Marking these temporarily as IMAGE fail, as they will
anyway require new baselines.
* platform/mac/media/track/track-cue-rendering-horizontal-expected.png: Added.
* platform/mac/media/track/track-cue-rendering-horizontal-expected.txt: Added.
* platform/mac/media/track/track-cue-rendering-vertical-expected.png: Added.
* platform/mac/media/track/track-cue-rendering-vertical-expected.txt: Added.

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

30 files changed:
LayoutTests/ChangeLog
LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-set.vtt [new file with mode: 0644]
LayoutTests/media/track/track-cue-rendering-horizontal.html [new file with mode: 0644]
LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt
LayoutTests/media/track/track-cue-rendering-vertical.html [new file with mode: 0644]
LayoutTests/media/video-test.js
LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/media/track/track-cue-rendering-vertical-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/media/track/track-cue-rendering-vertical-expected.txt [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/mediaControls.css
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h
Source/WebCore/html/track/TextTrackCue.cpp
Source/WebCore/html/track/TextTrackCue.h
Source/WebCore/rendering/RenderTextTrackCue.cpp [new file with mode: 0644]
Source/WebCore/rendering/RenderTextTrackCue.h [new file with mode: 0644]

index 6b00294..480c2ea 100644 (file)
@@ -1,3 +1,28 @@
+2012-08-22  Victor Carbune  <victor@rosedu.org>
+
+        Display a TextTrackCue when snap-to-lines flag is set
+        https://bugs.webkit.org/show_bug.cgi?id=79751
+
+        Reviewed by Tony Chang.
+
+        Test cases covering snap-to-lines horizontal and vertical positioning of cues.
+
+        * media/track/captions-webvtt/captions-snap-to-lines-set.vtt: Added.
+        * media/track/track-cue-rendering-horizontal.html: Added.
+        * media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt: Updated.
+        * media/track/track-cue-rendering-vertical.html: Added.
+        * media/video-test.js: Updated to support pixel test dumps.
+        * platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.png: Added.
+        * platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.txt: Added.
+        * platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.png: Added.
+        * platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.txt: Added.
+        * platform/chromium/TestExpectations: Marking these temporarily as IMAGE fail, as they will
+        anyway require new baselines.
+        * platform/mac/media/track/track-cue-rendering-horizontal-expected.png: Added.
+        * platform/mac/media/track/track-cue-rendering-horizontal-expected.txt: Added.
+        * platform/mac/media/track/track-cue-rendering-vertical-expected.png: Added.
+        * platform/mac/media/track/track-cue-rendering-vertical-expected.txt: Added.
+
 2012-08-22  Alejandro Piñeiro  <apinheiro@igalia.com>
 
         [Gtk] Dojo toggle buttons should expose ROLE_TOGGLE_BUTTON not ROLE_PUSH_BUTTON
diff --git a/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-set.vtt b/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-set.vtt
new file mode 100644 (file)
index 0000000..63dee27
--- /dev/null
@@ -0,0 +1,49 @@
+WEBVTT FILE
+
+1
+00:00:00.000 --> 00:00:00.500 line:0
+Cue 1: should be positioned at the top of the video.
+
+2
+00:00:00.000 --> 00:00:00.500 line:0
+Cue 2: should be the second cue and not overlap cue 1.
+
+3
+00:00:00.000 --> 00:00:00.500 line:1
+Cue 3: should become the third line from top to bottom.
+
+4
+00:00:00.000 --> 00:00:00.500 line:5
+Cue 4: should be fixed positioned around the middle.
+
+5
+00:00:00.000 --> 00:00:00.500 line:-1
+Cue 5: should be displayed at the bottom of the video.
+
+6
+00:00:00.000 --> 00:00:00.500
+Cue 6: should be on top of bottom positioned cue 5.
+
+1
+00:00:00.500 --> 00:00:01.000 vertical:rl
+Cue 1: 私は立派な人
+
+2
+00:00:00.500 --> 00:00:01.000 vertical:rl
+Cue 2: 私は立派な人
+
+3
+00:00:00.500 --> 00:00:01.000 vertical:rl line:3
+Cue 3: 私は立派な人
+
+4
+00:00:00.500 --> 00:00:01.000 vertical:rl line:4
+Cue 4: 私は立派な人
+
+5
+00:00:00.500 --> 00:00:01.000 vertical:lr
+Cue 5: 私は立派な人
+
+6
+00:00:00.500 --> 00:00:01.000 vertical:lr
+Cue 6: 私は立派な人
diff --git a/LayoutTests/media/track/track-cue-rendering-horizontal.html b/LayoutTests/media/track/track-cue-rendering-horizontal.html
new file mode 100644 (file)
index 0000000..ee2ce0c
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=../media-file.js></script>
+        <script src=../media-controls.js></script>
+
+        <script>
+        var requirePixelDump = true;
+
+        function loaded()
+        {
+            consoleWrite("Rendering horizontal line-positioned cues.");
+            findMediaElement();
+
+            testTrack = document.querySelector('track');
+            video.src = findMediaFile('video', '../content/test');
+
+            waitForEvent('seeked', endTest);
+            waitForEvent('canplaythrough', function() {
+                video.currentTime = .25;
+            });
+        }
+
+        </script>
+
+        <script src=../video-test.js></script>
+    </head>
+    <body onload="loaded()">
+        <video controls>
+            <track src="captions-webvtt/captions-snap-to-lines-set.vtt" kind="captions" default>
+        </video>
+    </body>
+</html>
index afe9aaf..ffdc3ff 100644 (file)
@@ -12,7 +12,7 @@ Active cues: 1
 * Cue 0 *
 EXPECTED (cueDisplayElement.innerText == 'This is a demo track to illustrate positioning features of cues.') OK
 Cue left position (percentage): 0
-Cue top position (percentage): 100
+Cue top position (percentage): 81
 
 ** Center **
 EVENT(seeked)
diff --git a/LayoutTests/media/track/track-cue-rendering-vertical.html b/LayoutTests/media/track/track-cue-rendering-vertical.html
new file mode 100644 (file)
index 0000000..007d8ad
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=../media-file.js></script>
+        <script src=../media-controls.js></script>
+
+        <script>
+        var requirePixelDump = true;
+
+        function loaded()
+        {
+            consoleWrite("Rendering vertical line-positioned cues with Japanese text.");
+            findMediaElement();
+
+            testTrack = document.querySelector('track');
+            video.src = findMediaFile('video', '../content/test');
+
+            waitForEvent('seeked', endTest);
+            waitForEvent('canplaythrough', function() {
+                video.currentTime = .75;
+            });
+        }
+
+        </script>
+
+        <script src=../video-test.js></script>
+    </head>
+    <body onload="loaded()">
+        <video controls>
+            <track src="captions-webvtt/captions-snap-to-lines-set.vtt" kind="captions" default>
+        </video>
+    </body>
+</html>
index a678ae4..edfddbb 100644 (file)
@@ -14,7 +14,10 @@ findMediaElement();
 logConsole();
 
 if (window.testRunner) {
-    testRunner.dumpAsText();
+    // Some track element rendering tests require text pixel dump.
+    if (typeof requirePixelDump == "undefined")
+        testRunner.dumpAsText();
+
     testRunner.waitUntilDone();
 }
 
diff --git a/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.png b/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.png
new file mode 100644 (file)
index 0000000..cb103ce
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.txt b/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-horizontal-expected.txt
new file mode 100644 (file)
index 0000000..3d8620e
--- /dev/null
@@ -0,0 +1,84 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x341
+  RenderBlock {HTML} at (0,0) size 800x341
+    RenderBody {BODY} at (8,8) size 784x325
+      RenderBlock (anonymous) at (0,0) size 784x245
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,245) size 784x80
+        RenderText {#text} at (0,0) size 250x19
+          text run at (0,0) width 250: "Rendering horizontal line-positioned cues."
+        RenderBR {BR} at (250,0) size 0x19
+        RenderText {#text} at (0,20) size 151x19
+          text run at (0,20) width 151: "EVENT(canplaythrough)"
+        RenderBR {BR} at (151,20) size 0x19
+        RenderText {#text} at (0,40) size 103x19
+          text run at (0,40) width 103: "EVENT(seeked)"
+        RenderBR {BR} at (103,40) size 0x19
+        RenderText {#text} at (0,60) size 97x19
+          text run at (0,60) width 97: "END OF TEST"
+        RenderBR {BR} at (97,60) size 0x19
+layer at (8,8) size 320x240
+  RenderVideo {VIDEO} at (0,0) size 320x240
+layer at (8,8) size 320x240
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (0,0) size 320x240
+    RenderBlock {DIV} at (0,205) size 320x35
+layer at (8,8) size 320x205
+  RenderBlock (relative positioned) {DIV} at (0,0) size 320x205 [color=#FFFFFF00]
+layer at (8,8) size 320x15
+  RenderBlock (positioned) {DIV} at (0,0) size 320x15 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 280x19 [bgcolor=#000000CC]
+      RenderText {#text} at (22,0) size 276x15
+        text run at (22,0) width 276: "Cue 1: should be positioned at the top of the video."
+    RenderInline {DIV} at (0,0) size 2x19 [bgcolor=#000000CC]
+layer at (8,27) size 320x15
+  RenderBlock (positioned) {DIV} at (0,19) size 320x15 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 308x19 [bgcolor=#000000CC]
+      RenderText {#text} at (8,0) size 304x15
+        text run at (8,0) width 304: "Cue 2: should be the second cue and not overlap cue 1."
+    RenderInline {DIV} at (0,0) size 2x19 [bgcolor=#000000CC]
+layer at (8,46) size 320x15
+  RenderBlock (positioned) {DIV} at (0,38) size 320x15 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 304x19 [bgcolor=#000000CC]
+      RenderText {#text} at (10,0) size 300x15
+        text run at (10,0) width 300: "Cue 3: should become the third line from top to bottom."
+    RenderInline {DIV} at (0,0) size 2x19 [bgcolor=#000000CC]
+layer at (8,103) size 320x15
+  RenderBlock (positioned) {DIV} at (0,95) size 320x15 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 294x19 [bgcolor=#000000CC]
+      RenderText {#text} at (15,0) size 290x15
+        text run at (15,0) width 290: "Cue 4: should be fixed positioned around the middle."
+    RenderInline {DIV} at (0,0) size 3x19 [bgcolor=#000000CC]
+layer at (8,194) size 320x15
+  RenderBlock (positioned) {DIV} at (0,186) size 320x15 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 296x19 [bgcolor=#000000CC]
+      RenderText {#text} at (14,0) size 292x15
+        text run at (14,0) width 292: "Cue 5: should be displayed at the bottom of the video."
+    RenderInline {DIV} at (0,0) size 2x19 [bgcolor=#000000CC]
+layer at (8,175) size 320x15
+  RenderBlock (positioned) {DIV} at (0,167) size 320x15 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 286x19 [bgcolor=#000000CC]
+      RenderText {#text} at (19,0) size 282x15
+        text run at (19,0) width 282: "Cue 6: should be on top of bottom positioned cue 5."
+    RenderInline {DIV} at (0,0) size 2x19 [bgcolor=#000000CC]
+layer at (13,213) size 310x30 scrollHeight 36
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (5,0) size 310x30 [bgcolor=#141414CC]
+    RenderButton {INPUT} at (9,0) size 30x30
+    RenderSlider {INPUT} at (48,11) size 91x8
+      RenderDeprecatedFlexibleBox {DIV} at (0,0) size 91x8 [border: (1px solid #E6E6E659)]
+        RenderBlock {DIV} at (1,1) size 71x24
+        RenderBlock {DIV} at (65,1) size 32x24
+    RenderDeprecatedFlexibleBox {DIV} at (154,0) size 25x30 [color=#FFFFFF]
+      RenderBlock (anonymous) at (0,0) size 25x30
+        RenderText {#text} at (0,7) size 25x16
+          text run at (0,7) width 25: "0:00"
+    RenderButton {INPUT} at (188,0) size 35x30
+    RenderSlider {INPUT} at (229,11) size 32x8
+      RenderDeprecatedFlexibleBox {DIV} at (0,0) size 32x8 [border: (1px solid #E6E6E659)]
+        RenderBlock {DIV} at (1,1) size 20x24
+        RenderBlock {DIV} at (14,1) size 24x24
+    RenderButton {INPUT} at (271,0) size 30x30
+layer at (58,216) size 32x24
+  RenderBlock (relative positioned) {DIV} at (-7,-8) size 32x24
+layer at (256,216) size 24x24
+  RenderBlock (relative positioned) {DIV} at (-7,-8) size 24x24
diff --git a/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.png b/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.png
new file mode 100644 (file)
index 0000000..ea9dc3f
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.txt b/LayoutTests/platform/chromium-linux/media/track/track-cue-rendering-vertical-expected.txt
new file mode 100644 (file)
index 0000000..be67835
--- /dev/null
@@ -0,0 +1,84 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x341
+  RenderBlock {HTML} at (0,0) size 800x341
+    RenderBody {BODY} at (8,8) size 784x325
+      RenderBlock (anonymous) at (0,0) size 784x245
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,245) size 784x80
+        RenderText {#text} at (0,0) size 349x19
+          text run at (0,0) width 349: "Rendering vertical line-positioned cues with Japanese text."
+        RenderBR {BR} at (349,0) size 0x19
+        RenderText {#text} at (0,20) size 151x19
+          text run at (0,20) width 151: "EVENT(canplaythrough)"
+        RenderBR {BR} at (151,20) size 0x19
+        RenderText {#text} at (0,40) size 103x19
+          text run at (0,40) width 103: "EVENT(seeked)"
+        RenderBR {BR} at (103,40) size 0x19
+        RenderText {#text} at (0,60) size 97x19
+          text run at (0,60) width 97: "END OF TEST"
+        RenderBR {BR} at (97,60) size 0x19
+layer at (8,8) size 320x240
+  RenderVideo {VIDEO} at (0,0) size 320x240
+layer at (8,8) size 320x240
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (0,0) size 320x240
+    RenderBlock {DIV} at (0,205) size 320x35
+layer at (8,8) size 320x205
+  RenderBlock (relative positioned) {DIV} at (0,0) size 320x205 [color=#FFFFFF00]
+layer at (12,8) size 15x205
+  RenderBlock (positioned) {DIV} at (4,0) size 15x205 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 19x115 [bgcolor=#000000CC]
+      RenderText {#text} at (0,45) size 15x111
+        text run at (0,45) width 111: "Cue 1: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 17x4 [bgcolor=#000000CC]
+layer at (31,8) size 15x205
+  RenderBlock (positioned) {DIV} at (23,0) size 15x205 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 19x115 [bgcolor=#000000CC]
+      RenderText {#text} at (0,45) size 15x111
+        text run at (0,45) width 111: "Cue 2: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 17x4 [bgcolor=#000000CC]
+layer at (256,8) size 15x205
+  RenderBlock (positioned) {DIV} at (248,0) size 15x205 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 19x115 [bgcolor=#000000CC]
+      RenderText {#text} at (0,45) size 15x111
+        text run at (0,45) width 111: "Cue 3: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 17x4 [bgcolor=#000000CC]
+layer at (237,8) size 15x205
+  RenderBlock (positioned) {DIV} at (229,0) size 15x205 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 19x115 [bgcolor=#000000CC]
+      RenderText {#text} at (0,45) size 15x111
+        text run at (0,45) width 111: "Cue 4: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 17x4 [bgcolor=#000000CC]
+layer at (309,8) size 15x205
+  RenderBlock (positioned) {DIV} at (301,0) size 15x205 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 19x115 [bgcolor=#000000CC]
+      RenderText {#text} at (0,45) size 15x111
+        text run at (0,45) width 111: "Cue 5: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 17x4 [bgcolor=#000000CC]
+layer at (290,8) size 15x205
+  RenderBlock (positioned) {DIV} at (282,0) size 15x205 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 19x115 [bgcolor=#000000CC]
+      RenderText {#text} at (0,45) size 15x111
+        text run at (0,45) width 111: "Cue 6: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 17x4 [bgcolor=#000000CC]
+layer at (13,213) size 310x30 scrollHeight 36
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (5,0) size 310x30 [bgcolor=#141414CC]
+    RenderButton {INPUT} at (9,0) size 30x30
+    RenderSlider {INPUT} at (48,11) size 91x8
+      RenderDeprecatedFlexibleBox {DIV} at (0,0) size 91x8 [border: (1px solid #E6E6E659)]
+        RenderBlock {DIV} at (1,1) size 71x24
+        RenderBlock {DIV} at (65,1) size 32x24
+    RenderDeprecatedFlexibleBox {DIV} at (154,0) size 25x30 [color=#FFFFFF]
+      RenderBlock (anonymous) at (0,0) size 25x30
+        RenderText {#text} at (0,7) size 25x16
+          text run at (0,7) width 25: "0:00"
+    RenderButton {INPUT} at (188,0) size 35x30
+    RenderSlider {INPUT} at (229,11) size 32x8
+      RenderDeprecatedFlexibleBox {DIV} at (0,0) size 32x8 [border: (1px solid #E6E6E659)]
+        RenderBlock {DIV} at (1,1) size 20x24
+        RenderBlock {DIV} at (14,1) size 24x24
+    RenderButton {INPUT} at (271,0) size 30x30
+layer at (64,216) size 32x24
+  RenderBlock (relative positioned) {DIV} at (-7,-8) size 32x24
+layer at (256,216) size 24x24
+  RenderBlock (relative positioned) {DIV} at (-7,-8) size 24x24
index 4d70a3d..0372589 100644 (file)
@@ -3448,6 +3448,9 @@ BUGWK93568 DEBUG : http/tests/misc/window-dot-stop.html = PASS TEXT
 // V8 does not support static attributes
 BUGWK93488 SKIP : fast/notifications/notifications-permission.html = TEXT
 
+BUGWK79751 : media/track/track-cue-rendering-horizontal.html = IMAGE
+BUGWK79751 : media/track/track-cue-rendering-vertical.html = IMAGE
+
 // Flaky
 BUGWK93799 MAC : fast/dom/HTMLMeterElement/meter-element-repaint-on-update-value.html = PASS IMAGE
 BUGWK93799 MAC : fast/dom/HTMLMeterElement/meter-element.html = PASS IMAGE
diff --git a/LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.png b/LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.png
new file mode 100644 (file)
index 0000000..959cbae
Binary files /dev/null and b/LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.png differ
diff --git a/LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.txt b/LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.txt
new file mode 100644 (file)
index 0000000..31d503c
--- /dev/null
@@ -0,0 +1,87 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x332
+  RenderBlock {HTML} at (0,0) size 800x332
+    RenderBody {BODY} at (8,8) size 784x316
+      RenderBlock (anonymous) at (0,0) size 784x244
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,244) size 784x72
+        RenderText {#text} at (0,0) size 266x18
+          text run at (0,0) width 266: "Rendering horizontal line-positioned cues."
+        RenderBR {BR} at (266,0) size 0x18
+        RenderText {#text} at (0,18) size 162x18
+          text run at (0,18) width 162: "EVENT(canplaythrough)"
+        RenderBR {BR} at (162,18) size 0x18
+        RenderText {#text} at (0,36) size 107x18
+          text run at (0,36) width 107: "EVENT(seeked)"
+        RenderBR {BR} at (107,36) size 0x18
+        RenderText {#text} at (0,54) size 102x18
+          text run at (0,54) width 102: "END OF TEST"
+        RenderBR {BR} at (102,54) size 0x18
+layer at (8,8) size 320x240
+  RenderVideo {VIDEO} at (0,0) size 320x240
+layer at (8,8) size 320x240
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (0,0) size 320x240
+layer at (8,8) size 320x215
+  RenderBlock (relative positioned) {DIV} at (0,0) size 320x215 [color=#FFFFFF00]
+layer at (8,8) size 320x14
+  RenderBlock (positioned) {DIV} at (0,0) size 320x14 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 280x18 [bgcolor=#000000CC]
+      RenderText {#text} at (22,0) size 276x14
+        text run at (22,0) width 276: "Cue 1: should be positioned at the top of the video."
+    RenderInline {DIV} at (0,0) size 3x18 [bgcolor=#000000CC]
+layer at (8,26) size 320x14
+  RenderBlock (positioned) {DIV} at (0,18) size 320x14 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 308x18 [bgcolor=#000000CC]
+      RenderText {#text} at (8,0) size 304x14
+        text run at (8,0) width 304: "Cue 2: should be the second cue and not overlap cue 1."
+    RenderInline {DIV} at (0,0) size 3x18 [bgcolor=#000000CC]
+layer at (8,44) size 320x14
+  RenderBlock (positioned) {DIV} at (0,36) size 320x14 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 300x18 [bgcolor=#000000CC]
+      RenderText {#text} at (12,0) size 296x14
+        text run at (12,0) width 296: "Cue 3: should become the third line from top to bottom."
+    RenderInline {DIV} at (0,0) size 2x18 [bgcolor=#000000CC]
+layer at (8,98) size 320x14
+  RenderBlock (positioned) {DIV} at (0,90) size 320x14 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 292x18 [bgcolor=#000000CC]
+      RenderText {#text} at (16,0) size 288x14
+        text run at (16,0) width 288: "Cue 4: should be fixed positioned around the middle."
+    RenderInline {DIV} at (0,0) size 3x18 [bgcolor=#000000CC]
+layer at (8,205) size 320x14
+  RenderBlock (positioned) {DIV} at (0,197) size 320x14 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 296x18 [bgcolor=#000000CC]
+      RenderText {#text} at (14,0) size 292x14
+        text run at (14,0) width 292: "Cue 5: should be displayed at the bottom of the video."
+    RenderInline {DIV} at (0,0) size 3x18 [bgcolor=#000000CC]
+layer at (8,187) size 320x14
+  RenderBlock (positioned) {DIV} at (0,179) size 320x14 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 284x18 [bgcolor=#000000CC]
+      RenderText {#text} at (20,0) size 280x14
+        text run at (20,0) width 280: "Cue 6: should be on top of bottom positioned cue 5."
+    RenderInline {DIV} at (0,0) size 3x18 [bgcolor=#000000CC]
+layer at (8,223) size 320x25
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (0,215) size 320x25
+    RenderButton {INPUT} at (6,3) size 18x18
+    RenderButton {INPUT} at (32,4) size 16x16
+    RenderDeprecatedFlexibleBox {DIV} at (49,5) size 216x15
+      RenderSlider {INPUT} at (45,2) size 126x13
+        RenderDeprecatedFlexibleBox {DIV} at (0,0) size 126x13
+          RenderBlock {DIV} at (0,2) size 116x8
+          RenderBlock {DIV} at (116,2) size 10x8
+    RenderButton {INPUT} at (297,4) size 16x16
+    RenderBlock {DIV} at (265,6) size 25x12
+layer at (57,230) size 45x11
+  RenderDeprecatedFlexibleBox {DIV} at (0,2) size 45x11 [color=#FFFFFF]
+    RenderBlock (anonymous) at (9,0) size 26x11
+      RenderText {#text} at (0,0) size 26x11
+        text run at (0,0) width 26: "00:00"
+layer at (228,230) size 45x11
+  RenderDeprecatedFlexibleBox {DIV} at (171,2) size 45x11 [color=#FFFFFF]
+    RenderBlock (anonymous) at (7,0) size 31x11
+      RenderText {#text} at (0,0) size 31x11
+        text run at (0,0) width 31: "-00:05"
+layer at (106,232) size 10x8
+  RenderBlock (relative positioned) {DIV} at (0,0) size 10x8
+layer at (275,229) size 14x12
+  RenderButton zI: 1 {INPUT} at (2,0) size 14x12
diff --git a/LayoutTests/platform/mac/media/track/track-cue-rendering-vertical-expected.png b/LayoutTests/platform/mac/media/track/track-cue-rendering-vertical-expected.png
new file mode 100644 (file)
index 0000000..3fb7821
Binary files /dev/null and b/LayoutTests/platform/mac/media/track/track-cue-rendering-vertical-expected.png differ
diff --git a/LayoutTests/platform/mac/media/track/track-cue-rendering-vertical-expected.txt b/LayoutTests/platform/mac/media/track/track-cue-rendering-vertical-expected.txt
new file mode 100644 (file)
index 0000000..6b010d5
--- /dev/null
@@ -0,0 +1,87 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x332
+  RenderBlock {HTML} at (0,0) size 800x332
+    RenderBody {BODY} at (8,8) size 784x316
+      RenderBlock (anonymous) at (0,0) size 784x244
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,244) size 784x72
+        RenderText {#text} at (0,0) size 368x18
+          text run at (0,0) width 368: "Rendering vertical line-positioned cues with Japanese text."
+        RenderBR {BR} at (368,0) size 0x18
+        RenderText {#text} at (0,18) size 162x18
+          text run at (0,18) width 162: "EVENT(canplaythrough)"
+        RenderBR {BR} at (162,18) size 0x18
+        RenderText {#text} at (0,36) size 107x18
+          text run at (0,36) width 107: "EVENT(seeked)"
+        RenderBR {BR} at (107,36) size 0x18
+        RenderText {#text} at (0,54) size 102x18
+          text run at (0,54) width 102: "END OF TEST"
+        RenderBR {BR} at (102,54) size 0x18
+layer at (8,8) size 320x240
+  RenderVideo {VIDEO} at (0,0) size 320x240
+layer at (8,8) size 320x240
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (0,0) size 320x240
+layer at (8,8) size 320x215
+  RenderBlock (relative positioned) {DIV} at (0,0) size 320x215 [color=#FFFFFF00]
+layer at (8,8) size 18x215
+  RenderBlock (positioned) {DIV} at (0,0) size 18x215 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 18x117 [bgcolor=#000000CC]
+      RenderText {#text} at (2,49) size 14x113
+        text run at (2,49) width 112: "Cue 1: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 16x5 [bgcolor=#000000CC]
+layer at (26,8) size 18x215
+  RenderBlock (positioned) {DIV} at (18,0) size 18x215 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 18x117 [bgcolor=#000000CC]
+      RenderText {#text} at (2,49) size 14x113
+        text run at (2,49) width 112: "Cue 2: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 16x5 [bgcolor=#000000CC]
+layer at (256,8) size 18x215
+  RenderBlock (positioned) {DIV} at (248,0) size 18x215 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 18x117 [bgcolor=#000000CC]
+      RenderText {#text} at (2,49) size 14x113
+        text run at (2,49) width 112: "Cue 3: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 16x5 [bgcolor=#000000CC]
+layer at (238,8) size 18x215
+  RenderBlock (positioned) {DIV} at (230,0) size 18x215 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 18x117 [bgcolor=#000000CC]
+      RenderText {#text} at (2,49) size 14x113
+        text run at (2,49) width 112: "Cue 4: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 16x5 [bgcolor=#000000CC]
+layer at (310,8) size 18x215
+  RenderBlock (positioned) {DIV} at (302,0) size 18x215 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 18x117 [bgcolor=#000000CC]
+      RenderText {#text} at (2,49) size 14x113
+        text run at (2,49) width 112: "Cue 5: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 16x5 [bgcolor=#000000CC]
+layer at (292,8) size 18x215
+  RenderBlock (positioned) {DIV} at (284,0) size 18x215 [color=#FFFFFF]
+    RenderInline {DIV} at (0,0) size 18x117 [bgcolor=#000000CC]
+      RenderText {#text} at (2,49) size 14x113
+        text run at (2,49) width 112: "Cue 6: \x{79C1}\x{306F}\x{7ACB}\x{6D3E}\x{306A}\x{4EBA}"
+    RenderInline {DIV} at (0,0) size 16x5 [bgcolor=#000000CC]
+layer at (8,223) size 320x25
+  RenderDeprecatedFlexibleBox (relative positioned) {DIV} at (0,215) size 320x25
+    RenderButton {INPUT} at (6,3) size 18x18
+    RenderButton {INPUT} at (32,4) size 16x16
+    RenderDeprecatedFlexibleBox {DIV} at (49,5) size 216x15
+      RenderSlider {INPUT} at (45,2) size 126x13
+        RenderDeprecatedFlexibleBox {DIV} at (0,0) size 126x13
+          RenderBlock {DIV} at (0,2) size 116x8
+          RenderBlock {DIV} at (116,2) size 10x8
+    RenderButton {INPUT} at (297,4) size 16x16
+    RenderBlock {DIV} at (265,6) size 25x12
+layer at (57,230) size 45x11
+  RenderDeprecatedFlexibleBox {DIV} at (0,2) size 45x11 [color=#FFFFFF]
+    RenderBlock (anonymous) at (9,0) size 26x11
+      RenderText {#text} at (0,0) size 26x11
+        text run at (0,0) width 26: "00:00"
+layer at (228,230) size 45x11
+  RenderDeprecatedFlexibleBox {DIV} at (171,2) size 45x11 [color=#FFFFFF]
+    RenderBlock (anonymous) at (7,0) size 31x11
+      RenderText {#text} at (0,0) size 31x11
+        text run at (0,0) width 31: "-00:05"
+layer at (116,232) size 10x8
+  RenderBlock (relative positioned) {DIV} at (0,0) size 10x8
+layer at (275,229) size 14x12
+  RenderButton zI: 1 {INPUT} at (2,0) size 14x12
index 86c7b44..a14c5be 100644 (file)
@@ -2090,6 +2090,7 @@ SET(WebCore_SOURCES
     rendering/RenderTextControlMultiLine.cpp
     rendering/RenderTextControlSingleLine.cpp
     rendering/RenderTextFragment.cpp
+    rendering/RenderTextTrackCue.cpp
     rendering/RenderTheme.cpp
     rendering/RenderTreeAsText.cpp
     rendering/RenderVideo.cpp
index 894e233..3bd0935 100644 (file)
@@ -1,3 +1,111 @@
+2012-08-22  Victor Carbune  <victor@rosedu.org>
+
+        Display a TextTrackCue when snap-to-lines flag is set
+        https://bugs.webkit.org/show_bug.cgi?id=79751
+
+        Reviewed by Tony Chang.
+
+        This patch implements rendering functionality for a given text track,
+        following closer the exact WebVTT specification. There are two new classes
+        which have been added in order to succesfully cover rendering when of a text
+        track cue.
+
+        RenderTextTrackCue handles the specific rendering algorithm required,
+        by checking for overlaps with other boxes that are in the same
+        container (these can be any other boxes, not necessarily other cues,
+        the video controls, for example).
+
+        TextTrackCueBox extends HTMLDivElement and is an intermediate layer
+        between the renderer class and the actual cue object. Its purpose is
+        to instantiate the particular renderer and cover all the default CSS
+        styling that needs to be applied to the cue.
+
+        The layout is done in two steps:
+          - Step 1: Layout the TextTrackCue with default CSS properties set (this is
+        the TextTrackCueBox decorated with the respective CSS elements)
+          - Step 2: RenderTextTrackCue adjusts the box position depending on the
+        parameters of the TextTrackCue object and the overlaps that may occur with
+        previously positioned cues.
+
+        Tests: media/track/track-cue-rendering-horizontal.html
+               media/track/track-cue-rendering-vertical.html
+
+        * CMakeLists.txt: Updated to include RenderTextTrackCue.
+        * GNUmakefile.list.am: Updated to include RenderTextTrackCue.
+        * Target.pri: Updated to include RenderTextTrackCue.
+        * WebCore.gypi: Updated to include RenderTextTrackCue.
+        * WebCore.vcproj/WebCore.vcproj: Updated to include RenderTextTrackCue.
+        * WebCore.xcodeproj/project.pbxproj: Updated to include RenderTextTrackCue.
+        * css/mediaControls.css: Removed unreliable CSS.
+        (video::-webkit-media-text-track-display): Removed properties.
+        * html/shadow/MediaControlElements.cpp: Updated to not use the new class.
+        (RenderTextTrackContainerElement):
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Simplified
+        the function by moving the check if track is rendered in TextTrack and used
+        the TextTrackCueBox for cues.
+        * html/track/TextTrack.cpp: Added a new method.
+        (WebCore::TextTrack::isRendered): Method that returns whether the track should
+        be rendered or not.
+        (WebCore):
+        * html/track/TextTrack.h: Added the isRendered method.
+        (TextTrack):
+        * html/track/TextTrackCue.cpp: Added several helper methods and
+        the TextTrackCueBox.
+        (WebCore):
+        (WebCore::TextTrackCueBox::TextTrackCueBox): The TextTrackCueBox extends
+        the HTMLDivElement and represents a bridge class between RenderTextTrackCue
+        and TextTrackCue. This is required as the layout is done in two steps, as
+        explained on top of the ChangeLog entry.
+        (WebCore::TextTrackCueBox::getCue): Returns the associated TextTrackCue object.
+        (WebCore::TextTrackCueBox::applyCSSProperties): Applies a part of the default CSS
+        properties, as defined by section 3.5.1 of the WebVTT specification.
+        (WebCore::TextTrackCueBox::shadowPseudoId): Moved the shadow pseudo id.
+        (WebCore::TextTrackCueBox::createRenderer): Creates the particular renderer.
+        (WebCore::TextTrackCue::TextTrackCue): Corrected the internal writing mode map.
+        (WebCore::TextTrackCue::calculateComputedLinePosition): Updated the compute line
+        position algorithm. This requires, however, a method to consider only rendered
+        tracks (and therefore will be addressed completely in subsequent changeset).
+        (WebCore::TextTrackCue::calculateDisplayParameters): Updated and corrected the
+        computed display parameters to match the current specification.
+        (WebCore::TextTrackCue::getDisplayTree): Update to use the TextTrackCueBox class
+        and moved CSS application to the respective class.
+        (WebCore::TextTrackCue::getPositionCoordinates): Added comment to specify in which
+        situation this method is used and change visibility to private.
+        (WebCore::TextTrackCue::getCSSWritingMode): Returns the CSS writing mode corresponding
+        to the cue writing mode.
+        (WebCore::TextTrackCue::getCSSSize): Returns the cue width / height (depending on the
+        writing direction.
+        (WebCore::TextTrackCue::getCSSPosition): Returns the default display position, that is
+        used in the first layout step.
+        * html/track/TextTrackCue.h:
+        (WebCore):
+        (TextTrackCueBox):
+        (WebCore::TextTrackCueBox::create): Initialization method.
+        (TextTrackCue):
+        (WebCore::TextTrackCue::getWritingDirection): Helper method to return the internal
+        values used to represent the writing direction.
+        * rendering/RenderTextTrackCue.cpp: Added.
+        (WebCore):
+        (WebCore::RenderTextTrackCue::RenderTextTrackCue):
+        (WebCore::RenderTextTrackCue::layout): The rendering steps, as mentioned in
+        the WebVTT rendering rules. Currently, this treats only the snap-to-lines set
+        case. It is implemented following closely the spec, and might be subject to
+        change as discussions on various bugs evolve.
+        (WebCore::RenderTextTrackCue::initializeLayoutParameters): Steps 1 - 7.
+        (WebCore::RenderTextTrackCue::placeBoxInDefaultPosition): Steps 8 - 10.
+        (WebCore::RenderTextTrackCue::isOutside): Inline method to check if the cue is outside.
+        (WebCore::RenderTextTrackCue::isOverlapping): Inline method to check if the cue overlaps other boxes.
+        (WebCore::RenderTextTrackCue::shouldSwitchDirection): Step 12.
+        (WebCore::RenderTextTrackCue::moveBoxesByStep): Step 13.
+        (WebCore::RenderTextTrackCue::switchDirection): Steps 15 - 18.
+        (WebCore::RenderTextTrackCue::repositionCueSnapToLinesSet): Cue repositioning
+        for text track cue when the snap to lines flag is set.
+        (WebCore::RenderTextTrackCue::repositionCueSnapToLinesNotSet): Cue repositioning
+        for text track cue when the snap to lines flag is not set. Not implemented yet.
+        * rendering/RenderTextTrackCue.h: Added.
+        (WebCore):
+        (RenderTextTrackCue): Rendering class, handling the display of cues.
+
 2012-08-21  Kentaro Hara  <haraken@chromium.org>
 
         [V8] Move matchesCurrentContext() from V8Proxy to ScriptController
index 95d15ee..f576420 100644 (file)
@@ -4263,6 +4263,8 @@ webcore_sources += \
        Source/WebCore/rendering/RenderTextControlSingleLine.cpp \
        Source/WebCore/rendering/RenderTextControlSingleLine.h \
        Source/WebCore/rendering/RenderText.cpp \
+       Source/WebCore/rendering/RenderTextTrackCue.cpp \
+       Source/WebCore/rendering/RenderTextTrackCue.h \
        Source/WebCore/rendering/RenderTextFragment.cpp \
        Source/WebCore/rendering/RenderTextFragment.h \
        Source/WebCore/rendering/RenderText.h \
index cbbdf28..8b0db21 100644 (file)
@@ -1174,6 +1174,7 @@ SOURCES += \
     rendering/RenderTextControlMultiLine.cpp \
     rendering/RenderTextControlSingleLine.cpp \
     rendering/RenderTextFragment.cpp \
+    rendering/RenderTextTrackCue.cpp \
     rendering/RenderTheme.cpp \
     rendering/RenderTreeAsText.cpp \
     rendering/RenderView.cpp \
index 9dc1ae2..f35340a 100644 (file)
             'rendering/RenderTextControlSingleLine.h',
             'rendering/RenderTextFragment.cpp',
             'rendering/RenderTextFragment.h',
+            'rendering/RenderTextTrackCue.cpp',
+            'rendering/RenderTextTrackCue.h',
             'rendering/RenderTheme.cpp',
             'rendering/RenderTheme.h',
             'rendering/RenderThemeChromiumAndroid.cpp',
index 751f0a0..90561a7 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\rendering\RenderTextTrackCue.cpp"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug_Cairo_CFLite|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release_Cairo_CFLite|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug_All|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Production|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\rendering\RenderTextTrackCue.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\rendering\RenderTheme.cpp"
                                >
                                <FileConfiguration
index c6eddd1..d95f658 100644 (file)
                86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86BE33FD15058CB200CE0FD8 /* PerformanceEntryList.cpp */; };
                86BE340415058CB200CE0FD8 /* PerformanceEntryList.h in Headers */ = {isa = PBXBuildFile; fileRef = 86BE33FE15058CB200CE0FD8 /* PerformanceEntryList.h */; };
                86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 86D982F6125C154000AD9E3D /* DocumentTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               86FF886115DE3D0700BD6B28 /* RenderTextTrackCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */; };
+               86FF886215DE3D0700BD6B28 /* RenderTextTrackCue.h in Headers */ = {isa = PBXBuildFile; fileRef = 86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */; };
                890AE0E11256A07900F5968C /* DirectoryReaderBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 890AE0E01256A07900F5968C /* DirectoryReaderBase.h */; };
                8931DE5B14C44C44000DC9D2 /* JSBlobCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */; };
                893C47A71238908B002B3D86 /* FileCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 893C47A51238908B002B3D86 /* FileCallback.h */; };
                86BE33FE15058CB200CE0FD8 /* PerformanceEntryList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceEntryList.h; sourceTree = "<group>"; };
                86BE33FF15058CB200CE0FD8 /* PerformanceEntryList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceEntryList.idl; sourceTree = "<group>"; };
                86D982F6125C154000AD9E3D /* DocumentTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentTiming.h; sourceTree = "<group>"; };
+               86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextTrackCue.cpp; sourceTree = "<group>"; };
+               86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextTrackCue.h; sourceTree = "<group>"; };
                890AE0E01256A07900F5968C /* DirectoryReaderBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DirectoryReaderBase.h; path = Modules/filesystem/DirectoryReaderBase.h; sourceTree = "<group>"; };
                8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBlobCustom.cpp; sourceTree = "<group>"; };
                893C47A51238908B002B3D86 /* FileCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileCallback.h; path = Modules/filesystem/FileCallback.h; sourceTree = "<group>"; };
                                083DAEA50F01A7FB00342754 /* RenderTextControlSingleLine.h */,
                                BCEA484E097D93020094C9E4 /* RenderTextFragment.cpp */,
                                BCEA484F097D93020094C9E4 /* RenderTextFragment.h */,
+                               86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */,
+                               86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */,
                                BCEA484A097D93020094C9E4 /* RenderTheme.cpp */,
                                BCEA484B097D93020094C9E4 /* RenderTheme.h */,
                                BCEA4848097D93020094C9E4 /* RenderThemeMac.h */,
                                083DAEA70F01A7FB00342754 /* RenderTextControlMultiLine.h in Headers */,
                                083DAEA90F01A7FB00342754 /* RenderTextControlSingleLine.h in Headers */,
                                BCEA488E097D93020094C9E4 /* RenderTextFragment.h in Headers */,
+                               86FF886215DE3D0700BD6B28 /* RenderTextTrackCue.h in Headers */,
                                BCEA488A097D93020094C9E4 /* RenderTheme.h in Headers */,
                                BCEA4887097D93020094C9E4 /* RenderThemeMac.h in Headers */,
                                93F1998C08245E59001E9ABC /* RenderTreeAsText.h in Headers */,
                                083DAEA60F01A7FB00342754 /* RenderTextControlMultiLine.cpp in Sources */,
                                083DAEA80F01A7FB00342754 /* RenderTextControlSingleLine.cpp in Sources */,
                                BCEA488D097D93020094C9E4 /* RenderTextFragment.cpp in Sources */,
+                               86FF886115DE3D0700BD6B28 /* RenderTextTrackCue.cpp in Sources */,
                                BCEA4889097D93020094C9E4 /* RenderTheme.cpp in Sources */,
                                BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */,
                                93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,
index 9d8221e..81b0e16 100644 (file)
@@ -253,7 +253,4 @@ video::-webkit-media-text-track-future-nodes {
 video::-webkit-media-text-track-display {
     position: absolute;
     color: rgba(255, 255, 255, 1);
-
-    top: 100%;
-    -webkit-transform: translate(0%, -100%);
 }
index 1b67afe..881c2de 100644 (file)
 
 #include "MediaControlElements.h"
 
+#include "CSSStyleDeclaration.h"
 #include "CSSValueKeywords.h"
 #include "DOMTokenList.h"
 #include "EventNames.h"
 #include "FloatConversion.h"
+#include "FloatPoint.h"
 #include "Frame.h"
+#include "HTMLDivElement.h"
 #include "HTMLMediaElement.h"
 #include "HTMLNames.h"
 #include "HTMLVideoElement.h"
+#include "LayoutRepainter.h"
 #include "LocalizedStrings.h"
 #include "MediaControls.h"
 #include "MouseEvent.h"
 #include "Page.h"
 #include "RenderDeprecatedFlexibleBox.h"
+#include "RenderInline.h"
 #include "RenderMedia.h"
 #include "RenderSlider.h"
+#include "RenderText.h"
 #include "RenderTheme.h"
 #include "RenderVideo.h"
 #include "RenderView.h"
@@ -1258,7 +1264,7 @@ const AtomicString& MediaControlCurrentTimeDisplayElement::shadowPseudoId() cons
 class RenderTextTrackContainerElement : public RenderBlock {
 public:
     RenderTextTrackContainerElement(Node*);
-    
+
 private:
     virtual void layout();
 };
@@ -1352,29 +1358,18 @@ void MediaControlTextTrackContainerElement::updateDisplay()
     // 10. For each text track cue cue in cues that has not yet had
     // corresponding CSS boxes added to output, in text track cue order, run the
     // following substeps:
-
-    // Simple renderer for now.
     for (size_t i = 0; i < activeCues.size(); ++i) {
         TextTrackCue* cue = activeCues[i].data();
 
         ASSERT(cue->isActive());
-        if (cue->track()->kind() != TextTrack::captionsKeyword() && cue->track()->kind() != TextTrack::subtitlesKeyword())
-            continue;
-
-        if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
+        if (!cue->track() || !cue->track()->isRendered())
             continue;
 
-        RefPtr<HTMLDivElement> displayTree = cue->getDisplayTree();
-
-        // Append only new display trees.
-        if (displayTree->hasChildNodes() && !contains(displayTree.get()))
-            appendChild(displayTree, ASSERT_NO_EXCEPTION, true);
-
-        // Note: the display tree of a cue is removed when the active flag of the cue is unset.
-
-        // FIXME(BUG 79751): Render the TextTrackCue when snap-to-lines is set.
+        RefPtr<TextTrackCueBox> displayBox = cue->getDisplayTree();
 
-        // FIXME(BUG 84296): Implement overlapping detection for cue boxes when snap-to-lines is not set.
+        if (displayBox->hasChildNodes() && !contains(static_cast<Node*>(displayBox.get())))
+            // Note: the display tree of a cue is removed when the active flag of the cue is unset.
+            appendChild(displayBox, ASSERT_NO_EXCEPTION, false);
     }
 
     // 11. Return output.
index 419489f..addc875 100644 (file)
@@ -294,6 +294,17 @@ void TextTrack::invalidateTrackIndex()
     m_trackIndex = invalidTrackIndex;
 }
 
+bool TextTrack::isRendered()
+{
+    if (m_kind != captionsKeyword() && m_kind != subtitlesKeyword())
+        return false;
+
+    if (m_mode != SHOWING && !m_showingByDefault)
+        return false;
+
+    return true;
+}
+
 TextTrackCueList* TextTrack::ensureTextTrackCueList()
 {
     if (!m_cues)
index 3cd7a74..957bcca 100644 (file)
@@ -110,6 +110,8 @@ public:
     int trackIndex();
     void invalidateTrackIndex();
 
+    bool isRendered();
+
 protected:
     TextTrack(ScriptExecutionContext*, TextTrackClient*, const String& kind, const String& label, const String& language, TextTrackType);
 
index 5a39444..e67ae8b 100644 (file)
@@ -41,6 +41,7 @@
 #include "Event.h"
 #include "HTMLDivElement.h"
 #include "HTMLMediaElement.h"
+#include "RenderTextTrackCue.h"
 #include "Text.h"
 #include "TextTrack.h"
 #include "TextTrackCueList.h"
@@ -88,6 +89,97 @@ static const String& verticalGrowingRightKeyword()
     return verticallr;
 }
 
+// ----------------------------
+
+TextTrackCueBox::TextTrackCueBox(Document* document, TextTrackCue* cue)
+    : HTMLElement(divTag, document)
+    , m_cue(cue)
+{
+}
+
+TextTrackCue* TextTrackCueBox::getCue() const
+{
+    return m_cue;
+}
+
+void TextTrackCueBox::applyCSSProperties()
+{
+    // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
+
+    // 3.5.1 On the (root) List of WebVTT Node Objects:
+
+    // the 'position' property must be set to 'absolute'
+    setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
+
+    //  the 'unicode-bidi' property must be set to 'plaintext'
+    setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext);
+
+    // FIXME: Determine the text direction using the BIDI algorithm. http://wkb.ug/79749
+    // the 'direction' property must be set to direction
+    setInlineStyleProperty(CSSPropertyDirection, CSSValueLtr);
+
+    // the 'writing-mode' property must be set to writing-mode
+    setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode(), false);
+
+    std::pair<float, float> position = m_cue->getCSSPosition();
+
+    // the 'top' property must be set to top,
+    setInlineStyleProperty(CSSPropertyTop, static_cast<double>(position.second), CSSPrimitiveValue::CSS_PERCENTAGE);
+
+    // the 'left' property must be set to left
+    setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
+
+    // the 'width' property must be set to width, and the 'height' property  must be set to height
+    if (m_cue->vertical() == horizontalKeyword()) {
+        setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
+        setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
+    } else {
+        setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
+        setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->getCSSSize()),  CSSPrimitiveValue::CSS_PERCENTAGE);
+    }
+
+    // The 'text-align' property on the (root) List of WebVTT Node Objects must
+    // be set to the value in the second cell of the row of the table below
+    // whose first cell is the value of the corresponding cue's text track cue
+    // alignment:
+    if (m_cue->align() == startKeyword())
+        setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
+    else if (m_cue->align() == endKeyword())
+        setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
+    else
+        setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
+
+    if (!m_cue->snapToLines()) {
+        // 10.13.1 Set up x and y:
+        // Note: x and y are set through the CSS left and top above.
+
+        // 10.13.2 Position the boxes in boxes such that the point x% along the
+        // width of the bounding box of the boxes in boxes is x% of the way
+        // across the width of the video's rendering area, and the point y%
+        // along the height of the bounding box of the boxes in boxes is y%
+        // of the way across the height of the video's rendering area, while
+        // maintaining the relative positions of the boxes in boxes to each
+        // other.
+        setInlineStyleProperty(CSSPropertyWebkitTransform,
+                String::format("translate(-%.2f%%, -%.2f%%)", position.first, position.second));
+
+        setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre);
+    }
+}
+
+const AtomicString& TextTrackCueBox::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display"));
+    return trackDisplayBoxShadowPseudoId;
+}
+
+RenderObject* TextTrackCueBox::createRenderer(RenderArena* arena, RenderStyle*)
+{
+    return new (arena) RenderTextTrackCue(this);
+}
+
+// ----------------------------
+
 TextTrackCue::TextTrackCue(ScriptExecutionContext* context, double start, double end, const String& content)
     : m_startTime(start)
     , m_endTime(end)
@@ -108,17 +200,18 @@ TextTrackCue::TextTrackCue(ScriptExecutionContext* context, double start, double
     , m_pastDocumentNodes(HTMLDivElement::create(static_cast<Document*>(context)))
     , m_futureDocumentNodes(HTMLDivElement::create(static_cast<Document*>(context)))
     , m_displayTreeShouldChange(true)
-    , m_displayTree(HTMLDivElement::create(static_cast<Document*>(context)))
-    , m_displayXPosition(undefinedPosition)
-    , m_displayYPosition(undefinedPosition)
+    , m_displayTree(TextTrackCueBox::create(static_cast<Document*>(m_scriptExecutionContext), this))
 {
     ASSERT(m_scriptExecutionContext->isDocument());
 
-    // The text track cue writing directions are directly relatd to the
-    // block-flow element, which can be set through the CSS writing modes.
+    // 4. If the text track cue writing direction is horizontal, then let
+    // writing-mode be 'horizontal-tb'. Otherwise, if the text track cue writing
+    // direction is vertical growing left, then let writing-mode be
+    // 'vertical-rl'. Otherwise, the text track cue writing direction is
+    // vertical growing right; let writing-mode be 'vertical-lr'.
     m_displayWritingModeMap[Horizontal] = CSSValueHorizontalTb;
-    m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalLr;
-    m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalRl;
+    m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalRl;
+    m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalLr;
 
     // A text track cue has a text track cue computed line position whose value
     // is defined in terms of the other aspects of the cue.
@@ -440,10 +533,27 @@ int TextTrackCue::calculateComputedLinePosition()
 
     // Otherwise, it is the value returned by the following algorithm:
 
-    // FIXME(BUG 79751): Complete determination algorithm when it is actually
-    // used - when displaying a TextTrackCue having snap-to-lines flag set.
+    // If cue is not associated with a text track, return -1 and abort these
+    // steps.
+    if (!track())
+        return -1;
+
+    // Let n be the number of text tracks whose text track mode is showing or
+    // showing by default and that are in the media element's list of text
+    // tracks before track.
 
-    return 100;
+    // FIXME: Add a method to cache the track index considering only
+    // rendered tracks (that have showing or showing by default mode set).
+    // http://wkb.ug/93779
+    int n = track()->trackIndex();
+
+    // Increment n by one.
+    n++;
+
+    // Negate n.
+    n = -n;
+
+    return n;
 }
 
 void TextTrackCue::calculateDisplayParameters()
@@ -457,7 +567,6 @@ void TextTrackCue::calculateDisplayParameters()
     // vertical growing left, then let block-flow be 'lr'. Otherwise, the text
     // track cue writing direction is vertical growing right; let block-flow be
     // 'rl'.
-
     m_displayWritingMode = m_displayWritingModeMap[m_writingDirection];
 
     // 10.5 Determine the value of maximum size for cue as per the appropriate
@@ -466,7 +575,7 @@ void TextTrackCue::calculateDisplayParameters()
     if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueLtr)
             || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueRtl)
             || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
-            || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
+            || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
         maximumSize = 100 - m_textPosition;
     } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr)
             || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl)
@@ -482,61 +591,56 @@ void TextTrackCue::calculateDisplayParameters()
     // be text track cue size. Otherwise, let size be maximum size.
     m_displaySize = std::min(m_cueSize, maximumSize);
 
-    // 10.7 If the text track cue writing direction is horizontal, then let
-    // width be 'size vw' and height be 'auto'. Otherwise, let width be 'auto'
-    // and height be 'size vh'. (These are CSS values used by the next section
-    // to set CSS properties for the rendering; 'vw' and 'vh' are CSS units.)
-    m_displayWidth = m_writingDirection == Horizontal ? m_displaySize : autoSize;
-    m_displayHeight = m_writingDirection == Horizontal ? autoSize : m_displaySize;
-
     // 10.8 Determine the value of x-position or y-position for cue as per the
     // appropriate rules from the following list:
-    if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueLtr)
-            || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueRtl)) {
-        m_displayXPosition = m_textPosition;
-    } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr)
-            || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl)) {
-        m_displayXPosition = 100 - m_textPosition;
+    if (m_writingDirection == Horizontal) {
+        if (m_cueAlignment == Start) {
+            if (m_displayDirection == CSSValueLtr)
+                m_displayPosition.first = m_textPosition;
+            else
+                m_displayPosition.first = 100 - m_textPosition - m_displaySize;
+        } else if (m_cueAlignment == End) {
+            if (m_displayDirection == CSSValueRtl)
+                m_displayPosition.first = 100 - m_textPosition;
+            else
+                m_displayPosition.first = m_textPosition - m_displaySize;
+        }
     }
 
     if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
             || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
-        m_displayYPosition = m_textPosition;
+        m_displayPosition.second = m_textPosition;
     } else if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
             || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
-        m_displayYPosition = 100 - m_textPosition;
+        m_displayPosition.second = 100 - m_textPosition;
     }
 
     if (m_writingDirection == Horizontal && m_cueAlignment == Middle) {
-        m_displayXPosition = m_textPosition - m_displaySize / 2;
-
-        if (m_displayDirection == CSSValueRtl)
-           m_displayXPosition = 100 - m_displayXPosition;
+        if (m_displayDirection == CSSValueLtr)
+            m_displayPosition.first = m_textPosition - m_displaySize / 2;
+        else
+           m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2;
     }
 
     if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Middle)
         || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Middle))
-        m_displayYPosition = m_textPosition - m_displaySize / 2;
+        m_displayPosition.second = m_textPosition - m_displaySize / 2;
 
     // 10.9 Determine the value of whichever of x-position or y-position is not
     // yet calculated for cue as per the appropriate rules from the following
     // list:
-    if (m_snapToLines && m_displayYPosition == undefinedPosition && m_writingDirection == Horizontal)
-        m_displayYPosition = 0;
+    if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
+        m_displayPosition.second = 0;
 
-    if (!m_snapToLines && m_writingDirection == Horizontal)
-        m_displayYPosition = m_computedLinePosition;
+    if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
+        m_displayPosition.second = m_computedLinePosition;
 
-    if (m_snapToLines && m_displayXPosition == undefinedPosition
+    if (m_snapToLines && m_displayPosition.first == undefinedPosition
             && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
-        m_displayXPosition = 0;
+        m_displayPosition.first = 0;
 
     if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
-        m_displayXPosition = m_computedLinePosition;
-
-    // 10.10 Let left be 'x-position vw' and top be 'y-position vh'.
-
-    // FIXME(Bug 79916): CSS top and left properties need to be applied.
+        m_displayPosition.first = m_computedLinePosition;
 }
 
 void TextTrackCue::updateDisplayTree(float movieTime)
@@ -584,10 +688,8 @@ void TextTrackCue::updateDisplayTree(float movieTime)
     }
 }
 
-PassRefPtr<HTMLDivElement> TextTrackCue::getDisplayTree()
+PassRefPtr<TextTrackCueBox> TextTrackCue::getDisplayTree()
 {
-    DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display"));
-
     if (!m_displayTreeShouldChange)
         return m_displayTree;
 
@@ -597,7 +699,6 @@ PassRefPtr<HTMLDivElement> TextTrackCue::getDisplayTree()
     // 10.11. Apply the terms of the CSS specifications to nodes within the
     // following constraints, thus obtaining a set of CSS boxes positioned
     // relative to an initial containing block:
-    m_displayTree->setShadowPseudoId(trackDisplayBoxShadowPseudoId, ASSERT_NO_EXCEPTION);
     m_displayTree->removeChildren();
 
     // The document tree is the tree of WebVTT Node Objects rooted at nodes.
@@ -621,38 +722,7 @@ PassRefPtr<HTMLDivElement> TextTrackCue::getDisplayTree()
     // is no line breaking opportunity. (Thus, normally text wraps as needed,
     // but if there is a particularly long word, it does not overflow as it
     // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
-
-    // FIXME(BUG 79916): CSS width property should be set to 'size vw', when the
-    // maximum cue size computation is corrected in the specification.
-    if (m_snapToLines)
-        m_displayTree->setInlineStyleProperty(CSSPropertyWidth, (double) m_cueSize, CSSPrimitiveValue::CSS_PERCENTAGE);
-
-    // FIXME(BUG 79750, 79751): Steps 10.12 - 10.14
-
-    if (!m_snapToLines) {
-        std::pair<double, double> position = getPositionCoordinates();
-
-        // 10.13.1 Set up x and y:
-        m_displayTree->setInlineStyleProperty(CSSPropertyLeft, position.first, CSSPrimitiveValue::CSS_PERCENTAGE);
-        m_displayTree->setInlineStyleProperty(CSSPropertyTop, position.second, CSSPrimitiveValue::CSS_PERCENTAGE);
-
-        // 10.13.2 Position the boxes in boxes such that the point x% along the
-        // width of the bounding box of the boxes in boxes is x% of the way
-        // across the width of the video's rendering area, and the point y%
-        // along the height of the bounding box of the boxes in boxes is y%
-        // of the way across the height of the video's rendering area, while
-        // maintaining the relative positions of the boxes in boxes to each
-        // other.
-        String translateX = "-" + String::number(position.first) + "%";
-        String translateY = "-" + String::number(position.second) + "%";
-        String webkitTransformTranslateValue = "translate(" + translateX + "," + translateY + ")";
-
-        m_displayTree->setInlineStyleProperty(CSSPropertyWebkitTransform,
-                                              webkitTransformTranslateValue);
-
-        m_displayTree->setInlineStyleProperty(CSSPropertyWhiteSpace,
-                                              CSSValuePre);
-    }
+    m_displayTree->applyCSSProperties();
 
     if (m_hasInnerTimestamps)
         updateDisplayTree(track()->mediaElement()->currentTime());
@@ -670,8 +740,9 @@ void TextTrackCue::removeDisplayTree()
         m_displayTree->remove(ASSERT_NO_EXCEPTION);
 }
 
-std::pair<double, double> TextTrackCue::getPositionCoordinates()
+std::pair<double, double> TextTrackCue::getPositionCoordinates() const
 {
+    // This method is used for setting x and y when snap to lines is not set.
     std::pair<double, double> coordinates;
 
     if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) {
@@ -926,6 +997,24 @@ NextSetting:
     }
 }
 
+int TextTrackCue::getCSSWritingMode() const
+{
+    return m_displayWritingMode;
+}
+
+int TextTrackCue::getCSSSize() const
+{
+    return m_displaySize;
+}
+
+std::pair<double, double> TextTrackCue::getCSSPosition() const
+{
+    if (!m_snapToLines)
+        return getPositionCoordinates();
+
+    return m_displayPosition;
+}
+
 const AtomicString& TextTrackCue::interfaceName() const
 {
     return eventNames().interfaceForTextTrackCue;
index 8bb17bf..115a868 100644 (file)
@@ -34,6 +34,7 @@
 #if ENABLE(VIDEO_TRACK)
 
 #include "EventTarget.h"
+#include "HTMLElement.h"
 #include "TextTrack.h"
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefCounted.h>
 namespace WebCore {
 
 class DocumentFragment;
+class HTMLDivElement;
 class ScriptExecutionContext;
 class TextTrack;
-class HTMLDivElement;
+class TextTrackCue;
+
+// ----------------------------
+
+class TextTrackCueBox : public HTMLElement {
+public:
+    static PassRefPtr<TextTrackCueBox> create(Document* document, TextTrackCue* cue)
+    {
+        return adoptRef(new TextTrackCueBox(document, cue));
+    }
+
+    TextTrackCue* getCue() const;
+    void applyCSSProperties();
+
+    virtual const AtomicString& shadowPseudoId() const OVERRIDE;
+
+private:
+    TextTrackCueBox(Document*, TextTrackCue*);
+
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;
+
+    TextTrackCue* m_cue;
+};
+
+// ----------------------------
 
 class TextTrackCue : public RefCounted<TextTrackCue>, public EventTarget {
 public:
@@ -103,13 +129,27 @@ public:
     bool isActive();
     void setIsActive(bool);
 
-    PassRefPtr<HTMLDivElement> getDisplayTree();
+    PassRefPtr<TextTrackCueBox> getDisplayTree();
     void updateDisplayTree(float);
     void removeDisplayTree();
 
+    int calculateComputedLinePosition();
+
     virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
+    std::pair<double, double> getCSSPosition() const;
+    int getCSSSize() const;
+    int getCSSWritingMode() const;
+
+    enum WritingDirection {
+        Horizontal,
+        VerticalGrowingLeft,
+        VerticalGrowingRight,
+        NumberOfWritingDirections
+    };
+    WritingDirection getWritingDirection() const { return m_writingDirection; }
+
     DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
 
@@ -123,10 +163,10 @@ protected:
 private:
     TextTrackCue(ScriptExecutionContext*, double start, double end, const String& content);
 
-    int calculateComputedLinePosition();
-    void calculateDisplayParameters();
+    std::pair<double, double> getPositionCoordinates() const;
+    void parseSettings(const String&);
 
-    std::pair<double, double> getPositionCoordinates();
+    void calculateDisplayParameters();
 
     void cueWillChange();
     void cueDidChange();
@@ -147,12 +187,6 @@ private:
     int m_cueSize;
     int m_cueIndex;
 
-    enum WritingDirection {
-        Horizontal,
-        VerticalGrowingLeft,
-        VerticalGrowingRight,
-        NumberOfWritingDirections
-    };
     WritingDirection m_writingDirection;
 
     enum Alignment { Start, Middle, End };
@@ -173,7 +207,7 @@ private:
     RefPtr<HTMLDivElement> m_futureDocumentNodes;
 
     bool m_displayTreeShouldChange;
-    RefPtr<HTMLDivElement> m_displayTree;
+    RefPtr<TextTrackCueBox> m_displayTree;
 
     int m_displayDirection;
 
@@ -181,11 +215,8 @@ private:
     int m_displayWritingMode;
 
     int m_displaySize;
-    int m_displayHeight;
-    int m_displayWidth;
 
-    double m_displayXPosition;
-    double m_displayYPosition;
+    std::pair<float, float> m_displayPosition;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/rendering/RenderTextTrackCue.cpp b/Source/WebCore/rendering/RenderTextTrackCue.cpp
new file mode 100644 (file)
index 0000000..ef8edda
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "RenderTextTrackCue.h"
+
+#include "TextTrackCue.h"
+
+namespace WebCore {
+
+RenderTextTrackCue::RenderTextTrackCue(TextTrackCueBox* node)
+    : RenderBlock(static_cast<Node*>(node))
+    , m_cue(node->getCue())
+{
+}
+
+void RenderTextTrackCue::layout()
+{
+    RenderBlock::layout();
+
+    LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
+    if (m_cue->snapToLines())
+        repositionCueSnapToLinesSet();
+    else
+        repositionCueSnapToLinesNotSet();
+    statePusher.pop();
+}
+
+bool RenderTextTrackCue::initializeLayoutParameters(InlineFlowBox*& firstLineBox, LayoutUnit& step, LayoutUnit& position)
+{
+    ASSERT(firstChild());
+
+    RenderBlock* parentBlock = containingBlock();
+    firstLineBox = toRenderInline(firstChild())->firstLineBox();
+
+    // 1. Horizontal: Let step be the height of the first line box in boxes.
+    //    Vertical: Let step be the width of the first line box in boxes.
+    step = m_cue->getWritingDirection() == TextTrackCue::Horizontal ? firstLineBox->height() : firstLineBox->width();
+
+    // 2. If step is zero, then jump to the step labeled done positioning below.
+    if (!step)
+        return false;
+
+    // 3. Let line position be the text track cue computed line position.
+    int linePosition = m_cue->calculateComputedLinePosition();
+
+    // 4. Vertical Growing Left: Add one to line position then negate it.
+    if (m_cue->getWritingDirection() == TextTrackCue::VerticalGrowingLeft)
+        linePosition = -(linePosition + 1);
+
+    // 5. Let position be the result of multiplying step and line position.
+    position = step * linePosition;
+
+    // 6. Vertical Growing Left: Decrease position by the width of the
+    // bounding box of the boxes in boxes, then increase position by step.
+    if (m_cue->getWritingDirection() == TextTrackCue::VerticalGrowingLeft) {
+        position -= width();
+        position += step;
+    }
+
+    // 7. If line position is less than zero...
+    if (linePosition < 0) {
+        // Horizontal / Vertical: ... then increase position by the
+        // height / width of the video's rendering area ...
+        position += m_cue->getWritingDirection() == TextTrackCue::Horizontal ? parentBlock->height() : parentBlock->width();
+
+        // ... and negate step.
+        step = -step;
+    }
+
+    return true;
+}
+
+void RenderTextTrackCue::placeBoxInDefaultPosition(LayoutUnit position, bool& switched)
+{
+    // 8. Move all boxes in boxes ...
+    if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
+        // Horizontal: ... down by the distance given by position
+        setY(y() + position);
+    else
+        // Vertical: ... right by the distance given by position
+        setX(x() + position);
+
+    // 9. Default: Remember the position of all the boxes in boxes as their
+    // default position.
+    m_fallbackPosition = FloatPoint(x(), y());
+
+    // 10. Let switched be false.
+    switched = false;
+}
+
+bool RenderTextTrackCue::isOutside() const
+{
+    return !containingBlock()->absoluteBoundingBoxRect().contains(absoluteBoundingBoxRect());
+}
+
+bool RenderTextTrackCue::isOverlapping() const
+{
+    for (RenderObject* box = previousSibling(); box; box = box->previousSibling()) {
+        IntRect boxRect = box->absoluteBoundingBoxRect();
+
+        if (absoluteBoundingBoxRect().intersects(boxRect))
+            return true;
+    }
+
+    return false;
+}
+
+bool RenderTextTrackCue::shouldSwitchDirection(InlineFlowBox* firstLineBox, LayoutUnit step) const
+{
+    LayoutUnit top = y();
+    LayoutUnit left = x();
+    LayoutUnit bottom = top + firstLineBox->height();
+    LayoutUnit right = left + firstLineBox->width();
+
+    // 12. Horizontal: If step is negative and the top of the first line
+    // box in boxes is now above the top of the video's rendering area,
+    // or if step is positive and the bottom of the first line box in
+    // boxes is now below the bottom of the video's rendering area, jump
+    // to the step labeled switch direction.
+    LayoutUnit parentHeight = containingBlock()->height();
+    if (m_cue->getWritingDirection() == TextTrackCue::Horizontal && ((step < 0 && top < 0) || (step > 0 && bottom > parentHeight)))
+        return true;
+
+    // 12. Vertical: If step is negative and the left edge of the first line
+    // box in boxes is now to the left of the left edge of the video's
+    // rendering area, or if step is positive and the right edge of the
+    // first line box in boxes is now to the right of the right edge of
+    // the video's rendering area, jump to the step labeled switch direction.
+    LayoutUnit parentWidth = containingBlock()->width();
+    if (m_cue->getWritingDirection() != TextTrackCue::Horizontal && ((step < 0 && left < 0) || (step > 0 && right > parentWidth)))
+        return true;
+
+    return false;
+}
+
+void RenderTextTrackCue::moveBoxesByStep(LayoutUnit step)
+{
+    // 13. Horizontal: Move all the boxes in boxes down by the distance
+    // given by step. (If step is negative, then this will actually
+    // result in an upwards movement of the boxes in absolute terms.)
+    if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
+        setY(y() + step);
+
+    // 13. Vertical: Move all the boxes in boxes right by the distance
+    // given by step. (If step is negative, then this will actually
+    // result in a leftwards movement of the boxes in absolute terms.)
+    else
+        setX(x() + step);
+}
+
+bool RenderTextTrackCue::switchDirection(bool& switched, LayoutUnit& step)
+{
+    // 15. Switch direction: Move all the boxes in boxes back to their
+    // default position as determined in the step above labeled default.
+    setX(m_fallbackPosition.x());
+    setY(m_fallbackPosition.y());
+
+    // 16. If switched is true, jump to the step labeled done
+    // positioning below.
+    if (switched)
+        return false;
+
+    // 17. Negate step.
+    step = -step;
+
+    // 18. Set switched to true.
+    switched = true;
+    return true;
+}
+
+void RenderTextTrackCue::repositionCueSnapToLinesSet()
+{
+    InlineFlowBox* firstLineBox;
+    LayoutUnit step;
+    LayoutUnit position;
+    if (!initializeLayoutParameters(firstLineBox, step, position))
+        return;
+
+    bool switched;
+    placeBoxInDefaultPosition(position, switched);
+
+    // 11. Step loop: If none of the boxes in boxes would overlap any of the boxes
+    // in output and all the boxes in output are within the video's rendering area
+    // then jump to the step labeled done positioning.
+    while (isOutside() || isOverlapping()) {
+        if (!shouldSwitchDirection(firstLineBox, step))
+            // 13. Move all the boxes in boxes ...
+            // 14. Jump back to the step labeled step loop.
+            moveBoxesByStep(step);
+        else if (!switchDirection(switched, step))
+            break;
+
+        // 19. Jump back to the step labeled step loop.
+    }
+}
+
+void RenderTextTrackCue::repositionCueSnapToLinesNotSet()
+{
+    // FIXME: Implement overlapping detection when snap-to-lines is not set. http://wkb.ug/84296
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/rendering/RenderTextTrackCue.h b/Source/WebCore/rendering/RenderTextTrackCue.h
new file mode 100644 (file)
index 0000000..8973ad8
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef RenderTextTrackCue_h
+#define RenderTextTrackCue_h
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "FloatPoint.h"
+#include "RenderBlock.h"
+#include "RenderInline.h"
+#include "RenderView.h"
+
+namespace WebCore {
+
+class TextTrackCueBox;
+
+class RenderTextTrackCue : public RenderBlock {
+public:
+    explicit RenderTextTrackCue(TextTrackCueBox*);
+
+private:
+    virtual void layout() OVERRIDE;
+
+    bool isOutside() const;
+    bool isOverlapping() const;
+    bool shouldSwitchDirection(InlineFlowBox*, LayoutUnit) const;
+
+    void moveBoxesByStep(LayoutUnit);
+    bool switchDirection(bool&, LayoutUnit&);
+
+    bool initializeLayoutParameters(InlineFlowBox*&, LayoutUnit&, LayoutUnit&);
+    void placeBoxInDefaultPosition(LayoutUnit, bool&);
+    void repositionCueSnapToLinesSet();
+
+    void repositionCueSnapToLinesNotSet();
+
+    TextTrackCue* m_cue;
+    FloatPoint m_fallbackPosition;
+};
+
+} // namespace WebCore
+
+#endif
+#endif // RenderTextTrackCue_h