Diff
Modified: trunk/LayoutTests/ChangeLog (99233 => 99234)
--- trunk/LayoutTests/ChangeLog 2011-11-03 20:24:16 UTC (rev 99233)
+++ trunk/LayoutTests/ChangeLog 2011-11-03 20:28:55 UTC (rev 99234)
@@ -1,3 +1,13 @@
+2011-11-03 Anna Cavender <[email protected]>
+
+ Tests for TextTrackCueList implementation.
+ https://bugs.webkit.org/show_bug.cgi?id=70451
+
+ Reviewed by Eric Carlson.
+
+ * media/track/track-text-track-cue-list-expected.txt: Added.
+ * media/track/track-text-track-cue-list.html: Added.
+
2011-11-03 Tony Chang <[email protected]>
Mark tests as slow in chromium.
Added: trunk/LayoutTests/media/track/track-text-track-cue-list-expected.txt (0 => 99234)
--- trunk/LayoutTests/media/track/track-text-track-cue-list-expected.txt (rev 0)
+++ trunk/LayoutTests/media/track/track-text-track-cue-list-expected.txt 2011-11-03 20:28:55 UTC (rev 99234)
@@ -0,0 +1,17 @@
+Tests TextTrackCueList functionality: length, operator[], and getCueById()
+
+
+*** Testing TextTrackCueList length
+EXPECTED (cues.length == '4') OK
+
+*** Testing TextTrackCueList [] operator
+EXPECTED (cues[0].id == '1') OK
+EXPECTED (cues[3].id == '4') OK
+EXPECTED (cues[4] == 'undefined') OK
+
+*** Testing TextTrackCueList getCueById()
+EXPECTED (cues.getCueById('1').startTime == '0') OK
+EXPECTED (cues.getCueById('4').startTime == '121') OK
+EXPECTED (cues.getCueById('junk') == 'undefined') OK
+END OF TEST
+
Added: trunk/LayoutTests/media/track/track-text-track-cue-list.html (0 => 99234)
--- trunk/LayoutTests/media/track/track-text-track-cue-list.html (rev 0)
+++ trunk/LayoutTests/media/track/track-text-track-cue-list.html 2011-11-03 20:28:55 UTC (rev 99234)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script src=""
+ <script src=""
+ <script>
+
+ function trackLoaded()
+ {
+ var testTrack = document.getElementById('testTrack');
+ cues = testTrack.track.cues;
+
+ consoleWrite("<br>*** Testing TextTrackCueList length");
+
+ testExpected("cues.length", 4);
+
+ consoleWrite("<br>*** Testing TextTrackCueList [] operator");
+
+ testExpected("cues[0].id", "1");
+ testExpected("cues[3].id", "4");
+ testExpected("cues[4]", undefined);
+
+ consoleWrite("<br>*** Testing TextTrackCueList getCueById()");
+
+ testExpected("cues.getCueById('1').startTime", 0);
+ testExpected("cues.getCueById('4').startTime", 121);
+ testExpected("cues.getCueById('junk')", undefined);
+
+ endTest();
+ }
+
+ </script>
+ </head>
+ <body>
+ <p>Tests TextTrackCueList functionality: length, operator[], and getCueById()</p>
+ <video>
+ <track id="testTrack" src="" kind="captions" _onload_="trackLoaded()">
+ </video>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (99233 => 99234)
--- trunk/Source/WebCore/ChangeLog 2011-11-03 20:24:16 UTC (rev 99233)
+++ trunk/Source/WebCore/ChangeLog 2011-11-03 20:28:55 UTC (rev 99234)
@@ -1,3 +1,33 @@
+2011-11-03 Anna Cavender <[email protected]>
+
+ Implement TextTrackCueList.
+ https://bugs.webkit.org/show_bug.cgi?id=70451
+
+ Reviewed by Eric Carlson.
+
+ Test: media/track/track-text-track-cue-list.html
+
+ * html/LoadableTextTrack.cpp:
+ (WebCore::LoadableTextTrack::newCuesAvailable):
+ Update TextTrack's TextTrackCueList (m_cues) when new cues are discovered.
+ * html/TextTrack.cpp:
+ (WebCore::TextTrack::TextTrack):
+ Create an empty TextTrackCueList upon TextTrack creation.
+ (WebCore::TextTrack::cues):
+ Return this TextTrack's list of cues.
+
+ Implement TextTrackCueList functionality:
+ * html/TextTrackCueList.cpp:
+ (WebCore::TextTrackCueList::TextTrackCueList):
+ (WebCore::TextTrackCueList::length):
+ (WebCore::TextTrackCueList::item):
+ (WebCore::TextTrackCueList::getCueById):
+ (WebCore::TextTrackCueList::add):
+ (WebCore::TextTrackCueList::remove):
+ (WebCore::TextTrackCueList::contains):
+ * html/TextTrackCueList.h:
+ (WebCore::TextTrackCueList::~TextTrackCueList):
+
2011-11-03 Joshua Bell <[email protected]>
IndexedDB result of deleting a record should be true or false
Modified: trunk/Source/WebCore/html/LoadableTextTrack.cpp (99233 => 99234)
--- trunk/Source/WebCore/html/LoadableTextTrack.cpp 2011-11-03 20:24:16 UTC (rev 99233)
+++ trunk/Source/WebCore/html/LoadableTextTrack.cpp 2011-11-03 20:28:55 UTC (rev 99234)
@@ -29,6 +29,8 @@
#include "LoadableTextTrack.h"
+#include "TextTrackCueList.h"
+
namespace WebCore {
LoadableTextTrack::LoadableTextTrack(TextTrackClient* trackClient, TextTrackLoadingClient* loadingClient, const String& kind, const String& label, const String& language, bool isDefault)
@@ -53,7 +55,18 @@
{
ASSERT_UNUSED(loader, m_loader == loader);
- // FIXME(62885): Implement.
+ Vector<RefPtr<TextTrackCue> > newCues;
+ m_loader->getNewCues(newCues);
+
+ for (size_t i = 0; i < newCues.size(); ++i)
+ newCues[i]->setTrack(this);
+
+ if (!m_cues)
+ m_cues = TextTrackCueList::create();
+ m_cues->add(newCues);
+
+ if (client())
+ client()->textTrackAddCues(this, m_cues.get());
}
void LoadableTextTrack::cueLoadingStarted(TextTrackLoader* loader)
Modified: trunk/Source/WebCore/html/TextTrack.cpp (99233 => 99234)
--- trunk/Source/WebCore/html/TextTrack.cpp 2011-11-03 20:24:16 UTC (rev 99233)
+++ trunk/Source/WebCore/html/TextTrack.cpp 2011-11-03 20:28:55 UTC (rev 99234)
@@ -99,13 +99,19 @@
ec = INVALID_ACCESS_ERR;
}
-PassRefPtr<TextTrackCueList> TextTrack::cues() const
+TextTrackCueList* TextTrack::cues() const
{
- // FIXME(62885): Implement.
+ // 4.8.10.12.5 If the text track mode ... is not the text track disabled mode,
+ // then the cues attribute must return a live TextTrackCueList object ...
+ // Otherwise, it must return null. When an object is returned, the
+ // same object must be returned each time.
+ // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-cues
+ if (m_mode != TextTrack::DISABLED)
+ return m_cues.get();
return 0;
}
-PassRefPtr<TextTrackCueList> TextTrack::activeCues() const
+TextTrackCueList* TextTrack::activeCues() const
{
// FIXME(62885): Implement.
return 0;
Modified: trunk/Source/WebCore/html/TextTrack.h (99233 => 99234)
--- trunk/Source/WebCore/html/TextTrack.h 2011-11-03 20:24:16 UTC (rev 99233)
+++ trunk/Source/WebCore/html/TextTrack.h 2011-11-03 20:28:55 UTC (rev 99234)
@@ -70,8 +70,8 @@
Mode mode() const;
void setMode(unsigned short, ExceptionCode&);
- PassRefPtr<TextTrackCueList> cues() const;
- PassRefPtr<TextTrackCueList> activeCues() const;
+ TextTrackCueList* cues() const;
+ TextTrackCueList* activeCues() const;
void readyStateChanged();
void modeChanged();
Modified: trunk/Source/WebCore/html/TextTrackCueList.cpp (99233 => 99234)
--- trunk/Source/WebCore/html/TextTrackCueList.cpp 2011-11-03 20:24:16 UTC (rev 99233)
+++ trunk/Source/WebCore/html/TextTrackCueList.cpp 2011-11-03 20:28:55 UTC (rev 99234)
@@ -33,42 +33,74 @@
TextTrackCueList::TextTrackCueList()
{
- // FIXME(62883): Implement.
}
unsigned long TextTrackCueList::length() const
{
- // FIXME(62883): Implement.
- return 0;
+ return m_list.size();
}
-TextTrackCue* TextTrackCueList::item(unsigned) const
+TextTrackCue* TextTrackCueList::item(unsigned index) const
{
- // FIXME(62883): Implement.
+ if (index < m_list.size())
+ return m_list[index].get();
return 0;
}
-TextTrackCue* TextTrackCueList::getCueById(const String&) const
+TextTrackCue* TextTrackCueList::getCueById(const String& id) const
{
- // FIXME(62883): Implement.
+ for (size_t i = 0; i < m_list.size(); ++i) {
+ if (m_list[i]->id() == id)
+ return m_list[i].get();
+ }
return 0;
}
-void TextTrackCueList::append(Vector<PassRefPtr<TextTrackCue> >&)
+void TextTrackCueList::add(const Vector<RefPtr<TextTrackCue> >& newCues)
{
- // FIXME(62883): Implement.
+ for (size_t i = 0; i < newCues.size(); ++i)
+ add(newCues[i]);
}
-void TextTrackCueList::append(const PassRefPtr<TextTrackCue>&)
+void TextTrackCueList::add(PassRefPtr<TextTrackCue> cue)
{
- // FIXME(62883): Implement.
+ add(cue, 0, m_list.size());
}
-void TextTrackCueList::remove(const PassRefPtr<TextTrackCue>&)
+void TextTrackCueList::add(PassRefPtr<TextTrackCue> cue, size_t start, size_t end)
{
- // FIXME(62883): Implement.
+ ASSERT(start >= 0 && start <= m_list.size());
+ ASSERT(end >= 0 && end <= m_list.size());
+
+ // Maintain text track cue order:
+ // http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-order
+ RefPtr<TextTrackCue> newCue = cue;
+ if (start == end) {
+ m_list.insert(start, newCue);
+ return;
+ }
+
+ size_t index = (start + end) / 2;
+ if (newCue->startTime() < m_list[index]->startTime() || (newCue->startTime() == m_list[index]->startTime() && newCue->endTime() > m_list[index]->endTime()))
+ add(newCue.release(), start, index);
+ else
+ add(newCue.release(), index + 1, end);
}
+void TextTrackCueList::remove(TextTrackCue* cue)
+{
+ size_t index = m_list.find(cue);
+ if (index == notFound)
+ return;
+ cue->setIsActive(false);
+ m_list.remove(index);
+}
+
+bool TextTrackCueList::contains(TextTrackCue* cue) const
+{
+ return m_list.contains(cue);
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/html/TextTrackCueList.h (99233 => 99234)
--- trunk/Source/WebCore/html/TextTrackCueList.h 2011-11-03 20:24:16 UTC (rev 99233)
+++ trunk/Source/WebCore/html/TextTrackCueList.h 2011-11-03 20:28:55 UTC (rev 99234)
@@ -42,17 +42,23 @@
return adoptRef(new TextTrackCueList);
}
+ ~TextTrackCueList() { }
+
unsigned long length() const;
TextTrackCue* item(unsigned index) const;
TextTrackCue* getCueById(const String&) const;
- PassRefPtr<TextTrackCueList> activeCues();
+ TextTrackCueList* activeCues();
- void append(const PassRefPtr<TextTrackCue>&);
- void append(Vector<PassRefPtr<TextTrackCue> >&);
- void remove(const PassRefPtr<TextTrackCue>&);
+ void add(PassRefPtr<TextTrackCue>);
+ void add(const Vector<RefPtr<TextTrackCue> >&);
+ void remove(TextTrackCue*);
+ bool contains(TextTrackCue*) const;
private:
TextTrackCueList();
+ void add(PassRefPtr<TextTrackCue>, size_t, size_t);
+
+ Vector<RefPtr<TextTrackCue> > m_list;
};
} // namespace WebCore