Changeset 244078 in webkit


Ignore:
Timestamp:
Apr 9, 2019 8:57:45 AM (5 years ago)
Author:
jer.noble@apple.com
Message:

Source/WebCore:
Test for: 196095 Inband Text Track cues interspersed with Data cues can display out of order.
https://bugs.webkit.org/show_bug.cgi?id=196097

Reviewed by Eric Carlson.

Test: media/track/track-in-band-metadata-display-order.html

Add a method in Internals to create a TextTrackCueGeneric (which can normally only be created
by parsing an in-band media track). This requires adding IDL for TextTrackCueGeneric, and exporting
TextTrackCueGeneric for testing.

Drive-by fixes:

Add runtime logging to MediaControlTextTrackContainerElement. This necessitates modifying the
parentMediaElement() method to take a const Node*, and const_cast that constness away in order to return
a HTMLMediaElement*

TextTrackCue, VTTCue, TextTrackCueGeneric, and DataCue should all use the WTF TypeCasts macros to
enable use of is<> and downcast<>.

  • Source/WebCore/CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • WebCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • html/shadow/MediaControlElementTypes.cpp:

(WebCore::parentMediaElement):

  • html/shadow/MediaControlElementTypes.h:
  • html/shadow/MediaControlElements.cpp:

(WebCore::MediaControlTextTrackContainerElement::updateDisplay):
(WebCore::MediaControlTextTrackContainerElement::logger const):
(WebCore::MediaControlTextTrackContainerElement::logIdentifier const):
(WebCore::MediaControlTextTrackContainerElement::logChannel const):

  • html/shadow/MediaControlElements.h:
  • html/track/DataCue.h:

(isType):

  • html/track/TextTrackCueGeneric.h:

(isType):

  • html/track/TextTrackCueGeneric.idl: Added.
  • html/track/VTTCue.h:

(isType):

  • testing/Internals.cpp:

(WebCore::Internals::createGenericCue):

  • testing/Internals.h:
  • testing/Internals.idl:

Tools:
Test for: 196095 Inband Text Track cues interspersed with Data cues can display out of order.
https://bugs.webkit.org/show_bug.cgi?id=196097

Reviewed by Eric Carlson.

Drive-by bug fix: allow tests to play audio without a user gesture by default.

  • DumpRenderTree/mac/DumpRenderTree.mm:

(resetWebPreferencesToConsistentValues):

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:
Add test for fix of #196095
https://bugs.webkit.org/show_bug.cgi?id=196097

Reviewed by Eric Carlson.

  • media/track/track-in-band-metadata-display-order-expected.txt: Added.
  • media/track/track-in-band-metadata-display-order.html: Added.
Location:
trunk
Files:
3 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r244061 r244078  
     12019-04-09  Jer Noble  <jer.noble@apple.com>
     2
     3        Add test for fix of #196095
     4        https://bugs.webkit.org/show_bug.cgi?id=196097
     5
     6        Reviewed by Eric Carlson.
     7
     8        * media/track/track-in-band-metadata-display-order-expected.txt: Added.
     9        * media/track/track-in-band-metadata-display-order.html: Added.
     10
    1112019-04-08  Chris Fleizach  <cfleizach@apple.com>
    212
  • trunk/Source/WebCore/CMakeLists.txt

    r244065 r244078  
    13691369        html/track/TextTrack.idl
    13701370        html/track/TextTrackCue.idl
     1371        html/track/TextTrackCueGeneric.idl
    13711372        html/track/TextTrackCueList.idl
    13721373        html/track/TextTrackList.idl
  • trunk/Source/WebCore/ChangeLog

    r244077 r244078  
     12019-04-09  Jer Noble  <jer.noble@apple.com>
     2
     3        Test for: 196095 Inband Text Track cues interspersed with Data cues can display out of order.
     4        https://bugs.webkit.org/show_bug.cgi?id=196097
     5
     6        Reviewed by Eric Carlson.
     7
     8        Test: media/track/track-in-band-metadata-display-order.html
     9
     10        Add a method in Internals to create a TextTrackCueGeneric (which can normally only be created
     11        by parsing an in-band media track). This requires adding IDL for TextTrackCueGeneric, and exporting
     12        TextTrackCueGeneric for testing.
     13
     14        Drive-by fixes:
     15
     16        Add runtime logging to MediaControlTextTrackContainerElement. This necessitates modifying the
     17        parentMediaElement() method to take a const Node*, and const_cast that constness away in order to return
     18        a HTMLMediaElement*
     19
     20        TextTrackCue, VTTCue, TextTrackCueGeneric, and DataCue should all use the WTF TypeCasts macros to
     21        enable use of is<> and downcast<>.
     22
     23        * Source/WebCore/CMakeLists.txt:
     24        * DerivedSources-input.xcfilelist:
     25        * DerivedSources-output.xcfilelist:
     26        * DerivedSources.make:
     27        * WebCore.xcodeproj/project.pbxproj:
     28        * Sources.txt:
     29        * html/shadow/MediaControlElementTypes.cpp:
     30        (WebCore::parentMediaElement):
     31        * html/shadow/MediaControlElementTypes.h:
     32        * html/shadow/MediaControlElements.cpp:
     33        (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
     34        (WebCore::MediaControlTextTrackContainerElement::logger const):
     35        (WebCore::MediaControlTextTrackContainerElement::logIdentifier const):
     36        (WebCore::MediaControlTextTrackContainerElement::logChannel const):
     37        * html/shadow/MediaControlElements.h:
     38        * html/track/DataCue.h:
     39        (isType):
     40        * html/track/TextTrackCueGeneric.h:
     41        (isType):
     42        * html/track/TextTrackCueGeneric.idl: Added.
     43        * html/track/VTTCue.h:
     44        (isType):
     45        * testing/Internals.cpp:
     46        (WebCore::Internals::createGenericCue):
     47        * testing/Internals.h:
     48        * testing/Internals.idl:
     49
    1502019-04-09  Sihui Liu  <sihui_liu@apple.com>
    251
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r243755 r244078  
    848848$(PROJECT_DIR)/html/track/TextTrack.idl
    849849$(PROJECT_DIR)/html/track/TextTrackCue.idl
     850$(PROJECT_DIR)/html/track/TextTrackCueGeneric.idl
    850851$(PROJECT_DIR)/html/track/TextTrackCueList.idl
    851852$(PROJECT_DIR)/html/track/TextTrackList.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r243755 r244078  
    17501750$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCue.cpp
    17511751$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCue.h
     1752$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueGeneric.cpp
     1753$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueGeneric.h
    17521754$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueList.cpp
    17531755$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueList.h
  • trunk/Source/WebCore/DerivedSources.make

    r243755 r244078  
    827827    $(WebCore)/html/track/TextTrack.idl \
    828828    $(WebCore)/html/track/TextTrackCue.idl \
     829    $(WebCore)/html/track/TextTrackCueGeneric.idl \
    829830    $(WebCore)/html/track/TextTrackCueList.idl \
    830831    $(WebCore)/html/track/TextTrackList.idl \
  • trunk/Source/WebCore/Sources.txt

    r243962 r244078  
    34363436JSTextTrack.cpp
    34373437JSTextTrackCue.cpp
     3438JSTextTrackCueGeneric.cpp
    34383439JSTextTrackCueList.cpp
    34393440JSTextTrackList.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r244054 r244078  
    1374813748                CDFC360318CA61C20026E56F /* RemoteCommandListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCommandListener.cpp; sourceTree = "<group>"; };
    1374913749                CDFC360418CA61C20026E56F /* RemoteCommandListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListener.h; sourceTree = "<group>"; };
     13750                CDFD78BA2242C4FE00D7208A /* JSTextTrackCueGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCueGeneric.h; sourceTree = "<group>"; };
     13751                CDFD78BB2242C4FF00D7208A /* JSTextTrackCueGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCueGeneric.cpp; sourceTree = "<group>"; };
     13752                CDFD78C22242FC4900D7208A /* TextTrackCueGeneric.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TextTrackCueGeneric.idl; sourceTree = "<group>"; };
    1375013753                CE057FA31220731100A476D5 /* DocumentMarkerController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentMarkerController.cpp; sourceTree = "<group>"; };
    1375113754                CE057FA41220731100A476D5 /* DocumentMarkerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarkerController.h; sourceTree = "<group>"; };
     
    2274222745                                070756D714239B4B00414161 /* JSTextTrackCue.cpp */,
    2274322746                                070756D814239B4B00414161 /* JSTextTrackCue.h */,
     22747                                CDFD78BB2242C4FF00D7208A /* JSTextTrackCueGeneric.cpp */,
     22748                                CDFD78BA2242C4FE00D7208A /* JSTextTrackCueGeneric.h */,
    2274422749                                070756D914239B4C00414161 /* JSTextTrackCueList.cpp */,
    2274522750                                070756DA14239B4E00414161 /* JSTextTrackCueList.h */,
     
    2368323688                                071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */,
    2368423689                                071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */,
     23690                                CDFD78C22242FC4900D7208A /* TextTrackCueGeneric.idl */,
    2368523691                                9759E93B14EF1CF80026A2DD /* TextTrackCueList.cpp */,
    2368623692                                9759E93C14EF1CF80026A2DD /* TextTrackCueList.h */,
  • trunk/Source/WebCore/html/shadow/MediaControlElementTypes.cpp

    r243482 r244078  
    5555class Event;
    5656
    57 RefPtr<HTMLMediaElement> parentMediaElement(Node* node)
     57RefPtr<HTMLMediaElement> parentMediaElement(const Node* node)
    5858{
    5959    if (!node)
     
    6161    RefPtr<Node> mediaNode = node->shadowHost();
    6262    if (!mediaNode)
    63         mediaNode = node;
     63        mediaNode = const_cast<Node*>(node);
    6464    if (!is<HTMLMediaElement>(*mediaNode))
    6565        return nullptr;
  • trunk/Source/WebCore/html/shadow/MediaControlElementTypes.h

    r243482 r244078  
    7373};
    7474
    75 RefPtr<HTMLMediaElement> parentMediaElement(Node*);
     75RefPtr<HTMLMediaElement> parentMediaElement(const Node*);
    7676inline RefPtr<HTMLMediaElement> parentMediaElement(const RenderObject& renderer) { return parentMediaElement(renderer.node()); }
    7777
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r243482 r244078  
    11731173
    11741174    activeCues.removeAllMatching([] (CueInterval& cueInterval) {
    1175         if (!cueInterval.data() || !cueInterval.data()->isRenderable())
     1175        if (!is<VTTCue>(cueInterval.data()))
    11761176            return true;
    11771177
    1178         RefPtr<VTTCue> cue = toVTTCue(cueInterval.data());
     1178        Ref<VTTCue> cue = downcast<VTTCue>(*cueInterval.data());
    11791179
    11801180        return !cue->isRenderable()
     
    11981198            continue;
    11991199
    1200         RefPtr<VTTCue> cue = toVTTCue(activeCues[i].data());
    1201         ASSERT(cue);
    1202         if (!cue)
    1203             continue;
    1204 
    1205         LOG(Media, "MediaControlTextTrackContainerElement::updateDisplay(%p) - adding and positioning cue #%zu: \"%s\", start=%.2f, end=%.2f, line=%.2f", this, i, cue->text().utf8().data(), cue->startTime(), cue->endTime(), cue->line());
     1200        RefPtr<VTTCue> cue = downcast<VTTCue>(activeCues[i].data());
     1201
     1202        DEBUG_LOG(LOGIDENTIFIER, "adding and positioning cue ", i, ": \"", cue->text(), "\", start=", cue->startTime(), ", end=", cue->endTime(), ", line=", cue->line());
    12061203        Ref<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize);
    12071204        RefPtr<VTTRegion> region = cue->track()->regions()->getRegionById(cue->regionId());
     
    14551452}
    14561453
     1454#if !RELEASE_LOG_DISABLED
     1455const Logger& MediaControlTextTrackContainerElement::logger() const
     1456{
     1457    return document().logger();
     1458}
     1459
     1460const void* MediaControlTextTrackContainerElement::logIdentifier() const
     1461{
     1462    if (auto mediaElement = parentMediaElement(this))
     1463        return mediaElement->logIdentifier();
     1464    return nullptr;
     1465}
     1466
     1467WTFLogChannel& MediaControlTextTrackContainerElement::logChannel() const
     1468{
     1469    return LogMedia;
     1470}
     1471#endif // !RELEASE_LOG_DISABLED
     1472
    14571473#endif // ENABLE(VIDEO_TRACK)
    14581474
  • trunk/Source/WebCore/html/shadow/MediaControlElements.h

    r243482 r244078  
    3434#include "MediaControlElementTypes.h"
    3535#include "TextTrackRepresentation.h"
     36#include <wtf/LoggerHelper.h>
    3637
    3738namespace WebCore {
     
    467468#if ENABLE(VIDEO_TRACK)
    468469
    469 class MediaControlTextTrackContainerElement final : public MediaControlDivElement, public TextTrackRepresentationClient {
     470class MediaControlTextTrackContainerElement final
     471    : public MediaControlDivElement
     472    , public TextTrackRepresentationClient
     473#if !RELEASE_LOG_DISABLED
     474    , private LoggerHelper
     475#endif
     476{
    470477    WTF_MAKE_ISO_ALLOCATED(MediaControlTextTrackContainerElement);
    471478public:
     
    481488    void updateActiveCuesFontSize();
    482489    void updateTextStrokeStyle();
    483    
     490
     491#if !RELEASE_LOG_DISABLED
     492    const Logger& logger() const final;
     493    const void* logIdentifier() const final;
     494    WTFLogChannel& logChannel() const final;
     495    const char* logClassName() const final { return "MediaControlTextTrackContainerElement"; }
     496#endif
     497
    484498    explicit MediaControlTextTrackContainerElement(Document&);
    485499
  • trunk/Source/WebCore/html/track/DataCue.h

    r243887 r244078  
    3434#include <JavaScriptCore/JSCJSValue.h>
    3535#include <wtf/MediaTime.h>
     36#include <wtf/TypeCasts.h>
    3637
    3738namespace WebCore {
     
    125126}
    126127
     128SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DataCue)
     129static bool isType(const WebCore::TextTrackCue& cue) { return cue.cueType() == WebCore::TextTrackCue::Data; }
     130SPECIALIZE_TYPE_TRAITS_END()
     131
    127132#endif
  • trunk/Source/WebCore/html/track/TextTrackCueGeneric.h

    r243887 r244078  
    3737// A "generic" cue is a non-WebVTT cue, so it is not positioned/sized with the WebVTT logic.
    3838class TextTrackCueGeneric final : public VTTCue {
    39     WTF_MAKE_ISO_ALLOCATED(TextTrackCueGeneric);
     39    WTF_MAKE_ISO_ALLOCATED_EXPORT(TextTrackCueGeneric, WEBCORE_EXPORT);
    4040public:
    4141    static Ref<TextTrackCueGeneric> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, const String& content)
     
    7272
    7373private:
    74     TextTrackCueGeneric(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String&);
     74    WEBCORE_EXPORT TextTrackCueGeneric(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String&);
    7575   
    7676    bool isOrderedBefore(const TextTrackCue*) const final;
     
    110110
    111111}
     112
     113SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::TextTrackCueGeneric)
     114static bool isType(const WebCore::TextTrackCue& cue) { return cue.cueType() == WebCore::TextTrackCue::Generic; }
     115SPECIALIZE_TYPE_TRAITS_END()
     116
    112117#endif
  • trunk/Source/WebCore/html/track/VTTCue.h

    r243887 r244078  
    3636#include "HTMLElement.h"
    3737#include "TextTrackCue.h"
     38#include <wtf/TypeCasts.h>
    3839
    3940namespace WebCore {
     
    262263} // namespace WTF
    263264
     265SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::VTTCue)
     266    static bool isType(const WebCore::TextTrackCue& cue) { return cue.isRenderable(); }
     267SPECIALIZE_TYPE_TRAITS_END()
     268
    264269#endif
  • trunk/Source/WebCore/testing/Internals.cpp

    r243958 r244078  
    214214#include "CaptionUserPreferences.h"
    215215#include "PageGroup.h"
     216#include "TextTrackCueGeneric.h"
    216217#endif
    217218
     
    35763577}
    35773578
     3579RefPtr<TextTrackCueGeneric> Internals::createGenericCue(double startTime, double endTime, String text)
     3580{
     3581    Document* document = contextDocument();
     3582    if (!document || !document->page())
     3583        return nullptr;
     3584#if ENABLE(VIDEO_TRACK)
     3585    return TextTrackCueGeneric::create(*document, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), text);
     3586#else
     3587    UNUSED_PARAM(startTime);
     3588    UNUSED_PARAM(endTime);
     3589    UNUSED_PARAM(text);
     3590    return nullptr;
     3591#endif
     3592}
     3593
    35783594#if ENABLE(VIDEO)
    35793595
  • trunk/Source/WebCore/testing/Internals.h

    r243958 r244078  
    9292class StringCallback;
    9393class StyleSheet;
     94class TextTrackCueGeneric;
    9495class TimeRanges;
    9596class TypeConversions;
     
    544545    ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
    545546    ExceptionOr<void> setCaptionDisplayMode(const String&);
     547    RefPtr<TextTrackCueGeneric> createGenericCue(double startTime, double endTime, String text);
    546548
    547549#if ENABLE(VIDEO)
  • trunk/Source/WebCore/testing/Internals.idl

    r243958 r244078  
    541541    [Conditional=VIDEO_TRACK, MayThrowException] void setPrimaryAudioTrackLanguageOverride(DOMString language);
    542542    [Conditional=VIDEO_TRACK, MayThrowException] void setCaptionDisplayMode(DOMString mode);
     543    [Conditional=VIDEO_TRACK] TextTrackCueGeneric createGenericCue(double startTime, double endTime, DOMString text);
    543544
    544545    [Conditional=VIDEO] TimeRanges createTimeRanges(Float32Array startTimes, Float32Array
  • trunk/Tools/ChangeLog

    r244076 r244078  
     12019-04-09  Jer Noble  <jer.noble@apple.com>
     2
     3        Test for: 196095 Inband Text Track cues interspersed with Data cues can display out of order.
     4        https://bugs.webkit.org/show_bug.cgi?id=196097
     5
     6        Reviewed by Eric Carlson.
     7
     8        Drive-by bug fix: allow tests to play audio without a user gesture by default.
     9
     10        * DumpRenderTree/mac/DumpRenderTree.mm:
     11        (resetWebPreferencesToConsistentValues):
     12        * WebKitTestRunner/TestController.cpp:
     13        (WTR::TestController::resetPreferencesToConsistentValues):
     14
    1152019-04-09  Pablo Saavedra  <psaavedra@igalia.com>
    216
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r243666 r244078  
    938938
    939939    [preferences setMediaPlaybackAllowsInline:YES];
     940    [preferences setMediaPlaybackRequiresUserGesture:NO];
    940941    [preferences setVideoPlaybackRequiresUserGesture:NO];
    941942    [preferences setAudioPlaybackRequiresUserGesture:NO];
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r243927 r244078  
    867867    WKPreferencesSetWebSQLDisabled(preferences, false);
    868868
     869    WKPreferencesSetMediaPlaybackRequiresUserGesture(preferences, false);
     870    WKPreferencesSetVideoPlaybackRequiresUserGesture(preferences, false);
     871    WKPreferencesSetAudioPlaybackRequiresUserGesture(preferences, false);
     872
    869873    platformResetPreferencesToConsistentValues();
    870874}
Note: See TracChangeset for help on using the changeset viewer.