Diff
Modified: trunk/LayoutTests/ChangeLog (137965 => 137966)
--- trunk/LayoutTests/ChangeLog 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/LayoutTests/ChangeLog 2012-12-18 01:56:28 UTC (rev 137966)
@@ -1,3 +1,19 @@
+2012-12-17 Dean Jackson <[email protected]>
+
+ Track menu should be sorted
+ https://bugs.webkit.org/show_bug.cgi?id=105229
+
+ Reviewed by Eric Carlson.
+
+ New test to make sure we sort the menu of available tracks.
+
+ * media/video-controls-captions-trackmenu-sorted-expected.txt: Added.
+ * media/video-controls-captions-trackmenu-sorted.html: Added.
+ * platform/chromium/TestExpectations:
+ * platform/efl/TestExpectations:
+ * platform/gtk/TestExpectations:
+ * platform/qt/TestExpectations:
+
2012-12-17 Mathew Dempsky <[email protected]>
Regression causing DOM objects to have unstable NPObject* references with v8 bindings
Added: trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted-expected.txt (0 => 137966)
--- trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted-expected.txt (rev 0)
+++ trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted-expected.txt 2012-12-18 01:56:28 UTC (rev 137966)
@@ -0,0 +1,26 @@
+Test that captions and subtitles are sorted in the menu.
+
+EVENT(canplaythrough)
+
+*** Set the user language preference.
+RUN(internals.setUserPreferredLanguages(['en']))
+
+*** Test menu section 0.
+First item should be labelled off OK
+a is the first real item in the list OK
+a comes before b OK
+b comes before c OK
+c comes before d OK
+Menu section 0 was ok.
+
+
+*** Test menu section 1.
+First item should be labelled off OK
+a is the first real item in the list OK
+a comes before b OK
+b comes before c OK
+c comes before d OK
+Menu section 1 was ok.
+
+END OF TEST
+
Property changes on: trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted.html (0 => 137966)
--- trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted.html (rev 0)
+++ trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted.html 2012-12-18 01:56:28 UTC (rev 137966)
@@ -0,0 +1,102 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Testing that the list of tracks is sorted</title>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script>
+ var captionsButtonCoordinates;
+
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function clickCCButton()
+ {
+ eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+
+ function startTest()
+ {
+ if (window.eventSender) {
+ consoleWrite("<br>*** Set the user language preference.");
+ run("internals.setUserPreferredLanguages(['en'])");
+
+ try {
+ captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button");
+ } catch (exception) {
+ failTest(exception.description);
+ return;
+ }
+ clickCCButton();
+ window.setTimeout(testSortedMenu, 100);
+ }
+ }
+
+ function testSortedMenu()
+ {
+ var trackListElement;
+ try {
+ trackListElement = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-closed-captions-track-list");
+ } catch (exception) {
+ failTest(exception.description);
+ return;
+ }
+ // Track list should have two <ul> elements.
+ var trackListSections = trackListElement.querySelectorAll("ul");
+ if (!trackListSections || trackListSections.length != 2) {
+ failTest("There should be two ul elements in track list menu");
+ return;
+ }
+ for (var i = 0; i < trackListSections.length; i++) {
+ consoleWrite("<br>*** Test menu section " + i + ".");
+ var lastTrackLabel = null;
+ var trackListItems = trackListSections[i].querySelectorAll("li");
+ if (!trackListItems || trackListItems.length != 5) {
+ failTest("There should be five li elements in this section");
+ return;
+ }
+ for (var j = 0; j < trackListItems.length; j++) {
+ var item = trackListItems[j];
+ if (j == 0)
+ logResult(item.textContent == "Off", "First item should be labelled off");
+ else {
+ if (lastTrackLabel)
+ logResult(item.textContent > lastTrackLabel, lastTrackLabel + " comes before " + item.textContent);
+ else
+ logResult(true, item.textContent + " is the first real item in the list");
+ lastTrackLabel = item.textContent;
+ }
+ }
+ consoleWrite("Menu section " + i + " was ok.<br>");
+ }
+ endTest();
+ }
+
+ function start()
+ {
+ findMediaElement();
+ waitForEvent('canplaythrough', startTest);
+ }
+ </script>
+ </head>
+
+ <body _onload_="start()">
+ <p>Test that captions and subtitles are sorted in the menu.</p>
+ <video width="500" height="300" controls>
+ <source src="" type="video/mp4">
+ <source src="" type="video/ogg">
+ <track label="c" kind="captions" src="" srclang="ja">
+ <track label="b" kind="captions" src="" srclang="en-au">
+ <track label="a" kind="captions" src="" srclang="en">
+ <track label="d" kind="captions" src="" srclang="ja">
+ <track label="b" kind="subtitles" src="" srclang="ja">
+ <track label="a" kind="subtitles" src="" srclang="en-au">
+ <track label="c" kind="subtitles" src="" srclang="en">
+ <track label="d" kind="subtitles" src="" srclang="ja">
+ </video>
+ </body>
+</html>
+
Property changes on: trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Modified: trunk/LayoutTests/platform/chromium/TestExpectations (137965 => 137966)
--- trunk/LayoutTests/platform/chromium/TestExpectations 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/LayoutTests/platform/chromium/TestExpectations 2012-12-18 01:56:28 UTC (rev 137966)
@@ -3615,6 +3615,7 @@
# Chromium still has the CC toggle button, not the menu of tracks.
webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
+webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
webkit.org/b/92835 [ Android Mac Win Debug ] svg/as-background-image/svg-as-background-5.html [ Pass Slow ]
Modified: trunk/LayoutTests/platform/efl/TestExpectations (137965 => 137966)
--- trunk/LayoutTests/platform/efl/TestExpectations 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/LayoutTests/platform/efl/TestExpectations 2012-12-18 01:56:28 UTC (rev 137966)
@@ -1641,6 +1641,7 @@
# EFL still has the CC toggle button, not the menu of tracks.
webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
+webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
# Fails until we enable the Resource Timing API.
webkit.org/b/61138 http/tests/w3c/webperf/submission/resource-timing [ Skip ]
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (137965 => 137966)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2012-12-18 01:56:28 UTC (rev 137966)
@@ -725,7 +725,8 @@
Bug(GTK) fast/media/print-restores-previous-mediatype.html [ Timeout ]
# GTK still has the CC toggle button, not the menu of tracks.
-webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Timeout ]
+webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
+webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
#////////////////////////////////////////////////////////////////////////////////////////
# End of Tests timing out
Modified: trunk/LayoutTests/platform/qt/TestExpectations (137965 => 137966)
--- trunk/LayoutTests/platform/qt/TestExpectations 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/LayoutTests/platform/qt/TestExpectations 2012-12-18 01:56:28 UTC (rev 137966)
@@ -2410,6 +2410,7 @@
# QT still has the CC toggle button, not the menu of tracks.
webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
+webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
# New, but failing test
webkit.org/b/101035 fast/images/exif-orientation-image-document.html
Modified: trunk/Source/WebCore/ChangeLog (137965 => 137966)
--- trunk/Source/WebCore/ChangeLog 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/Source/WebCore/ChangeLog 2012-12-18 01:56:28 UTC (rev 137966)
@@ -1,3 +1,24 @@
+2012-12-17 Dean Jackson <[email protected]>
+
+ Track menu should be sorted
+ https://bugs.webkit.org/show_bug.cgi?id=105229
+
+ Reviewed by Eric Carlson.
+
+ Make sure that the <li> elements in the track menu are correctly
+ sorted as they are built. This uses insertion sort, but it shouldn't
+ be horrible given that we don't expect a huge number of tracks.
+
+ Test: media/video-controls-captions-trackmenu-sorted.html
+
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
+ (WebCore::insertTextTrackMenuItemIntoSortedContainer): New function that calls insertBefore with
+ the correct parameters to ensure the <ul> is correctly sorted.
+ (WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
+ * html/shadow/MediaControlElements.h:
+ (MediaControlClosedCaptionsTrackListElement): Rename menuItems to m_menuItems for consistency.
+
2012-12-17 Matthew Dempsky <[email protected]>
Regression causing DOM objects to have unstable NPObject* references with v8 bindings
Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (137965 => 137966)
--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp 2012-12-18 01:56:28 UTC (rev 137966)
@@ -803,8 +803,8 @@
rebuildTrackListMenu();
bool captionsVisible = mediaElement->closedCaptionsVisible();
- for (unsigned i = 0, length = menuItems.size(); i < length; ++i) {
- RefPtr<Element> trackItem = menuItems[i];
+ for (unsigned i = 0, length = m_menuItems.size(); i < length; ++i) {
+ RefPtr<Element> trackItem = m_menuItems[i];
int trackIndex = trackListIndexForElement(trackItem.get());
if (trackIndex != HTMLMediaElement::textTracksIndexNotFound()) {
if (trackIndex == HTMLMediaElement::textTracksOffIndex()) {
@@ -826,12 +826,35 @@
#endif
}
+#if ENABLE(VIDEO_TRACK)
+static void insertTextTrackMenuItemIntoSortedContainer(RefPtr<Element>& item, RefPtr<Element>& container)
+{
+ // The container will always have the "Off" entry already present and it
+ // should remain at the start of the list.
+ ASSERT(container->childNodeCount() > 0);
+ ASSERT(item->childNodeCount() == 1); // Each item should have a single text node child for the label.
+ String itemLabel = toText(item->firstChild())->wholeText();
+
+ // This is an insertion sort :( However, there shouldn't be a horrible number of text track items.
+ for (int i = 1, numChildNodes = container->childNodeCount(); i < numChildNodes; ++i) {
+ Node* child = container->childNode(i);
+ ASSERT(child->childNodeCount() == 1); // Each item should have a single text node child for the label.
+ String childLabel = toText(child->firstChild())->wholeText();
+ if (codePointCompareLessThan(itemLabel, childLabel)) {
+ container->insertBefore(item, child);
+ return;
+ }
+ }
+ container->appendChild(item);
+}
+#endif
+
void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
{
#if ENABLE(VIDEO_TRACK)
// Remove any existing content.
removeChildren();
- menuItems.clear();
+ m_menuItems.clear();
m_trackListHasChanged = false;
@@ -853,27 +876,27 @@
RefPtr<Element> captionsHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION);
captionsHeader->appendChild(doc->createTextNode("Closed Captions"));
captionsSection->appendChild(captionsHeader);
- RefPtr<Element> captionsList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);
+ RefPtr<Element> captionsMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);
RefPtr<Element> subtitlesSection = doc->createElement(sectionTag, ASSERT_NO_EXCEPTION);
RefPtr<Element> subtitlesHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION);
subtitlesHeader->appendChild(doc->createTextNode("Subtitles"));
subtitlesSection->appendChild(subtitlesHeader);
- RefPtr<Element> subtitlesList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);
+ RefPtr<Element> subtitlesMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);
RefPtr<Element> trackItem;
trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION);
trackItem->appendChild(doc->createTextNode("Off"));
trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION);
- captionsList->appendChild(trackItem);
- menuItems.append(trackItem);
+ captionsMenuList->appendChild(trackItem);
+ m_menuItems.append(trackItem);
trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION);
trackItem->appendChild(doc->createTextNode("Off"));
trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION);
- subtitlesList->appendChild(trackItem);
- menuItems.append(trackItem);
+ subtitlesMenuList->appendChild(trackItem);
+ m_menuItems.append(trackItem);
bool hasCaptions = false;
bool hasSubtitles = false;
@@ -893,21 +916,21 @@
labelText = displayNameForLanguageLocale(track->language());
if (labelText.isNull() || labelText.isEmpty())
labelText = "No Label";
+ trackItem->appendChild(doc->createTextNode(labelText));
if (track->kind() == track->captionsKeyword()) {
hasCaptions = true;
- captionsList->appendChild(trackItem);
+ insertTextTrackMenuItemIntoSortedContainer(trackItem, captionsMenuList);
}
if (track->kind() == track->subtitlesKeyword()) {
hasSubtitles = true;
- subtitlesList->appendChild(trackItem);
+ insertTextTrackMenuItemIntoSortedContainer(trackItem, subtitlesMenuList);
}
- trackItem->appendChild(doc->createTextNode(labelText));
- menuItems.append(trackItem);
+ m_menuItems.append(trackItem);
}
- captionsSection->appendChild(captionsList);
- subtitlesSection->appendChild(subtitlesList);
+ captionsSection->appendChild(captionsMenuList);
+ subtitlesSection->appendChild(subtitlesMenuList);
if (hasCaptions)
appendChild(captionsSection);
Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.h (137965 => 137966)
--- trunk/Source/WebCore/html/shadow/MediaControlElements.h 2012-12-18 01:48:03 UTC (rev 137965)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.h 2012-12-18 01:56:28 UTC (rev 137966)
@@ -314,7 +314,7 @@
virtual void defaultEventHandler(Event*) OVERRIDE;
typedef Vector<RefPtr<Element> > TrackMenuItems;
- TrackMenuItems menuItems;
+ TrackMenuItems m_menuItems;
MediaControls* m_controls;
bool m_trackListHasChanged;
};