Changeset 206247 in webkit


Ignore:
Timestamp:
Sep 21, 2016 10:03:01 PM (8 years ago)
Author:
mitz@apple.com
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):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r206238 r206247  
     12016-09-21  Dan Bernstein  <mitz@apple.com>
     2
     3        [macOS] Upon layout, _webView:renderingProgressDidChange: fires before the intrinsic content size is updated
     4        https://bugs.webkit.org/show_bug.cgi?id=162359
     5        <rdar://problem/27776454>
     6
     7        Reviewed by Tim Horton.
     8
     9        Test: added to TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm
     10
     11        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h: Fixed a bug where
     12          m_pendingNewlyReachedLayoutMilestones was never initialized.
     13
     14        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h: Added
     15          m_pendingNewlyReachedLayoutMilestones member variable to this derived class as well.
     16        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
     17        (WebKit::TiledCoreAnimationDrawingArea::flushLayers): If we have pending milestones, notify
     18          the WebPageProxy now, after any content size changes have been sent.
     19        (WebKit::TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone): New override that
     20          accumulates the milestones into m_pendingNewlyReachedLayoutMilestones and returns true,
     21          so that the caller won’t notify the WebPageProxy immediately.
     22
    1232016-09-21  Anders Carlsson  <andersca@apple.com>
    224
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h

    r204665 r206247  
    164164    Vector<RemoteLayerTreeTransaction::TransactionCallbackID> m_pendingCallbackIDs;
    165165
    166     WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones;
     166    WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones { 0 };
    167167
    168168    WebCore::GraphicsLayer* m_contentLayer;
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h

    r202611 r206247  
    8787    void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
    8888
     89    bool dispatchDidReachLayoutMilestone(WebCore::LayoutMilestones) override;
     90
    8991    // WebCore::LayerFlushSchedulerClient
    9092    bool flushLayers() override;
     
    155157    WebCore::IntSize m_lastViewSizeForScaleToFit;
    156158    WebCore::IntSize m_lastDocumentSizeForScaleToFit;
     159
     160    WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones { 0 };
    157161};
    158162
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

    r202611 r206247  
    440440            applyTransientZoomToLayers(m_transientZoomScale, m_transientZoomOrigin);
    441441
     442        if (m_pendingNewlyReachedLayoutMilestones)
     443            m_webPage.send(Messages::WebPageProxy::DidReachLayoutMilestone(m_pendingNewlyReachedLayoutMilestones));
     444        m_pendingNewlyReachedLayoutMilestones = 0;
     445
    442446        return returnValue;
    443447    }
     
    865869}
    866870
     871bool TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone(WebCore::LayoutMilestones layoutMilestones)
     872{
     873    m_pendingNewlyReachedLayoutMilestones |= layoutMilestones;
     874    return true;
     875}
     876
    867877} // namespace WebKit
    868878
  • trunk/Tools/ChangeLog

    r206245 r206247  
     12016-09-21  Dan Bernstein  <mitz@apple.com>
     2
     3        [macOS] Upon layout, _webView:renderingProgressDidChange: fires before the intrinsic content size is updated
     4        https://bugs.webkit.org/show_bug.cgi?id=162359
     5        <rdar://problem/27776454>
     6
     7        Reviewed by Tim Horton.
     8
     9        * TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm:
     10        (TEST):
     11
    1122016-09-21  Keith Miller  <keith_miller@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm

    r205329 r206247  
    3737
    3838@interface AutoLayoutWKWebView : WKWebView
     39@property (nonatomic) BOOL expectingIntrinsicContentSizeChange;
     40@property (nonatomic) NSSize expectedIntrinsicContentSize;
    3941@end
    4042
    41 @implementation AutoLayoutWKWebView {
    42     BOOL _expectingIntrinsicContentSizeChange;
    43     NSSize _expectedIntrinsicContentSize;
    44 }
     43@implementation AutoLayoutWKWebView
    4544
    4645- (instancetype)initWithFrame:(NSRect)frame configuration:(WKWebViewConfiguration *)configuration
     
    157156    TestWebKitAPI::Util::run(&didEvaluateJavaScript);
    158157    didEvaluateJavaScript = false;
     158    [webView _setShouldExpandContentToViewHeightForAutoLayout:NO];
     159
     160    auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
     161
     162    __block bool didFinishNavigation = false;
     163    [navigationDelegate setDidFinishNavigation:^(WKWebView *, WKNavigation *) {
     164        didFinishNavigation = true;
     165    }];
     166    __block bool didFirstLayout = false;
     167    [navigationDelegate setRenderingProgressDidChange:^(WKWebView *, _WKRenderingProgressEvents progressEvents) {
     168        if (progressEvents & _WKRenderingProgressEventFirstLayout) {
     169            didFirstLayout = true;
     170            EXPECT_TRUE(didInvalidateIntrinsicContentSize);
     171        }
     172    }];
     173    [webView setNavigationDelegate:navigationDelegate.get()];
     174
     175    [webView _setMinimumLayoutWidth:100];
     176    didInvalidateIntrinsicContentSize = false;
     177    [webView setExpectingIntrinsicContentSizeChange:YES];
     178    [webView setExpectedIntrinsicContentSize:NSMakeSize(100, 400)];
     179    [webView loadHTMLString:@"<body style='margin: 0; height: 400px;'></body>" baseURL:nil];
     180    TestWebKitAPI::Util::run(&didInvalidateIntrinsicContentSize);
     181    EXPECT_FALSE(didFirstLayout);
     182    TestWebKitAPI::Util::run(&didFirstLayout);
     183    TestWebKitAPI::Util::run(&didFinishNavigation);
     184    [webView setNavigationDelegate:nil];
    159185}
    160186
Note: See TracChangeset for help on using the changeset viewer.