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

Changeset 243298 in webkit


Ignore:
Timestamp:
Mar 21, 2019, 10:21:38 AM (7 years ago)
Author:
Brent Fulgham
Message:

Hardening: Use WeakPtrs in VideoFullscreenInterface{Mac,AVKit}
https://bugs.webkit.org/show_bug.cgi?id=196052
<rdar://problem/48778571>

Reviewed by Eric Carlson.

The VideoFullscreenInterface{Mac,AVKit} implementations store their fullscreen model
and fullscreen change observer members as bare pointers, something we've been working
to eliminate.

This patch corrects this oversight.

No new tests since no changes in behavior.

  • platform/cocoa/VideoFullscreenChangeObserver.h:
  • platform/cocoa/VideoFullscreenModel.h:
  • platform/ios/VideoFullscreenInterfaceAVKit.h:
  • platform/ios/VideoFullscreenInterfaceAVKit.mm:

(VideoFullscreenInterfaceAVKit::setVideoFullscreenModel):
(VideoFullscreenInterfaceAVKit::setVideoFullscreenChangeObserver):
(VideoFullscreenInterfaceAVKit::presentingViewController):
(VideoFullscreenInterfaceAVKit::invalidate):
(VideoFullscreenInterfaceAVKit::preparedToExitFullscreen):
(VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
(VideoFullscreenInterfaceAVKit::doSetup):

  • platform/mac/VideoFullscreenInterfaceMac.h:

(WebCore::VideoFullscreenInterfaceMac::videoFullscreenModel const):
(WebCore::VideoFullscreenInterfaceMac::videoFullscreenChangeObserver const):

  • platform/mac/VideoFullscreenInterfaceMac.mm:

(WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenModel):
(WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenChangeObserver):
(WebCore::VideoFullscreenInterfaceMac::enterFullscreen):
(WebCore::VideoFullscreenInterfaceMac::invalidate):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243296 r243298  
     12019-03-21  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Hardening: Use WeakPtrs in VideoFullscreenInterface{Mac,AVKit}
     4        https://bugs.webkit.org/show_bug.cgi?id=196052
     5        <rdar://problem/48778571>
     6
     7        Reviewed by Eric Carlson.
     8
     9        The VideoFullscreenInterface{Mac,AVKit} implementations store their fullscreen model
     10        and fullscreen change observer members as bare pointers, something we've been working
     11        to eliminate.
     12       
     13        This patch corrects this oversight.
     14
     15        No new tests since no changes in behavior.
     16
     17        * platform/cocoa/VideoFullscreenChangeObserver.h:
     18        * platform/cocoa/VideoFullscreenModel.h:
     19        * platform/ios/VideoFullscreenInterfaceAVKit.h:
     20        * platform/ios/VideoFullscreenInterfaceAVKit.mm:
     21        (VideoFullscreenInterfaceAVKit::setVideoFullscreenModel):
     22        (VideoFullscreenInterfaceAVKit::setVideoFullscreenChangeObserver):
     23        (VideoFullscreenInterfaceAVKit::presentingViewController):
     24        (VideoFullscreenInterfaceAVKit::invalidate):
     25        (VideoFullscreenInterfaceAVKit::preparedToExitFullscreen):
     26        (VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
     27        (VideoFullscreenInterfaceAVKit::doSetup):
     28        * platform/mac/VideoFullscreenInterfaceMac.h:
     29        (WebCore::VideoFullscreenInterfaceMac::videoFullscreenModel const):
     30        (WebCore::VideoFullscreenInterfaceMac::videoFullscreenChangeObserver const):
     31        * platform/mac/VideoFullscreenInterfaceMac.mm:
     32        (WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenModel):
     33        (WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenChangeObserver):
     34        (WebCore::VideoFullscreenInterfaceMac::enterFullscreen):
     35        (WebCore::VideoFullscreenInterfaceMac::invalidate):
     36
    1372019-03-21  Megan Gardner  <megan_gardner@apple.com>
    238
  • trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h

    r237266 r243298  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131namespace WebCore {
    3232
    33 class VideoFullscreenChangeObserver {
     33class VideoFullscreenChangeObserver : public CanMakeWeakPtr<VideoFullscreenChangeObserver> {
    3434public:
    3535    virtual ~VideoFullscreenChangeObserver() { };
  • trunk/Source/WebCore/platform/cocoa/VideoFullscreenModel.h

    r238528 r243298  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545class VideoFullscreenModelClient;
    4646
    47 class VideoFullscreenModel {
     47class VideoFullscreenModel : public CanMakeWeakPtr<VideoFullscreenModel> {
    4848public:
    4949    virtual ~VideoFullscreenModel() { };
  • trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h

    r238528 r243298  
    11/*
    2  * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    128128    Mode m_targetMode;
    129129
    130     VideoFullscreenModel* videoFullscreenModel() const { return m_videoFullscreenModel; }
     130    VideoFullscreenModel* videoFullscreenModel() const { return m_videoFullscreenModel.get(); }
    131131    bool shouldExitFullscreenWithReason(ExitFullScreenReason);
    132132    HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_currentMode.mode(); }
     
    172172    RetainPtr<WebAVPlayerViewControllerDelegate> m_playerViewControllerDelegate;
    173173    RetainPtr<WebAVPlayerViewController> m_playerViewController;
    174     VideoFullscreenModel* m_videoFullscreenModel { nullptr };
    175     VideoFullscreenChangeObserver* m_fullscreenChangeObserver { nullptr };
     174    WeakPtr<VideoFullscreenModel> m_videoFullscreenModel;
     175    WeakPtr<VideoFullscreenChangeObserver> m_fullscreenChangeObserver;
    176176
    177177    // These are only used when fullscreen is presented in a separate window.
  • trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm

    r240168 r243298  
    11/*
    2  * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    764764        m_videoFullscreenModel->removeClient(*this);
    765765
    766     m_videoFullscreenModel = model;
     766    m_videoFullscreenModel = makeWeakPtr(model);
    767767
    768768    if (m_videoFullscreenModel) {
     
    783783void VideoFullscreenInterfaceAVKit::setVideoFullscreenChangeObserver(VideoFullscreenChangeObserver* observer)
    784784{
    785     m_fullscreenChangeObserver = observer;
     785    m_fullscreenChangeObserver = makeWeakPtr(observer);
    786786}
    787787
     
    834834UIViewController *VideoFullscreenInterfaceAVKit::presentingViewController()
    835835{
    836     auto *controller = videoFullscreenModel()->presentingViewController();
     836    auto *controller = videoFullscreenModel() ? videoFullscreenModel()->presentingViewController() : nil;
    837837    if (!controller)
    838838        controller = fallbackViewController(m_parentView.get());
     
    928928void VideoFullscreenInterfaceAVKit::invalidate()
    929929{
    930     m_videoFullscreenModel = nil;
    931     m_fullscreenChangeObserver = nil;
     930    m_videoFullscreenModel = nullptr;
     931    m_fullscreenChangeObserver = nullptr;
    932932   
    933933    cleanupFullscreen();
     
    967967
    968968    m_waitingForPreparedToExit = false;
    969     m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, true);
     969    ASSERT(m_videoFullscreenModel);
     970    if (m_videoFullscreenModel)
     971        m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, true);
    970972#endif
    971973}
     
    11361138   
    11371139    BOOL finished = reason == ExitFullScreenReason::DoneButtonTapped || reason == ExitFullScreenReason::PinchGestureHandled;
    1138     m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, finished);
     1140    ASSERT(m_videoFullscreenModel);
     1141    if (m_videoFullscreenModel)
     1142        m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, finished);
    11391143
    11401144    return false;
     
    12431247
    12441248#if PLATFORM(WATCHOS)
    1245     m_viewController = videoFullscreenModel()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController);
     1249    m_viewController = videoFullscreenModel() ? videoFullscreenModel()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController) : nil;
    12461250#endif
    12471251
  • trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h

    r236748 r243298  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5757    virtual ~VideoFullscreenInterfaceMac();
    5858    PlaybackSessionInterfaceMac& playbackSessionInterface() const { return m_playbackSessionInterface.get(); }
    59     VideoFullscreenModel* videoFullscreenModel() const { return m_videoFullscreenModel; }
     59    VideoFullscreenModel* videoFullscreenModel() const { return m_videoFullscreenModel.get(); }
    6060    PlaybackSessionModel* playbackSessionModel() const { return m_playbackSessionInterface->playbackSessionModel(); }
    6161    WEBCORE_EXPORT void setVideoFullscreenModel(VideoFullscreenModel*);
    62     VideoFullscreenChangeObserver* videoFullscreenChangeObserver() const { return m_fullscreenChangeObserver; }
     62    VideoFullscreenChangeObserver* videoFullscreenChangeObserver() const { return m_fullscreenChangeObserver.get(); }
    6363    WEBCORE_EXPORT void setVideoFullscreenChangeObserver(VideoFullscreenChangeObserver*);
    6464
     
    100100    WEBCORE_EXPORT VideoFullscreenInterfaceMac(PlaybackSessionInterfaceMac&);
    101101    Ref<PlaybackSessionInterfaceMac> m_playbackSessionInterface;
    102     VideoFullscreenModel* m_videoFullscreenModel { nullptr };
    103     VideoFullscreenChangeObserver* m_fullscreenChangeObserver { nullptr };
     102    WeakPtr<VideoFullscreenModel> m_videoFullscreenModel;
     103    WeakPtr<VideoFullscreenChangeObserver> m_fullscreenChangeObserver;
    104104    HTMLMediaElementEnums::VideoFullscreenMode m_mode { HTMLMediaElementEnums::VideoFullscreenModeNone };
    105105    RetainPtr<WebVideoFullscreenInterfaceMacObjC> m_webVideoFullscreenInterfaceObjC;
  • trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm

    r240822 r243298  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    377377    if (m_videoFullscreenModel)
    378378        m_videoFullscreenModel->removeClient(*this);
    379     m_videoFullscreenModel = model;
     379    m_videoFullscreenModel = makeWeakPtr(model);
    380380    if (m_videoFullscreenModel)
    381381        m_videoFullscreenModel->addClient(*this);
     
    384384void VideoFullscreenInterfaceMac::setVideoFullscreenChangeObserver(VideoFullscreenChangeObserver* observer)
    385385{
    386     m_fullscreenChangeObserver = observer;
     386    m_fullscreenChangeObserver = makeWeakPtr(observer);
    387387}
    388388
     
    448448    LOG(Fullscreen, "VideoFullscreenInterfaceMac::enterFullscreen(%p)", this);
    449449
     450    RELEASE_ASSERT(m_videoFullscreenModel);
    450451    if (mode() == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture) {
    451452        m_videoFullscreenModel->willEnterPictureInPicture();
     
    511512    LOG(Fullscreen, "VideoFullscreenInterfaceMac::invalidate(%p)", this);
    512513
    513     m_videoFullscreenModel = nil;
    514     m_fullscreenChangeObserver = nil;
     514    m_videoFullscreenModel = nullptr;
     515    m_fullscreenChangeObserver = nullptr;
    515516
    516517    cleanupFullscreen();
Note: See TracChangeset for help on using the changeset viewer.