Skip to content
  • dino@apple.com's avatar
    Make track list control active · acacedaf
    dino@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=101670
    
    Reviewed by Eric Carlson.
    
    Source/WebCore:
    
    Hook up the event handler for the captions menu so that it enables or
    disables tracks in the associated HTMLMediaElement.
    
    Test: media/video-controls-captions-trackmenu.html
    
    * html/HTMLMediaElement.cpp:
    (WebCore::HTMLMediaElement::toggleTrackAtIndex): New method to toggle the state of a track, by index.
    * html/HTMLMediaElement.h:
    (HTMLMediaElement): Ditto.
    (WebCore::HTMLMediaElement::textTracksOffIndex): Static method to return the "Off" value.
    * html/shadow/MediaControlElements.cpp:
    (WebCore::trackListIndexForElement): Helper function to take a track list <li> element and return the value of the custom attribute.
    (WebCore::MediaControlToggleClosedCaptionsButtonElement::updateDisplayType): Toggle the state of the button based on captions visibility.
    (WebCore::MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler): On Mac platforms show the captions menu. On other platforms, toggle captions.
    (WebCore::MediaControlClosedCaptionsTrackListElement::MediaControlClosedCaptionsTrackListElement): Now has a reference to the controls.
    (WebCore::MediaControlClosedCaptionsTrackListElement::create):
    (WebCore::MediaControlClosedCaptionsTrackListElement::defaultEventHandler): When the user clicks on a track list item, look
    for the custom attribute that identifies the associated track, and then toggle that track.
    (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Set a class on the track list elements so they can be
    styled by the injected CSS (with tick marks to represent visibility).
    (WebCore::MediaControlClosedCaptionsTrackListElement::resetTrackListMenu): When building the list of track menu items, add
    a custom HTML attribute to the element so that the corresponding track can be found in the event handler.
    * html/shadow/MediaControlElements.h:
    (MediaControlClosedCaptionsTrackListElement): Add a list of elements representing the track list.
    * html/shadow/MediaControlsApple.cpp:
    (WebCore::MediaControlsApple::createControls):
    (WebCore::MediaControlsApple::changedClosedCaptionsVisibility): Make sure to update the track menu.
    (WebCore::MediaControlsApple::reset):
    * html/shadow/MediaControlsApple.h:
    (MediaControlsApple):
    
    LayoutTests:
    
    New test that exercises the track list menu, and how it can be used
    to enable specific tracks. Since this is only enabled for Mac, it is
    skipped on all other platforms.
    
    Meanwhile, the existing test for a on/off captions button now
    does not work on Mac, so skip it there. I copied the functionality
    into the new test so we still have coverage.
    
    * media/video-controls-captions-trackmenu-expected.txt: Added.
    * media/video-controls-captions-trackmenu.html: Added.
    * platform/chromium/TestExpectations:
    * platform/efl/TestExpectations:
    * platform/gtk/TestExpectations:
    * platform/mac/TestExpectations:
    * platform/qt/TestExpectations:
    * platform/win/TestExpectations:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    acacedaf