Diff
Modified: trunk/LayoutTests/ChangeLog (134782 => 134783)
--- trunk/LayoutTests/ChangeLog 2012-11-15 17:02:27 UTC (rev 134782)
+++ trunk/LayoutTests/ChangeLog 2012-11-15 17:05:29 UTC (rev 134783)
@@ -1,3 +1,16 @@
+2012-11-15 Eric Carlson <[email protected]>
+
+ Update computed line position algorithm
+ https://bugs.webkit.org/show_bug.cgi?id=93779
+
+ Reviewed by Philippe Normand.
+
+ Compute the position of a text track relative to rendered tracks. This is needed to position
+ cues correctly when there is more than one text track.
+
+ * media/track/track-cue-container-rendering-position-expected.txt: Added.
+ * media/track/track-cue-container-rendering-position.html: Added.
+
2012-11-15 Andreas Kling <[email protected]>
REGRESSION(r134408): Heap-use-after-free in WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement().
Added: trunk/LayoutTests/media/track/track-cue-container-rendering-position-expected.txt (0 => 134783)
--- trunk/LayoutTests/media/track/track-cue-container-rendering-position-expected.txt (rev 0)
+++ trunk/LayoutTests/media/track/track-cue-container-rendering-position-expected.txt 2012-11-15 17:05:29 UTC (rev 134783)
@@ -0,0 +1,6 @@
+The top of the text track container should be in the bottom 25% of the video element.
+EVENT(canplaythrough)
+
+EXPECTED (cueDisplayElement.offsetTop > (video.videoHeight * .75) == 'true') OK
+END OF TEST
+
Added: trunk/LayoutTests/media/track/track-cue-container-rendering-position.html (0 => 134783)
--- trunk/LayoutTests/media/track/track-cue-container-rendering-position.html (rev 0)
+++ trunk/LayoutTests/media/track/track-cue-container-rendering-position.html 2012-11-15 17:05:29 UTC (rev 134783)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script src=""
+ <script src=""
+ <script src=""
+
+ <script>
+
+ var cueDisplayElement;
+
+ function testPosition()
+ {
+ if (!window.internals) {
+ consoleWrite("<br><b>** This test only works in DRT! **<" + "/b>");
+ return;
+ }
+
+ consoleWrite("");
+ cueDisplayElement = textTrackDisplayElement(video, 'display', 0);
+ testExpected("cueDisplayElement.offsetTop > (video.videoHeight * .75)", true);
+ endTest();
+ }
+
+ function loaded()
+ {
+ consoleWrite("The top of the text track container should be in the bottom 25% of the video element.");
+
+ findMediaElement();
+ video.src = "" '../content/test');
+ waitForEvent('canplaythrough', testPosition);
+ }
+
+ </script>
+ </head>
+ <body _onload_="loaded()">
+ <video controls>
+ <track src="" kind="captions" >
+ <track src="" kind="captions" >
+ <track src="" kind="captions" >
+ <track src="" kind="captions" >
+ <track src="" kind="captions" >
+ <track src="" kind="captions" default>
+ </video>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (134782 => 134783)
--- trunk/Source/WebCore/ChangeLog 2012-11-15 17:02:27 UTC (rev 134782)
+++ trunk/Source/WebCore/ChangeLog 2012-11-15 17:05:29 UTC (rev 134783)
@@ -1,3 +1,30 @@
+2012-11-15 Eric Carlson <[email protected]>
+
+ Update computed line position algorithm
+ https://bugs.webkit.org/show_bug.cgi?id=93779
+
+ Reviewed by Philippe Normand.
+
+ Compute the position of a text track relative to rendered tracks. This is needed to position
+ cues correctly when there is more than one text track.
+
+ Test: media/track/track-cue-container-rendering-position.html
+
+ * html/track/TextTrack.cpp:
+ (WebCore::TextTrack::invalidateTrackIndex): Invalidate both cached track indices.
+ (WebCore::TextTrack::trackIndexRelativeToRenderedTracks): Return the index of the track relative
+ to other rendered tracks.
+ * html/track/TextTrack.h:
+
+ * html/track/TextTrackCue.cpp:
+ (WebCore::TextTrackCue::calculateComputedLinePosition): Use trackIndexRelativeToRenderedTracks()
+ instead of trackIndex() so cues are positioned correctly.
+
+ * html/track/TextTrackList.cpp:
+ (TextTrackList::getTrackIndex): Change return type from unsigned to int.
+ (TextTrackList::getTrackIndexRelativeToRenderedTracks): New.
+ * html/track/TextTrackList.h:
+
2012-11-15 Dominik Röttsches <[email protected]>
[EFL] Bump Harfbuzz to allow fixing bug 101009 on EFL
Modified: trunk/Source/WebCore/html/track/TextTrack.cpp (134782 => 134783)
--- trunk/Source/WebCore/html/track/TextTrack.cpp 2012-11-15 17:02:27 UTC (rev 134782)
+++ trunk/Source/WebCore/html/track/TextTrack.cpp 2012-11-15 17:05:29 UTC (rev 134783)
@@ -104,8 +104,9 @@
, m_client(client)
, m_trackType(type)
, m_readinessState(NotLoaded)
+ , m_trackIndex(invalidTrackIndex)
+ , m_renderedTrackIndex(invalidTrackIndex)
, m_showingByDefault(false)
- , m_trackIndex(invalidTrackIndex)
{
setKind(kind);
}
@@ -313,6 +314,7 @@
void TextTrack::invalidateTrackIndex()
{
m_trackIndex = invalidTrackIndex;
+ m_renderedTrackIndex = invalidTrackIndex;
}
bool TextTrack::isRendered()
@@ -334,6 +336,16 @@
return m_cues.get();
}
+int TextTrack::trackIndexRelativeToRenderedTracks()
+{
+ ASSERT(m_mediaElement);
+
+ if (m_renderedTrackIndex == invalidTrackIndex)
+ m_renderedTrackIndex = m_mediaElement->textTracks()->getTrackIndexRelativeToRenderedTracks(this);
+
+ return m_renderedTrackIndex;
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/html/track/TextTrack.h (134782 => 134783)
--- trunk/Source/WebCore/html/track/TextTrack.h 2012-11-15 17:02:27 UTC (rev 134782)
+++ trunk/Source/WebCore/html/track/TextTrack.h 2012-11-15 17:05:29 UTC (rev 134783)
@@ -114,6 +114,7 @@
void invalidateTrackIndex();
bool isRendered();
+ int trackIndexRelativeToRenderedTracks();
protected:
TextTrack(ScriptExecutionContext*, TextTrackClient*, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType);
@@ -130,8 +131,9 @@
TextTrackClient* m_client;
TextTrackType m_trackType;
ReadinessState m_readinessState;
+ int m_trackIndex;
+ int m_renderedTrackIndex;
bool m_showingByDefault;
- int m_trackIndex;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (134782 => 134783)
--- trunk/Source/WebCore/html/track/TextTrackCue.cpp 2012-11-15 17:02:27 UTC (rev 134782)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp 2012-11-15 17:05:29 UTC (rev 134783)
@@ -554,12 +554,8 @@
// 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.
+ int n = track()->trackIndexRelativeToRenderedTracks();
- // 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++;
Modified: trunk/Source/WebCore/html/track/TextTrackList.cpp (134782 => 134783)
--- trunk/Source/WebCore/html/track/TextTrackList.cpp 2012-11-15 17:02:27 UTC (rev 134782)
+++ trunk/Source/WebCore/html/track/TextTrackList.cpp 2012-11-15 17:05:29 UTC (rev 134783)
@@ -56,7 +56,7 @@
return m_addTrackTracks.size() + m_elementTracks.size();
}
-unsigned TextTrackList::getTrackIndex(TextTrack *textTrack)
+int TextTrackList::getTrackIndex(TextTrack *textTrack)
{
if (textTrack->trackType() == TextTrack::TrackElement)
return static_cast<LoadableTextTrack*>(textTrack)->trackElementIndex();
@@ -69,6 +69,34 @@
return -1;
}
+int TextTrackList::getTrackIndexRelativeToRenderedTracks(TextTrack *textTrack)
+{
+ // Calculate the "Let n be the number of text tracks whose text track mode is showing and that are in the media element's list of text tracks before track."
+ int trackIndex = 0;
+
+ for (size_t i = 0; i < m_elementTracks.size(); ++i) {
+ if (!m_elementTracks[i]->isRendered())
+ continue;
+
+ if (m_elementTracks[i] == textTrack)
+ return trackIndex;
+ ++trackIndex;
+ }
+
+ for (size_t i = 0; i < m_addTrackTracks.size(); ++i) {
+ if (!m_addTrackTracks[i]->isRendered())
+ continue;
+
+ if (m_addTrackTracks[i] == textTrack)
+ return trackIndex;
+ ++trackIndex;
+ }
+
+ ASSERT_NOT_REACHED();
+
+ return -1;
+}
+
TextTrack* TextTrackList::item(unsigned index)
{
// 4.8.10.12.1 Text track model
Modified: trunk/Source/WebCore/html/track/TextTrackList.h (134782 => 134783)
--- trunk/Source/WebCore/html/track/TextTrackList.h 2012-11-15 17:02:27 UTC (rev 134782)
+++ trunk/Source/WebCore/html/track/TextTrackList.h 2012-11-15 17:05:29 UTC (rev 134783)
@@ -51,7 +51,8 @@
~TextTrackList();
unsigned length() const;
- unsigned getTrackIndex(TextTrack*);
+ int getTrackIndex(TextTrack*);
+ int getTrackIndexRelativeToRenderedTracks(TextTrack*);
TextTrack* item(unsigned index);
void append(PassRefPtr<TextTrack>);