Video elements don't return to the correct position when exiting fullscreen
authorpeng.liu6@apple.com <peng.liu6@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Apr 2020 21:07:14 +0000 (21:07 +0000)
committerpeng.liu6@apple.com <peng.liu6@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Apr 2020 21:07:14 +0000 (21:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=210529

Reviewed by Jer Noble.

Source/WebCore:

Add WEBCORE_EXPORT to the function setNeedsDOMWindowResizeEvent().

* dom/Document.h:

Source/WebKit:

Some web pages use the "resize" event handler to calculate the element size after
they exit fullscreen, and the calculation is based on the container element size which
might be affected by the fullscreen mode.

We need to call WebPageProxy::setNeedsDOMWindowResizeEvent() to fire the "resize" event
in the repaint callback after the exiting fullscreen process is completed and the
possible layout change due to exiting fullscreen is done. Otherwise the size calculation
might be wrong.

* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:
* UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
(-[WKFullScreenWindowController _completedExitFullScreen]):
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController completeFinishExitFullScreenAnimationAfterRepaint]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setNeedsDOMWindowResizeEvent):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

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

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm
Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index 88f1bf5..2165244 100644 (file)
@@ -1,3 +1,14 @@
+2020-04-15  Peng Liu  <peng.liu6@apple.com>
+
+        Video elements don't return to the correct position when exiting fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=210529
+
+        Reviewed by Jer Noble.
+
+        Add WEBCORE_EXPORT to the function setNeedsDOMWindowResizeEvent().
+
+        * dom/Document.h:
+
 2020-04-15  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iPadOS] Some pages indefinitely zoom in and out due to idempotent text autosizing
index 34fd00e..291134a 100644 (file)
@@ -1360,7 +1360,7 @@ public:
     bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
     void updateViewportUnitsOnResize();
 
-    void setNeedsDOMWindowResizeEvent();
+    WEBCORE_EXPORT void setNeedsDOMWindowResizeEvent();
     void setNeedsVisualViewportResize();
     void runResizeSteps();
 
index b379523..de279ff 100644 (file)
@@ -1,3 +1,30 @@
+2020-04-15  Peng Liu  <peng.liu6@apple.com>
+
+        Video elements don't return to the correct position when exiting fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=210529
+
+        Reviewed by Jer Noble.
+
+        Some web pages use the "resize" event handler to calculate the element size after
+        they exit fullscreen, and the calculation is based on the container element size which
+        might be affected by the fullscreen mode.
+
+        We need to call WebPageProxy::setNeedsDOMWindowResizeEvent() to fire the "resize" event
+        in the repaint callback after the exiting fullscreen process is completed and the
+        possible layout change due to exiting fullscreen is done. Otherwise the size calculation
+        might be wrong.
+
+        * UIProcess/WebPageProxy.cpp:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
+        (-[WKFullScreenWindowController _completedExitFullScreen]):
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController completeFinishExitFullScreenAnimationAfterRepaint]):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setNeedsDOMWindowResizeEvent):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2020-04-15  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iPadOS] Some pages indefinitely zoom in and out due to idempotent text autosizing
index c97e0ae..a673ecb 100644 (file)
@@ -10043,6 +10043,11 @@ void WebPageProxy::setShouldFireResizeEvents(bool shouldFireResizeEvents)
     send(Messages::WebPage::SetShouldFireResizeEvents(shouldFireResizeEvents));
 }
 
+void WebPageProxy::setNeedsDOMWindowResizeEvent()
+{
+    send(Messages::WebPage::SetNeedsDOMWindowResizeEvent());
+}
+
 #if !PLATFORM(IOS_FAMILY)
 bool WebPageProxy::shouldForceForegroundPriorityForClientNavigation() const
 {
index 28a76fd..ba78485 100644 (file)
@@ -1716,6 +1716,7 @@ public:
 #endif
 
     void setShouldFireResizeEvents(bool);
+    void setNeedsDOMWindowResizeEvent();
 
     void isNavigatingToAppBoundDomainTesting(CompletionHandler<void(bool)>&&);
     Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain() const { return m_isNavigatingToAppBoundDomain; }
index 5f44a8e..8ebe1f5 100644 (file)
@@ -775,8 +775,10 @@ static RetainPtr<UIWindow> makeWindowFromView(UIView *)
         _webViewPlaceholder.get().parent = nil;
         [_webViewPlaceholder removeFromSuperview];
 
-        if (auto page = [self._webView _page])
+        if (auto page = [self._webView _page]) {
             page->setSuppressVisibilityUpdates(false);
+            page->setNeedsDOMWindowResizeEvent();
+        }
     });
 
     if (auto page = [self._webView _page])
index 2e7910e..919ef79 100644 (file)
@@ -574,6 +574,7 @@ static RetainPtr<CGImageRef> takeWindowSnapshot(CGSWindowID windowID, bool captu
     
     _repaintCallback = nullptr;
     _page->setSuppressVisibilityUpdates(false);
+    _page->setNeedsDOMWindowResizeEvent();
 
     [CATransaction commit];
     [CATransaction flush];
index d43ca77..9e87d55 100644 (file)
@@ -3314,6 +3314,15 @@ void WebPage::setShouldFireResizeEvents(bool shouldFireResizeEvents)
         m_page->setShouldFireResizeEvents(shouldFireResizeEvents);
 }
 
+void WebPage::setNeedsDOMWindowResizeEvent()
+{
+    if (!m_page)
+        return;
+
+    if (auto* document = m_page->mainFrame().document())
+        document->setNeedsDOMWindowResizeEvent();
+}
+
 String WebPage::userAgent(const URL& webCoreURL) const
 {
     String userAgent = platformUserAgent(webCoreURL);
index d0ed9c0..7b6e1b6 100644 (file)
@@ -1685,6 +1685,7 @@ private:
     void urlSchemeTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, const WebCore::ResourceError&);
 
     void setShouldFireResizeEvents(bool);
+    void setNeedsDOMWindowResizeEvent();
 
     void setIsSuspended(bool);
 
index 076c1fa..b73e4dc 100644 (file)
@@ -601,6 +601,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
     GetProcessDisplayName() -> (String displayName) Async
 
     SetShouldFireResizeEvents(bool shouldFireResizeEvents)
+    SetNeedsDOMWindowResizeEvent()
 
     SetHasResourceLoadClient(bool has)
 }