Clean up some includes to improve WebKit2 build speed
https://bugs.webkit.org/show_bug.cgi?id=203071

Reviewed by Wenson Hsieh.

Source/WebCore:

No new tests, just shuffling code around.

* bindings/js/WindowProxy.cpp:
(WebCore::WindowProxy::WindowProxy):
(WebCore::WindowProxy::~WindowProxy):
(WebCore::WindowProxy::detachFromFrame):
(WebCore::WindowProxy::destroyJSWindowProxy):
(WebCore::WindowProxy::createJSWindowProxy):
(WebCore::WindowProxy::jsWindowProxiesAsVector const):
(WebCore::WindowProxy::clearJSWindowProxiesNotMatchingDOMWindow):
(WebCore::WindowProxy::setDOMWindow):
(WebCore::WindowProxy::attachDebugger):
(WebCore::WindowProxy::jsWindowProxies const):
(WebCore::WindowProxy::releaseJSWindowProxies):
(WebCore::WindowProxy::setJSWindowProxies):
* bindings/js/WindowProxy.h:
(WebCore::WindowProxy::existingJSWindowProxy const):
(WebCore::WindowProxy::jsWindowProxies const): Deleted.
(WebCore::WindowProxy::releaseJSWindowProxies): Deleted.
(WebCore::WindowProxy::setJSWindowProxies): Deleted.
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::~IOSurface):

Source/WebKit:

This is worth about 6% on WebKit2, and unlocks another 8% improvement
down the line (but which is less mechanical).

* NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkSocketChannel.h:
* NetworkProcess/WebStorage/StorageArea.h:
* NetworkProcess/WebStorage/StorageManager.cpp:
* NetworkProcess/WebStorage/StorageManagerSet.cpp:
* Platform/IPC/Connection.h:
* Shared/API/APIURL.h:
* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h:
* Shared/WebCoreArgumentCoders.cpp:
* Shared/WebCoreArgumentCoders.h:
* UIProcess/API/APIAttachment.h:
* UIProcess/API/Cocoa/_WKInspector.mm:
* UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
* UIProcess/TextCheckerCompletion.cpp:
* UIProcess/TextCheckerCompletion.h:
* UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::WebUserContentControllerProxy::addNetworkProcess):
(WebKit::WebUserContentControllerProxy::removeNetworkProcess):
* UIProcess/UserContent/WebUserContentControllerProxy.h:
(WebKit::WebUserContentControllerProxy::addNetworkProcess): Deleted.
(WebKit::WebUserContentControllerProxy::removeNetworkProcess): Deleted.
* WebProcess/Automation/WebAutomationSessionProxy.h:
* WebProcess/Network/NetworkProcessConnection.cpp:
* WebProcess/Network/NetworkProcessConnection.h:
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
* WebProcess/Plugins/Plugin.cpp:
* WebProcess/Plugins/Plugin.h:
* WebProcess/WebProcess.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 1d8ee5e..b1433e3 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2019-10-21  Tim Horton  <timothy_horton@apple.com>
+
+        Clean up some includes to improve WebKit2 build speed
+        https://bugs.webkit.org/show_bug.cgi?id=203071
+
+        Reviewed by Wenson Hsieh.
+
+        No new tests, just shuffling code around.
+
+        * bindings/js/WindowProxy.cpp:
+        (WebCore::WindowProxy::WindowProxy):
+        (WebCore::WindowProxy::~WindowProxy):
+        (WebCore::WindowProxy::detachFromFrame):
+        (WebCore::WindowProxy::destroyJSWindowProxy):
+        (WebCore::WindowProxy::createJSWindowProxy):
+        (WebCore::WindowProxy::jsWindowProxiesAsVector const):
+        (WebCore::WindowProxy::clearJSWindowProxiesNotMatchingDOMWindow):
+        (WebCore::WindowProxy::setDOMWindow):
+        (WebCore::WindowProxy::attachDebugger):
+        (WebCore::WindowProxy::jsWindowProxies const):
+        (WebCore::WindowProxy::releaseJSWindowProxies):
+        (WebCore::WindowProxy::setJSWindowProxies):
+        * bindings/js/WindowProxy.h:
+        (WebCore::WindowProxy::existingJSWindowProxy const):
+        (WebCore::WindowProxy::jsWindowProxies const): Deleted.
+        (WebCore::WindowProxy::releaseJSWindowProxies): Deleted.
+        (WebCore::WindowProxy::setJSWindowProxies): Deleted.
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (WebCore::IOSurface::~IOSurface):
+
 2019-10-21  Joonghun Park  <jh718.park@samsung.com>
 
         [GTK] Unreviewed. Fix build warning: unused parameter ‘Foo’ [-Wunused-parameter] since r251320.
diff --git a/Source/WebCore/bindings/js/WindowProxy.cpp b/Source/WebCore/bindings/js/WindowProxy.cpp
index de0bf88..5c695fe 100644
--- a/Source/WebCore/bindings/js/WindowProxy.cpp
+++ b/Source/WebCore/bindings/js/WindowProxy.cpp
@@ -54,13 +54,14 @@
 
 WindowProxy::WindowProxy(AbstractFrame& frame)
     : m_frame(&frame)
+    , m_jsWindowProxies(makeUniqueRef<ProxyMap>())
 {
 }
 
 WindowProxy::~WindowProxy()
 {
     ASSERT(!m_frame);
-    ASSERT(m_jsWindowProxies.isEmpty());
+    ASSERT(m_jsWindowProxies->isEmpty());
 }
 
 void WindowProxy::detachFromFrame()
@@ -70,9 +71,9 @@
     m_frame = nullptr;
 
     // It's likely that destroying windowProxies will create a lot of garbage.
-    if (!m_jsWindowProxies.isEmpty()) {
-        while (!m_jsWindowProxies.isEmpty()) {
-            auto it = m_jsWindowProxies.begin();
+    if (!m_jsWindowProxies->isEmpty()) {
+        while (!m_jsWindowProxies->isEmpty()) {
+            auto it = m_jsWindowProxies->begin();
             it->value->window()->setConsoleClient(nullptr);
             destroyJSWindowProxy(*it->key);
         }
@@ -82,8 +83,8 @@
 
 void WindowProxy::destroyJSWindowProxy(DOMWrapperWorld& world)
 {
-    ASSERT(m_jsWindowProxies.contains(&world));
-    m_jsWindowProxies.remove(&world);
+    ASSERT(m_jsWindowProxies->contains(&world));
+    m_jsWindowProxies->remove(&world);
     world.didDestroyWindowProxy(this);
 }
 
@@ -91,21 +92,21 @@
 {
     ASSERT(m_frame);
 
-    ASSERT(!m_jsWindowProxies.contains(&world));
+    ASSERT(!m_jsWindowProxies->contains(&world));
     ASSERT(m_frame->window());
 
     VM& vm = world.vm();
 
     Strong<JSWindowProxy> jsWindowProxy(vm, &JSWindowProxy::create(vm, *m_frame->window(), world));
     Strong<JSWindowProxy> jsWindowProxy2(jsWindowProxy);
-    m_jsWindowProxies.add(&world, jsWindowProxy);
+    m_jsWindowProxies->add(&world, jsWindowProxy);
     world.didCreateWindowProxy(this);
     return *jsWindowProxy.get();
 }
 
 Vector<JSC::Strong<JSWindowProxy>> WindowProxy::jsWindowProxiesAsVector() const
 {
-    return copyToVector(m_jsWindowProxies.values());
+    return copyToVector(m_jsWindowProxies->values());
 }
 
 JSDOMGlobalObject* WindowProxy::globalObject(DOMWrapperWorld& world)
@@ -128,7 +129,7 @@
 
 void WindowProxy::clearJSWindowProxiesNotMatchingDOMWindow(AbstractDOMWindow* newDOMWindow, bool goingIntoBackForwardCache)
 {
-    if (m_jsWindowProxies.isEmpty())
+    if (m_jsWindowProxies->isEmpty())
         return;
 
     JSLockHolder lock(commonVM());
@@ -154,7 +155,7 @@
 {
     ASSERT(newDOMWindow);
 
-    if (m_jsWindowProxies.isEmpty())
+    if (m_jsWindowProxies->isEmpty())
         return;
 
     ASSERT(m_frame);
@@ -189,7 +190,7 @@
 
 void WindowProxy::attachDebugger(JSC::Debugger* debugger)
 {
-    for (auto& windowProxy : m_jsWindowProxies.values())
+    for (auto& windowProxy : m_jsWindowProxies->values())
         windowProxy->attachDebugger(debugger);
 }
 
@@ -198,4 +199,19 @@
     return m_frame ? m_frame->window() : nullptr;
 }
 
+WindowProxy::ProxyMap::ValuesConstIteratorRange WindowProxy::jsWindowProxies() const
+{
+    return m_jsWindowProxies->values();
+}
+
+WindowProxy::ProxyMap WindowProxy::releaseJSWindowProxies()
+{
+    return std::exchange(m_jsWindowProxies, makeUniqueRef<ProxyMap>());
+}
+
+void WindowProxy::setJSWindowProxies(ProxyMap&& windowProxies)
+{
+    m_jsWindowProxies = makeUniqueRef<ProxyMap>(WTFMove(windowProxies));
+}
+
 } // namespace WebCore
diff --git a/Source/WebCore/bindings/js/WindowProxy.h b/Source/WebCore/bindings/js/WindowProxy.h
index 2c808bd..4436d8b 100644
--- a/Source/WebCore/bindings/js/WindowProxy.h
+++ b/Source/WebCore/bindings/js/WindowProxy.h
@@ -20,10 +20,10 @@
 
 #pragma once
 
-#include "DOMWrapperWorld.h"
 #include <JavaScriptCore/Strong.h>
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
+#include <wtf/UniqueRef.h>
 
 namespace JSC {
 class Debugger;
@@ -33,6 +33,7 @@
 
 class AbstractDOMWindow;
 class AbstractFrame;
+class DOMWrapperWorld;
 class JSDOMGlobalObject;
 class JSWindowProxy;
 
@@ -53,11 +54,11 @@
 
     void destroyJSWindowProxy(DOMWrapperWorld&);
 
-    ProxyMap::ValuesConstIteratorRange jsWindowProxies() const { return m_jsWindowProxies.values(); }
+    ProxyMap::ValuesConstIteratorRange jsWindowProxies() const;
     Vector<JSC::Strong<JSWindowProxy>> jsWindowProxiesAsVector() const;
 
-    ProxyMap releaseJSWindowProxies() { return std::exchange(m_jsWindowProxies, ProxyMap()); }
-    void setJSWindowProxies(ProxyMap&& windowProxies) { m_jsWindowProxies = WTFMove(windowProxies); }
+    WEBCORE_EXPORT ProxyMap releaseJSWindowProxies();
+    WEBCORE_EXPORT void setJSWindowProxies(ProxyMap&&);
 
     JSWindowProxy* jsWindowProxy(DOMWrapperWorld& world)
     {
@@ -72,8 +73,8 @@
 
     JSWindowProxy* existingJSWindowProxy(DOMWrapperWorld& world) const
     {
-        auto it = m_jsWindowProxies.find(&world);
-        return (it != m_jsWindowProxies.end()) ? it->value.get() : nullptr;
+        auto it = m_jsWindowProxies->find(&world);
+        return (it != m_jsWindowProxies->end()) ? it->value.get() : nullptr;
     }
 
     WEBCORE_EXPORT JSDOMGlobalObject* globalObject(DOMWrapperWorld&);
@@ -94,7 +95,7 @@
     WEBCORE_EXPORT JSWindowProxy& createJSWindowProxyWithInitializedScript(DOMWrapperWorld&);
 
     AbstractFrame* m_frame;
-    ProxyMap m_jsWindowProxies;
+    UniqueRef<ProxyMap> m_jsWindowProxies;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/dom/DocumentStorageAccess.cpp b/Source/WebCore/dom/DocumentStorageAccess.cpp
index ba01ae1..547405e 100644
--- a/Source/WebCore/dom/DocumentStorageAccess.cpp
+++ b/Source/WebCore/dom/DocumentStorageAccess.cpp
@@ -44,6 +44,13 @@
 
 namespace WebCore {
 
+DocumentStorageAccess::DocumentStorageAccess(Document& document)
+    : m_document(document)
+{
+}
+
+DocumentStorageAccess::~DocumentStorageAccess() = default;
+
 DocumentStorageAccess* DocumentStorageAccess::from(Document& document)
 {
     auto* supplement = static_cast<DocumentStorageAccess*>(Supplement<Document>::from(&document, supplementName()));
diff --git a/Source/WebCore/dom/DocumentStorageAccess.h b/Source/WebCore/dom/DocumentStorageAccess.h
index b96b13c..70345d6 100644
--- a/Source/WebCore/dom/DocumentStorageAccess.h
+++ b/Source/WebCore/dom/DocumentStorageAccess.h
@@ -51,10 +51,8 @@
 class DocumentStorageAccess final : public Supplement<Document>, public CanMakeWeakPtr<DocumentStorageAccess> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit DocumentStorageAccess(Document& document)
-        : m_document(document)
-    {
-    }
+    explicit DocumentStorageAccess(Document&);
+    ~DocumentStorageAccess();
 
     static void hasStorageAccess(Document&, Ref<DeferredPromise>&&);
     static void requestStorageAccess(Document&, Ref<DeferredPromise>&&);
diff --git a/Source/WebCore/platform/graphics/cocoa/IOSurface.h b/Source/WebCore/platform/graphics/cocoa/IOSurface.h
index 9800ca9..38f8aa2 100644
--- a/Source/WebCore/platform/graphics/cocoa/IOSurface.h
+++ b/Source/WebCore/platform/graphics/cocoa/IOSurface.h
@@ -29,7 +29,6 @@
 
 #include <objc/objc.h>
 #include <pal/spi/cocoa/IOSurfaceSPI.h>
-#include "GraphicsContext.h"
 #include "IntSize.h"
 
 #if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
@@ -43,6 +42,7 @@
 
 namespace WebCore {
 
+class GraphicsContext;
 class HostWindow;
     
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
@@ -104,6 +104,8 @@
     static std::unique_ptr<IOSurface> createFromImageBuffer(std::unique_ptr<ImageBuffer>);
 #endif
 
+    WEBCORE_EXPORT ~IOSurface();
+
     WEBCORE_EXPORT static void moveToPool(std::unique_ptr<IOSurface>&&);
 
     static IntSize maximumSize();
diff --git a/Source/WebCore/platform/graphics/cocoa/IOSurface.mm b/Source/WebCore/platform/graphics/cocoa/IOSurface.mm
index 3875fcf..dae187d 100644
--- a/Source/WebCore/platform/graphics/cocoa/IOSurface.mm
+++ b/Source/WebCore/platform/graphics/cocoa/IOSurface.mm
@@ -232,6 +232,8 @@
     m_totalBytes = IOSurfaceGetAllocSize(surface);
 }
 
+IOSurface::~IOSurface() = default;
+
 IntSize IOSurface::maximumSize()
 {
     IntSize maxSize(clampToInteger(IOSurfaceGetPropertyMaximum(kIOSurfaceWidth)), clampToInteger(IOSurfaceGetPropertyMaximum(kIOSurfaceHeight)));
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index ec0e175..9143845 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,44 @@
+2019-10-21  Tim Horton  <timothy_horton@apple.com>
+
+        Clean up some includes to improve WebKit2 build speed
+        https://bugs.webkit.org/show_bug.cgi?id=203071
+
+        Reviewed by Wenson Hsieh.
+
+        This is worth about 6% on WebKit2, and unlocks another 8% improvement
+        down the line (but which is less mechanical).
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+        * NetworkProcess/NetworkSocketChannel.h:
+        * NetworkProcess/WebStorage/StorageArea.h:
+        * NetworkProcess/WebStorage/StorageManager.cpp:
+        * NetworkProcess/WebStorage/StorageManagerSet.cpp:
+        * Platform/IPC/Connection.h:
+        * Shared/API/APIURL.h:
+        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h:
+        * Shared/WebCoreArgumentCoders.cpp:
+        * Shared/WebCoreArgumentCoders.h:
+        * UIProcess/API/APIAttachment.h:
+        * UIProcess/API/Cocoa/_WKInspector.mm:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
+        * UIProcess/TextCheckerCompletion.cpp:
+        * UIProcess/TextCheckerCompletion.h:
+        * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
+        (WebKit::WebUserContentControllerProxy::addNetworkProcess):
+        (WebKit::WebUserContentControllerProxy::removeNetworkProcess):
+        * UIProcess/UserContent/WebUserContentControllerProxy.h:
+        (WebKit::WebUserContentControllerProxy::addNetworkProcess): Deleted.
+        (WebKit::WebUserContentControllerProxy::removeNetworkProcess): Deleted.
+        * WebProcess/Automation/WebAutomationSessionProxy.h:
+        * WebProcess/Network/NetworkProcessConnection.cpp:
+        * WebProcess/Network/NetworkProcessConnection.h:
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        * WebProcess/Plugins/Plugin.cpp:
+        * WebProcess/Plugins/Plugin.h:
+        * WebProcess/WebProcess.cpp:
+
 2019-10-20  Brent Fulgham  <bfulgham@apple.com>
 
         Improve serialization logic
diff --git a/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp b/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
index 707ff820..d93545c 100644
--- a/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
+++ b/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
@@ -42,6 +42,7 @@
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/ResourceLoadStatistics.h>
 #include <wtf/CallbackAggregator.h>
+#include <wtf/CrossThreadCopier.h>
 #include <wtf/DateMath.h>
 #include <wtf/MathExtras.h>
 #include <wtf/text/StringBuilder.h>
diff --git a/Source/WebKit/NetworkProcess/Classifier/StorageAccessStatus.h b/Source/WebKit/NetworkProcess/Classifier/StorageAccessStatus.h
index 70b6a29..382f238 100644
--- a/Source/WebKit/NetworkProcess/Classifier/StorageAccessStatus.h
+++ b/Source/WebKit/NetworkProcess/Classifier/StorageAccessStatus.h
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#include <wtf/EnumTraits.h>
+
 namespace WebKit {
 
 enum class StorageAccessStatus : uint8_t {
diff --git a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
index 38b7c0e..40afdb8 100644
--- a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
+++ b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
@@ -27,7 +27,6 @@
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 
-#include "Connection.h"
 #include "StorageAccessStatus.h"
 #include "WebPageProxyIdentifier.h"
 #include "WebsiteDataType.h"
@@ -105,7 +104,7 @@
 
     static const OptionSet<WebsiteDataType>& monitoredDataTypes();
 
-    WorkQueue& statisticsQueue() { return m_statisticsQueue.get(); }
+    WTF::WorkQueue& statisticsQueue() { return m_statisticsQueue.get(); }
 
     void setNotifyPagesWhenDataRecordsWereScanned(bool);
     void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&);
@@ -206,7 +205,7 @@
     void flushAndDestroyPersistentStore();
 
     WeakPtr<NetworkSession> m_networkSession;
-    Ref<WorkQueue> m_statisticsQueue;
+    Ref<WTF::WorkQueue> m_statisticsQueue;
     std::unique_ptr<ResourceLoadStatisticsStore> m_statisticsStore;
     std::unique_ptr<ResourceLoadStatisticsPersistentStorage> m_persistentStorage;
 
diff --git a/Source/WebKit/NetworkProcess/NetworkSocketChannel.h b/Source/WebKit/NetworkProcess/NetworkSocketChannel.h
index 9df9aac..014d780 100644
--- a/Source/WebKit/NetworkProcess/NetworkSocketChannel.h
+++ b/Source/WebKit/NetworkProcess/NetworkSocketChannel.h
@@ -29,6 +29,7 @@
 #include "MessageSender.h"
 #include <pal/SessionID.h>
 #include <wtf/CompletionHandler.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 class ResourceRequest;
diff --git a/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h b/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h
index e0f8eab..cdd88d7 100644
--- a/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h
+++ b/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h
@@ -30,6 +30,7 @@
 #include "StorageAreaImplIdentifier.h"
 #include <WebCore/SecurityOriginData.h>
 #include <wtf/Forward.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 class StorageMap;
diff --git a/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp b/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp
index e5d1f25..98a3f96 100644
--- a/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp
+++ b/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp
@@ -39,6 +39,7 @@
 #include <WebCore/StorageMap.h>
 #include <WebCore/TextEncoding.h>
 #include <memory>
+#include <wtf/CrossThreadCopier.h>
 #include <wtf/WorkQueue.h>
 
 namespace WebKit {
diff --git a/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp b/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp
index 874e52d..b2d2dd6 100644
--- a/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp
+++ b/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp
@@ -30,6 +30,7 @@
 #include "StorageAreaMapMessages.h"
 #include "StorageManagerSetMessages.h"
 #include <WebCore/TextEncoding.h>
+#include <wtf/CrossThreadCopier.h>
 #include <wtf/threads/BinarySemaphore.h>
 
 namespace WebKit {
diff --git a/Source/WebKit/Platform/IPC/Connection.h b/Source/WebKit/Platform/IPC/Connection.h
index de3ee5e..33b0591 100644
--- a/Source/WebKit/Platform/IPC/Connection.h
+++ b/Source/WebKit/Platform/IPC/Connection.h
@@ -32,7 +32,6 @@
 #include "Encoder.h"
 #include "HandleMessage.h"
 #include "MessageReceiver.h"
-#include <WebCore/ScriptDisallowedScope.h>
 #include <atomic>
 #include <wtf/Condition.h>
 #include <wtf/Deque.h>
diff --git a/Source/WebKit/Shared/API/APIURL.h b/Source/WebKit/Shared/API/APIURL.h
index 3e61bbd..3e9975b 100644
--- a/Source/WebKit/Shared/API/APIURL.h
+++ b/Source/WebKit/Shared/API/APIURL.h
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "APIObject.h"
-#include "WebCoreArgumentCoders.h"
+#include "ArgumentCoders.h"
 #include <wtf/Forward.h>
 #include <wtf/URL.h>
 #include <wtf/text/WTFString.h>
diff --git a/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h b/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h
index 2d6408b..e76cfcd 100644
--- a/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h
+++ b/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h
@@ -27,6 +27,7 @@
 
 #if ENABLE(APPLE_PAY)
 
+#import <WebCore/ApplePaySessionPaymentRequest.h>
 #import <pal/spi/cocoa/PassKitSPI.h>
 
 namespace WebKit {
diff --git a/Source/WebKit/Shared/CacheModel.h b/Source/WebKit/Shared/CacheModel.h
index cd648b4..b5cd9fe 100644
--- a/Source/WebKit/Shared/CacheModel.h
+++ b/Source/WebKit/Shared/CacheModel.h
@@ -26,6 +26,7 @@
 #pragma once
 
 #include <stdint.h>
+#include <wtf/EnumTraits.h>
 #include <wtf/Forward.h>
 #include <wtf/Seconds.h>
 
diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
index 17db825..3ee38d9 100644
--- a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
@@ -32,6 +32,7 @@
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/BlobPart.h>
 #include <WebCore/CacheQueryOptions.h>
+#include <WebCore/CacheStorageConnection.h>
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/CompositionUnderline.h>
 #include <WebCore/Credential.h>
diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.h b/Source/WebKit/Shared/WebCoreArgumentCoders.h
index 015f896..e89efac 100644
--- a/Source/WebKit/Shared/WebCoreArgumentCoders.h
+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.h
@@ -27,7 +27,6 @@
 
 #include "ArgumentCoders.h"
 #include <WebCore/AutoplayEvent.h>
-#include <WebCore/CacheStorageConnection.h>
 #include <WebCore/ColorSpace.h>
 #include <WebCore/DiagnosticLoggingClient.h>
 #include <WebCore/FrameLoaderTypes.h>
@@ -41,6 +40,7 @@
 #include <WebCore/ServiceWorkerTypes.h>
 #include <WebCore/StoredCredentialsPolicy.h>
 #include <WebCore/WorkerType.h>
+#include <wtf/EnumTraits.h>
 
 #if ENABLE(APPLE_PAY)
 #include <WebCore/PaymentHeaders.h>
@@ -184,6 +184,11 @@
 #if ENABLE(INDEXED_DATABASE)
 using IDBKeyPath = Variant<String, Vector<String>>;
 #endif
+
+namespace DOMCacheEngine {
+struct CacheInfo;
+struct Record;
+}
 }
 
 namespace IPC {
diff --git a/Source/WebKit/UIProcess/API/APIAttachment.h b/Source/WebKit/UIProcess/API/APIAttachment.h
index 86ed05d..43a47dd 100644
--- a/Source/WebKit/UIProcess/API/APIAttachment.h
+++ b/Source/WebKit/UIProcess/API/APIAttachment.h
@@ -28,8 +28,8 @@
 #if ENABLE(ATTACHMENT_ELEMENT)
 
 #include "APIObject.h"
+#include "GenericCallback.h"
 #include "WKBase.h"
-#include "WebPageProxy.h"
 #include <wtf/RefPtr.h>
 #include <wtf/WeakPtr.h>
 #include <wtf/text/WTFString.h>
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm
index 3d15ec2..4d82e18 100644
--- a/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm
+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm
@@ -27,6 +27,7 @@
 #import "_WKInspector.h"
 
 #import "WKWebViewInternal.h"
+#import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import "_WKFrameHandleInternal.h"
 #import "_WKInspectorInternal.h"
diff --git a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm
index e0514f0..5884f1a 100644
--- a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm
+++ b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm
@@ -29,6 +29,7 @@
 #if HAVE(APP_SSO)
 
 #import "SOAuthorizationSession.h"
+#import "WebPageProxy.h"
 #import <wtf/RunLoop.h>
 
 @implementation WKSOAuthorizationDelegate
diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h
index b2dfd2c..cd363a8 100644
--- a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h
+++ b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h
@@ -30,6 +30,7 @@
 #include <wtf/Vector.h>
 
 OBJC_CLASS CALayer;
+OBJC_CLASS NSString;
 #if PLATFORM(IOS_FAMILY)
 OBJC_CLASS UIView;
 #endif
diff --git a/Source/WebKit/UIProcess/TextCheckerCompletion.cpp b/Source/WebKit/UIProcess/TextCheckerCompletion.cpp
index fb5ddff..fb644fc 100644
--- a/Source/WebKit/UIProcess/TextCheckerCompletion.cpp
+++ b/Source/WebKit/UIProcess/TextCheckerCompletion.cpp
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "TextCheckerCompletion.h"
 
+#include "WebPageProxy.h"
+
 namespace WebKit {
 using namespace WebCore;
 
diff --git a/Source/WebKit/UIProcess/TextCheckerCompletion.h b/Source/WebKit/UIProcess/TextCheckerCompletion.h
index eab2aeb..d24b3cf 100644
--- a/Source/WebKit/UIProcess/TextCheckerCompletion.h
+++ b/Source/WebKit/UIProcess/TextCheckerCompletion.h
@@ -25,12 +25,15 @@
 
 #pragma once
 
-#include "WebPageProxy.h"
 #include <WebCore/TextChecking.h>
 #include <wtf/Forward.h>
 
 namespace WebKit {
 
+using SpellDocumentTag = int64_t;
+
+class WebPageProxy;
+
 class TextCheckerCompletion : public RefCounted<TextCheckerCompletion> {
 public:
     static Ref<TextCheckerCompletion> create(uint64_t requestID, const WebCore::TextCheckingRequestData&, WebPageProxy*);
diff --git a/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp b/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp
index eafc457..236da66 100644
--- a/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp
+++ b/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp
@@ -84,6 +84,18 @@
 #endif
 }
 
+#if ENABLE(CONTENT_EXTENSIONS)
+void WebUserContentControllerProxy::addNetworkProcess(NetworkProcessProxy& proxy)
+{
+    m_networkProcesses.add(proxy);
+}
+
+void WebUserContentControllerProxy::removeNetworkProcess(NetworkProcessProxy& proxy)
+{
+    m_networkProcesses.remove(proxy);
+}
+#endif
+
 void WebUserContentControllerProxy::addProcess(WebProcessProxy& webProcessProxy, WebPageCreationParameters& parameters)
 {
     ASSERT(!m_processes.hasNullReferences());
diff --git a/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h b/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h
index 469d30e..2f532d5 100644
--- a/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h
+++ b/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h
@@ -27,8 +27,8 @@
 
 #include "APIObject.h"
 #include "MessageReceiver.h"
-#include "NetworkProcessProxy.h"
 #include "UserContentControllerIdentifier.h"
+#include "WebPageProxyIdentifier.h"
 #include <WebCore/PageIdentifier.h>
 #include <wtf/Forward.h>
 #include <wtf/HashCountedSet.h>
@@ -97,8 +97,8 @@
     void removeAllUserMessageHandlers(API::UserContentWorld&);
 
 #if ENABLE(CONTENT_EXTENSIONS)
-    void addNetworkProcess(NetworkProcessProxy& proxy) { m_networkProcesses.add(proxy); }
-    void removeNetworkProcess(NetworkProcessProxy& proxy) { m_networkProcesses.remove(proxy); }
+    void addNetworkProcess(NetworkProcessProxy&);
+    void removeNetworkProcess(NetworkProcessProxy&);
 
     void addContentRuleList(API::ContentRuleList&);
     void removeContentRuleList(const String&);
diff --git a/Source/WebKit/UIProcess/WebPasteboardProxy.h b/Source/WebKit/UIProcess/WebPasteboardProxy.h
index d890e30..458da14 100644
--- a/Source/WebKit/UIProcess/WebPasteboardProxy.h
+++ b/Source/WebKit/UIProcess/WebPasteboardProxy.h
@@ -28,6 +28,7 @@
 #include "MessageReceiver.h"
 #include "SandboxExtension.h"
 #include "SharedMemory.h"
+#include <WebCore/SharedBuffer.h>
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
 
diff --git a/Source/WebKit/UIProcess/WebsiteData/curl/WebsiteDataStoreCurl.cpp b/Source/WebKit/UIProcess/WebsiteData/curl/WebsiteDataStoreCurl.cpp
index 4138aec..0e0c06e 100644
--- a/Source/WebKit/UIProcess/WebsiteData/curl/WebsiteDataStoreCurl.cpp
+++ b/Source/WebKit/UIProcess/WebsiteData/curl/WebsiteDataStoreCurl.cpp
@@ -27,6 +27,7 @@
 #include "WebsiteDataStore.h"
 
 #include "NetworkProcessMessages.h"
+#include "WebCoreArgumentCoders.h"
 #include "WebProcessPool.h"
 #include "WebsiteDataStoreParameters.h"
 
diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
index 1ec7c8d..e139968 100644
--- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
+++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
@@ -52,6 +52,7 @@
 #import "WebContextMenuProxy.h"
 #import "WebDataListSuggestionsDropdownIOS.h"
 #import "WebEditCommandProxy.h"
+#import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import "_WKDownloadInternal.h"
 #import <WebCore/DOMPasteAccess.h>
diff --git a/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h b/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h
index b6ba78d..7872528 100644
--- a/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h
+++ b/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h
@@ -29,6 +29,7 @@
 #include "CoordinateSystem.h"
 #include <JavaScriptCore/JSBase.h>
 #include <WebCore/FrameIdentifier.h>
+#include <WebCore/IntRect.h>
 #include <WebCore/PageIdentifier.h>
 #include <wtf/text/WTFString.h>
 
diff --git a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
index 3083357..40c3b4b 100644
--- a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
+++ b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
@@ -33,6 +33,7 @@
 #include "StorageAreaMapMessages.h"
 #include "WebCacheStorageProvider.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebIDBConnectionToServer.h"
 #include "WebIDBConnectionToServerMessages.h"
 #include "WebLoaderStrategy.h"
 #include "WebMDNSRegisterMessages.h"
diff --git a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
index 817e445..e67b229 100644
--- a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
+++ b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
@@ -28,7 +28,6 @@
 
 #include "Connection.h"
 #include "ShareableResource.h"
-#include "WebIDBConnectionToServer.h"
 #include <WebCore/MessagePortChannelProvider.h>
 #include <WebCore/ServiceWorkerTypes.h>
 #include <wtf/RefCounted.h>
@@ -48,6 +47,7 @@
 
 namespace WebKit {
 
+class WebIDBConnectionToServer;
 class WebSWClientConnection;
 
 typedef uint64_t ResourceLoadIdentifier;
diff --git a/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 59f4825..977b8ed 100644
--- a/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -46,6 +46,10 @@
 #include "NetscapePluginUnix.h"
 #endif
 
+#if PLATFORM(COCOA)
+#include "LayerHostingContext.h"
+#endif
+
 namespace WebKit {
 using namespace WebCore;
 
diff --git a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
index 0d0a667..f772266 100644
--- a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
+++ b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
@@ -48,6 +48,7 @@
 #import "WebProcess.h"
 #import <JavaScriptCore/JSContextRef.h>
 #import <JavaScriptCore/JSObjectRef.h>
+#import <JavaScriptCore/OpaqueJSString.h>
 #import <Quartz/Quartz.h>
 #import <QuartzCore/QuartzCore.h>
 #import <WebCore/AXObjectCache.h>
diff --git a/Source/WebKit/WebProcess/Plugins/Plugin.cpp b/Source/WebKit/WebProcess/Plugins/Plugin.cpp
index 68003bb..230ca4e 100644
--- a/Source/WebKit/WebProcess/Plugins/Plugin.cpp
+++ b/Source/WebKit/WebProcess/Plugins/Plugin.cpp
@@ -30,6 +30,10 @@
 #include <WebCore/IntPoint.h>
 #include <wtf/SetForScope.h>
 
+#if PLATFORM(COCOA)
+#include "LayerHostingContext.h"
+#endif
+
 namespace WebKit {
 using namespace WebCore;
 
diff --git a/Source/WebKit/WebProcess/Plugins/Plugin.h b/Source/WebKit/WebProcess/Plugins/Plugin.h
index 43efadc..e42c7e9 100644
--- a/Source/WebKit/WebProcess/Plugins/Plugin.h
+++ b/Source/WebKit/WebProcess/Plugins/Plugin.h
@@ -26,16 +26,15 @@
 #pragma once
 
 #include <WebCore/FindOptions.h>
-#include <WebCore/GraphicsLayer.h>
+#include <WebCore/PlatformLayer.h>
 #include <WebCore/ScrollTypes.h>
-#include <WebCore/SecurityOrigin.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/URL.h>
 #include <wtf/Vector.h>
 
 #if PLATFORM(COCOA)
-#include "LayerHostingContext.h"
 typedef struct objc_object* id;
 
 OBJC_CLASS NSDictionary;
@@ -59,7 +58,6 @@
 class IntPoint;
 class IntRect;
 class IntSize;
-class FloatPoint;
 class Scrollbar;
 class SharedBuffer;
 }
@@ -79,6 +77,8 @@
     PDFPluginType,
 };
 
+enum class LayerHostingMode : uint8_t;
+
 class Plugin : public ThreadSafeRefCounted<Plugin> {
 public:
     struct Parameters {
diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h
index 3a1e5f4..bae86ab 100644
--- a/Source/WebKit/WebProcess/WebPage/WebPage.h
+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h
@@ -212,6 +212,7 @@
 class FindController;
 class GamepadData;
 class GeolocationPermissionRequestManager;
+class LayerHostingContext;
 class MediaDeviceSandboxExtensions;
 class NotificationPermissionRequestManager;
 class PDFPlugin;
diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp
index 0a1025e..b21f497 100644
--- a/Source/WebKit/WebProcess/WebProcess.cpp
+++ b/Source/WebKit/WebProcess/WebProcess.cpp
@@ -53,6 +53,7 @@
 #include "WebFrameNetworkingContext.h"
 #include "WebGamepadProvider.h"
 #include "WebGeolocationManager.h"
+#include "WebIDBConnectionToServer.h"
 #include "WebLoaderStrategy.h"
 #include "WebMediaKeyStorageManager.h"
 #include "WebMemorySampler.h"
diff --git a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm b/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm
index d96d20e..5300073 100644
--- a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm
+++ b/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm
@@ -28,6 +28,7 @@
 #if (PLATFORM(IOS_FAMILY) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
 
 #import "Attachment.h"
+#import "LayerHostingContext.h"
 #import "Logging.h"
 #import "PlaybackSessionManager.h"
 #import "VideoFullscreenManagerProxyMessages.h"
diff --git a/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm b/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm
index 8348597..93ec7b5 100644
--- a/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm
+++ b/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm
@@ -30,6 +30,7 @@
 #import "WebFrameInternal.h"
 #import "WebPDFViewIOS.h"
 #import <JavaScriptCore/JSContextRef.h>
+#import <JavaScriptCore/OpaqueJSString.h>
 #import <WebCore/DataTransfer.h>
 #import <WebCore/EventHandler.h>
 #import <WebCore/EventNames.h>