Title: [250069] trunk/Source/WebKit
Revision
250069
Author
[email protected]
Date
2019-09-18 17:07:32 -0700 (Wed, 18 Sep 2019)

Log Message

Eagerly create and add the m_layerHostingView to WKWebView.
https://bugs.webkit.org/show_bug.cgi?id=201942

Reviewed by Tim Horton.

Some apps will add subviews to WKWebView, and by the time we add our m_layerHostingView view we might be
adding it behind a view that should have been added behind our layer hosting view subview. This affected
the Spark email app, due to changes in order of loading delegate calls and when compositing is enabled.
Instead of delayed creation of m_layerHostingView, always create it and add it to to the WKWebView.
This ensures proper ordering of subviews when clients add a view behind all existing subviews.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::WebViewImpl): Create and add m_layerHostingView here.
(WebKit::WebViewImpl::setAcceleratedCompositingRootLayer): Remove creation and removal of m_layerHostingView.
Just set the sublayers of m_layerHostingView's layer here.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (250068 => 250069)


--- trunk/Source/WebKit/ChangeLog	2019-09-19 00:05:32 UTC (rev 250068)
+++ trunk/Source/WebKit/ChangeLog	2019-09-19 00:07:32 UTC (rev 250069)
@@ -1,3 +1,21 @@
+2019-09-18  Timothy Hatcher  <[email protected]>
+
+        Eagerly create and add the m_layerHostingView to WKWebView.
+        https://bugs.webkit.org/show_bug.cgi?id=201942
+
+        Reviewed by Tim Horton.
+
+        Some apps will add subviews to WKWebView, and by the time we add our m_layerHostingView view we might be
+        adding it behind a view that should have been added behind our layer hosting view subview. This affected
+        the Spark email app, due to changes in order of loading delegate calls and when compositing is enabled.
+        Instead of delayed creation of m_layerHostingView, always create it and add it to to the WKWebView.
+        This ensures proper ordering of subviews when clients add a view behind all existing subviews.
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::WebViewImpl): Create and add m_layerHostingView here.
+        (WebKit::WebViewImpl::setAcceleratedCompositingRootLayer): Remove creation and removal of m_layerHostingView.
+        Just set the sublayers of m_layerHostingView's layer here.
+
 2019-09-18  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Can't drag undocked Inspector window by its title text

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (250068 => 250069)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-09-19 00:05:32 UTC (rev 250068)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-09-19 00:07:32 UTC (rev 250069)
@@ -1332,6 +1332,22 @@
 
     [view addTrackingArea:m_primaryTrackingArea.get()];
 
+    // Create an NSView that will host our layer tree.
+    m_layerHostingView = adoptNS([[WKFlippedView alloc] initWithFrame:[m_view bounds]]);
+    [m_layerHostingView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+    [view addSubview:m_layerHostingView.get() positioned:NSWindowBelow relativeTo:nil];
+
+    // Create a root layer that will back the NSView.
+    RetainPtr<CALayer> layer = adoptNS([[CALayer alloc] init]);
+    [layer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+#ifndef NDEBUG
+    [layer setName:@"Hosting root layer"];
+#endif
+
+    [m_layerHostingView setLayer:layer.get()];
+    [m_layerHostingView setWantsLayer:YES];
+
     m_page->setIntrinsicDeviceScaleFactor(intrinsicDeviceScaleFactor());
 
     if (Class gestureClass = NSClassFromString(@"NSImmediateActionGestureRecognizer")) {
@@ -3746,34 +3762,8 @@
     [CATransaction begin];
     [CATransaction setDisableActions:YES];
 
-    if (rootLayer) {
-        if (!m_layerHostingView) {
-            // Create an NSView that will host our layer tree.
-            m_layerHostingView = adoptNS([[WKFlippedView alloc] initWithFrame:[m_view bounds]]);
-            [m_layerHostingView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+    [m_layerHostingView layer].sublayers = rootLayer ? @[ rootLayer ] : nil;
 
-            [m_view addSubview:m_layerHostingView.get() positioned:NSWindowBelow relativeTo:nil];
-
-            // Create a root layer that will back the NSView.
-            RetainPtr<CALayer> layer = adoptNS([[CALayer alloc] init]);
-            [layer setDelegate:[WebActionDisablingCALayerDelegate shared]];
-#ifndef NDEBUG
-            [layer setName:@"Hosting root layer"];
-#endif
-
-            [m_layerHostingView setLayer:layer.get()];
-            [m_layerHostingView setWantsLayer:YES];
-        }
-
-        [m_layerHostingView layer].sublayers = [NSArray arrayWithObject:rootLayer];
-    } else if (m_layerHostingView) {
-        [m_layerHostingView removeFromSuperview];
-        [m_layerHostingView setLayer:nil];
-        [m_layerHostingView setWantsLayer:NO];
-
-        m_layerHostingView = nullptr;
-    }
-
     [CATransaction commit];
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to