Title: [267599] trunk/Source/WebKit
Revision
267599
Author
[email protected]
Date
2020-09-25 15:09:29 -0700 (Fri, 25 Sep 2020)

Log Message

Replace the usages of (IPC::Attachment fencePort) with IPC::MachPort
https://bugs.webkit.org/show_bug.cgi?id=207683

Reviewed by Daniel Bates.

No new tests, no functional change.

* UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenManagerProxy::setVideoLayerFrame): Replace the
IPC::Attachment argument with a MachSendRight.
* WebProcess/cocoa/VideoFullscreenManager.h:
* WebProcess/cocoa/VideoFullscreenManager.messages.in:
* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::setVideoLayerFrameFenced):
r232451 adds a check for mach port disposition, which is not necessary now.
Because ArgumentCoder<MachSendRight>::decode() provides the check.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setTopContentInset): Replace the IPC::Attachment
argument with a MachSendRight.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setTopContentInsetFenced): Ditto.
r232451 adds a check for mach port disposition, which is not necessary now.
Because ArgumentCoder<MachSendRight>::decode() provides the check.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (267598 => 267599)


--- trunk/Source/WebKit/ChangeLog	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/ChangeLog	2020-09-25 22:09:29 UTC (rev 267599)
@@ -1,3 +1,32 @@
+2020-09-25  Peng Liu  <[email protected]>
+
+        Replace the usages of (IPC::Attachment fencePort) with IPC::MachPort
+        https://bugs.webkit.org/show_bug.cgi?id=207683
+
+        Reviewed by Daniel Bates.
+
+        No new tests, no functional change.
+
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+        (WebKit::VideoFullscreenManagerProxy::setVideoLayerFrame): Replace the
+        IPC::Attachment argument with a MachSendRight.
+        * WebProcess/cocoa/VideoFullscreenManager.h:
+        * WebProcess/cocoa/VideoFullscreenManager.messages.in:
+        * WebProcess/cocoa/VideoFullscreenManager.mm:
+        (WebKit::VideoFullscreenManager::setVideoLayerFrameFenced):
+        r232451 adds a check for mach port disposition, which is not necessary now.
+        Because ArgumentCoder<MachSendRight>::decode() provides the check.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setTopContentInset): Replace the IPC::Attachment
+        argument with a MachSendRight.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setTopContentInsetFenced): Ditto.
+        r232451 adds a check for mach port disposition, which is not necessary now.
+        Because ArgumentCoder<MachSendRight>::decode() provides the check.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2020-09-25  Wenson Hsieh  <[email protected]>
 
         Tweak the names of the GPU process audio/video capture internal feature flags

Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm (267598 => 267599)


--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2020-09-25 22:09:29 UTC (rev 267599)
@@ -788,18 +788,15 @@
 
 void VideoFullscreenManagerProxy::setVideoLayerFrame(PlaybackSessionContextIdentifier contextId, WebCore::FloatRect frame)
 {
-    @autoreleasepool {
 #if PLATFORM(IOS_FAMILY)
-        mach_port_name_t fencePort = [UIWindow _synchronizeDrawingAcrossProcesses];
+    auto fenceSendRight = MachSendRight::adopt([UIWindow _synchronizeDrawingAcrossProcesses]);
 #else
-        MachSendRight fenceSendRight;
-        if (DrawingAreaProxy* drawingArea = m_page->drawingArea())
-            fenceSendRight = drawingArea->createFence();
-        mach_port_name_t fencePort = fenceSendRight.leakSendRight();
+    MachSendRight fenceSendRight;
+    if (DrawingAreaProxy* drawingArea = m_page->drawingArea())
+        fenceSendRight = drawingArea->createFence();
 #endif
 
-        m_page->send(Messages::VideoFullscreenManager::SetVideoLayerFrameFenced(contextId, frame, IPC::Attachment(fencePort, MACH_MSG_TYPE_MOVE_SEND)));
-    }
+    m_page->send(Messages::VideoFullscreenManager::SetVideoLayerFrameFenced(contextId, frame, fenceSendRight));
 }
 
 void VideoFullscreenManagerProxy::setVideoLayerGravity(PlaybackSessionContextIdentifier contextId, WebCore::MediaPlayerEnums::VideoGravity gravity)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (267598 => 267599)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-09-25 22:09:29 UTC (rev 267599)
@@ -1821,10 +1821,7 @@
     if (!hasRunningProcess())
         return;
 #if PLATFORM(COCOA)
-    MachSendRight fence = m_drawingArea->createFence();
-
-    auto fenceAttachment = IPC::Attachment(fence.leakSendRight(), MACH_MSG_TYPE_MOVE_SEND);
-    send(Messages::WebPage::SetTopContentInsetFenced(contentInset, fenceAttachment));
+    send(Messages::WebPage::SetTopContentInsetFenced(contentInset, m_drawingArea->createFence()));
 #else
     send(Messages::WebPage::SetTopContentInset(contentInset));
 #endif

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (267598 => 267599)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-09-25 22:09:29 UTC (rev 267599)
@@ -3173,18 +3173,10 @@
 }
 
 #if PLATFORM(COCOA)
-void WebPage::setTopContentInsetFenced(float contentInset, IPC::Attachment fencePort)
+void WebPage::setTopContentInsetFenced(float contentInset, const WTF::MachSendRight& machSendRight)
 {
-    if (fencePort.disposition() != MACH_MSG_TYPE_MOVE_SEND) {
-        LOG(Layers, "WebPage::setTopContentInsetFenced(%g, fencePort) Received an invalid fence port: %d, disposition: %d", contentInset, fencePort.port(), fencePort.disposition());
-        return;
-    }
-
-    m_drawingArea->addFence(MachSendRight::create(fencePort.port()));
-
+    m_drawingArea->addFence(machSendRight);
     setTopContentInset(contentInset);
-
-    deallocateSendRightSafely(fencePort.port());
 }
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (267598 => 267599)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-09-25 22:09:29 UTC (rev 267599)
@@ -1531,7 +1531,7 @@
     void setBackgroundColor(const Optional<WebCore::Color>&);
 
 #if PLATFORM(COCOA)
-    void setTopContentInsetFenced(float, IPC::Attachment);
+    void setTopContentInsetFenced(float, const WTF::MachSendRight&);
 #endif
     void setTopContentInset(float);
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (267598 => 267599)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-09-25 22:09:29 UTC (rev 267599)
@@ -34,7 +34,7 @@
     TestProcessIncomingSyncMessagesWhenWaitingForSyncReply() -> (bool handled) Synchronous
 
 #if PLATFORM(COCOA)
-    SetTopContentInsetFenced(float contentInset, IPC::Attachment fencePort)
+    SetTopContentInsetFenced(float contentInset, MachSendRight machSendRight)
 #endif
     SetTopContentInset(float contentInset)
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h (267598 => 267599)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h	2020-09-25 22:09:29 UTC (rev 267599)
@@ -40,12 +40,15 @@
 #include <wtf/RefPtr.h>
 
 namespace IPC {
-class Attachment;
 class Connection;
 class Decoder;
 class MessageReceiver;
 }
 
+namespace WTF {
+class MachSendRight;
+}
+
 namespace WebCore {
 class FloatSize;
 class Node;
@@ -151,7 +154,7 @@
     void didExitFullscreen(PlaybackSessionContextIdentifier);
     void didEnterFullscreen(PlaybackSessionContextIdentifier, Optional<WebCore::FloatSize>);
     void didCleanupFullscreen(PlaybackSessionContextIdentifier);
-    void setVideoLayerFrameFenced(PlaybackSessionContextIdentifier, WebCore::FloatRect bounds, IPC::Attachment fencePort);
+    void setVideoLayerFrameFenced(PlaybackSessionContextIdentifier, WebCore::FloatRect bounds, const WTF::MachSendRight&);
     void setVideoLayerGravityEnum(PlaybackSessionContextIdentifier, unsigned gravity);
     void fullscreenModeChanged(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
     void fullscreenWillReturnToInline(PlaybackSessionContextIdentifier, bool isPageVisible);

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in (267598 => 267599)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in	2020-09-25 22:09:29 UTC (rev 267599)
@@ -31,7 +31,7 @@
     DidExitFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
     DidEnterFullscreen(WebKit::PlaybackSessionContextIdentifier contextId, Optional<WebCore::FloatSize> size)
     DidCleanupFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
-    SetVideoLayerFrameFenced(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
+    SetVideoLayerFrameFenced(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatRect bounds, MachSendRight machSendRight)
     SetVideoLayerGravityEnum(WebKit::PlaybackSessionContextIdentifier contextId, unsigned gravity)
     FullscreenModeChanged(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
     FullscreenWillReturnToInline(WebKit::PlaybackSessionContextIdentifier contextId, bool isPageVisible)

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (267598 => 267599)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2020-09-25 22:03:38 UTC (rev 267598)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2020-09-25 22:09:29 UTC (rev 267599)
@@ -543,15 +543,10 @@
     ensureModel(contextId).requestRouteSharingPolicyAndContextUID(WTFMove(reply));
 }
     
-void VideoFullscreenManager::setVideoLayerFrameFenced(PlaybackSessionContextIdentifier contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
+void VideoFullscreenManager::setVideoLayerFrameFenced(PlaybackSessionContextIdentifier contextId, WebCore::FloatRect bounds, const WTF::MachSendRight& machSendRight)
 {
     LOG(Fullscreen, "VideoFullscreenManager::setVideoLayerFrameFenced(%p, %x)", this, contextId);
 
-    if (fencePort.disposition() != MACH_MSG_TYPE_MOVE_SEND) {
-        LOG(Fullscreen, "VideoFullscreenManager::setVideoLayerFrameFenced(%p, %x) Received an invalid fence port: %d, disposition: %d", this, contextId, fencePort.port(), fencePort.disposition());
-        return;
-    }
-
     auto [model, interface] = ensureModelAndInterface(contextId);
 
     if (std::isnan(bounds.x()) || std::isnan(bounds.y()) || std::isnan(bounds.width()) || std::isnan(bounds.height())) {
@@ -560,9 +555,8 @@
     }
     
     if (auto* context = interface->layerHostingContext())
-        context->setFencePort(fencePort.port());
+        context->setFencePort(machSendRight.sendRight());
     model->setVideoLayerFrame(bounds);
-    deallocateSendRightSafely(fencePort.port());
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to