Replace LayerOrView typedef with a class
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Nov 2018 07:17:35 +0000 (07:17 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Nov 2018 07:17:35 +0000 (07:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191927

Reviewed by Tim Horton.

This typedef restricts remote layer representation to be either a CA layer or a view. We might want
have more flexibility, for example tiles don't really need to be UIViews. It will also make it easier
to unify Mac and iOS code, and hopefully make it less confusing too.

This patch introduces RemoteLayerTreeNode class that replaces most uses of LayerOrView typedef
(the rest are converted to pure CALayer). It also does a bunch of related cleanup.

* Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
* Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
(WebKit::RemoteLayerTreePropertyApplier::applyProperties):
(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):
(WebKit::applyPropertiesToLayer): Deleted.
* SourcesCocoa.txt:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _propertiesOfLayerWithID:]):
* UIProcess/Cocoa/LayerRepresentation.h: Removed.
* UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
* UIProcess/PageClient.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
(WebKit::RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator):
(WebKit::RemoteLayerTreeDrawingAreaProxy::layerWithIDForTesting const):
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
(WebKit::RemoteLayerTreeHost::rootNode const):
(WebKit::RemoteLayerTreeHost::rootLayer const): Deleted.
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::updateLayerTree):
(WebKit::RemoteLayerTreeHost::nodeForID const):
(WebKit::RemoteLayerTreeHost::layerWillBeRemoved):
(WebKit::RemoteLayerTreeHost::animationDidStart):
(WebKit::RemoteLayerTreeHost::animationDidEnd):
(WebKit::RemoteLayerTreeHost::clearLayers):
(WebKit::RemoteLayerTreeHost::layerWithIDForTesting const):
(WebKit::RemoteLayerTreeHost::layerForID const):
(WebKit::RemoteLayerTreeHost::rootLayer const):
(WebKit::RemoteLayerTreeHost::createLayer):
(WebKit::RemoteLayerTreeHost::detachRootLayer):
(WebKit::RemoteLayerTreeHost::mapAllIOSurfaceBackingStore):
(WebKit::RemoteLayerTreeHost::getLayer const): Deleted.
* UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h: Added.
(WebKit::RemoteLayerTreeNode::layer const):
(WebKit::RemoteLayerTreeNode::uiView const):
* UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm: Added.
(WebKit::RemoteLayerTreeNode::RemoteLayerTreeNode):
(WebKit::RemoteLayerTreeNode::detachFromParent):
* UIProcess/RemoteLayerTree/RemoteLayerTreeScrollingPerformanceData.mm:
(WebKit::RemoteLayerTreeScrollingPerformanceData::blankPixelCount const):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
* UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::createLayer):
* UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
(WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
(WebKit::layerRepresentationFromLayerOrView): Deleted.
* UIProcess/WebAuthentication/Cocoa/HidService.h:
* UIProcess/WebAuthentication/Cocoa/HidService.mm:
* UIProcess/WebPageProxy.h:
* UIProcess/ios/LayerRepresentation.mm: Removed.
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::setRemoteLayerTreeRootNode):
(WebKit::PageClientImpl::acceleratedCompositingRootLayer const):
(WebKit::PageClientImpl::setAcceleratedCompositingRootLayer): Deleted.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::setRemoteLayerTreeRootNode):
(WebKit::WebPageProxy::setAcceleratedCompositingRootLayer): Deleted.
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::setRemoteLayerTreeRootNode):
(WebKit::PageClientImpl::setAcceleratedCompositingRootLayer): Deleted.
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::setRemoteLayerTreeRootNode):
(WebKit::WebPageProxy::acceleratedCompositingRootLayer const):
(WebKit::WebPageProxy::setAcceleratedCompositingRootLayer): Deleted.
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::recursiveBuildTransaction):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238468 268f45cc-cd09-0410-ab3c-d52691b4dbfc

29 files changed:
Source/WebKit/ChangeLog
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
Source/WebKit/UIProcess/PageClient.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h [moved from Source/WebKit/UIProcess/ios/LayerRepresentation.mm with 67% similarity]
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm [moved from Source/WebKit/UIProcess/Cocoa/LayerRepresentation.h with 70% similarity]
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeScrollingPerformanceData.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm
Source/WebKit/UIProcess/WebAuthentication/Cocoa/HidService.h
Source/WebKit/UIProcess/WebAuthentication/Cocoa/HidService.mm
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/PageClientImplIOS.h
Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/UIProcess/mac/PageClientImplMac.h
Source/WebKit/UIProcess/mac/PageClientImplMac.mm
Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp

index 92b108e..d29bd51 100644 (file)
@@ -1,3 +1,93 @@
+2018-11-23  Antti Koivisto  <antti@apple.com>
+
+        Replace LayerOrView typedef with a class
+        https://bugs.webkit.org/show_bug.cgi?id=191927
+
+        Reviewed by Tim Horton.
+
+        This typedef restricts remote layer representation to be either a CA layer or a view. We might want
+        have more flexibility, for example tiles don't really need to be UIViews. It will also make it easier
+        to unify Mac and iOS code, and hopefully make it less confusing too.
+
+        This patch introduces RemoteLayerTreeNode class that replaces most uses of LayerOrView typedef
+        (the rest are converted to pure CALayer). It also does a bunch of related cleanup.
+
+        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
+        (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
+        (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):
+        (WebKit::applyPropertiesToLayer): Deleted.
+        * SourcesCocoa.txt:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _propertiesOfLayerWithID:]):
+        * UIProcess/Cocoa/LayerRepresentation.h: Removed.
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+        (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
+        * UIProcess/PageClient.h:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::layerWithIDForTesting const):
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
+        (WebKit::RemoteLayerTreeHost::rootNode const):
+        (WebKit::RemoteLayerTreeHost::rootLayer const): Deleted.
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::updateLayerTree):
+        (WebKit::RemoteLayerTreeHost::nodeForID const):
+        (WebKit::RemoteLayerTreeHost::layerWillBeRemoved):
+        (WebKit::RemoteLayerTreeHost::animationDidStart):
+        (WebKit::RemoteLayerTreeHost::animationDidEnd):
+        (WebKit::RemoteLayerTreeHost::clearLayers):
+        (WebKit::RemoteLayerTreeHost::layerWithIDForTesting const):
+        (WebKit::RemoteLayerTreeHost::layerForID const):
+        (WebKit::RemoteLayerTreeHost::rootLayer const):
+        (WebKit::RemoteLayerTreeHost::createLayer):
+        (WebKit::RemoteLayerTreeHost::detachRootLayer):
+        (WebKit::RemoteLayerTreeHost::mapAllIOSurfaceBackingStore):
+        (WebKit::RemoteLayerTreeHost::getLayer const): Deleted.
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h: Added.
+        (WebKit::RemoteLayerTreeNode::layer const):
+        (WebKit::RemoteLayerTreeNode::uiView const):
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm: Added.
+        (WebKit::RemoteLayerTreeNode::RemoteLayerTreeNode):
+        (WebKit::RemoteLayerTreeNode::detachFromParent):
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeScrollingPerformanceData.mm:
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::blankPixelCount const):
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
+        (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
+        * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
+        (WebKit::RemoteLayerTreeHost::createLayer):
+        * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
+        (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
+        (WebKit::layerRepresentationFromLayerOrView): Deleted.
+        * UIProcess/WebAuthentication/Cocoa/HidService.h:
+        * UIProcess/WebAuthentication/Cocoa/HidService.mm:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/LayerRepresentation.mm: Removed.
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::setRemoteLayerTreeRootNode):
+        (WebKit::PageClientImpl::acceleratedCompositingRootLayer const):
+        (WebKit::PageClientImpl::setAcceleratedCompositingRootLayer): Deleted.
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::setRemoteLayerTreeRootNode):
+        (WebKit::WebPageProxy::setAcceleratedCompositingRootLayer): Deleted.
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::setRemoteLayerTreeRootNode):
+        (WebKit::PageClientImpl::setAcceleratedCompositingRootLayer): Deleted.
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::setRemoteLayerTreeRootNode):
+        (WebKit::WebPageProxy::acceleratedCompositingRootLayer const):
+        (WebKit::WebPageProxy::setAcceleratedCompositingRootLayer): Deleted.
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
+
 2018-11-23  Jiewen Tan  <jiewen_tan@apple.com>
 
         [WebAuthN] Enable Web Authentication as an experimental feature for macOS
index 5555ff9..6584a90 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "LayerRepresentation.h"
+#include "RemoteLayerTreeNode.h"
 #include "RemoteLayerTreeTransaction.h"
 #include <wtf/HashMap.h>
 
@@ -35,10 +35,13 @@ class RemoteLayerTreeHost;
 
 class RemoteLayerTreePropertyApplier {
 public:
-    using RelatedLayerMap = HashMap<WebCore::GraphicsLayer::PlatformLayerID, CFTypeRef>;
-    static void applyProperties(CALayer *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&, RemoteLayerBackingStore::LayerContentsType);
+    using RelatedLayerMap = HashMap<WebCore::GraphicsLayer::PlatformLayerID, RemoteLayerTreeNode*>;
+    static void applyProperties(RemoteLayerTreeNode&, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&, RemoteLayerBackingStore::LayerContentsType);
+    static void applyPropertiesToLayer(CALayer *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, RemoteLayerBackingStore::LayerContentsType);
+
+private:
 #if PLATFORM(IOS_FAMILY)
-    static void applyProperties(UIView *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&, RemoteLayerBackingStore::LayerContentsType);
+    static void applyPropertiesToUIView(UIView *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
 #endif
 };
 
index d5d6173..202c591 100644 (file)
@@ -126,7 +126,7 @@ static void updateCustomAppearance(CALayer *layer, GraphicsLayer::CustomAppearan
 #endif
 }
 
-static void applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, RemoteLayerBackingStore::LayerContentsType layerContentsType)
+void RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, RemoteLayerBackingStore::LayerContentsType layerContentsType)
 {
     if (properties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
         layer.name = properties.name;
@@ -254,16 +254,22 @@ static void applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeHost* layerTre
         updateCustomAppearance(layer, properties.customAppearance);
 }
 
-void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers, RemoteLayerBackingStore::LayerContentsType layerContentsType)
+void RemoteLayerTreePropertyApplier::applyProperties(RemoteLayerTreeNode& node, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers, RemoteLayerBackingStore::LayerContentsType layerContentsType)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+    CALayer *layer = node.layer();
+
     applyPropertiesToLayer(layer, layerTreeHost, properties, layerContentsType);
 
+#if PLATFORM(IOS_FAMILY)
+    applyPropertiesToUIView(node.uiView(), properties, relatedLayers);
+#else
     if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);
         for (auto& child : properties.children) {
-            ASSERT(relatedLayers.get(child));
-            [children addObject:(__bridge id)relatedLayers.get(child)];
+            ASSERT(relatedLayers.contains(child));
+            [children addObject:relatedLayers.get(child)->layer()];
         }
 
         layer.sublayers = children.get();
@@ -273,34 +279,24 @@ void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayer
         if (!properties.maskLayerID)
             layer.mask = nullptr;
         else {
-#if PLATFORM(IOS_FAMILY)
-            UIView *maskView = (__bridge UIView *)relatedLayers.get(properties.maskLayerID);
-            // FIXME: need to check that the mask view is kept alive.
-            ASSERT(!maskView.layer.superlayer);
-            if (!maskView.layer.superlayer)
-                layer.mask = maskView.layer;
-#else
-            CALayer *maskLayer = (__bridge CALayer *)relatedLayers.get(properties.maskLayerID);
+            CALayer *maskLayer = relatedLayers.get(properties.maskLayerID)->layer();
             ASSERT(!maskLayer.superlayer);
             if (!maskLayer.superlayer)
                 layer.mask = maskLayer;
-#endif
         }
     }
+#endif
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
 #if PLATFORM(IOS_FAMILY)
-void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers, RemoteLayerBackingStore::LayerContentsType layerContentsType)
+void RemoteLayerTreePropertyApplier::applyPropertiesToUIView(UIView *view, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
 {
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    applyPropertiesToLayer(view.layer, layerTreeHost, properties, layerContentsType);
-
     if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);
         for (auto& child : properties.children) {
-            ASSERT(relatedLayers.get(child));
-            [children addObject:(__bridge id)relatedLayers.get(child)];
+            ASSERT(relatedLayers.contains(child));
+            [children addObject:relatedLayers.get(child)->uiView()];
         }
 
         if (properties.customAppearance == GraphicsLayer::CustomAppearance::LightBackdrop || properties.customAppearance == GraphicsLayer::CustomAppearance::DarkBackdrop) {
@@ -324,7 +320,7 @@ void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTr
         if (!properties.maskLayerID)
             maskOwnerLayer.mask = nullptr;
         else {
-            UIView *maskView = (__bridge UIView *)relatedLayers.get(properties.maskLayerID);
+            UIView *maskView = relatedLayers.get(properties.maskLayerID)->uiView();
             // FIXME: need to check that the mask view is kept alive.
             ASSERT(!maskView.layer.superlayer);
             if (!maskView.layer.superlayer)
@@ -335,7 +331,6 @@ void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTr
     if (properties.changedProperties.containsAny({ RemoteLayerTreeTransaction::ContentsHiddenChanged, RemoteLayerTreeTransaction::UserInteractionEnabledChanged }))
         view.userInteractionEnabled = !properties.contentsHidden && properties.userInteractionEnabled;
 
-    END_BLOCK_OBJC_EXCEPTIONS;
 }
 #endif
 
index e88c5fe..6ac8fec 100644 (file)
@@ -368,7 +368,6 @@ UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm
 
 UIProcess/ios/DragDropInteractionState.mm
 UIProcess/ios/InputViewUpdateDeferrer.mm
-UIProcess/ios/LayerRepresentation.mm
 UIProcess/ios/PageClientImplIOS.mm
 UIProcess/ios/ProcessAssertionIOS.mm
 UIProcess/ios/ResourceLoadStatisticsPersistentStorageIOS.mm
@@ -446,6 +445,7 @@ UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm
 
 UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
 UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm
+UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm
 UIProcess/RemoteLayerTree/RemoteLayerTreeScrollingPerformanceData.mm
 UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
 UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp
index 8369e33..061cc7a 100644 (file)
@@ -6366,7 +6366,7 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 
 - (NSDictionary *)_propertiesOfLayerWithID:(unsigned long long)layerID
 {
-    CALayer* layer = asLayer(downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).layerWithIDForTesting(layerID));
+    CALayer* layer = downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).layerWithIDForTesting(layerID);
     if (!layer)
         return nil;
 
index aceeb9f..7d3abc7 100644 (file)
@@ -478,7 +478,8 @@ void VideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, uint
     }
 
 #if PLATFORM(IOS_FAMILY)
-    UIView *parentView = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootLayer();
+    auto* rootNode = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootNode();
+    UIView *parentView = rootNode ? rootNode->uiView() : nil;
     interface->setupFullscreen(*model->layerHostView(), initialRect, parentView, videoFullscreenMode, allowsPictureInPicture, standby);
 #else
     IntRect initialWindowRect;
index a16ae20..7defa40 100644 (file)
@@ -42,8 +42,8 @@
 #include <wtf/WeakPtr.h>
 
 #if PLATFORM(COCOA)
-#include "LayerRepresentation.h"
 #include "PluginComplexTextInputState.h"
+#include "RemoteLayerTreeNode.h"
 #include "WKFoundation.h"
 
 OBJC_CLASS CALayer;
@@ -245,8 +245,8 @@ public:
     virtual void notifyInputContextAboutDiscardedComposition() = 0;
     virtual void makeFirstResponder() = 0;
     virtual void assistiveTechnologyMakeFirstResponder() = 0;
-    virtual void setAcceleratedCompositingRootLayer(LayerOrView *) = 0;
-    virtual LayerOrView *acceleratedCompositingRootLayer() const = 0;
+    virtual void setRemoteLayerTreeRootNode(RemoteLayerTreeNode*) = 0;
+    virtual CALayer *acceleratedCompositingRootLayer() const = 0;
     virtual RefPtr<ViewSnapshot> takeViewSnapshot() = 0;
 #if ENABLE(MAC_GESTURE_EVENTS)
     virtual void gestureEventWasNotHandledByWebCore(const NativeWebGestureEvent&) = 0;
index 401b70c..d02a0ee 100644 (file)
@@ -58,7 +58,7 @@ public:
 
     bool isAlwaysOnLoggingAllowed() const;
 
-    LayerOrView* layerWithIDForTesting(uint64_t) const;
+    CALayer *layerWithIDForTesting(uint64_t) const;
 
 private:
     void sizeDidChange() override;
index 8b7a5d2..eb3e53a 100644 (file)
@@ -204,7 +204,7 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
 
     if (m_remoteLayerTreeHost->updateLayerTree(layerTreeTransaction)) {
         if (layerTreeTransaction.transactionID() >= m_transactionIDForUnhidingContent)
-            m_webPageProxy.setAcceleratedCompositingRootLayer(m_remoteLayerTreeHost->rootLayer());
+            m_webPageProxy.setRemoteLayerTreeRootNode(m_remoteLayerTreeHost->rootNode());
         else
             m_remoteLayerTreeHost->detachRootLayer();
     }
@@ -239,7 +239,7 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
         scrollPosition = layerTreeTransaction.scrollPosition();
 #endif
         updateDebugIndicator(layerTreeTransaction.contentsSize(), rootLayerChanged, scale, scrollPosition);
-        asLayer(m_debugIndicatorLayerTreeHost->rootLayer()).name = @"Indicator host root";
+        m_debugIndicatorLayerTreeHost->rootLayer().name = @"Indicator host root";
     }
 
     m_webPageProxy.layerTreeCommitComplete();
@@ -337,7 +337,7 @@ void RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator()
 void RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator(IntSize contentsSize, bool rootLayerChanged, float scale, const IntPoint& scrollPosition)
 {
     // Make sure we're the last sublayer.
-    CALayer *rootLayer = asLayer(m_remoteLayerTreeHost->rootLayer());
+    CALayer *rootLayer = m_remoteLayerTreeHost->rootLayer();
     [m_tileMapHostLayer removeFromSuperlayer];
     [rootLayer addSublayer:m_tileMapHostLayer.get()];
 
@@ -350,7 +350,7 @@ void RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator(IntSize contentsSize,
 
     if (rootLayerChanged) {
         [m_tileMapHostLayer setSublayers:@[]];
-        [m_tileMapHostLayer addSublayer:asLayer(m_debugIndicatorLayerTreeHost->rootLayer())];
+        [m_tileMapHostLayer addSublayer:m_debugIndicatorLayerTreeHost->rootLayer()];
         [m_tileMapHostLayer addSublayer:m_exposedRectIndicatorLayer.get()];
     }
     
@@ -500,7 +500,7 @@ bool RemoteLayerTreeDrawingAreaProxy::isAlwaysOnLoggingAllowed() const
     return m_webPageProxy.isAlwaysOnLoggingAllowed();
 }
 
-LayerOrView* RemoteLayerTreeDrawingAreaProxy::layerWithIDForTesting(uint64_t layerID) const
+CALayer *RemoteLayerTreeDrawingAreaProxy::layerWithIDForTesting(uint64_t layerID) const
 {
     return m_remoteLayerTreeHost->layerWithIDForTesting(layerID);
 }
index 5ad1b2a..afa5543 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "LayerRepresentation.h"
+#include "RemoteLayerTreeNode.h"
 #include "RemoteLayerTreeTransaction.h"
 #include <WebCore/PlatformCALayer.h>
 #include <wtf/HashMap.h>
@@ -45,11 +45,14 @@ public:
     explicit RemoteLayerTreeHost(RemoteLayerTreeDrawingAreaProxy&);
     virtual ~RemoteLayerTreeHost();
 
-    LayerOrView *getLayer(WebCore::GraphicsLayer::PlatformLayerID) const;
-    LayerOrView *rootLayer() const { return m_rootLayer; }
+    RemoteLayerTreeNode* nodeForID(WebCore::GraphicsLayer::PlatformLayerID) const;
+    RemoteLayerTreeNode* rootNode() const { return m_rootNode; }
 
     static WebCore::GraphicsLayer::PlatformLayerID layerID(CALayer*);
 
+    CALayer *layerForID(WebCore::GraphicsLayer::PlatformLayerID) const;
+    CALayer *rootLayer() const;
+
     // Returns true if the root layer changed.
     bool updateLayerTree(const RemoteLayerTreeTransaction&, float indicatorScaleFactor  = 1);
 
@@ -72,18 +75,18 @@ public:
     // This avoids keeping an outstanding InUse reference when suspended.
     void mapAllIOSurfaceBackingStore();
 
-    LayerOrView* layerWithIDForTesting(uint64_t) const;
+    CALayer *layerWithIDForTesting(uint64_t) const;
 
 private:
-    LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
+    void createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
     RetainPtr<WKEmbeddedView> createEmbeddedView(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
     static void setLayerID(CALayer *, WebCore::GraphicsLayer::PlatformLayerID);
 
     void layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID);
 
     RemoteLayerTreeDrawingAreaProxy* m_drawingArea { nullptr };
-    LayerOrView *m_rootLayer { nullptr };
-    HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<LayerOrView>> m_layers;
+    RemoteLayerTreeNode* m_rootNode { nullptr };
+    HashMap<WebCore::GraphicsLayer::PlatformLayerID, std::unique_ptr<RemoteLayerTreeNode>> m_nodes;
     HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<WKAnimationDelegate>> m_animationDelegates;
     HashMap<WebCore::GraphicsLayer::EmbeddedViewID, RetainPtr<WKEmbeddedView>> m_embeddedViews;
     HashMap<WebCore::GraphicsLayer::PlatformLayerID, WebCore::GraphicsLayer::EmbeddedViewID> m_layerToEmbeddedViewMap;
index 93cfad8..562ad7f 100644 (file)
@@ -75,13 +75,13 @@ bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& tran
     }
 
     bool rootLayerChanged = false;
-    LayerOrView *rootLayer = getLayer(transaction.rootLayerID());
+    auto* rootNode = nodeForID(transaction.rootLayerID());
     
-    if (!rootLayer)
+    if (!rootNode)
         RELEASE_LOG_IF_ALLOWED("%p RemoteLayerTreeHost::updateLayerTree - failed to find root layer with ID %llu", this, transaction.rootLayerID());
 
-    if (m_rootLayer != rootLayer) {
-        m_rootLayer = rootLayer;
+    if (m_rootNode != rootNode) {
+        m_rootNode = rootNode;
         rootLayerChanged = true;
     }
 
@@ -99,35 +99,35 @@ bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& tran
         auto layerID = changedLayer.key;
         const RemoteLayerTreeTransaction::LayerProperties& properties = *changedLayer.value;
 
-        LayerOrView *layer = getLayer(layerID);
-        ASSERT(layer);
+        auto* node = nodeForID(layerID);
+        ASSERT(node);
 
         RemoteLayerTreePropertyApplier::RelatedLayerMap relatedLayers;
         if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
             for (auto& child : properties.children)
-                relatedLayers.set(child, (__bridge CFTypeRef)getLayer(child));
+                relatedLayers.set(child, nodeForID(child));
         }
 
         if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged && properties.maskLayerID)
-            relatedLayers.set(properties.maskLayerID, (__bridge CFTypeRef)getLayer(properties.maskLayerID));
+            relatedLayers.set(properties.maskLayerID, nodeForID(properties.maskLayerID));
 
         if (properties.changedProperties & RemoteLayerTreeTransaction::ClonedContentsChanged && properties.clonedLayerID)
             clonesToUpdate.append(LayerIDPair(layerID, properties.clonedLayerID));
 
         if (m_isDebugLayerTreeHost) {
-            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers, layerContentsType);
+            RemoteLayerTreePropertyApplier::applyProperties(*node, this, properties, relatedLayers, layerContentsType);
 
             if (properties.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
-                asLayer(layer).borderWidth = properties.borderWidth / indicatorScaleFactor;
-            asLayer(layer).masksToBounds = false;
+                node->layer().borderWidth = properties.borderWidth / indicatorScaleFactor;
+            node->layer().masksToBounds = false;
         } else
-            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers, layerContentsType);
+            RemoteLayerTreePropertyApplier::applyProperties(*node, this, properties, relatedLayers, layerContentsType);
     }
     
     for (const auto& layerPair : clonesToUpdate) {
-        LayerOrView *layer = getLayer(layerPair.first);
-        LayerOrView *clonedLayer = getLayer(layerPair.second);
-        asLayer(layer).contents = asLayer(clonedLayer).contents;
+        auto* layer = layerForID(layerPair.first);
+        auto* clonedLayer = layerForID(layerPair.second);
+        layer.contents = clonedLayer.contents;
     }
 
     for (auto& destroyedLayer : transaction.destroyedLayers())
@@ -136,17 +136,17 @@ bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& tran
     // Drop the contents of any layers which were unparented; the Web process will re-send
     // the backing store in the commit that reparents them.
     for (auto& newlyUnreachableLayerID : transaction.layerIDsWithNewlyUnreachableBackingStore())
-        asLayer(getLayer(newlyUnreachableLayerID)).contents = nullptr;
+        layerForID(newlyUnreachableLayerID).contents = nullptr;
 
     return rootLayerChanged;
 }
 
-LayerOrView *RemoteLayerTreeHost::getLayer(GraphicsLayer::PlatformLayerID layerID) const
+RemoteLayerTreeNode* RemoteLayerTreeHost::nodeForID(GraphicsLayer::PlatformLayerID layerID) const
 {
     if (!layerID)
-        return nil;
+        return nullptr;
 
-    return m_layers.get(layerID).get();
+    return m_nodes.get(layerID);
 }
 
 void RemoteLayerTreeHost::layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID layerID)
@@ -163,7 +163,7 @@ void RemoteLayerTreeHost::layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLay
         m_layerToEmbeddedViewMap.remove(embeddedViewIter);
     }
 
-    m_layers.remove(layerID);
+    m_nodes.remove(layerID);
 }
 
 void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, CAAnimation *animation, MonotonicTime startTime)
@@ -171,7 +171,7 @@ void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLaye
     if (!m_drawingArea)
         return;
 
-    CALayer *layer = asLayer(getLayer(layerID));
+    CALayer *layer = layerForID(layerID);
     if (!layer)
         return;
 
@@ -192,7 +192,7 @@ void RemoteLayerTreeHost::animationDidEnd(WebCore::GraphicsLayer::PlatformLayerI
     if (!m_drawingArea)
         return;
 
-    CALayer *layer = asLayer(getLayer(layerID));
+    CALayer *layer = layerForID(layerID);
     if (!layer)
         return;
 
@@ -215,24 +215,20 @@ void RemoteLayerTreeHost::detachFromDrawingArea()
 
 void RemoteLayerTreeHost::clearLayers()
 {
-    for (auto& idLayer : m_layers) {
-        m_animationDelegates.remove(idLayer.key);
-#if PLATFORM(IOS_FAMILY)
-        [idLayer.value.get() removeFromSuperview];
-#else
-        [asLayer(idLayer.value.get()) removeFromSuperlayer];
-#endif
+    for (auto& keyAndNode : m_nodes) {
+        m_animationDelegates.remove(keyAndNode.key);
+        keyAndNode.value->detachFromParent();
     }
 
-    m_layers.clear();
+    m_nodes.clear();
     m_embeddedViews.clear();
     m_layerToEmbeddedViewMap.clear();
-    m_rootLayer = nullptr;
+    m_rootNode = nullptr;
 }
 
-LayerOrView* RemoteLayerTreeHost::layerWithIDForTesting(uint64_t layerID) const
+CALayer *RemoteLayerTreeHost::layerWithIDForTesting(uint64_t layerID) const
 {
-    return getLayer(layerID);
+    return layerForID(layerID);
 }
 
 static NSString* const WKLayerIDPropertyKey = @"WKLayerID";
@@ -247,12 +243,27 @@ WebCore::GraphicsLayer::PlatformLayerID RemoteLayerTreeHost::layerID(CALayer* la
     return [[layer valueForKey:WKLayerIDPropertyKey] unsignedLongLongValue];
 }
 
+CALayer *RemoteLayerTreeHost::layerForID(WebCore::GraphicsLayer::PlatformLayerID layerID) const
+{
+    auto* node = nodeForID(layerID);
+    if (!node)
+        return nil;
+    return node->layer();
+}
+
+CALayer *RemoteLayerTreeHost::rootLayer() const
+{
+    if (!m_rootNode)
+        return nil;
+    return m_rootNode->layer();
+}
+
 #if !PLATFORM(IOS_FAMILY)
-LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties*)
+void RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties*)
 {
-    RetainPtr<CALayer>& layer = m_layers.add(properties.layerID, nullptr).iterator->value;
+    ASSERT(!m_nodes.contains(properties.layerID));
 
-    ASSERT(!layer);
+    RetainPtr<CALayer> layer;
 
     switch (properties.type) {
     case PlatformCALayer::LayerTypeLayer:
@@ -297,18 +308,16 @@ LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::
     [layer setDelegate:[WebActionDisablingCALayerDelegate shared]];
     setLayerID(layer.get(), properties.layerID);
 
-    return layer.get();
+    m_nodes.add(properties.layerID, std::make_unique<RemoteLayerTreeNode>(WTFMove(layer)));
 }
 #endif
 
 void RemoteLayerTreeHost::detachRootLayer()
 {
-#if PLATFORM(IOS_FAMILY)
-    [m_rootLayer removeFromSuperview];
-#else
-    [asLayer(m_rootLayer) removeFromSuperlayer];
-#endif
-    m_rootLayer = nullptr;
+    if (!m_rootNode)
+        return;
+    m_rootNode->detachFromParent();
+    m_rootNode = nullptr;
 }
 
 #if HAVE(IOSURFACE)
@@ -328,7 +337,7 @@ static void recursivelyMapIOSurfaceBackingStore(CALayer *layer)
 void RemoteLayerTreeHost::mapAllIOSurfaceBackingStore()
 {
 #if HAVE(IOSURFACE)
-    recursivelyMapIOSurfaceBackingStore(asLayer(m_rootLayer));
+    recursivelyMapIOSurfaceBackingStore(rootLayer());
 #endif
 }
 
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "config.h"
-#import "LayerRepresentation.h"
+#pragma once
 
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS CALayer;
 #if PLATFORM(IOS_FAMILY)
-#import <UIKit/UIView.h>
-CALayer *asLayer(LayerOrView *view)
-{
-    return view.layer;
-}
+OBJC_CLASS UIView;
+#endif
+
+namespace WebKit {
+
+class RemoteLayerTreeNode {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    RemoteLayerTreeNode(RetainPtr<CALayer>);
+#if PLATFORM(IOS_FAMILY)
+    RemoteLayerTreeNode(RetainPtr<UIView>);
+#endif
+
+    ~RemoteLayerTreeNode();
+
+    CALayer *layer() const { return m_layer.get(); }
+#if PLATFORM(IOS_FAMILY)
+    UIView *uiView() const { return m_uiView.get(); }
+#endif
+
+    void detachFromParent();
+
+private:
+    RetainPtr<CALayer> m_layer;
+#if PLATFORM(IOS_FAMILY)
+    RetainPtr<UIView> m_uiView;
 #endif
+};
+
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef LayerRepresentation_h
-#define LayerRepresentation_h
+#include "config.h"
+#include "RemoteLayerTreeNode.h"
 
-#if PLATFORM(IOS_FAMILY)
-
-OBJC_CLASS CALayer;
-OBJC_CLASS UIView;
-typedef UIView LayerOrView;
-
-CALayer *asLayer(LayerOrView *);
-
-#else
+namespace WebKit {
 
-OBJC_CLASS CALayer;
-typedef CALayer LayerOrView;
+RemoteLayerTreeNode::RemoteLayerTreeNode(RetainPtr<CALayer> layer)
+    : m_layer(WTFMove(layer))
+{
+}
 
-inline CALayer *asLayer(LayerOrView *layer)
+#if PLATFORM(IOS_FAMILY)
+RemoteLayerTreeNode::RemoteLayerTreeNode(RetainPtr<UIView> uiView)
+    : m_layer([uiView.get() layer])
+    , m_uiView(WTFMove(uiView))
 {
-    return layer;
 }
+#endif
+
+RemoteLayerTreeNode::~RemoteLayerTreeNode() = default;
 
+void RemoteLayerTreeNode::detachFromParent()
+{
+#if PLATFORM(IOS_FAMILY)
+    [uiView() removeFromSuperview];
+#else
+    [layer() removeFromSuperlayer];
 #endif
+}
 
-#endif // LayerRepresentation_h
+}
index 85dacfe..813b181 100644 (file)
@@ -100,7 +100,7 @@ static CALayer *findTileGridContainerLayer(CALayer *layer)
 
 unsigned RemoteLayerTreeScrollingPerformanceData::blankPixelCount(const FloatRect& visibleRect) const
 {
-    CALayer *rootLayer = asLayer(m_drawingArea.remoteLayerTreeHost().rootLayer());
+    CALayer *rootLayer = m_drawingArea.remoteLayerTreeHost().rootLayer();
 
     CALayer *tileGridContainer = findTileGridContainerLayer(rootLayer);
     if (!tileGridContainer) {
index a86e16e..ea73ca2 100644 (file)
@@ -95,11 +95,12 @@ void RemoteScrollingCoordinatorProxy::commitScrollingTreeState(const RemoteScrol
 }
 
 #if !PLATFORM(IOS_FAMILY)
+
 void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost)
 {
     for (auto& currNode : stateTree.nodeMap().values()) {
         if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
-            currNode->setLayer(layerTreeHost.getLayer(currNode->layer()));
+            currNode->setLayer(layerTreeHost.layerForID(currNode->layer()));
 
         switch (currNode->nodeType()) {
         case MainFrameScrollingNode:
@@ -107,30 +108,30 @@ void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree&
             ScrollingStateFrameScrollingNode& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(*currNode);
             
             if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer))
-                scrollingStateNode.setScrolledContentsLayer(layerTreeHost.getLayer(scrollingStateNode.scrolledContentsLayer()));
+                scrollingStateNode.setScrolledContentsLayer(layerTreeHost.layerForID(scrollingStateNode.scrolledContentsLayer()));
 
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer))
-                scrollingStateNode.setCounterScrollingLayer(layerTreeHost.getLayer(scrollingStateNode.counterScrollingLayer()));
+                scrollingStateNode.setCounterScrollingLayer(layerTreeHost.layerForID(scrollingStateNode.counterScrollingLayer()));
 
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer))
-                scrollingStateNode.setInsetClipLayer(layerTreeHost.getLayer(scrollingStateNode.insetClipLayer()));
+                scrollingStateNode.setInsetClipLayer(layerTreeHost.layerForID(scrollingStateNode.insetClipLayer()));
 
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer))
-                scrollingStateNode.setContentShadowLayer(layerTreeHost.getLayer(scrollingStateNode.contentShadowLayer()));
+                scrollingStateNode.setContentShadowLayer(layerTreeHost.layerForID(scrollingStateNode.contentShadowLayer()));
 
             // FIXME: we should never have header and footer layers coming from the WebProcess.
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer))
-                scrollingStateNode.setHeaderLayer(layerTreeHost.getLayer(scrollingStateNode.headerLayer()));
+                scrollingStateNode.setHeaderLayer(layerTreeHost.layerForID(scrollingStateNode.headerLayer()));
 
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer))
-                scrollingStateNode.setFooterLayer(layerTreeHost.getLayer(scrollingStateNode.footerLayer()));
+                scrollingStateNode.setFooterLayer(layerTreeHost.layerForID(scrollingStateNode.footerLayer()));
             break;
         }
         case OverflowScrollingNode: {
             ScrollingStateOverflowScrollingNode& scrollingStateNode = downcast<ScrollingStateOverflowScrollingNode>(*currNode);
 
             if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer))
-                scrollingStateNode.setScrolledContentsLayer(layerTreeHost.getLayer(scrollingStateNode.scrolledContentsLayer()));
+                scrollingStateNode.setScrolledContentsLayer(layerTreeHost.layerForID(scrollingStateNode.scrolledContentsLayer()));
             break;
         }
         case FixedNode:
index bd4ddf5..9adffde 100644 (file)
@@ -58,11 +58,11 @@ static RetainPtr<UIView> createRemoteView(pid_t pid, uint32_t contextID)
     return adoptNS([[WKRemoteView alloc] initWithFrame:CGRectZero contextID:contextID]);
 }
 
-LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
+void RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
 {
-    RetainPtr<LayerOrView>& view = m_layers.add(properties.layerID, nullptr).iterator->value;
+    ASSERT(!m_nodes.contains(properties.layerID));
 
-    ASSERT(!view);
+    RetainPtr<UIView> view;
 
     switch (properties.type) {
     case PlatformCALayer::LayerTypeLayer:
@@ -117,7 +117,7 @@ LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::
 
     setLayerID([view layer], properties.layerID);
 
-    return view.get();
+    m_nodes.add(properties.layerID, std::make_unique<RemoteLayerTreeNode>(WTFMove(view)));
 }
 
 RetainPtr<WKEmbeddedView> RemoteLayerTreeHost::createEmbeddedView(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
index c82ab41..e38435b 100644 (file)
@@ -29,8 +29,8 @@
 #if PLATFORM(IOS_FAMILY)
 #if ENABLE(ASYNC_SCROLLING)
 
-#import "LayerRepresentation.h"
 #import "RemoteLayerTreeHost.h"
+#import "RemoteLayerTreeNode.h"
 #import "WebPageProxy.h"
 #import <UIKit/UIView.h>
 #import <WebCore/ScrollingStateFrameScrollingNode.h>
 namespace WebKit {
 using namespace WebCore;
 
-static LayerRepresentation layerRepresentationFromLayerOrView(LayerOrView *layerOrView)
-{
-    return LayerRepresentation(layerOrView.layer);
-}
-
 void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost)
 {
     for (auto& currNode : stateTree.nodeMap().values()) {
@@ -60,10 +55,10 @@ void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree&
             ScrollingStateOverflowScrollingNode& scrollingStateNode = downcast<ScrollingStateOverflowScrollingNode>(*currNode);
             
             if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::ScrollLayer))
-                scrollingStateNode.setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode.layer())));
+                scrollingStateNode.setLayer(layerTreeHost.layerForID(scrollingStateNode.layer()));
             
             if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer))
-                scrollingStateNode.setScrolledContentsLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode.scrolledContentsLayer())));
+                scrollingStateNode.setScrolledContentsLayer(layerTreeHost.layerForID(scrollingStateNode.scrolledContentsLayer()));
             break;
         };
         case MainFrameScrollingNode:
@@ -71,23 +66,23 @@ void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree&
             ScrollingStateFrameScrollingNode& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(*currNode);
             
             if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::ScrollLayer))
-                scrollingStateNode.setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode.layer())));
+                scrollingStateNode.setLayer(layerTreeHost.layerForID(scrollingStateNode.layer()));
 
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer))
-                scrollingStateNode.setCounterScrollingLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode.counterScrollingLayer())));
+                scrollingStateNode.setCounterScrollingLayer(layerTreeHost.layerForID(scrollingStateNode.counterScrollingLayer()));
 
             // FIXME: we should never have header and footer layers coming from the WebProcess.
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer))
-                scrollingStateNode.setHeaderLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode.headerLayer())));
+                scrollingStateNode.setHeaderLayer(layerTreeHost.layerForID(scrollingStateNode.headerLayer()));
 
             if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer))
-                scrollingStateNode.setFooterLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode.footerLayer())));
+                scrollingStateNode.setFooterLayer(layerTreeHost.layerForID(scrollingStateNode.footerLayer()));
             break;
         }
         case FixedNode:
         case StickyNode:
             if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
-                currNode->setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(currNode->layer())));
+                currNode->setLayer(layerTreeHost.layerForID(currNode->layer()));
             break;
         }
     }
index bc36323..7d2d35f 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "AuthenticatorTransportService.h"
 #include <IOKit/hid/IOHIDManager.h>
+#include <wtf/RetainPtr.h>
 #include <wtf/UniqueRef.h>
 
 namespace WebKit {
index 554d826..2b386e0 100644 (file)
@@ -35,6 +35,7 @@
 #import <WebCore/DeviceResponseConverter.h>
 #import <WebCore/FidoConstants.h>
 #import <WebCore/FidoHidMessage.h>
+#import <wtf/RunLoop.h>
 
 namespace WebKit {
 using namespace fido;
index 071772c..c393685 100644 (file)
@@ -112,7 +112,7 @@ OBJC_CLASS _WKRemoteObjectRegistry;
 
 #if PLATFORM(COCOA)
 #include "DynamicViewportSizeUpdate.h"
-#include "LayerRepresentation.h"
+#include "RemoteLayerTreeNode.h"
 #include "TouchBarMenuData.h"
 #include "TouchBarMenuItemData.h"
 #endif
@@ -699,8 +699,8 @@ public:
     bool shouldDelayWindowOrderingForEvent(const WebMouseEvent&);
     bool acceptsFirstMouse(int eventNumber, const WebMouseEvent&);
 
-    void setAcceleratedCompositingRootLayer(LayerOrView*);
-    LayerOrView* acceleratedCompositingRootLayer() const;
+    void setRemoteLayerTreeRootNode(RemoteLayerTreeNode*);
+    CALayer *acceleratedCompositingRootLayer() const;
 
     void setTextAsync(const String&);
     void insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup = false, EditingRangeIsRelativeTo = EditingRangeIsRelativeTo::EditableRoot, bool suppressSelectionUpdate = false);
index 479b56a..ca45a1d 100644 (file)
@@ -121,8 +121,8 @@ private:
     void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
     void exitAcceleratedCompositingMode() override;
     void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
-    void setAcceleratedCompositingRootLayer(LayerOrView *) override;
-    LayerOrView *acceleratedCompositingRootLayer() const override;
+    void setRemoteLayerTreeRootNode(RemoteLayerTreeNode*) override;
+    CALayer* acceleratedCompositingRootLayer() const override;
     LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
 
     RefPtr<ViewSnapshot> takeViewSnapshot() override;
index d140da3..233bd89 100644 (file)
@@ -495,12 +495,12 @@ void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
 {
 }
 
-void PageClientImpl::setAcceleratedCompositingRootLayer(LayerOrView *rootLayer)
+void PageClientImpl::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode)
 {
-    [m_contentView _setAcceleratedCompositingRootView:rootLayer];
+    [m_contentView _setAcceleratedCompositingRootView:rootNode ? rootNode->uiView() : nil];
 }
 
-LayerOrView *PageClientImpl::acceleratedCompositingRootLayer() const
+CALayer *PageClientImpl::acceleratedCompositingRootLayer() const
 {
     notImplemented();
     return nullptr;
index dc80283..efa83ca 100644 (file)
@@ -991,9 +991,9 @@ void WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication(const String&
     notImplemented();
 }
 
-void WebPageProxy::setAcceleratedCompositingRootLayer(LayerOrView* rootLayer)
+void WebPageProxy::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode)
 {
-    pageClient().setAcceleratedCompositingRootLayer(rootLayer);
+    pageClient().setRemoteLayerTreeRootNode(rootNode);
     m_frozenRemoteLayerTreeHost = nullptr;
 }
 
index 08f45db..6bc8bdd 100644 (file)
@@ -75,8 +75,8 @@ private:
     bool isVisuallyIdle() override;
     LayerHostingMode viewLayerHostingMode() override;
     ColorSpaceData colorSpace() override;
-    void setAcceleratedCompositingRootLayer(LayerOrView *) override;
-    LayerOrView *acceleratedCompositingRootLayer() const override;
+    void setRemoteLayerTreeRootNode(RemoteLayerTreeNode*) override;
+    CALayer *acceleratedCompositingRootLayer() const override;
 
     void processDidExit() override;
     void processWillSwap() override;
index 9134168..e374b99 100644 (file)
@@ -542,9 +542,9 @@ void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& la
     m_impl->setAcceleratedCompositingRootLayer(renderLayer);
 }
 
-void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
+void PageClientImpl::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode)
 {
-    m_impl->setAcceleratedCompositingRootLayer(rootLayer);
+    m_impl->setAcceleratedCompositingRootLayer(rootNode ? rootNode->layer() : nil);
 }
 
 CALayer *PageClientImpl::acceleratedCompositingRootLayer() const
index 06dbaa5..bc8bc41 100644 (file)
@@ -143,7 +143,7 @@ MachSendRight TiledCoreAnimationDrawingAreaProxy::createFence()
     if (!m_webPageProxy.isValid())
         return MachSendRight();
 
-    RetainPtr<CAContext> rootLayerContext = [asLayer(m_webPageProxy.acceleratedCompositingRootLayer()) context];
+    RetainPtr<CAContext> rootLayerContext = [m_webPageProxy.acceleratedCompositingRootLayer() context];
     if (!rootLayerContext)
         return MachSendRight();
 
index 15c7d76..fffc5e0 100644 (file)
@@ -455,13 +455,13 @@ void WebPageProxy::intrinsicContentSizeDidChange(const IntSize& intrinsicContent
     pageClient().intrinsicContentSizeDidChange(intrinsicContentSize);
 }
 
-void WebPageProxy::setAcceleratedCompositingRootLayer(LayerOrView* rootLayer)
+void WebPageProxy::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode)
 {
-    pageClient().setAcceleratedCompositingRootLayer(rootLayer);
+    pageClient().setRemoteLayerTreeRootNode(rootNode);
     m_frozenRemoteLayerTreeHost = nullptr;
 }
 
-LayerOrView* WebPageProxy::acceleratedCompositingRootLayer() const
+CALayer *WebPageProxy::acceleratedCompositingRootLayer() const
 {
     return pageClient().acceleratedCompositingRootLayer();
 }
index f4441fd..2819069 100644 (file)
                E4436ECF1A0D040B00EAD204 /* NetworkCacheStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E4436EC21A0CFDB200EAD204 /* NetworkCacheStorage.h */; };
                E489D28C1A0A2DB80078C06A /* NetworkCacheCoders.h in Headers */ = {isa = PBXBuildFile; fileRef = E489D2851A0A2DB80078C06A /* NetworkCacheCoders.h */; };
                E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E49D40D61AD3FB170066B7B9 /* NetworkCacheBlobStorage.h */; };
+               E4E57F6B21A83B1200345F3C /* RemoteLayerTreeNode.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E57F6A21A83B1100345F3C /* RemoteLayerTreeNode.h */; };
                E4E864931B16750700C82F40 /* VersionChecks.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E8648E1B1673FB00C82F40 /* VersionChecks.h */; };
                E52CF55220A35C3A00DADA27 /* WebDataListSuggestionPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF55020A35C3A00DADA27 /* WebDataListSuggestionPicker.h */; };
                E548EBD121015F0E00BE3C32 /* WKFormColorPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E548EBCF21015F0E00BE3C32 /* WKFormColorPicker.h */; };
                E489D2851A0A2DB80078C06A /* NetworkCacheCoders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheCoders.h; sourceTree = "<group>"; };
                E49D40D61AD3FB170066B7B9 /* NetworkCacheBlobStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheBlobStorage.h; sourceTree = "<group>"; };
                E49D40D81AD3FB210066B7B9 /* NetworkCacheBlobStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheBlobStorage.cpp; sourceTree = "<group>"; };
+               E4E57F6821A83B0300345F3C /* RemoteLayerTreeNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeNode.mm; sourceTree = "<group>"; };
+               E4E57F6A21A83B1100345F3C /* RemoteLayerTreeNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerTreeNode.h; sourceTree = "<group>"; };
                E4E8648E1B1673FB00C82F40 /* VersionChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionChecks.h; sourceTree = "<group>"; };
                E4E8648F1B1673FB00C82F40 /* VersionChecks.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VersionChecks.mm; sourceTree = "<group>"; };
                E52CF55020A35C3A00DADA27 /* WebDataListSuggestionPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebDataListSuggestionPicker.h; sourceTree = "<group>"; };
                                1AB16ADF1648656D00290D62 /* RemoteLayerTreeDrawingAreaProxy.mm */,
                                1AA3D75A1651B44F008713D0 /* RemoteLayerTreeHost.h */,
                                1AA3D7591651B44F008713D0 /* RemoteLayerTreeHost.mm */,
+                               E4E57F6A21A83B1100345F3C /* RemoteLayerTreeNode.h */,
+                               E4E57F6821A83B0300345F3C /* RemoteLayerTreeNode.mm */,
                                0F707C791A1FEEA300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.h */,
                                0F707C771A1FEE8300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.mm */,
                                0F594794187B3B6000437857 /* RemoteScrollingCoordinatorProxy.cpp */,
                                7A8A9D5A1EF13029009801AE /* APIInjectedBundleBundleClient.h in Headers */,
                                7A8A9D581EF119B0009801AE /* APIInjectedBundleClient.h in Headers */,
                                377512311DF0DEE2008A351C /* APIInjectedBundleEditorClient.h in Headers */,
+                               E4E57F6B21A83B1200345F3C /* RemoteLayerTreeNode.h in Headers */,
                                3769079E18F340A2001DFF04 /* APIInjectedBundleFormClient.h in Headers */,
                                7A3ACE1B1EEEF79B00A864A4 /* APIInjectedBundlePageLoaderClient.h in Headers */,
                                7A8A9D5C1EF14598009801AE /* APIInjectedBundlePageResourceLoadClient.h in Headers */,
index 415b1b8..eca95e7 100644 (file)
@@ -174,7 +174,7 @@ void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeContext& co
         }
 
         if (isPlatformCALayerRemoteCustom()) {
-            RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap(), RemoteLayerBackingStore::LayerContentsType::CAMachPort);
+            RemoteLayerTreePropertyApplier::applyPropertiesToLayer(platformLayer(), nullptr, m_properties, RemoteLayerBackingStore::LayerContentsType::CAMachPort);
             didCommit();
             return;
         }