[webkit-changes] [WebKit/WebKit] 9a1b8a: Hardening: Use ThreadSafeWeakPtrs in VideoFullscre...
Jean-Yves Avenard
noreply at github.com
Thu Jun 15 06:18:16 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9a1b8a792aee871c2564489d255b19cd9d218e22
https://github.com/WebKit/WebKit/commit/9a1b8a792aee871c2564489d255b19cd9d218e22
Author: Jean-Yves Avenard <jya at apple.com>
Date: 2023-06-15 (Thu, 15 Jun 2023)
Changed paths:
M Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
M Source/WebCore/PlatformMac.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/dom/EventListener.h
M Source/WebCore/html/HTMLAttachmentElement.cpp
M Source/WebCore/html/HTMLMediaElement.h
M Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
M Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp
M Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.h
R Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h
M Source/WebCore/platform/cocoa/VideoFullscreenModel.h
M Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h
M Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm
M Source/WebCore/platform/cocoa/WebAVPlayerLayer.mm
M Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h
M Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm
M Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
M Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h
M Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm
M Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h
M Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
M Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm
M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.h
M Source/WebKitLegacy/mac/DOM/ObjCEventListener.h
Log Message:
-----------
Hardening: Use ThreadSafeWeakPtrs in VideoFullscreenInterface{Mac,AVKit}
https://bugs.webkit.org/show_bug.cgi?id=258025
rdar://110311635
Reviewed by Youenn Fablet.
The VideoFullscreenInterface{Mac,AVKit} implementations store their fullscreen model
and fullscreen change observer members as bare pointers. The use of WeakPtr
wasn't possible at the time (see webkit.org/b/199698) as the objects are
allocated on the UIThread and use on the WebThread.
So we use the new ThreadSafeWeakPtr instead.
VideoFullscreenInterface{Mac,AVKit} alwas referred to its VideoFullscreenChangeObserver
and VideoFullscreenModel as a pair and always using a single class implementing
both protocols (respectively VideoFullscreenControllerContext and VideoFullscreenModelContext).
We merge the two into a VideoFullscreenModel which now implements
`ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr`.
This solves two problems:
1- there's complexity in implementing a class that inherits from two classes
implementing the same methods (ref()/deref())
2- It simplifies the logic used.
Fly-by: moves default implementation of EventListener::operator==.
No new tests since no changes in behavior.
* Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp:
* Source/WebCore/PlatformMac.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/EventListener.h:
(WebCore::EventListener::operator== const):
* Source/WebCore/html/HTMLAttachmentElement.cpp:
* Source/WebCore/html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::waitForPreparedForInlineThen): Deleted.
* Source/WebCore/inspector/agents/InspectorDOMAgent.cpp:
* Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp:
* Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.h:
* Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h: Removed.
* Source/WebCore/platform/cocoa/VideoFullscreenModel.h:
(WebCore::VideoFullscreenModel::requestUpdateInlineRect):
(WebCore::VideoFullscreenModel::requestVideoContentLayer):
(WebCore::VideoFullscreenModel::returnVideoContentLayer):
(WebCore::VideoFullscreenModel::returnVideoView):
(WebCore::VideoFullscreenModel::didSetupFullscreen):
(WebCore::VideoFullscreenModel::didEnterFullscreen):
(WebCore::VideoFullscreenModel::failedToEnterFullscreen):
(WebCore::VideoFullscreenModel::willExitFullscreen):
(WebCore::VideoFullscreenModel::didExitFullscreen):
(WebCore::VideoFullscreenModel::didCleanupFullscreen):
(WebCore::VideoFullscreenModel::fullscreenMayReturnToInline):
(WebCore::VideoFullscreenModelClient::didExitPictureInPicture):
(WebCore::VideoFullscreenModel::~VideoFullscreenModel): Deleted.
(WebCore::VideoFullscreenModelClient::modelDestroyed): Deleted.
* Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h:
(WebCore::VideoFullscreenModelVideoElement::create): Deleted.
(WebCore::VideoFullscreenModelVideoElement::videoElement const): Deleted.
(WebCore::VideoFullscreenModelVideoElement::setVideoFullscreenLayer): Deleted.
(WebCore::VideoFullscreenModelVideoElement::waitForPreparedForInlineThen): Deleted.
(WebCore::VideoFullscreenModelVideoElement::logClassName const): Deleted.
* Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm:
(WebCore::VideoFullscreenModelVideoElement::VideoListener::VideoListener):
(WebCore::VideoFullscreenModelVideoElement::VideoListener::handleEvent):
(WebCore::VideoFullscreenModelVideoElement::VideoFullscreenModelVideoElement):
(WebCore::VideoFullscreenModelVideoElement::~VideoFullscreenModelVideoElement):
(WebCore::VideoFullscreenModelVideoElement::cleanVideoListeners):
(WebCore::VideoFullscreenModelVideoElement::setVideoElement):
(WebCore::VideoFullscreenModelVideoElement::handleEvent): Deleted.
* Source/WebCore/platform/cocoa/WebAVPlayerLayer.mm:
(-[WebAVPlayerLayer dealloc]):
(-[WebAVPlayerLayer fullscreenModel]):
(-[WebAVPlayerLayer setFullscreenModel:]):
(-[WebAVPlayerLayer resolveBounds]):
(-[WebAVPlayerLayer setVideoGravity:]):
(-[WebAVPlayerLayer loggerPtr]):
* Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h:
* Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm:
(VideoFullscreenInterfaceAVKit::~VideoFullscreenInterfaceAVKit):
(VideoFullscreenInterfaceAVKit::setVideoFullscreenModel):
(VideoFullscreenInterfaceAVKit::presentingViewController):
(VideoFullscreenInterfaceAVKit::cleanupFullscreen):
(VideoFullscreenInterfaceAVKit::invalidate):
(VideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen):
(VideoFullscreenInterfaceAVKit::preparedToExitFullscreen):
(VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStop):
(VideoFullscreenInterfaceAVKit::willStartPictureInPicture):
(VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture): fly-by fix: if we failed to enter PiP
then there would be no need to return to standby fullscreen. So set flag accordingly.
(VideoFullscreenInterfaceAVKit::willStopPictureInPicture):
(VideoFullscreenInterfaceAVKit::didStopPictureInPicture):
(VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
(VideoFullscreenInterfaceAVKit::doSetup):
(VideoFullscreenInterfaceAVKit::finalizeSetup):
(VideoFullscreenInterfaceAVKit::doEnterFullscreen):
(VideoFullscreenInterfaceAVKit::doExitFullscreen):
(VideoFullscreenInterfaceAVKit::returnToStandby):
(VideoFullscreenInterfaceAVKit::setMode):
(VideoFullscreenInterfaceAVKit::clearMode):
(VideoFullscreenInterfaceAVKit::setVideoFullscreenChangeObserver): Deleted.
(VideoFullscreenInterfaceAVKit::modelDestroyed): Deleted.
* Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm:
(VideoFullscreenControllerContext::~VideoFullscreenControllerContext):
(VideoFullscreenControllerContext::didCleanupFullscreen):
(VideoFullscreenControllerContext::setUpFullscreen):
* Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h:
(WebCore::VideoFullscreenInterfaceMac::videoFullscreenModel const):
(WebCore::VideoFullscreenInterfaceMac::videoFullscreenChangeObserver const): Deleted.
* Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm:
(-[WebVideoFullscreenInterfaceMacObjC setUpPIPForVideoView:withFrame:inWindow:]):
(-[WebVideoFullscreenInterfaceMacObjC boundsDidChangeForVideoViewContainer:]):
(-[WebVideoFullscreenInterfaceMacObjC pipShouldClose:]):
(-[WebVideoFullscreenInterfaceMacObjC pipDidClose:]):
(WebCore::VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac):
(WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenModel):
(WebCore::VideoFullscreenInterfaceMac::setMode):
(WebCore::VideoFullscreenInterfaceMac::clearMode):
(WebCore::VideoFullscreenInterfaceMac::setupFullscreen):
(WebCore::VideoFullscreenInterfaceMac::enterFullscreen):
(WebCore::VideoFullscreenInterfaceMac::cleanupFullscreen):
(WebCore::VideoFullscreenInterfaceMac::invalidate):
(WebCore::VideoFullscreenInterfaceMac::requestHideAndExitPiP):
(WebCore::VideoFullscreenInterfaceMac::setVideoFullscreenChangeObserver): Deleted.
* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenManagerProxy::createModelAndInterface):
(WebKit::VideoFullscreenModelContext::~VideoFullscreenModelContext): Deleted.
* Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
(-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.h:
(): Deleted.
* Source/WebKitLegacy/mac/DOM/ObjCEventListener.h: use override keywords.
Canonical link: https://commits.webkit.org/265195@main
More information about the webkit-changes
mailing list