Skip to content

Commit

Permalink
Remove unnecessary headers including other headers
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259499
rdar://112862626

Reviewed by Tim Horton.

The WebPageProxy::broadcastFrameRemovalToOtherProcesses message was the only reason ProcessIdentifier.h
was included from the widely-included WebPageProxy.h.  Use the sender's connection instead of the sender's ProcessID.

DecoderOrError and LayerCreationProperties required a few includes just for the implicit constructors and destructors.
Make them explicit instead of including an unnecessary header.

Doing this exposed an unnecessary copy in RemoteLayerTreeContext::buildTransaction.  Add some Vector support
to make it a move instead of a copy.

* Source/WTF/wtf/Vector.h:
(WTF::copyToVector):
(WTF::moveToVectorOf):
(WTF::moveToVector):
* Source/WebKit/NetworkProcess/storage/LocalStorageManager.cpp:
* Source/WebKit/Platform/IPC/Connection.cpp:
* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm:
* Source/WebKit/Platform/IPC/unix/UnixMessage.h:
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties):
* Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp:
(WebKit::AuxiliaryProcessProxy::createMobileGestaltSandboxExtensionIfNeeded const):
* Source/WebKit/UIProcess/AuxiliaryProcessProxy.h:
* Source/WebKit/UIProcess/Cocoa/AuxiliaryProcessProxyCocoa.mm:
* Source/WebKit/UIProcess/GPU/GPUProcessProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::broadcastFrameRemovalToOtherProcesses):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::broadcastFrameRemovalToOtherProcesses):
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::buildTransaction):

Canonical link: https://commits.webkit.org/266333@main
  • Loading branch information
achristensen07 committed Jul 26, 2023
1 parent 934e4c3 commit 96d6de2
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 34 deletions.
20 changes: 17 additions & 3 deletions Source/WTF/wtf/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -1897,14 +1897,28 @@ inline auto copyToVectorOf(const Collection& collection) -> Vector<DestinationIt
}

template<typename Collection>
struct CopyToVectorResult {
struct CopyOrMoveToVectorResult {
using Type = typename std::remove_cv<typename CollectionInspector<Collection>::SourceItemType>::type;
};

template<typename Collection>
inline auto copyToVector(const Collection& collection) -> Vector<typename CopyToVectorResult<Collection>::Type>
inline Vector<typename CopyOrMoveToVectorResult<Collection>::Type> copyToVector(const Collection& collection)
{
return copyToVectorOf<typename CopyToVectorResult<Collection>::Type>(collection);
return copyToVectorOf<typename CopyOrMoveToVectorResult<Collection>::Type>(collection);
}

template<typename DestinationItemType, typename Collection>
inline auto moveToVectorOf(Collection&& collection) -> Vector<DestinationItemType>
{
return WTF::map(collection, [] (auto&& v) -> DestinationItemType {
return WTFMove(v);
});
}

template<typename Collection>
inline Vector<typename CopyOrMoveToVectorResult<Collection>::Type> moveToVector(Collection&& collection)
{
return moveToVectorOf<typename CopyOrMoveToVectorResult<Collection>::Type>(collection);
}

} // namespace WTF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "SQLiteStorageArea.h"
#include "StorageAreaRegistry.h"
#include <WebCore/SecurityOriginData.h>
#include <wtf/FileSystem.h>

namespace WebKit {

Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/Platform/IPC/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1512,4 +1512,8 @@ const char* errorAsString(Error error)
return "";
}

Connection::DecoderOrError::DecoderOrError(DecoderOrError&&) = default;

Connection::DecoderOrError::~DecoderOrError() = default;

} // namespace IPC
6 changes: 4 additions & 2 deletions Source/WebKit/Platform/IPC/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

#pragma once

#include "Decoder.h"
#include "Encoder.h"
#include "MessageReceiveQueueMap.h"
#include "MessageReceiver.h"
#include "ReceiverMatcher.h"
Expand Down Expand Up @@ -148,6 +146,8 @@ template<typename AsyncReplyResult> struct AsyncReplyError {
static AsyncReplyResult create() { return AsyncReplyResult { }; };
};

class Decoder;
class Encoder;
class MachMessage;
class UnixMessage;
class WorkQueueMessageReceiver;
Expand Down Expand Up @@ -331,6 +331,8 @@ class Connection : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<Connec
{
ASSERT(error != Error::NoError);
}
DecoderOrError(DecoderOrError&&);
~DecoderOrError();
};

static RefPtr<Connection> connection(UniqueID);
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import "Connection.h"

#import "DataReference.h"
#import "Encoder.h"
#import "IPCUtilities.h"
#import "ImportanceAssertion.h"
#import "Logging.h"
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/Platform/IPC/unix/UnixMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#pragma once

#include "Attachment.h"
#include "Encoder.h"
#include <wtf/Vector.h>

namespace IPC {
Expand Down
26 changes: 12 additions & 14 deletions Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@
#include "RemoteLayerBackingStore.h"
#include "TransactionID.h"
#include <WebCore/Color.h>
#include <WebCore/FilterOperations.h>
#include <WebCore/FloatPoint3D.h>
#include <WebCore/FloatSize.h>
#include <WebCore/HTMLMediaElementIdentifier.h>
#include <WebCore/LayoutMilestone.h>
#include <WebCore/MediaPlayerEnums.h>
#include <WebCore/Model.h>
#include <WebCore/PlatformCALayer.h>
#include <WebCore/ScrollTypes.h>
#include <WebCore/TransformationMatrix.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/text/StringHash.h>
Expand All @@ -57,11 +54,6 @@
#include <WebCore/AcceleratedEffectValues.h>
#endif

namespace IPC {
class Decoder;
class Encoder;
}

namespace WebKit {

struct LayerProperties;
Expand Down Expand Up @@ -93,18 +85,24 @@ class RemoteLayerTreeTransaction {
WebCore::FloatSize initialSize;
WebCore::FloatSize naturalSize;
};

WebCore::PlatformLayerIdentifier layerID;
WebCore::PlatformCALayer::LayerType type { WebCore::PlatformCALayer::LayerTypeLayer };
std::optional<VideoElementData> videoElementData;
std::variant<
using AdditionalData = std::variant<
NoAdditionalData, // PlatformCALayerRemote and PlatformCALayerRemoteTiledBacking
CustomData, // PlatformCALayerRemoteCustom
#if ENABLE(MODEL_ELEMENT)
Ref<WebCore::Model>, // PlatformCALayerRemoteModelHosting
#endif
WebCore::LayerHostingContextIdentifier // PlatformCALayerRemoteHost
> additionalData;
>;

WebCore::PlatformLayerIdentifier layerID;
WebCore::PlatformCALayer::LayerType type { WebCore::PlatformCALayer::LayerTypeLayer };
std::optional<VideoElementData> videoElementData;
AdditionalData additionalData;

LayerCreationProperties();
LayerCreationProperties(WebCore::PlatformLayerIdentifier, WebCore::PlatformCALayer::LayerType, std::optional<VideoElementData>&&, AdditionalData&&);
LayerCreationProperties(LayerCreationProperties&&);
LayerCreationProperties& operator=(LayerCreationProperties&&);

std::optional<WebCore::LayerHostingContextIdentifier> hostIdentifier() const;
uint32_t hostingContextID() const;
Expand Down
12 changes: 12 additions & 0 deletions Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,18 @@ static void dumpChangedLayers(TextStream& ts, const LayerPropertiesMap& changedL
ChangedLayers::ChangedLayers(LayerPropertiesMap&& changedLayerProperties)
: changedLayerProperties(WTFMove(changedLayerProperties)) { }

RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties() = default;

RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties(LayerCreationProperties&&) = default;

auto RemoteLayerTreeTransaction::LayerCreationProperties::operator=(LayerCreationProperties&&) -> LayerCreationProperties& = default;

RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties(WebCore::PlatformLayerIdentifier layerID, WebCore::PlatformCALayer::LayerType type, std::optional<RemoteLayerTreeTransaction::LayerCreationProperties::VideoElementData>&& videoElementData, RemoteLayerTreeTransaction::LayerCreationProperties::AdditionalData&& additionalData)
: layerID(layerID)
, type(type)
, videoElementData(WTFMove(videoElementData))
, additionalData(WTFMove(additionalData)) { }

std::optional<WebCore::LayerHostingContextIdentifier> RemoteLayerTreeTransaction::LayerCreationProperties::hostIdentifier() const
{
if (auto* identifier = std::get_if<WebCore::LayerHostingContextIdentifier>(&additionalData))
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "config.h"
#include "AuxiliaryProcessProxy.h"

#include "AuxiliaryProcessCreationParameters.h"
#include "AuxiliaryProcessMessages.h"
#include "Logging.h"
#include "OverrideLanguages.h"
Expand Down Expand Up @@ -476,7 +477,7 @@ AuxiliaryProcessCreationParameters AuxiliaryProcessProxy::auxiliaryProcessParame
return parameters;
}

std::optional<SandboxExtension::Handle> AuxiliaryProcessProxy::createMobileGestaltSandboxExtensionIfNeeded() const
std::optional<SandboxExtensionHandle> AuxiliaryProcessProxy::createMobileGestaltSandboxExtensionIfNeeded() const
{
#if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
if (_MGCacheValid())
Expand Down
11 changes: 8 additions & 3 deletions Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,29 @@

#pragma once

#include "AuxiliaryProcessCreationParameters.h"
#include "Connection.h"
#include "MessageReceiverMap.h"
#include "ProcessLauncher.h"
#include "ProcessThrottler.h"
#include "ResponsivenessTimer.h"
#include "SandboxExtension.h"
#include <WebCore/ProcessIdentifier.h>
#include <memory>
#include <wtf/ProcessID.h>
#include <wtf/SystemTracing.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/UniqueRef.h>

namespace WebCore {
class SharedBuffer;
}

namespace WebKit {

class ProcessThrottler;
class ProcessAssertion;
class SandboxExtensionHandle;

struct AuxiliaryProcessCreationParameters;

class AuxiliaryProcessProxy : public ThreadSafeRefCounted<AuxiliaryProcessProxy, WTF::DestructionThread::MainRunLoop>, public ResponsivenessTimer::Client, private ProcessLauncher::Client, public IPC::Connection::Client {
WTF_MAKE_NONCOPYABLE(AuxiliaryProcessProxy);
Expand Down Expand Up @@ -161,7 +166,7 @@ class AuxiliaryProcessProxy : public ThreadSafeRefCounted<AuxiliaryProcessProxy,

bool operator==(const AuxiliaryProcessProxy& other) const { return (this == &other); }

std::optional<SandboxExtension::Handle> createMobileGestaltSandboxExtensionIfNeeded() const;
std::optional<SandboxExtensionHandle> createMobileGestaltSandboxExtensionIfNeeded() const;

#if USE(RUNNINGBOARD)
void wakeUpTemporarilyForIPC();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#import "config.h"
#import "AuxiliaryProcessProxy.h"

#import <WebCore/SharedBuffer.h>
#import <WebCore/WebMAudioUtilitiesCocoa.h>
#import <wtf/cocoa/VectorCocoa.h>

Expand Down
7 changes: 5 additions & 2 deletions Source/WebKit/UIProcess/GPU/GPUProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "AuxiliaryProcessProxy.h"
#include "ProcessLauncher.h"
#include "ProcessTerminationReason.h"
#include "ProcessThrottler.h"
#include "ProcessThrottlerClient.h"
#include "ShareableBitmap.h"
Expand Down Expand Up @@ -58,8 +57,12 @@ class SecurityOriginData;

namespace WebKit {

enum class ProcessTerminationReason : uint8_t;

class SandboxExtensionHandle;
class WebProcessProxy;
class WebsiteDataStore;

struct GPUProcessConnectionParameters;
struct GPUProcessCreationParameters;

Expand Down Expand Up @@ -123,7 +126,7 @@ class GPUProcessProxy final : public AuxiliaryProcessProxy, private ProcessThrot

#if PLATFORM(COCOA) && ENABLE(REMOTE_INSPECTOR)
bool hasSentGPUToolsSandboxExtensions() const { return m_hasSentGPUToolsSandboxExtensions; }
static Vector<SandboxExtension::Handle> createGPUToolsSandboxExtensionHandlesIfNeeded();
static Vector<SandboxExtensionHandle> createGPUToolsSandboxExtensionHandlesIfNeeded();
#endif

private:
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5862,10 +5862,10 @@ void WebPageProxy::createRemoteSubframesInOtherProcesses(WebFrameProxy& newFrame
});
}

void WebPageProxy::broadcastFrameRemovalToOtherProcesses(WebCore::ProcessIdentifier processID, WebCore::FrameIdentifier frameID)
void WebPageProxy::broadcastFrameRemovalToOtherProcesses(IPC::Connection& connection, WebCore::FrameIdentifier frameID)
{
forEachWebContentProcess([&](auto& webProcess) {
if (webProcess.coreProcessIdentifier() == processID)
if (!webProcess.hasConnection() || webProcess.connection() == &connection)
return;
webProcess.send(Messages::WebPage::FrameWasRemovedInAnotherProcess(frameID), webPageID());
});
Expand Down
3 changes: 1 addition & 2 deletions Source/WebKit/UIProcess/WebPageProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "APIObject.h"
#include "MessageReceiver.h"
#include "MessageSender.h"
#include <WebCore/ProcessIdentifier.h>
#include <WebCore/SleepDisablerIdentifier.h>
#include <wtf/CheckedRef.h>
#include <wtf/ProcessID.h>
Expand Down Expand Up @@ -2174,7 +2173,7 @@ class WebPageProxy final : public API::ObjectImpl<API::Object::Type::Page>, publ
HashMap<WebCore::RegistrableDomain, WeakPtr<RemotePageProxy>> takeRemotePageMap();

void createRemoteSubframesInOtherProcesses(WebFrameProxy&);
void broadcastFrameRemovalToOtherProcesses(WebCore::ProcessIdentifier, WebCore::FrameIdentifier);
void broadcastFrameRemovalToOtherProcesses(IPC::Connection&, WebCore::FrameIdentifier);

void addOpenedPage(WebPageProxy&);
bool hasOpenedPage() const;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/WebPageProxy.messages.in
Original file line number Diff line number Diff line change
Expand Up @@ -632,5 +632,5 @@ messages -> WebPageProxy {
RequestCookieConsent() -> (enum:uint8_t WebCore::CookieConsentDecisionResult result)

DidApplyLinkDecorationFiltering(URL originalURL, URL adjustedURL)
BroadcastFrameRemovalToOtherProcesses(WebCore::ProcessIdentifier processID, WebCore::FrameIdentifier frameID)
BroadcastFrameRemovalToOtherProcesses(WebCore::FrameIdentifier frameID)
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void WebFrameLoaderClient::broadcastFrameRemovalToOtherProcesses()
ASSERT_NOT_REACHED();
return;
}
webPage->send(Messages::WebPageProxy::BroadcastFrameRemovalToOtherProcesses(Process::identifier(), m_frame->frameID()));
webPage->send(Messages::WebPageProxy::BroadcastFrameRemovalToOtherProcesses(m_frame->frameID()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,8 @@
if (paintedAnyBackingStore)
m_nextRenderingUpdateRequiresSynchronousImageDecoding = false;

transaction.setCreatedLayers(copyToVector(m_createdLayers.values()));
transaction.setCreatedLayers(moveToVector(std::exchange(m_createdLayers, { }).values()));
transaction.setDestroyedLayerIDs(WTFMove(m_destroyedLayers));

m_createdLayers.clear();
}

void RemoteLayerTreeContext::layerPropertyChangedWhileBuildingTransaction(PlatformCALayerRemote& layer)
Expand Down

0 comments on commit 96d6de2

Please sign in to comment.