Title: [238550] trunk/Source/WebKit
Revision
238550
Author
[email protected]
Date
2018-11-27 05:34:17 -0800 (Tue, 27 Nov 2018)

Log Message

Factor mask layer applying in RemoteLayerTreePropertyApplier into a shared function
https://bugs.webkit.org/show_bug.cgi?id=192001

Reviewed by Tim Horton.

* Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
* Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
(WebKit::RemoteLayerTreePropertyApplier::applyProperties):
(WebKit::RemoteLayerTreePropertyApplier::updateMask):

Shared function, with some special tricks for iOS backdrop layers.

(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (238549 => 238550)


--- trunk/Source/WebKit/ChangeLog	2018-11-27 12:39:27 UTC (rev 238549)
+++ trunk/Source/WebKit/ChangeLog	2018-11-27 13:34:17 UTC (rev 238550)
@@ -1,5 +1,21 @@
 2018-11-27  Antti Koivisto  <[email protected]>
 
+        Factor mask layer applying in RemoteLayerTreePropertyApplier into a shared function
+        https://bugs.webkit.org/show_bug.cgi?id=192001
+
+        Reviewed by Tim Horton.
+
+        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
+        (WebKit::RemoteLayerTreePropertyApplier::updateMask):
+
+        Shared function, with some special tricks for iOS backdrop layers.
+
+        (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):
+
+2018-11-27  Antti Koivisto  <[email protected]>
+
         Stop collecting related layers in RemoteLayerTreeHost::updateLayerTree
         https://bugs.webkit.org/show_bug.cgi?id=192003
 

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h (238549 => 238550)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h	2018-11-27 12:39:27 UTC (rev 238549)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h	2018-11-27 13:34:17 UTC (rev 238550)
@@ -41,6 +41,7 @@
 
 private:
     static void updateChildren(RemoteLayerTreeNode&, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
+    static void updateMask(RemoteLayerTreeNode&, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
 #if PLATFORM(IOS_FAMILY)
     static void applyPropertiesToUIView(UIView *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
 #endif

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm (238549 => 238550)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm	2018-11-27 12:39:27 UTC (rev 238549)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm	2018-11-27 13:34:17 UTC (rev 238550)
@@ -258,25 +258,14 @@
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    CALayer *layer = node.layer();
-
-    applyPropertiesToLayer(layer, layerTreeHost, properties, layerContentsType);
+    applyPropertiesToLayer(node.layer(), layerTreeHost, properties, layerContentsType);
     updateChildren(node, properties, relatedLayers);
+    updateMask(node, properties, relatedLayers);
 
 #if PLATFORM(IOS_FAMILY)
     applyPropertiesToUIView(node.uiView(), properties, relatedLayers);
-#else
-    if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged) {
-        if (!properties.maskLayerID)
-            layer.mask = nullptr;
-        else {
-            CALayer *maskLayer = relatedLayers.get(properties.maskLayerID)->layer();
-            ASSERT(!maskLayer.superlayer);
-            if (!maskLayer.superlayer)
-                layer.mask = maskLayer;
-        }
-    }
 #endif
+
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
@@ -328,30 +317,39 @@
     node.layer().sublayers = sublayers.get();
 }
 
-#if PLATFORM(IOS_FAMILY)
-void RemoteLayerTreePropertyApplier::applyPropertiesToUIView(UIView *view, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
+void RemoteLayerTreePropertyApplier::updateMask(RemoteLayerTreeNode& node, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
 {
-    if (properties.changedProperties.contains(RemoteLayerTreeTransaction::MaskLayerChanged)) {
-        CALayer *maskOwnerLayer = view.layer;
+    if (!properties.changedProperties.contains(RemoteLayerTreeTransaction::MaskLayerChanged))
+        return;
 
+    auto maskOwnerLayer = [&] {
+        CALayer *layer = node.layer();
+#if PLATFORM(IOS_FAMILY)
         if (properties.customAppearance == GraphicsLayer::CustomAppearance::LightBackdrop || properties.customAppearance == GraphicsLayer::CustomAppearance::DarkBackdrop) {
             // This is a UIBackdropView, which means any mask must be applied to the CABackdropLayer rather
             // that the view's layer. The backdrop is the first layer child.
-            if (view.layer.sublayers.count && [view.layer.sublayers[0] isKindOfClass:[CABackdropLayer class]])
-                maskOwnerLayer = view.layer.sublayers[0];
+            if (layer.sublayers.count && [layer.sublayers[0] isKindOfClass:[CABackdropLayer class]])
+                layer = layer.sublayers[0];
         }
+#endif
+        return layer;
+    };
 
-        if (!properties.maskLayerID)
-            maskOwnerLayer.mask = nullptr;
-        else {
-            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)
-                maskOwnerLayer.mask = maskView.layer;
-        }
+    if (!properties.maskLayerID) {
+        maskOwnerLayer().mask = nullptr;
+        return;
     }
 
+    CALayer *maskLayer = relatedLayers.get(properties.maskLayerID)->layer();
+    ASSERT(!maskLayer.superlayer);
+    if (maskLayer.superlayer)
+        return;
+    maskOwnerLayer().mask = maskLayer;
+}
+
+#if PLATFORM(IOS_FAMILY)
+void RemoteLayerTreePropertyApplier::applyPropertiesToUIView(UIView *view, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
+{
     if (properties.changedProperties.containsAny({ RemoteLayerTreeTransaction::ContentsHiddenChanged, RemoteLayerTreeTransaction::UserInteractionEnabledChanged }))
         view.userInteractionEnabled = !properties.contentsHidden && properties.userInteractionEnabled;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to