Changeset 135934 in webkit
- Timestamp:
- Nov 27, 2012 3:45:13 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r135928 r135934 1 2012-11-27 Dean Jackson <dino@apple.com> 2 3 Make track list control active 4 https://bugs.webkit.org/show_bug.cgi?id=101670 5 6 Reviewed by Eric Carlson. 7 8 New test that exercises the track list menu, and how it can be used 9 to enable specific tracks. Since this is only enabled for Mac, it is 10 skipped on all other platforms. 11 12 Meanwhile, the existing test for a on/off captions button now 13 does not work on Mac, so skip it there. I copied the functionality 14 into the new test so we still have coverage. 15 16 * media/video-controls-captions-trackmenu-expected.txt: Added. 17 * media/video-controls-captions-trackmenu.html: Added. 18 * platform/chromium/TestExpectations: 19 * platform/efl/TestExpectations: 20 * platform/gtk/TestExpectations: 21 * platform/mac/TestExpectations: 22 * platform/qt/TestExpectations: 23 * platform/win/TestExpectations: 24 1 25 2012-11-27 Tony Chang <tony@chromium.org> 2 26 -
trunk/LayoutTests/platform/chromium/TestExpectations
r135928 r135934 3708 3708 webkit.org/b/94242 [ Android Debug ] media/track/track-cues-sorted-before-dispatch.html [ Crash Pass Timeout ] 3709 3709 3710 # Chromium still has the CC toggle button, not the menu of tracks. 3711 webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ] 3712 3710 3713 # Supposedly started failing between CR r140760 and CR r141216. The failures 3711 3714 # look like they involve antialiasing; the fact that the test clearly expects -
trunk/LayoutTests/platform/efl/TestExpectations
r135919 r135934 1705 1705 webkit.org/b/102493 fast/events/mouse-cursor.html [ Failure ] 1706 1706 1707 # EFL still has the CC toggle button, not the menu of tracks. 1708 webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ] 1709 1707 1710 # Fails until we enable the Resource Timing API. 1708 1711 webkit.org/b/61138 http/tests/w3c/webperf/submission/resource-timing [ Skip ] -
trunk/LayoutTests/platform/gtk/TestExpectations
r135926 r135934 1400 1400 webkit.org/b/102993 media/video-zoom-controls.html [ Failure ] 1401 1401 1402 # GTK still has the CC toggle button, not the menu of tracks. 1403 webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ] 1404 1402 1405 # Fix for https://bugs.webkit.org/show_bug.cgi?id=97192 introduces these regressions 1403 1406 webkit.org/b/102776 webkit.org/b/102993 media/media-document-audio-repaint.html [ Failure ] -
trunk/LayoutTests/platform/mac/TestExpectations
r135919 r135934 1215 1215 webkit.org/b/100142 css3/filters/effect-reference.html [ Fail ] 1216 1216 1217 # Mac doesn't have a toggle for CC any more, it's based on a menu of choices. 1218 webkit.org/b/101670 media/video-controls-captions.html [ Skip ] 1219 1217 1220 # Overflowing LayoutUnits cause RenderGeometryMap assertions 1218 1221 webkit.org/b/67434 [ Debug ] fast/overflow/overflow-height-float-not-removed-crash.html [ Skip ] -
trunk/LayoutTests/platform/qt/TestExpectations
r135917 r135934 2383 2383 webkit.org/b/102993 fast/repaint/slider-thumb-float.html [ Failure ] 2384 2384 2385 # QT still has the CC toggle button, not the menu of tracks. 2386 webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ] 2387 2385 2388 # New, but failing test 2386 2389 webkit.org/b/101035 fast/images/exif-orientation-image-document.html -
trunk/LayoutTests/platform/win/TestExpectations
r135913 r135934 2350 2350 webkit.org/b/98666 webkit.org/b/102993 fast/repaint/slider-thumb-float.html [ Failure ] 2351 2351 2352 # Win doesn't support track menu 2353 webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ] 2354 2352 2355 #https://bugs.webkit.org/show_bug.cgi?id=98079 2353 2356 http/tests/security/cross-origin-local-storage-wk1.html -
trunk/Source/WebCore/ChangeLog
r135927 r135934 1 2012-11-27 Dean Jackson <dino@apple.com> 2 3 Make track list control active 4 https://bugs.webkit.org/show_bug.cgi?id=101670 5 6 Reviewed by Eric Carlson. 7 8 Hook up the event handler for the captions menu so that it enables or 9 disables tracks in the associated HTMLMediaElement. 10 11 Test: media/video-controls-captions-trackmenu.html 12 13 * html/HTMLMediaElement.cpp: 14 (WebCore::HTMLMediaElement::toggleTrackAtIndex): New method to toggle the state of a track, by index. 15 * html/HTMLMediaElement.h: 16 (HTMLMediaElement): Ditto. 17 (WebCore::HTMLMediaElement::textTracksOffIndex): Static method to return the "Off" value. 18 * html/shadow/MediaControlElements.cpp: 19 (WebCore::trackListIndexForElement): Helper function to take a track list <li> element and return the value of the custom attribute. 20 (WebCore::MediaControlToggleClosedCaptionsButtonElement::updateDisplayType): Toggle the state of the button based on captions visibility. 21 (WebCore::MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler): On Mac platforms show the captions menu. On other platforms, toggle captions. 22 (WebCore::MediaControlClosedCaptionsTrackListElement::MediaControlClosedCaptionsTrackListElement): Now has a reference to the controls. 23 (WebCore::MediaControlClosedCaptionsTrackListElement::create): 24 (WebCore::MediaControlClosedCaptionsTrackListElement::defaultEventHandler): When the user clicks on a track list item, look 25 for the custom attribute that identifies the associated track, and then toggle that track. 26 (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Set a class on the track list elements so they can be 27 styled by the injected CSS (with tick marks to represent visibility). 28 (WebCore::MediaControlClosedCaptionsTrackListElement::resetTrackListMenu): When building the list of track menu items, add 29 a custom HTML attribute to the element so that the corresponding track can be found in the event handler. 30 * html/shadow/MediaControlElements.h: 31 (MediaControlClosedCaptionsTrackListElement): Add a list of elements representing the track list. 32 * html/shadow/MediaControlsApple.cpp: 33 (WebCore::MediaControlsApple::createControls): 34 (WebCore::MediaControlsApple::changedClosedCaptionsVisibility): Make sure to update the track menu. 35 (WebCore::MediaControlsApple::reset): 36 * html/shadow/MediaControlsApple.h: 37 (MediaControlsApple): 38 1 39 2012-11-27 Joshua Bell <jsbell@chromium.org> 2 40 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r135906 r135934 2999 2999 } 3000 3000 3001 void HTMLMediaElement::toggleTrackAtIndex(int index, bool exclusive) 3002 { 3003 TextTrackList* trackList = textTracks(); 3004 if (!trackList || !trackList->length()) 3005 return; 3006 3007 for (int i = 0, length = trackList->length(); i < length; ++i) { 3008 TextTrack* track = trackList->item(i); 3009 track->setShowingByDefault(false); 3010 if (i == index) 3011 track->setMode(TextTrack::showingKeyword()); 3012 else if (exclusive || index == HTMLMediaElement::textTracksOffIndex()) 3013 track->setMode(TextTrack::disabledKeyword()); 3014 } 3015 } 3016 3001 3017 void HTMLMediaElement::configureTextTracks() 3002 3018 { -
trunk/Source/WebCore/html/HTMLMediaElement.h
r135886 r135934 246 246 void configureTextTrackGroup(const TrackGroup&) const; 247 247 248 void toggleTrackAtIndex(int index, bool exclusive = true); 249 static int textTracksOffIndex() { return -1; } 250 248 251 bool userPrefersCaptions() const; 249 252 bool userIsInterestedInThisTrackKind(String) const; -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r134507 r135934 37 37 #include "DOMTokenList.h" 38 38 #include "EventNames.h" 39 #include "EventTarget.h" 39 40 #include "FloatConversion.h" 40 41 #include "FloatPoint.h" … … 64 65 #include "Text.h" 65 66 #if ENABLE(VIDEO_TRACK) 67 #include "TextTrack.h" 66 68 #include "TextTrackList.h" 67 69 #endif … … 77 79 static const float cScanRepeatDelay = 1.5f; 78 80 static const float cScanMaximumRate = 8; 81 82 #if ENABLE(VIDEO_TRACK) 83 static const char* textTracksOffAttrValue = "-1"; // This must match HTMLMediaElement::textTracksOffIndex() 84 static const int textTracksIndexNotFound = -2; 85 #endif 79 86 80 87 HTMLMediaElement* toParentMediaElement(Node* node) … … 99 106 return static_cast<MediaControlElement*>(element)->displayType(); 100 107 } 108 109 #if ENABLE(VIDEO_TRACK) 110 static const AtomicString& trackIndexAttributeName() 111 { 112 DEFINE_STATIC_LOCAL(AtomicString, name, ("x-webkit-track-index", AtomicString::ConstructFromLiteral)); 113 return name; 114 } 115 116 static int trackListIndexForElement(Element* element) 117 { 118 const AtomicString trackIndexAttributeValue = element->getAttribute(trackIndexAttributeName()); 119 if (trackIndexAttributeValue.isNull() || trackIndexAttributeValue.isEmpty()) 120 return textTracksIndexNotFound; 121 bool ok; 122 int trackIndex = trackIndexAttributeValue.toInt(&ok); 123 if (!ok) 124 return textTracksIndexNotFound; 125 return trackIndex; 126 } 127 #endif 101 128 102 129 // ---------------------------- … … 902 929 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() 903 930 { 904 setDisplayType(mediaController()->closedCaptionsVisible() ? MediaHideClosedCaptionsButton : MediaShowClosedCaptionsButton); 931 bool captionsVisible = mediaController()->closedCaptionsVisible(); 932 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowClosedCaptionsButton); 933 setChecked(captionsVisible); 905 934 } 906 935 … … 908 937 { 909 938 if (event->type() == eventNames().clickEvent) { 910 // FIXME: This is now incorrectly doing two things at once: showing the list of captions and toggling display. 911 // https://bugs.webkit.org/show_bug.cgi?id=101670 939 // FIXME: It's not great that the shared code is dictating behavior of platform-specific 940 // UI. Not all ports may want the closed captions button to toggle a list of tracks, so 941 // we have to use #if. 942 // https://bugs.webkit.org/show_bug.cgi?id=101877 943 #if !PLATFORM(MAC) 912 944 mediaController()->setClosedCaptionsVisible(!mediaController()->closedCaptionsVisible()); 913 945 setChecked(mediaController()->closedCaptionsVisible()); 946 updateDisplayType(); 947 #else 914 948 m_controls->toggleClosedCaptionTrackList(); 915 updateDisplayType(); 949 #endif 916 950 event->setDefaultHandled(); 917 951 } … … 928 962 // ---------------------------- 929 963 930 inline MediaControlClosedCaptionsTrackListElement::MediaControlClosedCaptionsTrackListElement(Document* document )964 inline MediaControlClosedCaptionsTrackListElement::MediaControlClosedCaptionsTrackListElement(Document* document, MediaControls* controls) 931 965 : MediaControlElement(document) 932 { 933 } 934 935 PassRefPtr<MediaControlClosedCaptionsTrackListElement> MediaControlClosedCaptionsTrackListElement::create(Document* document) 936 { 937 RefPtr<MediaControlClosedCaptionsTrackListElement> element = adoptRef(new MediaControlClosedCaptionsTrackListElement(document)); 966 , m_controls(controls) 967 { 968 } 969 970 PassRefPtr<MediaControlClosedCaptionsTrackListElement> MediaControlClosedCaptionsTrackListElement::create(Document* document, MediaControls* controls) 971 { 972 ASSERT(controls); 973 RefPtr<MediaControlClosedCaptionsTrackListElement> element = adoptRef(new MediaControlClosedCaptionsTrackListElement(document, controls)); 938 974 return element.release(); 939 975 } … … 941 977 void MediaControlClosedCaptionsTrackListElement::defaultEventHandler(Event* event) 942 978 { 943 // FIXME: Hook this up to actual text tracks. 944 // https://bugs.webkit.org/show_bug.cgi?id=101670 945 UNUSED_PARAM(event); 979 #if ENABLE(VIDEO_TRACK) 980 if (event->type() == eventNames().clickEvent) { 981 // FIXME: Add modifier key for exclusivity override. 982 // http://webkit.org/b/103361 983 984 Node* target = event->target()->toNode(); 985 if (!target || !target->isElementNode()) 986 return; 987 988 // When we created the elements in the track list, we gave them a custom 989 // attribute representing the index in the HTMLMediaElement's list of tracks. 990 // Check if the event target has such a custom element and, if so, 991 // tell the HTMLMediaElement to enable that track. 992 993 int trackIndex = trackListIndexForElement(toElement(target)); 994 if (trackIndex == textTracksIndexNotFound) 995 return; 996 997 HTMLMediaElement* mediaElement = toParentMediaElement(this); 998 if (!mediaElement) 999 return; 1000 1001 mediaElement->toggleTrackAtIndex(trackIndex); 1002 1003 // We've selected a track to display, so we can now close the menu. 1004 m_controls->toggleClosedCaptionTrackList(); 1005 updateDisplay(); 1006 } 1007 1008 MediaControlElement::defaultEventHandler(event); 1009 #endif 946 1010 } 947 1011 … … 953 1017 954 1018 void MediaControlClosedCaptionsTrackListElement::updateDisplay() 1019 { 1020 #if ENABLE(VIDEO_TRACK) 1021 DEFINE_STATIC_LOCAL(AtomicString, selectedClassValue, ("selected", AtomicString::ConstructFromLiteral)); 1022 1023 if (!mediaController()->hasClosedCaptions()) 1024 return; 1025 1026 HTMLMediaElement* mediaElement = toParentMediaElement(this); 1027 if (!mediaElement) 1028 return; 1029 1030 TextTrackList* trackList = mediaElement->textTracks(); 1031 1032 if (!trackList || !trackList->length()) 1033 return; 1034 1035 bool captionsVisible = mediaElement->closedCaptionsVisible(); 1036 for (unsigned i = 0, length = menuItems.size(); i < length; ++i) { 1037 RefPtr<Element> trackItem = menuItems[i]; 1038 int trackIndex = trackListIndexForElement(trackItem.get()); 1039 if (trackIndex != textTracksIndexNotFound) { 1040 if (trackIndex == HTMLMediaElement::textTracksOffIndex()) { 1041 if (captionsVisible) 1042 trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION); 1043 else 1044 trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION); 1045 } else { 1046 TextTrack* track = trackList->item(trackIndex); 1047 if (!track) 1048 continue; 1049 if (track->mode() == TextTrack::showingKeyword()) 1050 trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION); 1051 else 1052 trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION); 1053 } 1054 } 1055 } 1056 #endif 1057 } 1058 1059 void MediaControlClosedCaptionsTrackListElement::resetTrackListMenu() 955 1060 { 956 1061 #if ENABLE(VIDEO_TRACK) 957 1062 // Remove any existing content. 958 1063 removeChildren(); 1064 menuItems.clear(); 959 1065 960 1066 if (!mediaController()->hasClosedCaptions()) … … 988 1094 trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION); 989 1095 trackItem->appendChild(doc->createTextNode("Off")); 990 // FIXME: These lists are not yet live. Mark the Off entry as the selected one for now. 991 trackItem->setAttribute(classAttr, "selected"); 1096 trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION); 992 1097 captionsList->appendChild(trackItem); 1098 menuItems.append(trackItem); 993 1099 994 1100 trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION); 995 1101 trackItem->appendChild(doc->createTextNode("Off")); 996 // FIXME: These lists are not yet live. Mark the Off entry as the selected one for now. 997 trackItem->setAttribute(classAttr, "selected"); 1102 trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION); 998 1103 subtitlesList->appendChild(trackItem); 1104 menuItems.append(trackItem); 999 1105 1000 1106 bool hasCaptions = false; … … 1004 1110 TextTrack* track = trackList->item(i); 1005 1111 trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION); 1112 1113 // Add a custom attribute to the <li> element which will allow 1114 // us to easily associate the user tapping here with the 1115 // track. Since this list is rebuilt if the tracks change, we 1116 // should always be in sync. 1117 trackItem->setAttribute(trackIndexAttributeName(), String::number(i), ASSERT_NO_EXCEPTION); 1118 1006 1119 AtomicString labelText = track->label(); 1007 1120 if (labelText.isNull() || labelText.isEmpty()) … … 1019 1132 } 1020 1133 trackItem->appendChild(doc->createTextNode(labelText)); 1134 menuItems.append(trackItem); 1021 1135 } 1022 1136 … … 1028 1142 if (hasSubtitles) 1029 1143 appendChild(subtitlesSection); 1144 1145 updateDisplay(); 1030 1146 #endif 1031 1147 } -
trunk/Source/WebCore/html/shadow/MediaControlElements.h
r134507 r135934 416 416 class MediaControlClosedCaptionsTrackListElement : public MediaControlElement { 417 417 public: 418 static PassRefPtr<MediaControlClosedCaptionsTrackListElement> create(Document* );418 static PassRefPtr<MediaControlClosedCaptionsTrackListElement> create(Document*, MediaControls*); 419 419 420 420 virtual void defaultEventHandler(Event*); … … 422 422 423 423 void updateDisplay(); 424 425 private: 426 MediaControlClosedCaptionsTrackListElement(Document*); 424 void resetTrackListMenu(); 425 426 private: 427 MediaControlClosedCaptionsTrackListElement(Document*, MediaControls*); 427 428 428 429 virtual MediaControlElementType displayType() const { return MediaClosedCaptionsTrackList; } 429 430 virtual const AtomicString& shadowPseudoId() const; 431 432 typedef Vector<RefPtr<Element> > TrackMenuItems; 433 TrackMenuItems menuItems; 434 MediaControls* m_controls; 430 435 }; 431 436 -
trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp
r134507 r135934 150 150 RefPtr<MediaControlClosedCaptionsContainerElement> closedCaptionsContainer = MediaControlClosedCaptionsContainerElement::create(document); 151 151 152 RefPtr<MediaControlClosedCaptionsTrackListElement> closedCaptionsTrackList = MediaControlClosedCaptionsTrackListElement::create(document );152 RefPtr<MediaControlClosedCaptionsTrackListElement> closedCaptionsTrackList = MediaControlClosedCaptionsTrackListElement::create(document, controls.get()); 153 153 controls->m_closedCaptionsTrackList = closedCaptionsTrackList.get(); 154 154 closedCaptionsContainer->appendChild(closedCaptionsTrackList.release(), ec, true); … … 290 290 } 291 291 292 void MediaControlsApple::changedClosedCaptionsVisibility() 293 { 294 MediaControls::changedClosedCaptionsVisibility(); 295 if (m_closedCaptionsTrackList) 296 m_closedCaptionsTrackList->updateDisplay(); 297 } 298 292 299 void MediaControlsApple::reset() 293 300 { … … 324 331 m_toggleClosedCaptionsButton->show(); 325 332 if (m_closedCaptionsTrackList) 326 m_closedCaptionsTrackList-> updateDisplay();333 m_closedCaptionsTrackList->resetTrackListMenu(); 327 334 } else 328 335 m_toggleClosedCaptionsButton->hide(); -
trunk/Source/WebCore/html/shadow/MediaControlsApple.h
r134507 r135934 59 59 virtual void updateStatusDisplay() OVERRIDE; 60 60 61 virtual void changedClosedCaptionsVisibility() OVERRIDE; 61 62 void toggleClosedCaptionTrackList(); 62 63
Note: See TracChangeset
for help on using the changeset viewer.