Changeset 256060 in webkit


Ignore:
Timestamp:
Feb 7, 2020 2:07:37 PM (4 years ago)
Author:
eric.carlson@apple.com
Message:

Captions sometimes render at the wrong size when in fullscreen and PiP
https://bugs.webkit.org/show_bug.cgi?id=207389
<rdar://problem/58677864>

Reviewed by Jer Noble.

The TextTrackRepresentation, used to render captions when in fullscreen and PiP on
iOS and and in PiP on macOS, frequently rendered captions before layout completed
immediately after it was created. Fix this by having it not render until a layout
happens. Additionally, make the code more efficient by hiding the TextTrackRepresentation's
backing layer when cues are not visible instead of destroying the whole object.
Drive by: RELEASE_LOG_DISABLED is always defined for PLATFORM(COCOA), so remove it
from the macOS/iOS media players to make it easier to add logging to VideoFullscreenLayerManagerObjC.

  • html/HTMLMediaElement.cpp:

(WebCore::convertEnumerationToString):
(WebCore::HTMLMediaElement::configureTextTrackDisplay):

  • html/HTMLMediaElementEnums.h:

(WTF::LogArgument<WebCore::HTMLMediaElementEnums::TextTrackVisibilityCheckType>::toString):

  • html/shadow/MediaControlElements.cpp:

(WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
(WebCore::MediaControlTextTrackContainerElement::updateDisplay):
(WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentation):
(WebCore::MediaControlTextTrackContainerElement::clearTextTrackRepresentation):
(WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle):
(WebCore::MediaControlTextTrackContainerElement::layoutIfNecessary):
(WebCore::MediaControlTextTrackContainerElement::updateVideoDisplaySize):
(WebCore::MediaControlTextTrackContainerElement::updateSizes):
(WebCore::MediaControlTextTrackContainerElement::updateCueStyles):
(WebCore::MediaControlTextTrackContainerElement::logger const):
(WebCore::MediaControlTextTrackContainerElement::logIdentifier const):
(WebCore::MediaControlTextTrackContainerElement::updateTimerFired): Deleted.
(WebCore::MediaControlTextTrackContainerElement::updateStyleForTextTrackRepresentation): Deleted.

  • platform/graphics/TextTrackRepresentation.h:
  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
(WebCore::MediaPlayerPrivateAVFoundation::logChannel const):

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateAudioTracks):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoTracks):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
(-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::mediaPlayerLogger):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::logChannel const):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::logChannel const):

  • platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h:
  • platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm:

(WebCore::VideoFullscreenLayerManagerObjC::VideoFullscreenLayerManagerObjC):
(WebCore::VideoFullscreenLayerManagerObjC::setVideoLayer):
(WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenLayer):
(WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenFrame):
(WebCore::VideoFullscreenLayerManagerObjC::didDestroyVideoLayer):
(WebCore::VideoFullscreenLayerManagerObjC::syncTextTrackBounds):
(WebCore::VideoFullscreenLayerManagerObjC::setTextTrackRepresentation):
(WebCore::VideoFullscreenLayerManagerObjC::logChannel const):

  • platform/graphics/cocoa/TextTrackRepresentationCocoa.h:
  • platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:

(-[WebCoreTextTrackRepresentationCocoaHelper observeValueForKeyPath:ofObject:change:context:]):
(TextTrackRepresentationCocoa::setHidden const):
(TextTrackRepresentationCocoa::boundsChanged):

  • rendering/RenderMediaControlElements.cpp:

(WebCore::RenderTextTrackContainerElement::layout):

Location:
trunk/Source/WebCore
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r256051 r256060  
     12020-02-07  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Captions sometimes render at the wrong size when in fullscreen and PiP
     4        https://bugs.webkit.org/show_bug.cgi?id=207389
     5        <rdar://problem/58677864>
     6
     7        Reviewed by Jer Noble.
     8
     9        The TextTrackRepresentation, used to render captions when in fullscreen and PiP on
     10        iOS and and in PiP on macOS, frequently rendered captions before layout completed
     11        immediately after it was created. Fix this by having it not render until a layout
     12        happens. Additionally, make the code more efficient by hiding the TextTrackRepresentation's
     13        backing layer when cues are not visible instead of destroying the whole object.
     14        Drive by: RELEASE_LOG_DISABLED is always defined for PLATFORM(COCOA), so remove it
     15        from the macOS/iOS media players to make it easier to add logging to VideoFullscreenLayerManagerObjC.
     16       
     17
     18        * html/HTMLMediaElement.cpp:
     19        (WebCore::convertEnumerationToString):
     20        (WebCore::HTMLMediaElement::configureTextTrackDisplay):
     21        * html/HTMLMediaElementEnums.h:
     22        (WTF::LogArgument<WebCore::HTMLMediaElementEnums::TextTrackVisibilityCheckType>::toString):
     23        * html/shadow/MediaControlElements.cpp:
     24        (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
     25        (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
     26        (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentation):
     27        (WebCore::MediaControlTextTrackContainerElement::clearTextTrackRepresentation):
     28        (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle):
     29        (WebCore::MediaControlTextTrackContainerElement::layoutIfNecessary):
     30        (WebCore::MediaControlTextTrackContainerElement::updateVideoDisplaySize):
     31        (WebCore::MediaControlTextTrackContainerElement::updateSizes):
     32        (WebCore::MediaControlTextTrackContainerElement::updateCueStyles):
     33        (WebCore::MediaControlTextTrackContainerElement::logger const):
     34        (WebCore::MediaControlTextTrackContainerElement::logIdentifier const):
     35        (WebCore::MediaControlTextTrackContainerElement::updateTimerFired): Deleted.
     36        (WebCore::MediaControlTextTrackContainerElement::updateStyleForTextTrackRepresentation): Deleted.
     37        * platform/graphics/TextTrackRepresentation.h:
     38        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     39        (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
     40        (WebCore::MediaPlayerPrivateAVFoundation::logChannel const):
     41        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
     42        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     43        (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
     44        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame):
     45        (WebCore::MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect):
     46        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateAudioTracks):
     47        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoTracks):
     48        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
     49        (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
     50        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     51        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::mediaPlayerLogger):
     52        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     53        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
     54        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::logChannel const):
     55        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
     56        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
     57        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
     58        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::logChannel const):
     59        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h:
     60        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm:
     61        (WebCore::VideoFullscreenLayerManagerObjC::VideoFullscreenLayerManagerObjC):
     62        (WebCore::VideoFullscreenLayerManagerObjC::setVideoLayer):
     63        (WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenLayer):
     64        (WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenFrame):
     65        (WebCore::VideoFullscreenLayerManagerObjC::didDestroyVideoLayer):
     66        (WebCore::VideoFullscreenLayerManagerObjC::syncTextTrackBounds):
     67        (WebCore::VideoFullscreenLayerManagerObjC::setTextTrackRepresentation):
     68        (WebCore::VideoFullscreenLayerManagerObjC::logChannel const):
     69        * platform/graphics/cocoa/TextTrackRepresentationCocoa.h:
     70        * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
     71        (-[WebCoreTextTrackRepresentationCocoaHelper observeValueForKeyPath:ofObject:change:context:]):
     72        (TextTrackRepresentationCocoa::setHidden const):
     73        (TextTrackRepresentationCocoa::boundsChanged):
     74        * rendering/RenderMediaControlElements.cpp:
     75        (WebCore::RenderTextTrackContainerElement::layout):
     76
    1772020-02-07  Sam Weinig  <weinig@apple.com>
    278
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r255191 r256060  
    275275}
    276276
     277String convertEnumerationToString(HTMLMediaElement::TextTrackVisibilityCheckType enumerationValue)
     278{
     279    static const NeverDestroyed<String> values[] = {
     280        MAKE_STATIC_STRING_IMPL("CheckTextTrackVisibility"),
     281        MAKE_STATIC_STRING_IMPL("AssumeTextTrackVisibilityChanged"),
     282    };
     283    static_assert(static_cast<size_t>(HTMLMediaElement::TextTrackVisibilityCheckType::CheckTextTrackVisibility) == 0, "TextTrackVisibilityCheckType::CheckTextTrackVisibility is not 0 as expected");
     284    static_assert(static_cast<size_t>(HTMLMediaElement::TextTrackVisibilityCheckType::AssumeTextTrackVisibilityChanged) == 1, "TextTrackVisibilityCheckType::AssumeTextTrackVisibilityChanged is not 1 as expected");
     285    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
     286    return values[static_cast<size_t>(enumerationValue)];
     287}
     288
    277289#if ENABLE(VIDEO_TRACK)
    278290
     
    65356547void HTMLMediaElement::configureTextTrackDisplay(TextTrackVisibilityCheckType checkType)
    65366548{
    6537     ALWAYS_LOG(LOGIDENTIFIER);
     6549    ALWAYS_LOG(LOGIDENTIFIER, checkType);
    65386550    ASSERT(m_textTracks);
    65396551
  • trunk/Source/WebCore/html/HTMLMediaElementEnums.h

    r237207 r256060  
    4848String convertEnumerationToString(HTMLMediaElementEnums::ReadyState);
    4949String convertEnumerationToString(HTMLMediaElementEnums::NetworkState);
     50String convertEnumerationToString(HTMLMediaElementEnums::TextTrackVisibilityCheckType);
    5051
    5152} // namespace WebCore
     
    7273};
    7374
     75template <>
     76struct LogArgument<WebCore::HTMLMediaElementEnums::TextTrackVisibilityCheckType> {
     77    static String toString(const WebCore::HTMLMediaElementEnums::TextTrackVisibilityCheckType type)
     78    {
     79        return convertEnumerationToString(type);
     80    }
     81};
     82
    7483}; // namespace WTF
    7584
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r254893 r256060  
    10941094MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(Document& document)
    10951095    : MediaControlDivElement(document, MediaTextTrackDisplayContainer)
    1096     , m_updateTimer(*this, &MediaControlTextTrackContainerElement::updateTimerFired)
    1097     , m_fontSize(0)
    1098     , m_fontSizeIsImportant(false)
    1099     , m_updateTextTrackRepresentationStyle(false)
    11001096{
    11011097    setPseudo(AtomString("-webkit-media-text-track-container", AtomString::ConstructFromLiteral));
     
    12061202
    12071203    // 11. Return output.
    1208     if (hasChildNodes()) {
     1204    if (hasChildNodes())
    12091205        show();
     1206    else
     1207        hide();
     1208
     1209    if (m_textTrackRepresentation || video.requiresTextTrackRepresentation())
    12101210        updateTextTrackRepresentation();
    1211     } else {
    1212         hide();
    1213         clearTextTrackRepresentation();
    1214     }
    12151211}
    12161212
     
    12941290}
    12951291
    1296 void MediaControlTextTrackContainerElement::updateTimerFired()
    1297 {
    1298     if (!document().page())
    1299         return;
    1300 
     1292void MediaControlTextTrackContainerElement::updateTextTrackRepresentation()
     1293{
    13011294    auto mediaElement = parentMediaElement(this);
    13021295    if (!mediaElement)
    13031296        return;
    13041297
    1305     for (auto& activeCue : mediaElement->currentlyActiveCues())
    1306         activeCue.data()->recalculateStyles();
    1307 
    1308     if (m_textTrackRepresentation)
    1309         updateStyleForTextTrackRepresentation();
    1310 
    1311     updateActiveCuesFontSize();
    1312     updateDisplay();
    1313     updateTextStrokeStyle();
    1314 }
    1315 
    1316 void MediaControlTextTrackContainerElement::updateTextTrackRepresentation()
    1317 {
    1318     auto mediaElement = parentMediaElement(this);
    1319     if (!mediaElement)
    1320         return;
    1321 
    1322     if (!mediaElement->requiresTextTrackRepresentation()) {
     1298    auto requiresTextTrackRepresentation = mediaElement->requiresTextTrackRepresentation();
     1299    if (!hasChildNodes() || !requiresTextTrackRepresentation) {
    13231300        if (m_textTrackRepresentation) {
    1324             clearTextTrackRepresentation();
    1325             updateSizes(ForceUpdate::Yes);
     1301            if (!requiresTextTrackRepresentation) {
     1302                clearTextTrackRepresentation();
     1303                updateSizes(ForceUpdate::Yes);
     1304            } else
     1305                m_textTrackRepresentation->setHidden(true);
    13261306        }
    13271307        return;
     
    13291309
    13301310    if (!m_textTrackRepresentation) {
     1311        ALWAYS_LOG(LOGIDENTIFIER);
     1312
     1313        m_waitingForFirstLayout = true;
    13311314        m_textTrackRepresentation = TextTrackRepresentation::create(*this);
    13321315        if (document().page())
    13331316            m_textTrackRepresentation->setContentScale(document().page()->deviceScaleFactor());
    1334         m_updateTextTrackRepresentationStyle = true;
    13351317        mediaElement->setTextTrackRepresentation(m_textTrackRepresentation.get());
    1336     }
    1337 
    1338     m_textTrackRepresentation->update();
    1339     updateStyleForTextTrackRepresentation();
     1318        updateSizes();
     1319        updateTextTrackRepresentationStyle();
     1320    }
     1321
     1322    m_textTrackRepresentation->setHidden(false);
     1323    if (!m_waitingForFirstLayout)
     1324        m_textTrackRepresentation->update();
    13401325}
    13411326
     
    13451330        return;
    13461331
     1332    ALWAYS_LOG(LOGIDENTIFIER);
     1333
     1334    m_waitingForFirstLayout = true;
    13471335    m_textTrackRepresentation = nullptr;
    1348     m_updateTextTrackRepresentationStyle = true;
    13491336    if (auto mediaElement = parentMediaElement(this))
    13501337        mediaElement->setTextTrackRepresentation(nullptr);
    1351     updateStyleForTextTrackRepresentation();
     1338    updateTextTrackRepresentationStyle();
    13521339    updateActiveCuesFontSize();
    13531340}
    13541341
    1355 void MediaControlTextTrackContainerElement::updateStyleForTextTrackRepresentation()
    1356 {
    1357     if (!m_updateTextTrackRepresentationStyle)
    1358         return;
    1359 
    1360     m_updateTextTrackRepresentationStyle = false;
    1361 
     1342void MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle()
     1343{
    13621344    if (m_textTrackRepresentation) {
    13631345        setInlineStyleProperty(CSSPropertyWidth, m_videoDisplaySize.size().width(), CSSUnitType::CSS_PX);
     
    13891371}
    13901372
    1391 void MediaControlTextTrackContainerElement::updateSizes(ForceUpdate force)
    1392 {
     1373void MediaControlTextTrackContainerElement::layoutIfNecessary()
     1374{
     1375    m_waitingForFirstLayout = false;
     1376
     1377    auto sizeChanged = updateVideoDisplaySize();
     1378    if (m_textTrackRepresentation)
     1379        m_textTrackRepresentation->update();
     1380
     1381    if (!sizeChanged)
     1382        return;
     1383
     1384    // FIXME (121170): This function is called during layout, and should lay out the text tracks immediately.
     1385    m_taskQueue.enqueueTask([this] () {
     1386        updateCueStyles();
     1387    });
     1388}
     1389
     1390bool MediaControlTextTrackContainerElement::updateVideoDisplaySize()
     1391{
     1392    if (!document().page())
     1393        return false;
     1394
    13931395    auto mediaElement = parentMediaElement(this);
    13941396    if (!mediaElement)
    1395         return;
    1396 
    1397     if (!document().page())
    1398         return;
     1397        return false;
    13991398
    14001399    IntRect videoBox;
     
    14061405    } else {
    14071406        if (!is<RenderVideo>(mediaElement->renderer()))
    1408             return;
     1407            return false;
    14091408        videoBox = downcast<RenderVideo>(*mediaElement->renderer()).videoBox();
    14101409    }
    14111410
    1412     if (force == ForceUpdate::No && m_videoDisplaySize == videoBox)
    1413         return;
     1411    if (m_videoDisplaySize == videoBox)
     1412        return false;
    14141413
    14151414    m_videoDisplaySize = videoBox;
    1416     m_updateTextTrackRepresentationStyle = true;
     1415    updateTextTrackRepresentationStyle();
     1416
     1417    return true;
     1418}
     1419
     1420void MediaControlTextTrackContainerElement::updateSizes(ForceUpdate force)
     1421{
     1422    if (updateVideoDisplaySize() || force == ForceUpdate::Yes)
     1423        updateCueStyles();
     1424}
     1425
     1426void MediaControlTextTrackContainerElement::updateCueStyles()
     1427{
     1428    if (!document().page())
     1429        return;
     1430
     1431    auto mediaElement = parentMediaElement(this);
     1432    if (!mediaElement)
     1433        return;
     1434
    14171435    mediaElement->syncTextTrackBounds();
    14181436
    1419     // FIXME (121170): This function is called during layout, and should lay out the text tracks immediately.
    1420     m_updateTimer.startOneShot(0_s);
     1437    for (auto& activeCue : mediaElement->currentlyActiveCues())
     1438        activeCue.data()->recalculateStyles();
     1439
     1440    updateActiveCuesFontSize();
     1441    updateDisplay();
     1442    updateTextStrokeStyle();
    14211443}
    14221444
     
    14671489const Logger& MediaControlTextTrackContainerElement::logger() const
    14681490{
    1469     return document().logger();
     1491    if (!m_logger)
     1492        m_logger = &document().logger();
     1493
     1494    return *m_logger;
    14701495}
    14711496
    14721497const void* MediaControlTextTrackContainerElement::logIdentifier() const
    14731498{
    1474     if (auto mediaElement = parentMediaElement(this))
    1475         return mediaElement->logIdentifier();
    1476     return nullptr;
     1499    if (!m_logIdentifier) {
     1500        if (auto mediaElement = parentMediaElement(this))
     1501            m_logIdentifier = mediaElement->logIdentifier();
     1502    }
     1503
     1504    return m_logIdentifier;
    14771505}
    14781506
  • trunk/Source/WebCore/html/shadow/MediaControlElements.h

    r251950 r256060  
    3232#if ENABLE(VIDEO)
    3333
     34#include "GenericTaskQueue.h"
    3435#include "MediaControlElementTypes.h"
    3536#include "TextTrackRepresentation.h"
     
    483484    enum class ForceUpdate { Yes, No };
    484485    void updateSizes(ForceUpdate force = ForceUpdate::No);
     486    void layoutIfNecessary();
    485487
    486488    void updateDisplay();
     
    489491
    490492private:
    491     void updateTimerFired();
     493    explicit MediaControlTextTrackContainerElement(Document&);
     494
     495    bool updateVideoDisplaySize();
     496    void updateCueStyles();
    492497    void updateActiveCuesFontSize();
    493498    void updateTextStrokeStyle();
    494499    void processActiveVTTCue(VTTCue&);
     500    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
     501
     502    RefPtr<Image> createTextTrackRepresentationImage() override;
     503    void textTrackRepresentationBoundsChanged(const IntRect&) override;
     504    void updateTextTrackRepresentation();
     505    void clearTextTrackRepresentation();
     506    void updateTextTrackRepresentationStyle();
    495507
    496508#if !RELEASE_LOG_DISABLED
     
    499511    WTFLogChannel& logChannel() const final;
    500512    const char* logClassName() const final { return "MediaControlTextTrackContainerElement"; }
    501 #endif
    502 
    503     explicit MediaControlTextTrackContainerElement(Document&);
    504 
    505     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
    506 
    507     RefPtr<Image> createTextTrackRepresentationImage() override;
    508     void textTrackRepresentationBoundsChanged(const IntRect&) override;
    509     void updateTextTrackRepresentation();
    510     void clearTextTrackRepresentation();
    511     void updateStyleForTextTrackRepresentation();
     513    mutable RefPtr<Logger> m_logger;
     514    mutable const void* m_logIdentifier { nullptr };
     515#endif
     516
    512517    std::unique_ptr<TextTrackRepresentation> m_textTrackRepresentation;
    513518
    514     Timer m_updateTimer;
     519    GenericTaskQueue<Timer> m_taskQueue;
    515520    IntRect m_videoDisplaySize;
    516     int m_fontSize;
    517     bool m_fontSizeIsImportant;
    518     bool m_updateTextTrackRepresentationStyle;
     521    int m_fontSize { 0 };
     522    bool m_fontSizeIsImportant { false };
     523    bool m_waitingForFirstLayout { true };
    519524};
    520525
  • trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp

    r248846 r256060  
    3737public:
    3838    virtual ~NullTextTrackRepresentation() = default;
    39     void update() override { }
    40     PlatformLayer* platformLayer() override { return nullptr; }
    41     void setContentScale(float) override { }
    42     IntRect bounds() const override { return IntRect(); }
     39    void update() final { }
     40    PlatformLayer* platformLayer() final { return nullptr; }
     41    void setContentScale(float) final { }
     42    IntRect bounds() const final { return IntRect(); }
     43    void setHidden(bool) const final { }
    4344};
    4445
  • trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h

    r241183 r256060  
    5656    virtual void setContentScale(float) = 0;
    5757    virtual IntRect bounds() const = 0;
     58    virtual void setHidden(bool) const = 0;
    5859};
    5960
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r255581 r256060  
    405405MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlayer* player)
    406406    : MediaPlayerPrivateAVFoundation(player)
    407     , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>())
     407    , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>(logger(), logIdentifier()))
    408408    , m_videoFullscreenGravity(MediaPlayer::VideoGravity::ResizeAspect)
    409409    , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:makeWeakPtr(*this)]))
     
    10921092void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame(FloatRect frame)
    10931093{
     1094    ALWAYS_LOG(LOGIDENTIFIER, "width = ", frame.size().width(), ", height = ", frame.size().height());
    10941095    m_videoFullscreenLayerManager->setVideoFullscreenFrame(frame);
    10951096}
     
    15591560    ASSERT(m_imageGenerator);
    15601561
    1561 #if !RELEASE_LOG_DISABLED
    15621562    MonotonicTime start = MonotonicTime::now();
    1563 #endif
    15641563
    15651564    [m_imageGenerator.get() setMaximumSize:CGSize(rect.size())];
     
    15671566    RetainPtr<CGImageRef> image = adoptCF(CGImageCreateCopyWithColorSpace(rawImage.get(), sRGBColorSpaceRef()));
    15681567
    1569 #if !RELEASE_LOG_DISABLED
    15701568    INFO_LOG(LOGIDENTIFIER, "creating image took ", (MonotonicTime::now() - start).seconds());
    1571 #endif
    15721569
    15731570    return image;
     
    20162013void MediaPlayerPrivateAVFoundationObjC::updateAudioTracks()
    20172014{
    2018 #if !RELEASE_LOG_DISABLED
    20192015    size_t count = m_audioTracks.size();
    2020 #endif
    20212016
    20222017    Vector<String> characteristics = player()->preferredAudioCharacteristics();
     
    20342029        track->resetPropertiesFromTrack();
    20352030
    2036 #if !RELEASE_LOG_DISABLED
    20372031    ALWAYS_LOG(LOGIDENTIFIER, "track count was ", count, ", is ", m_audioTracks.size());
    2038 #endif
    20392032}
    20402033
    20412034void MediaPlayerPrivateAVFoundationObjC::updateVideoTracks()
    20422035{
    2043 #if !RELEASE_LOG_DISABLED
    20442036    size_t count = m_videoTracks.size();
    2045 #endif
    20462037
    20472038    determineChangedTracksFromNewTracksAndOldItems(m_cachedTracks.get(), AVMediaTypeVideo, m_videoTracks, &VideoTrackPrivateAVFObjC::create, player(), &MediaPlayer::removeVideoTrack, &MediaPlayer::addVideoTrack);
     
    20582049        track->resetPropertiesFromTrack();
    20592050
    2060 #if !RELEASE_LOG_DISABLED
    20612051    ALWAYS_LOG(LOGIDENTIFIER, "track count was ", count, ", is ", m_videoTracks.size());
    2062 #endif
    20632052}
    20642053
     
    22292218    }
    22302219
    2231 #if !RELEASE_LOG_DISABLED
    22322220    MonotonicTime start = MonotonicTime::now();
    2233 #endif
    22342221
    22352222    m_lastImage = m_pixelBufferConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get());
    22362223
    2237 #if !RELEASE_LOG_DISABLED
    22382224    INFO_LOG(LOGIDENTIFIER, "creating buffer took ", (MonotonicTime::now() - start).seconds());
    2239 #endif
    22402225#endif // HAVE(CORE_VIDEO)
    22412226}
     
    34513436            }
    34523437
    3453 #if !RELEASE_LOG_DISABLED
    34543438            if (player->logger().willLog(player->logChannel(), WTFLogLevel::Debug) && !([keyPath isEqualToString:@"loadedTimeRanges"] || [keyPath isEqualToString:@"seekableTimeRanges"])) {
    34553439                auto identifier = Logger::LogSiteIdentifier("MediaPlayerPrivateAVFoundation", "observeValueForKeyPath", player->logIdentifier());
     
    34653449                    player->logger().debug(player->logChannel(), identifier, willChange ? "will" : "did", " change '", [keyPath UTF8String], "'");
    34663450            }
    3467 #endif
    34683451        });
    34693452    });
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r254214 r256060  
    6464    : public CanMakeWeakPtr<MediaPlayerPrivateMediaSourceAVFObjC>
    6565    , public MediaPlayerPrivateInterface
    66 #if !RELEASE_LOG_DISABLED
    6766    , private LoggerHelper
    68 #endif
    6967{
    7068public:
     
    151149    bool shouldCheckHardwareSupport() const;
    152150
    153 #if !RELEASE_LOG_DISABLED
    154151    const Logger& logger() const final { return m_logger.get(); }
    155152    const char* logClassName() const override { return "MediaPlayerPrivateMediaSourceAVFObjC"; }
     
    159156    const void* mediaPlayerLogIdentifier() { return logIdentifier(); }
    160157    const Logger& mediaPlayerLogger() { return logger(); }
    161 #endif
    162158
    163159    enum SeekState {
     
    328324    bool m_shouldPlayToTarget { false };
    329325#endif
    330     std::unique_ptr<VideoFullscreenLayerManagerObjC> m_videoFullscreenLayerManager;
    331 
    332     Ref<EffectiveRateChangedListener> m_effectiveRateChangedListener;
    333 
    334 #if !RELEASE_LOG_DISABLED
    335326    Ref<const Logger> m_logger;
    336327    const void* m_logIdentifier;
    337 #endif
     328    std::unique_ptr<VideoFullscreenLayerManagerObjC> m_videoFullscreenLayerManager;
     329
     330    Ref<EffectiveRateChangedListener> m_effectiveRateChangedListener;
    338331};
    339332
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r254964 r256060  
    138138    , m_seeking(false)
    139139    , m_loadingProgressed(false)
    140     , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>())
    141     , m_effectiveRateChangedListener(EffectiveRateChangedListener::create(*this, [m_synchronizer timebase]))
    142 #if !RELEASE_LOG_DISABLED
    143140    , m_logger(player->mediaPlayerLogger())
    144141    , m_logIdentifier(player->mediaPlayerLogIdentifier())
    145 #endif
     142    , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>(m_logger, m_logIdentifier))
     143    , m_effectiveRateChangedListener(EffectiveRateChangedListener::create(*this, [m_synchronizer timebase]))
    146144{
    147145    auto logSiteIdentifier = LOGIDENTIFIER;
     
    12221220}
    12231221
    1224 #if !RELEASE_LOG_DISABLED
    12251222WTFLogChannel& MediaPlayerPrivateMediaSourceAVFObjC::logChannel() const
    12261223{
    12271224    return LogMediaSource;
    12281225}
     1226
     1227}
     1228
    12291229#endif
    1230 
    1231 }
    1232 
    1233 #endif
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h

    r254817 r256060  
    5353
    5454class MediaPlayerPrivateMediaStreamAVFObjC final : public MediaPlayerPrivateInterface, private MediaStreamPrivate::Observer, private MediaStreamTrackPrivate::Observer, public SampleBufferDisplayLayer::Client
    55 #if !RELEASE_LOG_DISABLED
    5655    , private LoggerHelper
    57 #endif
    5856{
    5957public:
     
    7674    void destroyLayers();
    7775
    78 #if !RELEASE_LOG_DISABLED
    7976    const Logger& logger() const final { return m_logger.get(); }
    8077    const char* logClassName() const override { return "MediaPlayerPrivateMediaStreamAVFObjC"; }
    8178    const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
    8279    WTFLogChannel& logChannel() const final;
    83 #endif
    8480
    8581    PlatformLayer* rootLayer() const;
     
    244240    CGAffineTransform m_videoTransform;
    245241    std::unique_ptr<SampleBufferDisplayLayer> m_sampleBufferDisplayLayer;
     242
     243    Ref<const Logger> m_logger;
     244    const void* m_logIdentifier;
    246245    std::unique_ptr<VideoFullscreenLayerManagerObjC> m_videoFullscreenLayerManager;
    247246
    248247    // SampleBufferDisplayLayer::Client
    249248    void sampleBufferDisplayLayerStatusDidChange(SampleBufferDisplayLayer&) final;
    250 
    251 #if !RELEASE_LOG_DISABLED
    252     Ref<const Logger> m_logger;
    253     const void* m_logIdentifier;
    254 #endif
    255249
    256250    RetainPtr<WebRootSampleBufferBoundsChangeListener> m_boundsChangeListener;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm

    r254817 r256060  
    145145    : m_player(player)
    146146    , m_clock(PAL::Clock::create())
    147     , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>())
    148 #if !RELEASE_LOG_DISABLED
    149147    , m_logger(player->mediaPlayerLogger())
    150148    , m_logIdentifier(player->mediaPlayerLogIdentifier())
    151 #endif
     149    , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>(m_logger, m_logIdentifier))
    152150    , m_boundsChangeListener(adoptNS([[WebRootSampleBufferBoundsChangeListener alloc] initWithParent:this]))
    153151{
     
    10571055}
    10581056
    1059 #if !RELEASE_LOG_DISABLED
    10601057WTFLogChannel& MediaPlayerPrivateMediaStreamAVFObjC::logChannel() const
    10611058{
    10621059    return LogMedia;
    10631060}
     1061
     1062}
     1063
    10641064#endif
    1065 
    1066 }
    1067 
    1068 #endif
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h

    r252346 r256060  
    3232#include "WebVideoContainerLayer.h"
    3333#include <wtf/Function.h>
     34#include <wtf/LoggerHelper.h>
    3435#include <wtf/Noncopyable.h>
    3536#include <wtf/RetainPtr.h>
     
    3940namespace WebCore {
    4041
    41 class VideoFullscreenLayerManagerObjC final : public VideoFullscreenLayerManager {
     42class VideoFullscreenLayerManagerObjC final : public VideoFullscreenLayerManager , public LoggerHelper {
    4243    WTF_MAKE_FAST_ALLOCATED;
    4344public:
    44     VideoFullscreenLayerManagerObjC();
     45    VideoFullscreenLayerManagerObjC(const Logger&, const void*);
    4546
    4647    PlatformLayer *videoInlineLayer() const final { return m_videoInlineLayer.get(); }
     
    5859
    5960private:
     61    const Logger& logger() const final { return m_logger.get(); }
     62    const void* logIdentifier() const final { return m_logIdentifier; }
     63    const char* logClassName() const final { return "VideoFullscreenLayerManagerObjC"; }
     64    WTFLogChannel& logChannel() const final;
     65
     66    Ref<const Logger> m_logger;
     67    const void* m_logIdentifier;
     68
    6069    RetainPtr<PlatformLayer> m_textTrackRepresentationLayer;
    6170    RetainPtr<WebVideoContainerLayer> m_videoInlineLayer;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm

    r252346 r256060  
    2828
    2929#import "Color.h"
     30#import "Logging.h"
    3031#import "TextTrackRepresentation.h"
    3132#import "WebCoreCALayerExtras.h"
     
    4041namespace WebCore {
    4142
    42 VideoFullscreenLayerManagerObjC::VideoFullscreenLayerManagerObjC()
     43VideoFullscreenLayerManagerObjC::VideoFullscreenLayerManagerObjC(const Logger& logger, const void* logIdentifier)
    4344    : VideoFullscreenLayerManager()
     45    , m_logger(logger)
     46    , m_logIdentifier(logIdentifier)
    4447{
    4548}
     
    4750void VideoFullscreenLayerManagerObjC::setVideoLayer(PlatformLayer *videoLayer, IntSize contentSize)
    4851{
     52    ALWAYS_LOG(LOGIDENTIFIER, contentSize.width(), ", ", contentSize.height());
     53
    4954    m_videoLayer = videoLayer;
    5055    m_videoInlineFrame = CGRectMake(0, 0, contentSize.width(), contentSize.height());
     
    8287    }
    8388
     89    ALWAYS_LOG(LOGIDENTIFIER);
     90
    8491    m_videoFullscreenLayer = videoFullscreenLayer;
    8592
     
    122129void VideoFullscreenLayerManagerObjC::setVideoFullscreenFrame(FloatRect videoFullscreenFrame)
    123130{
     131    ALWAYS_LOG(LOGIDENTIFIER, videoFullscreenFrame.x(), ", ", videoFullscreenFrame.y(), ", ", videoFullscreenFrame.width(), ", ", videoFullscreenFrame.height());
     132
    124133    m_videoFullscreenFrame = videoFullscreenFrame;
    125134    if (!m_videoFullscreenLayer)
     
    132141void VideoFullscreenLayerManagerObjC::didDestroyVideoLayer()
    133142{
     143    ALWAYS_LOG(LOGIDENTIFIER);
     144
    134145    [m_videoLayer removeFromSuperlayer];
    135146
     
    148159        return;
    149160
     161    if (m_textTrackRepresentationLayer.get().bounds == m_videoFullscreenFrame)
     162        return;
     163
    150164    [CATransaction begin];
    151165    [CATransaction setDisableActions:YES];
     
    158172void VideoFullscreenLayerManagerObjC::setTextTrackRepresentation(TextTrackRepresentation* representation)
    159173{
     174    ALWAYS_LOG(LOGIDENTIFIER);
     175
    160176    PlatformLayer* representationLayer = representation ? representation->platformLayer() : nil;
    161177    if (representationLayer == m_textTrackRepresentationLayer) {
     
    181197}
    182198
    183 }
    184 
     199WTFLogChannel& VideoFullscreenLayerManagerObjC::logChannel() const
     200{
     201    return LogMedia;
     202}
     203
     204}
     205
  • trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.h

    r237266 r256060  
    2929#if (PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))) && ENABLE(VIDEO_TRACK)
    3030
    31 #import "TextTrackRepresentation.h"
    32 #import <QuartzCore/CALayer.h>
    33 #import <wtf/RetainPtr.h>
     31#include "GenericTaskQueue.h"
     32#include "TextTrackRepresentation.h"
     33#include <QuartzCore/CALayer.h>
     34#include <wtf/RetainPtr.h>
    3435
    3536@class WebCoreTextTrackRepresentationCocoaHelper;
     
    4445    TextTrackRepresentationClient& client() const { return m_client; }
    4546
    46     PlatformLayer* platformLayer() override { return m_layer.get(); }
    47     IntRect bounds() const override;
     47    PlatformLayer* platformLayer() final { return m_layer.get(); }
     48
     49    IntRect bounds() const final;
     50    void boundsChanged();
    4851
    4952private:
    50     void update() override;
    51     void setContentScale(float) override;
     53    void update() final;
     54    void setContentScale(float) final;
     55    void setHidden(bool) const final;
    5256
     57    GenericTaskQueue<Timer> m_taskQueue;
    5358    TextTrackRepresentationClient& m_client;
    5459    RetainPtr<CALayer> m_layer;
  • trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm

    r248846 r256060  
    9393#else
    9494    if (_parent && [keyPath isEqual:@"bounds"] && object == _parent->platformLayer())
    95         _parent->client().textTrackRepresentationBoundsChanged(_parent->bounds());
     95        _parent->boundsChanged();
    9696#endif
    9797}
     
    138138}
    139139
     140void TextTrackRepresentationCocoa::setHidden(bool hidden) const
     141{
     142    [m_layer.get() setHidden:hidden];
     143}
     144
    140145IntRect TextTrackRepresentationCocoa::bounds() const
    141146{
     
    143148}
    144149
     150void TextTrackRepresentationCocoa::boundsChanged()
     151{
     152    m_taskQueue.enqueueTask([this] () {
     153        client().textTrackRepresentationBoundsChanged(bounds());
     154    });
     155}
     156
    145157#endif // (PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))) && ENABLE(VIDEO_TRACK)
  • trunk/Source/WebCore/rendering/RenderMediaControlElements.cpp

    r238963 r256060  
    105105
    106106    LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext());
    107     static_cast<MediaControlTextTrackContainerElement*>(element())->updateSizes();
     107    static_cast<MediaControlTextTrackContainerElement*>(element())->layoutIfNecessary();
    108108}
    109109
Note: See TracChangeset for help on using the changeset viewer.