⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243450 in webkit


Ignore:
Timestamp:
Mar 25, 2019, 1:39:59 PM (7 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:
  • 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
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243444 r243450  
     12019-03-25  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-03-25  Antti Koivisto  <antti@apple.com>
    212
  • trunk/Source/WebCore/CMakeLists.txt

    r243433 r243450  
    13841384        html/track/TextTrack.idl
    13851385        html/track/TextTrackCue.idl
     1386        html/track/TextTrackCueGeneric.idl
    13861387        html/track/TextTrackCueList.idl
    13871388        html/track/TextTrackList.idl
  • trunk/Source/WebCore/ChangeLog

    r243444 r243450  
     12019-03-25  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        * html/shadow/MediaControlElementTypes.cpp:
     29        (WebCore::parentMediaElement):
     30        * html/shadow/MediaControlElementTypes.h:
     31        * html/shadow/MediaControlElements.cpp:
     32        (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
     33        (WebCore::MediaControlTextTrackContainerElement::logger const):
     34        (WebCore::MediaControlTextTrackContainerElement::logIdentifier const):
     35        (WebCore::MediaControlTextTrackContainerElement::logChannel const):
     36        * html/shadow/MediaControlElements.h:
     37        * html/track/DataCue.h:
     38        (isType):
     39        * html/track/TextTrackCueGeneric.h:
     40        (isType):
     41        * html/track/TextTrackCueGeneric.idl: Added.
     42        * html/track/VTTCue.h:
     43        (isType):
     44        * testing/Internals.cpp:
     45        (WebCore::Internals::createGenericCue):
     46        * testing/Internals.h:
     47        * testing/Internals.idl:
     48
    1492019-03-25  Antti Koivisto  <antti@apple.com>
    250
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r243419 r243450  
    868868$(PROJECT_DIR)/html/track/TextTrack.idl
    869869$(PROJECT_DIR)/html/track/TextTrackCue.idl
     870$(PROJECT_DIR)/html/track/TextTrackCueGeneric.idl
    870871$(PROJECT_DIR)/html/track/TextTrackCueList.idl
    871872$(PROJECT_DIR)/html/track/TextTrackList.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r243419 r243450  
    17401740$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCue.cpp
    17411741$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCue.h
     1742$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueGeneric.cpp
     1743$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueGeneric.h
    17421744$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueList.cpp
    17431745$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSTextTrackCueList.h
  • trunk/Source/WebCore/DerivedSources.make

    r243419 r243450  
    847847    $(WebCore)/html/track/TextTrack.idl \
    848848    $(WebCore)/html/track/TextTrackCue.idl \
     849    $(WebCore)/html/track/TextTrackCueGeneric.idl \
    849850    $(WebCore)/html/track/TextTrackCueList.idl \
    850851    $(WebCore)/html/track/TextTrackList.idl \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r243438 r243450  
    42294229                CDF756A3215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF756A1215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h */; };
    42304230                CDFC360618CA61C20026E56F /* RemoteCommandListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFC360418CA61C20026E56F /* RemoteCommandListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
     4231                CDFD78C32242FCC600D7208A /* JSTextTrackCueGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDFD78BB2242C4FF00D7208A /* JSTextTrackCueGeneric.cpp */; };
    42314232                CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE057FA41220731100A476D5 /* DocumentMarkerController.h */; settings = {ATTRIBUTES = (Private, ); }; };
    42324233                CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */; settings = {ATTRIBUTES = (); }; };
     
    1394013941                CDFC360318CA61C20026E56F /* RemoteCommandListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCommandListener.cpp; sourceTree = "<group>"; };
    1394113942                CDFC360418CA61C20026E56F /* RemoteCommandListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListener.h; sourceTree = "<group>"; };
     13943                CDFD78BA2242C4FE00D7208A /* JSTextTrackCueGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCueGeneric.h; sourceTree = "<group>"; };
     13944                CDFD78BB2242C4FF00D7208A /* JSTextTrackCueGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCueGeneric.cpp; sourceTree = "<group>"; };
     13945                CDFD78C22242FC4900D7208A /* TextTrackCueGeneric.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TextTrackCueGeneric.idl; sourceTree = "<group>"; };
    1394213946                CE057FA31220731100A476D5 /* DocumentMarkerController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentMarkerController.cpp; sourceTree = "<group>"; };
    1394313947                CE057FA41220731100A476D5 /* DocumentMarkerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarkerController.h; sourceTree = "<group>"; };
     
    2313523139                                070756D714239B4B00414161 /* JSTextTrackCue.cpp */,
    2313623140                                070756D814239B4B00414161 /* JSTextTrackCue.h */,
     23141                                CDFD78BB2242C4FF00D7208A /* JSTextTrackCueGeneric.cpp */,
     23142                                CDFD78BA2242C4FE00D7208A /* JSTextTrackCueGeneric.h */,
    2313723143                                070756D914239B4C00414161 /* JSTextTrackCueList.cpp */,
    2313823144                                070756DA14239B4E00414161 /* JSTextTrackCueList.h */,
     
    2407624082                                071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */,
    2407724083                                071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */,
     24084                                CDFD78C22242FC4900D7208A /* TextTrackCueGeneric.idl */,
    2407824085                                9759E93B14EF1CF80026A2DD /* TextTrackCueList.cpp */,
    2407924086                                9759E93C14EF1CF80026A2DD /* TextTrackCueList.h */,
     
    3311333120                                CD063F821E23FA8900812BE3 /* InitDataRegistry.cpp in Sources */,
    3311433121                                538EC93E1F99BF5A004D22A8 /* JSQuickTimePluginReplacement.cpp in Sources */,
     33122                                CDFD78C32242FCC600D7208A /* JSTextTrackCueGeneric.cpp in Sources */,
    3311533123                                935C477009AC4D7300A6AAB4 /* KeyEventMac.mm in Sources */,
    3311633124                                CDA98E0B1603CD6000FEA3B1 /* LegacyCDM.cpp in Sources */,
  • trunk/Source/WebCore/html/shadow/MediaControlElementTypes.cpp

    r229694 r243450  
    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

    r229694 r243450  
    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

    r243341 r243450  
    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

    r237266 r243450  
    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

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

    r236531 r243450  
    7171
    7272private:
    73     TextTrackCueGeneric(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String&);
     73    WEBCORE_TESTSUPPORT_EXPORT TextTrackCueGeneric(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String&);
    7474   
    7575    bool isOrderedBefore(const TextTrackCue*) const final;
     
    109109
    110110}
     111
     112SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::TextTrackCueGeneric)
     113static bool isType(const WebCore::TextTrackCue& cue) { return cue.cueType() == WebCore::TextTrackCue::Generic; }
     114SPECIALIZE_TYPE_TRAITS_END()
     115
    111116#endif
  • trunk/Source/WebCore/html/track/VTTCue.h

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

    r243324 r243450  
    214214#include "CaptionUserPreferences.h"
    215215#include "PageGroup.h"
     216#include "TextTrackCueGeneric.h"
    216217#endif
    217218
     
    35793580}
    35803581
     3582RefPtr<TextTrackCueGeneric> Internals::createGenericCue(double startTime, double endTime, String text)
     3583{
     3584    Document* document = contextDocument();
     3585    if (!document || !document->page())
     3586        return nullptr;
     3587#if ENABLE(VIDEO_TRACK)
     3588    return TextTrackCueGeneric::create(*document, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), text);
     3589#else
     3590    UNUSED_PARAM(startTime);
     3591    UNUSED_PARAM(endTime);
     3592    UNUSED_PARAM(text);
     3593    return nullptr;
     3594#endif
     3595}
     3596
    35813597#if ENABLE(VIDEO)
    35823598
  • trunk/Source/WebCore/testing/Internals.h

    r243324 r243450  
    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

    r243324 r243450  
    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

    r243445 r243450  
     12019-03-25  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-03-25  Wenson Hsieh  <wenson_hsieh@apple.com>
    216
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r242534 r243450  
    939939
    940940    [preferences setMediaPlaybackAllowsInline:YES];
     941    [preferences setMediaPlaybackRequiresUserGesture:NO];
    941942    [preferences setVideoPlaybackRequiresUserGesture:NO];
    942943    [preferences setAudioPlaybackRequiresUserGesture:NO];
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r243347 r243450  
    855855    WKPreferencesSetWebSQLDisabled(preferences, false);
    856856
     857    WKPreferencesSetMediaPlaybackRequiresUserGesture(preferences, false);
     858    WKPreferencesSetVideoPlaybackRequiresUserGesture(preferences, false);
     859    WKPreferencesSetAudioPlaybackRequiresUserGesture(preferences, false);
     860
    857861    platformResetPreferencesToConsistentValues();
    858862}
Note: See TracChangeset for help on using the changeset viewer.