Title: [209782] trunk
Revision
209782
Author
[email protected]
Date
2016-12-13 15:37:15 -0800 (Tue, 13 Dec 2016)

Log Message

Fullscreen in WebKit2 does not restore topContentInset upon exiting; leaves top of page not visible
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):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (209781 => 209782)


--- trunk/Source/WebKit2/ChangeLog	2016-12-13 23:24:47 UTC (rev 209781)
+++ trunk/Source/WebKit2/ChangeLog	2016-12-13 23:37:15 UTC (rev 209782)
@@ -1,3 +1,28 @@
+2016-12-13  Jer Noble  <[email protected]>
+
+        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  <[email protected]>
 
         [Mac][WK2] Tighten Keychain directory access

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (209781 => 209782)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h	2016-12-13 23:24:47 UTC (rev 209781)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h	2016-12-13 23:37:15 UTC (rev 209782)
@@ -170,7 +170,7 @@
     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 @@
     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 };

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (209781 => 209782)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm	2016-12-13 23:24:47 UTC (rev 209781)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm	2016-12-13 23:37:15 UTC (rev 209782)
@@ -1615,15 +1615,22 @@
     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 @@
         return;
 
     m_didScheduleSetTopContentInset = false;
-    m_page->setTopContentInset(m_topContentInset);
+    m_page->setTopContentInset(m_pendingTopContentInset);
 }
 
 void WebViewImpl::prepareContentInRect(CGRect rect)

Modified: trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm (209781 => 209782)


--- trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm	2016-12-13 23:24:47 UTC (rev 209781)
+++ trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm	2016-12-13 23:37:15 UTC (rev 209782)
@@ -415,6 +415,7 @@
     [self _manager]->setAnimatingFullScreen(false);
     _page->scalePage(_savedScale, IntPoint());
     [self _manager]->restoreScrollPosition();
+    _page->setTopContentInset(_savedTopContentInset);
 
     if (_repaintCallback) {
         _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated);

Modified: trunk/Tools/ChangeLog (209781 => 209782)


--- trunk/Tools/ChangeLog	2016-12-13 23:24:47 UTC (rev 209781)
+++ trunk/Tools/ChangeLog	2016-12-13 23:37:15 UTC (rev 209782)
@@ -1,3 +1,13 @@
+2016-12-13  Jer Noble  <[email protected]>
+
+        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  <[email protected]>
 
         [Cocoa] Implement -shouldInsertText: on WKWebProcessPlugInEditingDelegate

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenTopContentInset.mm (209781 => 209782)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenTopContentInset.mm	2016-12-13 23:24:47 UTC (rev 209781)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenTopContentInset.mm	2016-12-13 23:37:15 UTC (rev 209782)
@@ -58,6 +58,7 @@
     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 @@
     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
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to