Diff
Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/ChangeLog 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog 2019-03-27 23:44:04 UTC (rev 243581)
@@ -1,5 +1,81 @@
2019-03-27 Alan Coon <[email protected]>
+ Cherry-pick r243337. rdar://problem/49307958
+
+ Hardening: Use WeakPtrs in PlaybackSessionInterface{Mac,AVKit}
+ https://bugs.webkit.org/show_bug.cgi?id=195935
+ <rdar://problem/49007015>
+
+ Reviewed by Eric Carlson.
+
+ The PlaybackSessionInterface{Mac,AVKit} implementations store their playback session model
+ and playback controls manager 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/PlaybackSessionModel.h:
+ * platform/ios/PlaybackSessionInterfaceAVKit.h:
+ * platform/ios/PlaybackSessionInterfaceAVKit.mm:
+ (WebCore::PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit):
+ (WebCore::playbackSessionModel const): Moved to implementation since WEBCORE_EXPORT is not
+ supposed to be used with inline methods.
+ * platform/mac/PlaybackSessionInterfaceMac.h:
+ * platform/mac/PlaybackSessionInterfaceMac.mm:
+ (WebCore::PlaybackSessionInterfaceMac::PlaybackSessionInterfaceMac):
+ (WebCore::PlaybackSessionInterfaceMac::playbackSessionModel const):
+ (WebCore::PlaybackSessionInterfaceMac::beginScrubbing):
+ (WebCore::PlaybackSessionInterfaceMac::endScrubbing):
+ (WebCore::PlaybackSessionInterfaceMac::playBackControlsManager):
+ * platform/mac/VideoFullscreenInterfaceMac.mm:
+ (WebCore::VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac):
+ * platform/mac/WebPlaybackControlsManager.mm:
+ (-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
+ (-[WebPlaybackControlsManager setCurrentAudioTouchBarMediaSelectionOption:]):
+ (-[WebPlaybackControlsManager setCurrentLegibleTouchBarMediaSelectionOption:]):
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243337 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-03-21 Brent Fulgham <[email protected]>
+
+ Hardening: Use WeakPtrs in PlaybackSessionInterface{Mac,AVKit}
+ https://bugs.webkit.org/show_bug.cgi?id=195935
+ <rdar://problem/49007015>
+
+ Reviewed by Eric Carlson.
+
+ The PlaybackSessionInterface{Mac,AVKit} implementations store their playback session model
+ and playback controls manager 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/PlaybackSessionModel.h:
+ * platform/ios/PlaybackSessionInterfaceAVKit.h:
+ * platform/ios/PlaybackSessionInterfaceAVKit.mm:
+ (WebCore::PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit):
+ (WebCore::playbackSessionModel const): Moved to implementation since WEBCORE_EXPORT is not
+ supposed to be used with inline methods.
+ * platform/mac/PlaybackSessionInterfaceMac.h:
+ * platform/mac/PlaybackSessionInterfaceMac.mm:
+ (WebCore::PlaybackSessionInterfaceMac::PlaybackSessionInterfaceMac):
+ (WebCore::PlaybackSessionInterfaceMac::playbackSessionModel const):
+ (WebCore::PlaybackSessionInterfaceMac::beginScrubbing):
+ (WebCore::PlaybackSessionInterfaceMac::endScrubbing):
+ (WebCore::PlaybackSessionInterfaceMac::playBackControlsManager):
+ * platform/mac/VideoFullscreenInterfaceMac.mm:
+ (WebCore::VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac):
+ * platform/mac/WebPlaybackControlsManager.mm:
+ (-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
+ (-[WebPlaybackControlsManager setCurrentAudioTouchBarMediaSelectionOption:]):
+ (-[WebPlaybackControlsManager setCurrentLegibleTouchBarMediaSelectionOption:]):
+
+2019-03-27 Alan Coon <[email protected]>
+
Cherry-pick r243331. rdar://problem/49308068
Do not insert the first-letter anonymous container until after we've constructed the first-letter renderer.
Modified: branches/safari-607-branch/Source/WebCore/platform/cocoa/PlaybackSessionModel.h (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/platform/cocoa/PlaybackSessionModel.h 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/platform/cocoa/PlaybackSessionModel.h 2019-03-27 23:44:04 UTC (rev 243581)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
#include <wtf/Forward.h>
#include <wtf/Ref.h>
#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -37,7 +38,7 @@
class PlaybackSessionModelClient;
struct MediaSelectionOption;
-class PlaybackSessionModel {
+class PlaybackSessionModel : public CanMakeWeakPtr<PlaybackSessionModel> {
public:
virtual ~PlaybackSessionModel() { };
virtual void addClient(PlaybackSessionModelClient&) = 0;
Modified: branches/safari-607-branch/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h 2019-03-27 23:44:04 UTC (rev 243581)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -62,7 +62,7 @@
return adoptRef(*new PlaybackSessionInterfaceAVKit(model));
}
virtual ~PlaybackSessionInterfaceAVKit();
- PlaybackSessionModel* playbackSessionModel() const { return m_playbackSessionModel; }
+ PlaybackSessionModel* playbackSessionModel() const;
// PlaybackSessionModelClient
WEBCORE_EXPORT void durationChanged(double) override;
@@ -86,7 +86,7 @@
WEBCORE_EXPORT PlaybackSessionInterfaceAVKit(PlaybackSessionModel&);
RetainPtr<WebAVPlayerController> m_playerController;
- PlaybackSessionModel* m_playbackSessionModel { nullptr };
+ WeakPtr<PlaybackSessionModel> m_playbackSessionModel;
};
}
Modified: branches/safari-607-branch/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm 2019-03-27 23:44:04 UTC (rev 243581)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -51,7 +51,7 @@
PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit(PlaybackSessionModel& model)
: m_playerController(adoptNS([[WebAVPlayerController alloc] init]))
- , m_playbackSessionModel(&model)
+ , m_playbackSessionModel(makeWeakPtr(model))
{
model.addClient(*this);
[m_playerController setPlaybackSessionInterface:this];
@@ -77,6 +77,11 @@
invalidate();
}
+PlaybackSessionModel* playbackSessionModel() const
+{
+ return m_playbackSessionModel.get();
+}
+
void PlaybackSessionInterfaceAVKit::durationChanged(double duration)
{
WebAVPlayerController* playerController = m_playerController.get();
Modified: branches/safari-607-branch/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.h (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.h 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.h 2019-03-27 23:44:04 UTC (rev 243581)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +32,8 @@
#include "PlaybackSessionModel.h"
#include <wtf/RefCounted.h>
#include <wtf/RetainPtr.h>
+#include <wtf/WeakObjCPtr.h>
+#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
OBJC_CLASS WebPlaybackControlsManager;
@@ -74,9 +76,9 @@
private:
PlaybackSessionInterfaceMac(PlaybackSessionModel&);
- PlaybackSessionModel* m_playbackSessionModel { nullptr };
+ WeakPtr<PlaybackSessionModel> m_playbackSessionModel;
#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
- WebPlaybackControlsManager *m_playbackControlsManager { nullptr };
+ WeakObjCPtr<WebPlaybackControlsManager> m_playbackControlsManager;
void updatePlaybackControlsManagerTiming(double currentTime, double anchorTime, double playbackRate, bool isPlaying);
#endif
Modified: branches/safari-607-branch/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.mm (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.mm 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.mm 2019-03-27 23:44:04 UTC (rev 243581)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -52,7 +52,7 @@
}
PlaybackSessionInterfaceMac::PlaybackSessionInterfaceMac(PlaybackSessionModel& model)
- : m_playbackSessionModel(&model)
+ : m_playbackSessionModel(makeWeakPtr(model))
{
}
@@ -63,7 +63,7 @@
PlaybackSessionModel* PlaybackSessionInterfaceMac::playbackSessionModel() const
{
- return m_playbackSessionModel;
+ return m_playbackSessionModel.get();
}
void PlaybackSessionInterfaceMac::durationChanged(double duration)
@@ -110,12 +110,14 @@
#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
updatePlaybackControlsManagerTiming(m_playbackSessionModel ? m_playbackSessionModel->currentTime() : 0, [[NSProcessInfo processInfo] systemUptime], 0, false);
#endif
- playbackSessionModel()->beginScrubbing();
+ if (auto* model = playbackSessionModel())
+ model->beginScrubbing();
}
void PlaybackSessionInterfaceMac::endScrubbing()
{
- playbackSessionModel()->endScrubbing();
+ if (auto* model = playbackSessionModel())
+ model->endScrubbing();
}
#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
@@ -214,7 +216,7 @@
WebPlaybackControlsManager *PlaybackSessionInterfaceMac::playBackControlsManager()
{
- return m_playbackControlsManager;
+ return m_playbackControlsManager.getAutoreleased();
}
void PlaybackSessionInterfaceMac::setPlayBackControlsManager(WebPlaybackControlsManager *manager)
Modified: branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm 2019-03-27 23:44:04 UTC (rev 243581)
@@ -366,8 +366,8 @@
VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac()
{
- if (m_playbackSessionInterface->playbackSessionModel())
- m_playbackSessionInterface->playbackSessionModel()->removeClient(*this);
+ if (auto* model = m_playbackSessionInterface->playbackSessionModel())
+ model->removeClient(*this);
if (m_videoFullscreenModel)
m_videoFullscreenModel->removeClient(*this);
}
Modified: branches/safari-607-branch/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm (243580 => 243581)
--- branches/safari-607-branch/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm 2019-03-27 23:44:01 UTC (rev 243580)
+++ branches/safari-607-branch/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm 2019-03-27 23:44:04 UTC (rev 243581)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -94,7 +94,8 @@
{
UNUSED_PARAM(toleranceBefore);
UNUSED_PARAM(toleranceAfter);
- _playbackSessionInterfaceMac->playbackSessionModel()->seekToTime(time);
+ if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel())
+ model->seekToTime(time);
}
- (void)cancelThumbnailAndAudioAmplitudeSampleGeneration
@@ -193,7 +194,8 @@
if (audioMediaSelectionOption && _audioTouchBarMediaSelectionOptions)
index = [_audioTouchBarMediaSelectionOptions indexOfObject:audioMediaSelectionOption];
- _playbackSessionInterfaceMac->playbackSessionModel()->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
+ if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel())
+ model->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
}
- (NSArray<AVTouchBarMediaSelectionOption *> *)legibleTouchBarMediaSelectionOptions
@@ -223,7 +225,8 @@
if (legibleMediaSelectionOption && _legibleTouchBarMediaSelectionOptions)
index = [_legibleTouchBarMediaSelectionOptions indexOfObject:legibleMediaSelectionOption];
- _playbackSessionInterfaceMac->playbackSessionModel()->selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
+ if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel())
+ model->selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
}
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300