Diff
Modified: trunk/LayoutTests/ChangeLog (165904 => 165905)
--- trunk/LayoutTests/ChangeLog 2014-03-19 18:27:51 UTC (rev 165904)
+++ trunk/LayoutTests/ChangeLog 2014-03-19 19:00:14 UTC (rev 165905)
@@ -1,5 +1,20 @@
2014-03-19 Brent Fulgham <bfulg...@apple.com>
+ Fix cue rendering test and include support for left/right alignment
+ https://bugs.webkit.org/show_bug.cgi?id=130406
+
+ Reviewed by Eric Carlson.
+
+ Merged from Blink (patch by vcarb...@chromium.org):
+ https://chromium.googlesource.com/chromium/blink/+/e695703cb603421c741e59a557a7989113c13b94
+ http://crbug.com/25155003
+
+ * media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt: Revised for left/right alignment tags.
+ * media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt: Ditto.
+ * media/track/track-cue-rendering-snap-to-lines-not-set.html: Ditto.
+
+2014-03-19 Brent Fulgham <bfulg...@apple.com>
+
Unreviewed test system fix.
* TestExpectations: I mistakenly checked in the region-webvtt tests as enabled. This feature is not
Modified: trunk/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt (165904 => 165905)
--- trunk/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt 2014-03-19 18:27:51 UTC (rev 165904)
+++ trunk/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt 2014-03-19 19:00:14 UTC (rev 165905)
@@ -1,7 +1,7 @@
WEBVTT FILE
1
-00:00:00.000 --> 00:00:00.500
+00:00:00.000 --> 00:00:00.500 line:100% position:50%
This is a demo track to illustrate positioning features of cues.
2
@@ -17,11 +17,11 @@
Or on the top-right corner.
5
-00:00:02.000 --> 00:00:02.500 line:100% position:100% align:end
+00:00:02.000 --> 00:00:02.500 line:100% position:100% align:right
Bottom-right corner.
6
-00:00:02.500 --> 00:00:03.000 line:100% position:0% align:start
+00:00:02.500 --> 00:00:03.000 line:100% position:0% align:left
And, as you might expect, the bottom-left one.
7
@@ -29,7 +29,7 @@
Cues are implicitly displayed within the viewport area.
8
-00:00:03.500 --> 00:00:04.000 line:100% position:50%
+00:00:03.500 --> 00:00:04.000 line:100% position:50% align:middle
And always on top of the controls, if these are visible.
9
@@ -53,9 +53,9 @@
Random cue 1.
14
-00:00:04.000 --> 00:00:05.000 line:33% position:44%
+00:00:04.000 --> 00:00:05.000 line:33% position:44% align:start
Random cue 2.
15
-00:00:04.000 --> 00:00:05.000 line:55% position:23%
+00:00:04.000 --> 00:00:05.000 line:55% position:23% align:start
Random cue 3.
Modified: trunk/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt (165904 => 165905)
--- trunk/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt 2014-03-19 18:27:51 UTC (rev 165904)
+++ trunk/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt 2014-03-19 19:00:14 UTC (rev 165905)
@@ -2,18 +2,15 @@
Test that TextTrack's cues are rendered correctly when the snap to lines flag is not set.
EVENT(canplaythrough)
-The track container and the media controls should completely cover the video element
-EXPECTED (cueDisplayContainer.offsetHeight + controlsPanelElement.offsetHeight == video.videoHeight == 'true') OK
-EXPECTED (cueDisplayContainer.offsetWidth == video.videoWidth == 'true') OK
-
** Default **
EVENT(seeked)
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): 87
+Cue alignment (default or as specified): middle
+Cue left position (percentage): 50
+Cue top position (percentage): 100
** Center **
EVENT(seeked)
@@ -21,6 +18,7 @@
* Cue 0 *
EXPECTED (cueDisplayElement.innerText == 'Using HTML5 captions, you can position the cues anywhere.') OK
+Cue alignment (default or as specified): middle
Cue left position (percentage): 50
Cue top position (percentage): 50
@@ -30,6 +28,7 @@
* Cue 0 *
EXPECTED (cueDisplayElement.innerText == 'For example, here is a cue on the top left-corner.') OK
+Cue alignment (default or as specified): start
Cue left position (percentage): 0
Cue top position (percentage): 0
@@ -39,6 +38,7 @@
* Cue 0 *
EXPECTED (cueDisplayElement.innerText == 'Or on the top-right corner.') OK
+Cue alignment (default or as specified): end
Cue left position (percentage): 100
Cue top position (percentage): 0
@@ -48,6 +48,7 @@
* Cue 0 *
EXPECTED (cueDisplayElement.innerText == 'Bottom-right corner.') OK
+Cue alignment (default or as specified): right
Cue left position (percentage): 100
Cue top position (percentage): 100
@@ -57,6 +58,7 @@
* Cue 0 *
EXPECTED (cueDisplayElement.innerText == 'And, as you might expect, the bottom-left one.') OK
+Cue alignment (default or as specified): left
Cue left position (percentage): 0
Cue top position (percentage): 100
@@ -66,6 +68,7 @@
* Cue 0 *
EXPECTED (cueDisplayElement.innerText == 'Cues are implicitly displayed within the viewport area.') OK
+Cue alignment (default or as specified): middle
Cue left position (percentage): 50
Cue top position (percentage): 50
@@ -75,36 +78,43 @@
* Cue 0 *
EXPECTED (cueDisplayElement.innerText == 'You may even have multiple cues in the same time.') OK
+Cue alignment (default or as specified): middle
Cue left position (percentage): 50
Cue top position (percentage): 50
* Cue 1 *
EXPECTED (cueDisplayElement.innerText == 'Top-left cue.') OK
+Cue alignment (default or as specified): start
Cue left position (percentage): 0
Cue top position (percentage): 0
* Cue 2 *
EXPECTED (cueDisplayElement.innerText == 'Top-right cue.') OK
+Cue alignment (default or as specified): end
Cue left position (percentage): 100
Cue top position (percentage): 7
* Cue 3 *
EXPECTED (cueDisplayElement.innerText == 'Bottom cue.') OK
+Cue alignment (default or as specified): middle
Cue left position (percentage): 50
Cue top position (percentage): 100
* Cue 4 *
EXPECTED (cueDisplayElement.innerText == 'Random cue 1.') OK
+Cue alignment (default or as specified): end
Cue left position (percentage): 100
Cue top position (percentage): 25
* Cue 5 *
EXPECTED (cueDisplayElement.innerText == 'Random cue 2.') OK
+Cue alignment (default or as specified): start
Cue left position (percentage): 44
Cue top position (percentage): 33
* Cue 6 *
EXPECTED (cueDisplayElement.innerText == 'Random cue 3.') OK
+Cue alignment (default or as specified): start
Cue left position (percentage): 23
Cue top position (percentage): 43
END OF TEST
Modified: trunk/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html (165904 => 165905)
--- trunk/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html 2014-03-19 18:27:51 UTC (rev 165904)
+++ trunk/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html 2014-03-19 19:00:14 UTC (rev 165905)
@@ -44,12 +44,12 @@
consoleWrite("Active cues: " + testTrack.track.activeCues.length);
for (var i = 0; i < testTrack.track.activeCues.length; ++i) {
-
cueDisplayElement = textTrackDisplayElement(video, 'display', i);
consoleWrite("");
consoleWrite("* Cue " + i + " *");
testExpected("cueDisplayElement.innerText", testTrack.track.activeCues[i].text);
+ consoleWrite("Cue alignment (default or as specified): " + testTrack.track.activeCues[i].align);
consoleWrite("Cue left position (percentage): " + Math.round(cueDisplayElement.offsetLeft / cueDisplayContainer.offsetWidth * 100));
consoleWrite("Cue top position (percentage): " + Math.round(cueDisplayElement.offsetTop / cueDisplayContainer.offsetHeight * 100));
@@ -74,14 +74,6 @@
currentTestCase++;
}
- function testInitialContainer()
- {
- consoleWrite("");
- consoleWrite("The track container and the media controls should completely cover the video element");
- testExpected("cueDisplayContainer.offsetHeight + controlsPanelElement.offsetHeight == video.videoHeight", true);
- testExpected("cueDisplayContainer.offsetWidth == video.videoWidth", true);
- }
-
function loaded()
{
consoleWrite("Test that TextTrack's cues are rendered correctly when the snap to lines flag is not set.");
@@ -93,7 +85,6 @@
waitForEvent('canplaythrough', function() {
cueDisplayContainer = textTrackDisplayElement(video);
- testInitialContainer();
runNextTestCase();
});
}
Modified: trunk/Source/WebCore/ChangeLog (165904 => 165905)
--- trunk/Source/WebCore/ChangeLog 2014-03-19 18:27:51 UTC (rev 165904)
+++ trunk/Source/WebCore/ChangeLog 2014-03-19 19:00:14 UTC (rev 165905)
@@ -1,3 +1,29 @@
+2014-03-19 Brent Fulgham <bfulg...@apple.com>
+
+ Fix cue rendering test and include support for left/right alignment
+ https://bugs.webkit.org/show_bug.cgi?id=130406
+
+ Reviewed by Eric Carlson.
+
+ Merged from Blink (patch by vcarb...@chromium.org):
+ https://chromium.googlesource.com/chromium/blink/+/e695703cb603421c741e59a557a7989113c13b94
+ http://crbug.com/25155003
+
+ No new tests. Covered by media/track/track-cue-rendering-snap-to-lines-not-set.html.
+
+ * html/track/VTTCue.cpp:
+ (WebCore::leftKeyword): Added.
+ (WebCore::rightKeyword): Added.
+ (WebCore::VTTCueBox::applyCSSProperties): Added.
+ (WebCore::VTTCue::VTTCue):
+ (WebCore::VTTCue::align): Handle left/right alignment.
+ (WebCore::VTTCue::setAlign): Ditto.
+ (WebCore::VTTCue::calculateDisplayParameters): Refactored and revised for left/right tokens.
+ (WebCore::VTTCue::setCueSettings): Ditto.
+ (WebCore::VTTCue::getCSSAlignment): Added.
+ (WebCore::VTTCue::getCSSWritingMode): Added.
+ * html/track/VTTCue.h:
+
2014-03-18 Anders Carlsson <ander...@apple.com>
Add new functionality that will be required by the history item decoding
Modified: trunk/Source/WebCore/html/track/VTTCue.cpp (165904 => 165905)
--- trunk/Source/WebCore/html/track/VTTCue.cpp 2014-03-19 18:27:51 UTC (rev 165904)
+++ trunk/Source/WebCore/html/track/VTTCue.cpp 2014-03-19 19:00:14 UTC (rev 165905)
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -59,6 +59,16 @@
static const int undefinedPosition = -1;
+static const CSSValueID displayWritingModeMap[] = {
+ CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr
+};
+COMPILE_ASSERT(WTF_ARRAY_LENGTH(displayWritingModeMap) == VTTCue::NumberOfWritingDirections, displayWritingModeMap_has_wrong_size);
+
+static const CSSValueID displayAlignmentMap[] = {
+ CSSValueStart, CSSValueCenter, CSSValueEnd, CSSValueLeft, CSSValueRight
+};
+COMPILE_ASSERT(WTF_ARRAY_LENGTH(displayAlignmentMap) == VTTCue::NumberOfAlignments, displayAlignmentMap_has_wrong_size);
+
static const String& startKeyword()
{
DEPRECATED_DEFINE_STATIC_LOCAL(const String, start, (ASCIILiteral("start")));
@@ -77,6 +87,18 @@
return end;
}
+static const String& leftKeyword()
+{
+ DEPRECATED_DEFINE_STATIC_LOCAL(const String, left, ("left"));
+ return left;
+}
+
+static const String& rightKeyword()
+{
+ DEPRECATED_DEFINE_STATIC_LOCAL(const String, right, ("right"));
+ return right;
+}
+
static const String& horizontalKeyword()
{
return emptyString();
@@ -153,12 +175,7 @@
// 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);
+ setInlineStyleProperty(CSSPropertyTextAlign, m_cue->getCSSAlignment());
if (!m_cue->snapToLines()) {
// 10.13.1 Set up x and y:
@@ -205,18 +222,9 @@
, m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))
, m_displayTreeShouldChange(true)
, m_displayDirection(CSSValueLtr)
- , m_displayWritingMode(CSSValueInherit)
, m_displaySize(0)
, m_notifyRegion(true)
{
- // 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] = CSSValueVerticalRl;
- m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalLr;
}
VTTCue::~VTTCue()
@@ -363,6 +371,10 @@
return middleKeyword();
case End:
return endKeyword();
+ case Left:
+ return leftKeyword();
+ case Right:
+ return rightKeyword();
default:
ASSERT_NOT_REACHED();
return emptyString();
@@ -384,6 +396,10 @@
alignment = Middle;
else if (value == endKeyword())
alignment = End;
+ else if (value == leftKeyword())
+ alignment = Left;
+ else if (value == rightKeyword())
+ alignment = Right;
else
ec = SYNTAX_ERR;
@@ -576,65 +592,80 @@
// 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];
+ // The above step is done through the writing direction static map.
+
// 10.5 Determine the value of maximum size for cue as per the appropriate
// rules from the following list:
int maximumSize = m_textPosition;
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 == Start)) {
+ || (m_writingDirection == Horizontal && m_cueAlignment == Left)
+ || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == Start || m_cueAlignment == Left))
+ || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == Start || m_cueAlignment == Left))) {
maximumSize = 100 - m_textPosition;
} else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr)
|| (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl)
- || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
+ || (m_writingDirection == Horizontal && m_cueAlignment == Right)
+ || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == End || m_cueAlignment == Right))
+ || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == End || m_cueAlignment == Right))) {
maximumSize = m_textPosition;
} else if (m_cueAlignment == Middle) {
maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosition);
maximumSize = maximumSize * 2;
- }
+ } else
+ ASSERT_NOT_REACHED();
// 10.6 If the text track cue size is less than maximum size, then let size
// be text track cue size. Otherwise, let size be maximum size.
m_displaySize = std::min(m_cueSize, maximumSize);
+ // FIXME: Understand why step 10.7 is missing (just a copy/paste error?)
+ // Could be done within a spec implementation check - http://crbug.com/301580
+
// 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) {
- if (m_cueAlignment == Start) {
+ switch (m_cueAlignment) {
+ case Start:
if (m_displayDirection == CSSValueLtr)
m_displayPosition.first = m_textPosition;
else
m_displayPosition.first = 100 - m_textPosition - m_displaySize;
- } else if (m_cueAlignment == End) {
+ break;
+ case End:
if (m_displayDirection == CSSValueRtl)
m_displayPosition.first = 100 - m_textPosition;
else
m_displayPosition.first = m_textPosition - m_displaySize;
+ break;
+ case Left:
+ if (m_displayDirection == CSSValueLtr)
+ m_displayPosition.first = m_textPosition;
+ else
+ m_displayPosition.first = 100 - m_textPosition;
+ break;
+ case Right:
+ if (m_displayDirection == CSSValueLtr)
+ m_displayPosition.first = m_textPosition - m_displaySize;
+ else
+ m_displayPosition.first = 100 - m_textPosition - m_displaySize;
+ break;
+ case Middle:
+ if (m_displayDirection == CSSValueLtr)
+ m_displayPosition.first = m_textPosition - m_displaySize / 2;
+ else
+ m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2;
+ break;
+ case NumberOfAlignments:
+ ASSERT_NOT_REACHED();
}
}
- if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
- m_displayPosition.second = m_textPosition;
- } else if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
- m_displayPosition.second = 100 - m_textPosition;
- }
+ // 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.
+ m_computedLinePosition = calculateComputedLinePosition();
- if (m_writingDirection == Horizontal && m_cueAlignment == Middle) {
- 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_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:
@@ -650,10 +681,6 @@
if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
m_displayPosition.first = m_computedLinePosition;
-
- // 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.
- m_computedLinePosition = calculateComputedLinePosition();
}
void VTTCue::markFutureAndPastNodes(ContainerNode* root, double previousTimestamp, double movieTime)
@@ -1020,6 +1047,14 @@
// 3. If value is a case-sensitive match for the string "end", then let cue's text track cue alignment be end alignment.
else if (cueAlignment == endKeyword())
m_cueAlignment = End;
+
+ // 4. If value is a case-sensitive match for the string "left", then let cue's text track cue alignment be left alignment.
+ else if (cueAlignment == leftKeyword())
+ m_cueAlignment = Left;
+
+ // 5. If value is a case-sensitive match for the string "right", then let cue's text track cue alignment be right alignment.
+ else if (cueAlignment == rightKeyword())
+ m_cueAlignment = Right;
}
break;
#if ENABLE(WEBVTT_REGIONS)
@@ -1046,6 +1081,11 @@
#endif
}
+CSSValueID VTTCue::getCSSAlignment() const
+{
+ return displayAlignmentMap[m_cueAlignment];
+}
+
CSSValueID VTTCue::getCSSWritingDirection() const
{
return m_displayDirection;
@@ -1053,7 +1093,7 @@
CSSValueID VTTCue::getCSSWritingMode() const
{
- return m_displayWritingMode;
+ return displayWritingModeMap[m_writingDirection];
}
int VTTCue::getCSSSize() const
Modified: trunk/Source/WebCore/html/track/VTTCue.h (165904 => 165905)
--- trunk/Source/WebCore/html/track/VTTCue.h 2014-03-19 18:27:51 UTC (rev 165904)
+++ trunk/Source/WebCore/html/track/VTTCue.h 2014-03-19 19:00:14 UTC (rev 165905)
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -127,12 +127,13 @@
std::pair<double, double> getCSSPosition() const;
+ CSSValueID getCSSAlignment() const;
int getCSSSize() const;
CSSValueID getCSSWritingDirection() const;
CSSValueID getCSSWritingMode() const;
enum WritingDirection {
- Horizontal,
+ Horizontal = 0,
VerticalGrowingLeft,
VerticalGrowingRight,
NumberOfWritingDirections
@@ -140,9 +141,12 @@
WritingDirection getWritingDirection() const { return m_writingDirection; }
enum CueAlignment {
- Start,
+ Start = 0,
Middle,
- End
+ End,
+ Left,
+ Right,
+ NumberOfAlignments
};
CueAlignment getAlignment() const { return m_cueAlignment; }
@@ -208,9 +212,6 @@
CSSValueID m_displayDirection;
- CSSValueID m_displayWritingModeMap[NumberOfWritingDirections];
- CSSValueID m_displayWritingMode;
-
int m_displaySize;
std::pair<float, float> m_displayPosition;