Title: [295620] trunk/Source
- Revision
- 295620
- Author
- d...@apple.com
- Date
- 2022-06-16 18:11:03 -0700 (Thu, 16 Jun 2022)
Log Message
Clean up code that protects volume from being set on iOS
https://bugs.webkit.org/show_bug.cgi?id=241657
<rdar://problem/95252820>
Reviewed by Eric Carlson.
The code to protect HTMLMediaElement.volume from being writable is guarded
by some PLATFORM(IOS_FAMILY) tests. Make this a
HAVE(MEDIA_VOLUME_PER_ELEMENT) test so it can be expanded a bit easier.
* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setVolume):
(WebCore::HTMLMediaElement::updateVolume):
(WebCore::HTMLMediaElement::cancelPendingTasks):
(WebCore::HTMLMediaElement::mediaVolumeDidChange):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVolume):
Canonical link: https://commits.webkit.org/251625@main
Modified Paths
Diff
Modified: trunk/Source/WTF/wtf/PlatformHave.h (295619 => 295620)
--- trunk/Source/WTF/wtf/PlatformHave.h 2022-06-17 00:51:38 UTC (rev 295619)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2022-06-17 01:11:03 UTC (rev 295620)
@@ -1256,3 +1256,8 @@
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000)
#define HAVE_POWERLOG_TASK_MODE_QUERY 1
#endif
+
+#if !PLATFORM(IOS_FAMILY)
+#define HAVE_MEDIA_VOLUME_PER_ELEMENT 1
+#endif
+
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (295619 => 295620)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2022-06-17 00:51:38 UTC (rev 295619)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2022-06-17 01:11:03 UTC (rev 295620)
@@ -3924,7 +3924,7 @@
if (m_volume == volume)
return { };
-#if !PLATFORM(IOS_FAMILY)
+#if HAVE(MEDIA_VOLUME_PER_ELEMENT)
if (volume && processingUserGestureForMedia())
removeBehaviorRestrictionsAfterFirstUserGesture(MediaElementSession::AllRestrictions & ~MediaElementSession::RequireUserGestureToControlControlsManager);
@@ -5610,14 +5610,7 @@
{
if (!m_player)
return;
-#if PLATFORM(IOS_FAMILY)
- // Only the user can change audio volume so update the cached volume and post the changed event.
- float volume = m_player->volume();
- if (m_volume != volume) {
- m_volume = volume;
- scheduleEvent(eventNames().volumechangeEvent);
- }
-#else
+#if HAVE(MEDIA_VOLUME_PER_ELEMENT)
// Avoid recursion when the player reports volume changes.
if (!processingMediaPlayerCallback()) {
m_player->setMuted(effectiveMuted());
@@ -5625,7 +5618,14 @@
}
document().updateIsPlayingMedia();
-#endif // PLATFORM(IOS_FAMILY)
+#else
+ // Only the user can change audio volume so update the cached volume and post the changed event.
+ float volume = m_player->volume();
+ if (m_volume != volume) {
+ m_volume = volume;
+ scheduleEvent(eventNames().volumechangeEvent);
+ }
+#endif
}
void HTMLMediaElement::scheduleUpdatePlayState()
@@ -5817,7 +5817,7 @@
m_resumeTaskCancellationGroup.cancel();
m_seekTaskCancellationGroup.cancel();
m_playbackControlsManagerBehaviorRestrictionsTaskCancellationGroup.cancel();
-#if PLATFORM(IOS_FAMILY)
+#if !HAVE(MEDIA_VOLUME_PER_ELEMENT)
m_volumeRevertTaskCancellationGroup.cancel();
#endif
}
@@ -6071,8 +6071,8 @@
void HTMLMediaElement::mediaVolumeDidChange()
{
- // FIXME: We should try to reconcile this so there's no difference for PLATFORM(IOS_FAMILY).
-#if !PLATFORM(IOS_FAMILY)
+ // FIXME: We should try to reconcile this so there's no difference for !HAVE(MEDIA_VOLUME_PER_ELEMENT).
+#if HAVE(MEDIA_VOLUME_PER_ELEMENT)
INFO_LOG(LOGIDENTIFIER);
updateVolume();
#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (295619 => 295620)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2022-06-17 00:51:38 UTC (rev 295619)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2022-06-17 01:11:03 UTC (rev 295620)
@@ -1590,7 +1590,7 @@
void MediaPlayerPrivateAVFoundationObjC::setVolume(float volume)
{
-#if PLATFORM(IOS_FAMILY)
+#if !HAVE(MEDIA_VOLUME_PER_ELEMENT)
UNUSED_PARAM(volume);
return;
#else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes