Title: [206247] trunk
Revision
206247
Author
m...@apple.com
Date
2016-09-21 22:03:01 -0700 (Wed, 21 Sep 2016)

Log Message

[macOS] Upon layout, _webView:renderingProgressDidChange: fires before the intrinsic content size is updated
https://bugs.webkit.org/show_bug.cgi?id=162359
<rdar://problem/27776454>

Reviewed by Tim Horton.

Source/WebKit2:

Test: added to TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h: Fixed a bug where
  m_pendingNewlyReachedLayoutMilestones was never initialized.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h: Added
  m_pendingNewlyReachedLayoutMilestones member variable to this derived class as well.
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::flushLayers): If we have pending milestones, notify
  the WebPageProxy now, after any content size changes have been sent.
(WebKit::TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone): New override that
  accumulates the milestones into m_pendingNewlyReachedLayoutMilestones and returns true,
  so that the caller won’t notify the WebPageProxy immediately.

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (206246 => 206247)


--- trunk/Source/WebKit2/ChangeLog	2016-09-22 04:36:22 UTC (rev 206246)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-22 05:03:01 UTC (rev 206247)
@@ -1,3 +1,25 @@
+2016-09-21  Dan Bernstein  <m...@apple.com>
+
+        [macOS] Upon layout, _webView:renderingProgressDidChange: fires before the intrinsic content size is updated
+        https://bugs.webkit.org/show_bug.cgi?id=162359
+        <rdar://problem/27776454>
+
+        Reviewed by Tim Horton.
+
+        Test: added to TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm
+
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h: Fixed a bug where
+          m_pendingNewlyReachedLayoutMilestones was never initialized.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h: Added
+          m_pendingNewlyReachedLayoutMilestones member variable to this derived class as well.
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::flushLayers): If we have pending milestones, notify
+          the WebPageProxy now, after any content size changes have been sent.
+        (WebKit::TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone): New override that
+          accumulates the milestones into m_pendingNewlyReachedLayoutMilestones and returns true,
+          so that the caller won’t notify the WebPageProxy immediately.
+
 2016-09-21  Anders Carlsson  <ander...@apple.com>
 
         support openPaymentSetup API on ApplePaySession object

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h (206246 => 206247)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h	2016-09-22 04:36:22 UTC (rev 206246)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h	2016-09-22 05:03:01 UTC (rev 206247)
@@ -163,7 +163,7 @@
     uint64_t m_currentTransactionID;
     Vector<RemoteLayerTreeTransaction::TransactionCallbackID> m_pendingCallbackIDs;
 
-    WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones;
+    WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones { 0 };
 
     WebCore::GraphicsLayer* m_contentLayer;
     WebCore::GraphicsLayer* m_viewOverlayRootLayer;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (206246 => 206247)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2016-09-22 04:36:22 UTC (rev 206246)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2016-09-22 05:03:01 UTC (rev 206247)
@@ -86,6 +86,8 @@
 
     void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
 
+    bool dispatchDidReachLayoutMilestone(WebCore::LayoutMilestones) override;
+
     // WebCore::LayerFlushSchedulerClient
     bool flushLayers() override;
 
@@ -154,6 +156,8 @@
     bool m_isScalingViewToFitDocument { false };
     WebCore::IntSize m_lastViewSizeForScaleToFit;
     WebCore::IntSize m_lastDocumentSizeForScaleToFit;
+
+    WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones { 0 };
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (206246 => 206247)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2016-09-22 04:36:22 UTC (rev 206246)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2016-09-22 05:03:01 UTC (rev 206247)
@@ -439,6 +439,10 @@
         if (m_transientZoomScale != 1)
             applyTransientZoomToLayers(m_transientZoomScale, m_transientZoomOrigin);
 
+        if (m_pendingNewlyReachedLayoutMilestones)
+            m_webPage.send(Messages::WebPageProxy::DidReachLayoutMilestone(m_pendingNewlyReachedLayoutMilestones));
+        m_pendingNewlyReachedLayoutMilestones = 0;
+
         return returnValue;
     }
 }
@@ -864,6 +868,12 @@
     m_layerHostingContext->setFencePort(fencePort.sendRight());
 }
 
+bool TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone(WebCore::LayoutMilestones layoutMilestones)
+{
+    m_pendingNewlyReachedLayoutMilestones |= layoutMilestones;
+    return true;
+}
+
 } // namespace WebKit
 
 #endif // !PLATFORM(IOS)

Modified: trunk/Tools/ChangeLog (206246 => 206247)


--- trunk/Tools/ChangeLog	2016-09-22 04:36:22 UTC (rev 206246)
+++ trunk/Tools/ChangeLog	2016-09-22 05:03:01 UTC (rev 206247)
@@ -1,3 +1,14 @@
+2016-09-21  Dan Bernstein  <m...@apple.com>
+
+        [macOS] Upon layout, _webView:renderingProgressDidChange: fires before the intrinsic content size is updated
+        https://bugs.webkit.org/show_bug.cgi?id=162359
+        <rdar://problem/27776454>
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm:
+        (TEST):
+
 2016-09-21  Keith Miller  <keith_mil...@apple.com>
 
         Fix build for future versions of Clang.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm (206246 => 206247)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm	2016-09-22 04:36:22 UTC (rev 206246)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm	2016-09-22 05:03:01 UTC (rev 206247)
@@ -36,12 +36,11 @@
 static bool didEvaluateJavaScript;
 
 @interface AutoLayoutWKWebView : WKWebView
+@property (nonatomic) BOOL expectingIntrinsicContentSizeChange;
+@property (nonatomic) NSSize expectedIntrinsicContentSize;
 @end
 
-@implementation AutoLayoutWKWebView {
-    BOOL _expectingIntrinsicContentSizeChange;
-    NSSize _expectedIntrinsicContentSize;
-}
+@implementation AutoLayoutWKWebView
 
 - (instancetype)initWithFrame:(NSRect)frame configuration:(WKWebViewConfiguration *)configuration
 {
@@ -156,6 +155,33 @@
     }];
     TestWebKitAPI::Util::run(&didEvaluateJavaScript);
     didEvaluateJavaScript = false;
+    [webView _setShouldExpandContentToViewHeightForAutoLayout:NO];
+
+    auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
+
+    __block bool didFinishNavigation = false;
+    [navigationDelegate setDidFinishNavigation:^(WKWebView *, WKNavigation *) {
+        didFinishNavigation = true;
+    }];
+    __block bool didFirstLayout = false;
+    [navigationDelegate setRenderingProgressDidChange:^(WKWebView *, _WKRenderingProgressEvents progressEvents) {
+        if (progressEvents & _WKRenderingProgressEventFirstLayout) {
+            didFirstLayout = true;
+            EXPECT_TRUE(didInvalidateIntrinsicContentSize);
+        }
+    }];
+    [webView setNavigationDelegate:navigationDelegate.get()];
+
+    [webView _setMinimumLayoutWidth:100];
+    didInvalidateIntrinsicContentSize = false;
+    [webView setExpectingIntrinsicContentSizeChange:YES];
+    [webView setExpectedIntrinsicContentSize:NSMakeSize(100, 400)];
+    [webView loadHTMLString:@"<body style='margin: 0; height: 400px;'></body>" baseURL:nil];
+    TestWebKitAPI::Util::run(&didInvalidateIntrinsicContentSize);
+    EXPECT_FALSE(didFirstLayout);
+    TestWebKitAPI::Util::run(&didFirstLayout);
+    TestWebKitAPI::Util::run(&didFinishNavigation);
+    [webView setNavigationDelegate:nil];
 }
 
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to