Title: [159711] trunk
- Revision
- 159711
- Author
- commit-qu...@webkit.org
- Date
- 2013-11-22 13:44:22 -0800 (Fri, 22 Nov 2013)
Log Message
Add TextTrackList::getTrackById().
https://bugs.webkit.org/show_bug.cgi?id=124785
Patch by Brendan Long <b.l...@cablelabs.com> on 2013-11-22
Reviewed by Eric Carlson.
Source/WebCore:
Test: media/track/track-id.html
* html/track/TextTrackList.cpp: Add getTrackById()
(TextTrackList::getTrackById):
* html/track/TextTrackList.h: Same.
* html/track/TextTrackList.idl: Same.
LayoutTests:
Update this test to make it more interesting. It now checks that the "id"
changes when the <track> id changes, makes sure TextTrack::id is readonly,
and looks the track up by id with getTrackById().
* media/track/track-id-expected.txt:
* media/track/track-id.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (159710 => 159711)
--- trunk/LayoutTests/ChangeLog 2013-11-22 21:22:50 UTC (rev 159710)
+++ trunk/LayoutTests/ChangeLog 2013-11-22 21:44:22 UTC (rev 159711)
@@ -1,3 +1,17 @@
+2013-11-22 Brendan Long <b.l...@cablelabs.com>
+
+ Add TextTrackList::getTrackById().
+ https://bugs.webkit.org/show_bug.cgi?id=124785
+
+ Reviewed by Eric Carlson.
+
+ Update this test to make it more interesting. It now checks that the "id"
+ changes when the <track> id changes, makes sure TextTrack::id is readonly,
+ and looks the track up by id with getTrackById().
+
+ * media/track/track-id-expected.txt:
+ * media/track/track-id.html:
+
2013-11-22 Filip Pizlo <fpi...@apple.com>
BytecodeGenerator should align the stack according to native conventions
Modified: trunk/LayoutTests/media/track/track-id-expected.txt (159710 => 159711)
--- trunk/LayoutTests/media/track/track-id-expected.txt 2013-11-22 21:22:50 UTC (rev 159710)
+++ trunk/LayoutTests/media/track/track-id-expected.txt 2013-11-22 21:44:22 UTC (rev 159711)
@@ -1,7 +1,16 @@
-Tests that the 'id' attribute on a TextTrack matches the track element.
+Tests that the TextTrack "id" attribute is appropriately set.
-EXPECTED (video.textTracks[0].id == 'Test-ID-123') OK
+++ Test default attribute value
+EXPECTED (textTrack.id == 'LoremIpsum') OK
+EXPECTED (video.textTracks[0].id == 'LoremIpsum') OK
+
+++ Make sure we can look tracks up by id
+EXPECTED (video.textTracks.getTrackById('LoremIpsum') == '[object TextTrack]') OK
+
+++ Test that it's readonly
+RUN(textTrack.id = 'newvalue';)
+EXPECTED (textTrack.id == 'LoremIpsum') OK
END OF TEST
Modified: trunk/LayoutTests/media/track/track-id.html (159710 => 159711)
--- trunk/LayoutTests/media/track/track-id.html 2013-11-22 21:22:50 UTC (rev 159710)
+++ trunk/LayoutTests/media/track/track-id.html 2013-11-22 21:44:22 UTC (rev 159711)
@@ -1,29 +1,42 @@
<!DOCTYPE html>
<html>
<head>
+
<script src=""
<script src=""
<script>
- function loaded()
+ var textTrack;
+
+ function start()
{
findMediaElement();
- var trackElement = video.firstElementChild;
+ consoleWrite("");
- testExpected("video.textTracks[0].id", trackElement.id);
+ textTrack = document.getElementById("LoremIpsum").track;
+ consoleWrite("<b>++ Test default attribute value</b>");
+ testExpected("textTrack.id", "LoremIpsum");
+ testExpected("video.textTracks[0].id", "LoremIpsum");
consoleWrite("");
+
+ consoleWrite("<b>++ Make sure we can look tracks up by id</b>");
+ testExpected("video.textTracks.getTrackById('LoremIpsum')", textTrack);
+ consoleWrite("");
+
+ consoleWrite("<b>++ Test that it's readonly</b>");
+ run("textTrack.id = 'newvalue';");
+ testExpected("textTrack.id", "LoremIpsum");
+
endTest();
}
- setCaptionDisplayMode('Automatic');
-
</script>
</head>
- <body _onload_="loaded()">
- <p>Tests that the 'id' attribute on a TextTrack matches the track element.</p>
+ <body _onload_="start()">
+ <p>Tests that the TextTrack "id" attribute is appropriately set.</p>
<video>
- <track id="Test-ID-123" src=""
+ <track id="LoremIpsum" src=""
</video>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (159710 => 159711)
--- trunk/Source/WebCore/ChangeLog 2013-11-22 21:22:50 UTC (rev 159710)
+++ trunk/Source/WebCore/ChangeLog 2013-11-22 21:44:22 UTC (rev 159711)
@@ -1,3 +1,17 @@
+2013-11-22 Brendan Long <b.l...@cablelabs.com>
+
+ Add TextTrackList::getTrackById().
+ https://bugs.webkit.org/show_bug.cgi?id=124785
+
+ Reviewed by Eric Carlson.
+
+ Test: media/track/track-id.html
+
+ * html/track/TextTrackList.cpp: Add getTrackById()
+ (TextTrackList::getTrackById):
+ * html/track/TextTrackList.h: Same.
+ * html/track/TextTrackList.idl: Same.
+
2013-11-22 Hans Muller <hmul...@adobe.com>
[CSS Shapes] When the <box> value is set, derive radii from border-radius
Modified: trunk/Source/WebCore/html/track/TextTrackList.cpp (159710 => 159711)
--- trunk/Source/WebCore/html/track/TextTrackList.cpp 2013-11-22 21:22:50 UTC (rev 159710)
+++ trunk/Source/WebCore/html/track/TextTrackList.cpp 2013-11-22 21:44:22 UTC (rev 159711)
@@ -127,6 +127,22 @@
return 0;
}
+TextTrack* TextTrackList::getTrackById(const AtomicString& id)
+{
+ // 4.8.10.12.5 Text track API
+ // The getTrackById(id) method must return the first TextTrack in the
+ // TextTrackList object whose id IDL attribute would return a value equal
+ // to the value of the id argument.
+ for (unsigned i = 0; i < length(); ++i) {
+ TextTrack* track = item(i);
+ if (track->id() == id)
+ return track;
+ }
+
+ // When no tracks match the given argument, the method must return null.
+ return nullptr;
+}
+
void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track)
{
Vector<RefPtr<TrackBase>>* tracks = 0;
Modified: trunk/Source/WebCore/html/track/TextTrackList.h (159710 => 159711)
--- trunk/Source/WebCore/html/track/TextTrackList.h 2013-11-22 21:22:50 UTC (rev 159710)
+++ trunk/Source/WebCore/html/track/TextTrackList.h 2013-11-22 21:44:22 UTC (rev 159711)
@@ -48,6 +48,7 @@
virtual bool contains(TrackBase*) const OVERRIDE;
TextTrack* item(unsigned index) const;
+ TextTrack* getTrackById(const AtomicString&);
TextTrack* lastItem() const { return item(length() - 1); }
void append(PassRefPtr<TextTrack>);
Modified: trunk/Source/WebCore/html/track/TextTrackList.idl (159710 => 159711)
--- trunk/Source/WebCore/html/track/TextTrackList.idl 2013-11-22 21:22:50 UTC (rev 159710)
+++ trunk/Source/WebCore/html/track/TextTrackList.idl 2013-11-22 21:44:22 UTC (rev 159711)
@@ -31,6 +31,7 @@
] interface TextTrackList {
readonly attribute unsigned long length;
getter TextTrack item(unsigned long index);
+ TextTrack getTrackById(DOMString id);
attribute EventListener onaddtrack;
attribute EventListener onremovetrack;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes