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

Changeset 243579 in webkit


Ignore:
Timestamp:
Mar 27, 2019, 4:43:57 PM (7 years ago)
Author:
Alan Coon
Message:

Cherry-pick r243298. rdar://problem/49308011

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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243298 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-607-branch/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-607-branch/Source/WebCore/ChangeLog

    r243575 r243579  
     12019-03-27  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r243298. rdar://problem/49308011
     4
     5    Hardening: Use WeakPtrs in VideoFullscreenInterface{Mac,AVKit}
     6    https://bugs.webkit.org/show_bug.cgi?id=196052
     7    <rdar://problem/48778571>
     8   
     9    Reviewed by Eric Carlson.
     10   
     11    The VideoFullscreenInterface{Mac,AVKit} implementations store their fullscreen model
     12    and fullscreen change observer members as bare pointers, something we've been working
     13    to eliminate.
     14   
     15    This patch corrects this oversight.
     16   
     17    No new tests since no changes in behavior.
     18   
     19    * platform/cocoa/VideoFullscreenChangeObserver.h:
     20    * platform/cocoa/VideoFullscreenModel.h:
     21    * platform/ios/VideoFullscreenInterfaceAVKit.h:
     22    * platform/ios/VideoFullscreenInterfaceAVKit.mm:
     23    (VideoFullscreenInterfaceAVKit::setVideoFullscreenModel):
     24    (VideoFullscreenInterfaceAVKit::setVideoFullscreenChangeObserver):
     25    (VideoFullscreenInterfaceAVKit::presentingViewController):
     26    (VideoFullscreenInterfaceAVKit::invalidate):
     27    (VideoFullscreenInterfaceAVKit::preparedToExitFullscreen):
     28    (VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
     29    (VideoFullscreenInterfaceAVKit::doSetup):
     30    * platform/mac/VideoFullscreenInterfaceMac.h:
     31    (WebCore::VideoFullscreenInterfaceMac::videoFullscreenModel const):
     32    (WebCore::VideoFullscreenInterfaceMac::videoFullscreenChangeObserver const):
     33    * platform/mac/VideoFullscreenInterfaceMac.mm:
     34    (WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenModel):
     35    (WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenChangeObserver):
     36    (WebCore::VideoFullscreenInterfaceMac::enterFullscreen):
     37    (WebCore::VideoFullscreenInterfaceMac::invalidate):
     38   
     39    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     40
     41    2019-03-21  Brent Fulgham  <bfulgham@apple.com>
     42
     43            Hardening: Use WeakPtrs in VideoFullscreenInterface{Mac,AVKit}
     44            https://bugs.webkit.org/show_bug.cgi?id=196052
     45            <rdar://problem/48778571>
     46
     47            Reviewed by Eric Carlson.
     48
     49            The VideoFullscreenInterface{Mac,AVKit} implementations store their fullscreen model
     50            and fullscreen change observer members as bare pointers, something we've been working
     51            to eliminate.
     52
     53            This patch corrects this oversight.
     54
     55            No new tests since no changes in behavior.
     56
     57            * platform/cocoa/VideoFullscreenChangeObserver.h:
     58            * platform/cocoa/VideoFullscreenModel.h:
     59            * platform/ios/VideoFullscreenInterfaceAVKit.h:
     60            * platform/ios/VideoFullscreenInterfaceAVKit.mm:
     61            (VideoFullscreenInterfaceAVKit::setVideoFullscreenModel):
     62            (VideoFullscreenInterfaceAVKit::setVideoFullscreenChangeObserver):
     63            (VideoFullscreenInterfaceAVKit::presentingViewController):
     64            (VideoFullscreenInterfaceAVKit::invalidate):
     65            (VideoFullscreenInterfaceAVKit::preparedToExitFullscreen):
     66            (VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
     67            (VideoFullscreenInterfaceAVKit::doSetup):
     68            * platform/mac/VideoFullscreenInterfaceMac.h:
     69            (WebCore::VideoFullscreenInterfaceMac::videoFullscreenModel const):
     70            (WebCore::VideoFullscreenInterfaceMac::videoFullscreenChangeObserver const):
     71            * platform/mac/VideoFullscreenInterfaceMac.mm:
     72            (WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenModel):
     73            (WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenChangeObserver):
     74            (WebCore::VideoFullscreenInterfaceMac::enterFullscreen):
     75            (WebCore::VideoFullscreenInterfaceMac::invalidate):
     76
    1772019-03-27  Alan Coon  <alancoon@apple.com>
    278
  • branches/safari-607-branch/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h

    r237266 r243579  
    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() { };
  • branches/safari-607-branch/Source/WebCore/platform/cocoa/VideoFullscreenModel.h

    r238528 r243579  
    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() { };
  • branches/safari-607-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h

    r238528 r243579  
    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.
  • branches/safari-607-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm

    r239255 r243579  
    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
     
    772772        m_videoFullscreenModel->removeClient(*this);
    773773
    774     m_videoFullscreenModel = model;
     774    m_videoFullscreenModel = makeWeakPtr(model);
    775775
    776776    if (m_videoFullscreenModel) {
     
    791791void VideoFullscreenInterfaceAVKit::setVideoFullscreenChangeObserver(VideoFullscreenChangeObserver* observer)
    792792{
    793     m_fullscreenChangeObserver = observer;
     793    m_fullscreenChangeObserver = makeWeakPtr(observer);
    794794}
    795795
     
    842842UIViewController *VideoFullscreenInterfaceAVKit::presentingViewController()
    843843{
    844     auto *controller = videoFullscreenModel()->presentingViewController();
     844    auto *controller = videoFullscreenModel() ? videoFullscreenModel()->presentingViewController() : nil;
    845845    if (!controller)
    846846        controller = fallbackViewController(m_parentView.get());
     
    936936void VideoFullscreenInterfaceAVKit::invalidate()
    937937{
    938     m_videoFullscreenModel = nil;
    939     m_fullscreenChangeObserver = nil;
     938    m_videoFullscreenModel = nullptr;
     939    m_fullscreenChangeObserver = nullptr;
    940940   
    941941    cleanupFullscreen();
     
    975975
    976976    m_waitingForPreparedToExit = false;
    977     m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, true);
     977    ASSERT(m_videoFullscreenModel);
     978    if (m_videoFullscreenModel)
     979        m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, true);
    978980#endif
    979981}
     
    11441146   
    11451147    BOOL finished = reason == ExitFullScreenReason::DoneButtonTapped || reason == ExitFullScreenReason::PinchGestureHandled;
    1146     m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, finished);
     1148    ASSERT(m_videoFullscreenModel);
     1149    if (m_videoFullscreenModel)
     1150        m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, finished);
    11471151
    11481152    return false;
     
    12511255
    12521256#if PLATFORM(WATCHOS)
    1253     m_viewController = videoFullscreenModel()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController);
     1257    m_viewController = videoFullscreenModel() ? videoFullscreenModel()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController) : nil;
    12541258#endif
    12551259
  • branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h

    r236748 r243579  
    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;
  • branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm

    r241077 r243579  
    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.