Fullscreen in WebKit2 does not restore topContentInset upon exiting; leaves top of...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 23:37:15 +0000 (23:37 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 23:37:15 +0000 (23:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165697

Source/WebKit2:

Delegate the values of topContentInset() from WebViewImpl (used by WKWebView and WKView) to the
WebPageProxy, so that setting the topContentInset() on WebPageProxy is reflected in the getters
for the two view classes.

Reviewed by Tim Horton.

* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::topContentInset): Deleted.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::updateContentInsetsIfAutomatic):
(WebKit::WebViewImpl::topContentInset):
(WebKit::WebViewImpl::setTopContentInset):
(WebKit::WebViewImpl::dispatchSetTopContentInset):
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController enterFullScreen:]):
(-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
(-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
(-[WKFullScreenWindowController _saveTopContentInset]): Deleted.
(-[WKFullScreenWindowController _restoreTopContentInset]): Deleted.

Tools:

Reviewed by Tim Horton.

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

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenTopContentInset.mm

index 37a26ea..2e61059 100644 (file)
@@ -1,3 +1,28 @@
+2016-12-13  Jer Noble  <jer.noble@apple.com>
+
+        Fullscreen in WebKit2 does not restore topContentInset upon exiting; leaves top of page not visible
+        https://bugs.webkit.org/show_bug.cgi?id=165697
+
+        Delegate the values of topContentInset() from WebViewImpl (used by WKWebView and WKView) to the
+        WebPageProxy, so that setting the topContentInset() on WebPageProxy is reflected in the getters
+        for the two view classes.
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/Cocoa/WebViewImpl.h:
+        (WebKit::WebViewImpl::topContentInset): Deleted.
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::updateContentInsetsIfAutomatic):
+        (WebKit::WebViewImpl::topContentInset):
+        (WebKit::WebViewImpl::setTopContentInset):
+        (WebKit::WebViewImpl::dispatchSetTopContentInset):
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController enterFullScreen:]):
+        (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
+        (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
+        (-[WKFullScreenWindowController _saveTopContentInset]): Deleted.
+        (-[WKFullScreenWindowController _restoreTopContentInset]): Deleted.
+
 2016-12-13  Brent Fulgham  <bfulgham@apple.com>
 
         [Mac][WK2] Tighten Keychain directory access
index b29da78..65a99ce 100644 (file)
@@ -170,7 +170,7 @@ public:
     bool automaticallyAdjustsContentInsets() const { return m_automaticallyAdjustsContentInsets; }
     void updateContentInsetsIfAutomatic();
     void setTopContentInset(CGFloat);
-    CGFloat topContentInset() const { return m_topContentInset; }
+    CGFloat topContentInset() const;
 
     void prepareContentInRect(CGRect);
     void updateViewExposedRect();
@@ -606,7 +606,7 @@ private:
     bool m_windowOcclusionDetectionEnabled { true };
 
     bool m_automaticallyAdjustsContentInsets { false };
-    CGFloat m_topContentInset { 0 };
+    CGFloat m_pendingTopContentInset { 0 };
     bool m_didScheduleSetTopContentInset { false };
 
     CGSize m_resizeScrollOffset { 0, 0 };
index ead62a5..0e17401 100644 (file)
@@ -1615,15 +1615,22 @@ void WebViewImpl::updateContentInsetsIfAutomatic()
     if ((window.styleMask & NSWindowStyleMaskFullSizeContentView) && !window.titlebarAppearsTransparent && ![m_view enclosingScrollView]) {
         NSRect contentLayoutRect = [m_view convertRect:window.contentLayoutRect fromView:nil];
         CGFloat newTopContentInset = NSMaxY(contentLayoutRect) - NSHeight(contentLayoutRect);
-        if (m_topContentInset != newTopContentInset)
+        if (m_page->topContentInset() != newTopContentInset)
             setTopContentInset(newTopContentInset);
     } else
         setTopContentInset(0);
 }
 
+CGFloat WebViewImpl::topContentInset() const
+{
+    if (m_didScheduleSetTopContentInset)
+        return m_pendingTopContentInset;
+    return m_page->topContentInset();
+}
+
 void WebViewImpl::setTopContentInset(CGFloat contentInset)
 {
-    m_topContentInset = contentInset;
+    m_pendingTopContentInset = contentInset;
 
     if (m_didScheduleSetTopContentInset)
         return;
@@ -1644,7 +1651,7 @@ void WebViewImpl::dispatchSetTopContentInset()
         return;
 
     m_didScheduleSetTopContentInset = false;
-    m_page->setTopContentInset(m_topContentInset);
+    m_page->setTopContentInset(m_pendingTopContentInset);
 }
 
 void WebViewImpl::prepareContentInRect(CGRect rect)
index ecf2526..9e1c947 100644 (file)
@@ -415,6 +415,7 @@ static const float minVideoWidth = 480 + 20 + 20; // Note: Keep in sync with med
     [self _manager]->setAnimatingFullScreen(false);
     _page->scalePage(_savedScale, IntPoint());
     [self _manager]->restoreScrollPosition();
+    _page->setTopContentInset(_savedTopContentInset);
 
     if (_repaintCallback) {
         _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated);
index b122134..ba58825 100644 (file)
@@ -1,3 +1,13 @@
+2016-12-13  Jer Noble  <jer.noble@apple.com>
+
+        Fullscreen in WebKit2 does not restore topContentInset upon exiting; leaves top of page not visible
+        https://bugs.webkit.org/show_bug.cgi?id=165697
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenTopContentInset.mm:
+        (TestWebKitAPI::TEST):
+
 2016-12-13  Andy Estes  <aestes@apple.com>
 
         [Cocoa] Implement -shouldInsertText: on WKWebProcessPlugInEditingDelegate
index 01f6e88..d11c80a 100644 (file)
@@ -58,6 +58,7 @@ TEST(Fullscreen, TopContentInset)
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
     [webView _setTopContentInset:10];
+    [webView _setAutomaticallyAdjustsContentInsets:NO];
     [configuration preferences]._fullScreenEnabled = YES;
     RetainPtr<FullscreenChangeMessageHandler> handler = adoptNS([[FullscreenChangeMessageHandler alloc] init]);
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"fullscreenChangeHandler"];
@@ -75,6 +76,11 @@ TEST(Fullscreen, TopContentInset)
     TestWebKitAPI::Util::run(&receivedFullscreenChangeMessage);
     ASSERT_EQ(window.get().screen.frame.size.width, webView.get().frame.size.width);
     ASSERT_EQ(window.get().screen.frame.size.height + webView.get()._topContentInset, webView.get().frame.size.height);
+
+    receivedFullscreenChangeMessage = false;
+    [webView mouseDown:event];
+    TestWebKitAPI::Util::run(&receivedFullscreenChangeMessage);
+    ASSERT_EQ(10, webView.get()._topContentInset);
 }
 
 } // namespace TestWebKitAPI