Title: [233059] trunk/Source
Revision
233059
Author
jer.no...@apple.com
Date
2018-06-21 14:23:12 -0700 (Thu, 21 Jun 2018)

Log Message

[Fullscreen] Page sometimes ends up with an incorrect zoom level after entering fullscreen
https://bugs.webkit.org/show_bug.cgi?id=186822

Reviewed by Simon Fraser.

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::setOverrideViewportArguments):
(WebCore::Document::updateViewportArguments):
* dom/Document.h:

Source/WebKit:

Set the minimum zoom, maximum zoom, zoom bouncing, and user scalability settings of the
WKWebView's UIScrollView upon entering fullscreen, and restore those same settings upon
exit. Override the viewport arguments upon entering fullscreen, restore them upon exit.

* Platform/IPC/ArgumentCoder.h:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ViewportArguments>::decode):
* Shared/WebCoreArgumentCoders.h:
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::forceAlwaysUserScalable const):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::setOverrideViewportArguments):
* UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
(WebKit::WKWebViewState::applyTo):
(WebKit::WKWebViewState::store):
(-[WKFullScreenWindowController enterFullScreen]):
(-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::forceAlwaysUserScalable const):
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::setOverrideViewportArguments):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233058 => 233059)


--- trunk/Source/WebCore/ChangeLog	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebCore/ChangeLog	2018-06-21 21:23:12 UTC (rev 233059)
@@ -1,3 +1,15 @@
+2018-06-21  Jer Noble  <jer.no...@apple.com>
+
+        [Fullscreen] Page sometimes ends up with an incorrect zoom level after entering fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=186822
+
+        Reviewed by Simon Fraser.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setOverrideViewportArguments):
+        (WebCore::Document::updateViewportArguments):
+        * dom/Document.h:
+
 2018-06-20  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         RenderSVGInline has to be inline always regardless of its css display value

Modified: trunk/Source/WebCore/dom/Document.cpp (233058 => 233059)


--- trunk/Source/WebCore/dom/Document.cpp	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebCore/dom/Document.cpp	2018-06-21 21:23:12 UTC (rev 233059)
@@ -3425,6 +3425,15 @@
     page()->chrome().dispatchDisabledAdaptationsDidChange(m_disabledAdaptations);
 }
 
+void Document::setOverrideViewportArguments(const std::optional<ViewportArguments>& viewportArguments)
+{
+    if (viewportArguments == m_overrideViewportArguments)
+        return;
+
+    m_overrideViewportArguments = viewportArguments;
+    updateViewportArguments();
+}
+
 void Document::processViewport(const String& features, ViewportArguments::Type origin)
 {
     ASSERT(!features.isNull());
@@ -3451,7 +3460,7 @@
 #ifndef NDEBUG
         m_didDispatchViewportPropertiesChanged = true;
 #endif
-        page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments);
+        page()->chrome().dispatchViewportPropertiesDidChange(m_overrideViewportArguments ? m_overrideViewportArguments.value() : m_viewportArguments);
         page()->chrome().didReceiveDocType(*frame());
     }
 }

Modified: trunk/Source/WebCore/dom/Document.h (233058 => 233059)


--- trunk/Source/WebCore/dom/Document.h	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebCore/dom/Document.h	2018-06-21 21:23:12 UTC (rev 233059)
@@ -391,6 +391,9 @@
 
     void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
     ViewportArguments viewportArguments() const { return m_viewportArguments; }
+
+    WEBCORE_EXPORT void setOverrideViewportArguments(const std::optional<ViewportArguments>&);
+
     OptionSet<DisabledAdaptations> disabledAdaptations() const { return m_disabledAdaptations; }
 #ifndef NDEBUG
     bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
@@ -1715,6 +1718,7 @@
     Timer m_loadEventDelayTimer;
 
     ViewportArguments m_viewportArguments;
+    std::optional<ViewportArguments> m_overrideViewportArguments;
     OptionSet<DisabledAdaptations> m_disabledAdaptations;
 
     DocumentTiming m_documentTiming;

Modified: trunk/Source/WebKit/ChangeLog (233058 => 233059)


--- trunk/Source/WebKit/ChangeLog	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/ChangeLog	2018-06-21 21:23:12 UTC (rev 233059)
@@ -1,5 +1,35 @@
 2018-06-21  Jer Noble  <jer.no...@apple.com>
 
+        [Fullscreen] Page sometimes ends up with an incorrect zoom level after entering fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=186822
+
+        Reviewed by Simon Fraser.
+
+        Set the minimum zoom, maximum zoom, zoom bouncing, and user scalability settings of the
+        WKWebView's UIScrollView upon entering fullscreen, and restore those same settings upon
+        exit. Override the viewport arguments upon entering fullscreen, restore them upon exit.
+
+        * Platform/IPC/ArgumentCoder.h:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<ViewportArguments>::decode):
+        * Shared/WebCoreArgumentCoders.h:
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::forceAlwaysUserScalable const):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::setOverrideViewportArguments):
+        * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
+        (WebKit::WKWebViewState::applyTo):
+        (WebKit::WKWebViewState::store):
+        (-[WKFullScreenWindowController enterFullScreen]):
+        (-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::forceAlwaysUserScalable const):
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::setOverrideViewportArguments):
+
+2018-06-21  Jer Noble  <jer.no...@apple.com>
+
         [Fullscreen] Use secondary glyph style for fullscreen controls
         https://bugs.webkit.org/show_bug.cgi?id=186862
         <rdar://problem/41212210>

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h (233058 => 233059)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h	2018-06-21 21:23:12 UTC (rev 233059)
@@ -31,6 +31,7 @@
 class IntConstraint;
 class DoubleConstraint;
 class ResourceResponse;
+struct ViewportArguments;
 }
 
 namespace IPC {

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (233058 => 233059)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2018-06-21 21:23:12 UTC (rev 233059)
@@ -659,6 +659,14 @@
 {
     return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
 }
+
+std::optional<ViewportArguments> ArgumentCoder<ViewportArguments>::decode(Decoder& decoder)
+{
+    ViewportArguments viewportArguments;
+    if (!SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments))
+        return std::nullopt;
+    return WTFMove(viewportArguments);
+}
 #endif // PLATFORM(IOS)
 
 

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (233058 => 233059)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2018-06-21 21:23:12 UTC (rev 233059)
@@ -267,6 +267,7 @@
 template<> struct ArgumentCoder<WebCore::ViewportArguments> {
     static void encode(Encoder&, const WebCore::ViewportArguments&);
     static bool decode(Decoder&, WebCore::ViewportArguments&);
+    static std::optional<WebCore::ViewportArguments> decode(Decoder&);
 };
 #endif // PLATFORM(IOS)
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (233058 => 233059)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-06-21 21:23:12 UTC (rev 233059)
@@ -560,6 +560,7 @@
     void setMaximumUnobscuredSize(const WebCore::FloatSize&);
     void setDeviceOrientation(int32_t);
     int32_t deviceOrientation() const { return m_deviceOrientation; }
+    void setOverrideViewportArguments(const std::optional<WebCore::ViewportArguments>&);
     void willCommitLayerTree(uint64_t transactionID);
 
     void selectWithGesture(const WebCore::IntPoint, WebCore::TextGranularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithAssistedNode, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&&);
@@ -606,6 +607,7 @@
     void getSelectionContext(WTF::Function<void(const String&, const String&, const String&, CallbackBase::Error)>&&);
     void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, uint64_t requestID);
     void setForceAlwaysUserScalable(bool);
+    bool forceAlwaysUserScalable() const { return m_forceAlwaysUserScalable; }
     void setIsScrollingOrZooming(bool);
     void requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, uint32_t offset, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);
     void requestRectsAtSelectionOffsetWithText(int32_t offset, const String&, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (233058 => 233059)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2018-06-21 21:23:12 UTC (rev 233059)
@@ -354,6 +354,12 @@
     }
 }
 
+void WebPageProxy::setOverrideViewportArguments(const std::optional<ViewportArguments>& viewportArguments)
+{
+    if (isValid())
+        m_process->send(Messages::WebPage::SetOverrideViewportArguments(viewportArguments), m_pageID);
+}
+
 static bool exceedsRenderTreeSizeSizeThreshold(uint64_t thresholdSize, uint64_t committedSize)
 {
     const double thesholdSizeFraction = 0.5; // Empirically-derived.

Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm (233058 => 233059)


--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm	2018-06-21 21:23:12 UTC (rev 233059)
@@ -44,6 +44,7 @@
 #import <WebCore/GeometryUtilities.h>
 #import <WebCore/IntRect.h>
 #import <WebCore/LocalizedStrings.h>
+#import <WebCore/ViewportArguments.h>
 #import <WebCore/WebCoreNSURLExtras.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <pal/spi/cocoa/NSStringSPI.h>
@@ -95,6 +96,10 @@
     UIEdgeInsets _savedObscuredInsets = UIEdgeInsetsZero;
     UIEdgeInsets _savedScrollIndicatorInsets = UIEdgeInsetsZero;
     CGPoint _savedContentOffset = CGPointZero;
+    CGFloat _savedMinimumZoomScale = 1;
+    CGFloat _savedMaximumZoomScale = 1;
+    BOOL _savedBouncesZoom = NO;
+    BOOL _savedForceAlwaysUserScalable = NO;
 
     void applyTo(WKWebView* webView)
     {
@@ -104,8 +109,12 @@
         [[webView scrollView] setContentOffset:_savedContentOffset];
         [[webView scrollView] setScrollIndicatorInsets:_savedScrollIndicatorInsets];
         [webView _page]->setTopContentInset(_savedTopContentInset);
+        [webView _page]->setForceAlwaysUserScalable(_savedForceAlwaysUserScalable);
         [webView _setViewScale:_savedViewScale];
         [[webView scrollView] setZoomScale:_savedZoomScale];
+        webView.scrollView.minimumZoomScale = _savedMinimumZoomScale;
+        webView.scrollView.maximumZoomScale = _savedMaximumZoomScale;
+        webView.scrollView.bouncesZoom = _savedBouncesZoom;
     }
     
     void store(WKWebView* webView)
@@ -116,8 +125,12 @@
         _savedContentOffset = [[webView scrollView] contentOffset];
         _savedScrollIndicatorInsets = [[webView scrollView] scrollIndicatorInsets];
         _savedTopContentInset = [webView _page]->topContentInset();
+        _savedForceAlwaysUserScalable = [webView _page]->forceAlwaysUserScalable();
         _savedViewScale = [webView _viewScale];
         _savedZoomScale = [[webView scrollView] zoomScale];
+        _savedMinimumZoomScale = webView.scrollView.minimumZoomScale;
+        _savedMaximumZoomScale = webView.scrollView.maximumZoomScale;
+        _savedBouncesZoom = webView.scrollView.bouncesZoom;
     }
 };
 
@@ -494,6 +507,13 @@
         
         [self _manager]->setAnimatingFullScreen(true);
 
+        ViewportArguments arguments { ViewportArguments::CSSDeviceAdaptation };
+        arguments.zoom = 1;
+        arguments.minZoom = 1;
+        arguments.maxZoom = 1;
+        arguments.userZoom = 1;
+        [webView _page]->setOverrideViewportArguments(arguments);
+
         _repaintCallback = VoidCallback::create([protectedSelf = retainPtr(self), self](WebKit::CallbackBase::Error) {
             _repaintCallback = nullptr;
             if (auto* manager = [protectedSelf _manager]) {
@@ -628,6 +648,7 @@
     [webView becomeFirstResponder];
 
     _viewState.applyTo(webView.get());
+    [webView _page]->setOverrideViewportArguments(std::nullopt);
 
     [webView setNeedsLayout];
     [webView layoutIfNeeded];

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (233058 => 233059)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-06-21 21:23:12 UTC (rev 233059)
@@ -657,7 +657,8 @@
 
     void enableInspectorNodeSearch();
     void disableInspectorNodeSearch();
-    
+
+    bool forceAlwaysUserScalable() const { return m_forceAlwaysUserScalable; }
     void setForceAlwaysUserScalable(bool);
 #endif
 
@@ -890,6 +891,7 @@
     void setViewportConfigurationViewLayoutSize(const WebCore::FloatSize&);
     void setMaximumUnobscuredSize(const WebCore::FloatSize&);
     void setDeviceOrientation(int32_t);
+    void setOverrideViewportArguments(const std::optional<WebCore::ViewportArguments>&);
     void dynamicViewportSizeUpdate(const WebCore::FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, DynamicViewportSizeUpdateID);
     std::optional<float> scaleFromUIProcess(const VisibleContentRectUpdateInfo&) const;
     void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, MonotonicTime oldestTimestamp);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (233058 => 233059)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-06-21 21:23:12 UTC (rev 233059)
@@ -48,6 +48,7 @@
     SetViewportConfigurationViewLayoutSize(WebCore::FloatSize size)
     SetMaximumUnobscuredSize(WebCore::FloatSize size)
     SetDeviceOrientation(int32_t deviceOrientation)
+    SetOverrideViewportArguments(std::optional<WebCore::ViewportArguments> arguments)
     DynamicViewportSizeUpdate(WebCore::FloatSize viewLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::RectEdges<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
 
     HandleTap(WebCore::IntPoint point, uint64_t lastLayerTreeTransactionId)

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (233058 => 233059)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-06-21 21:11:28 UTC (rev 233058)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-06-21 21:23:12 UTC (rev 233059)
@@ -2484,6 +2484,12 @@
     m_page->mainFrame().orientationChanged();
 }
 
+void WebPage::setOverrideViewportArguments(const std::optional<WebCore::ViewportArguments>& arguments)
+{
+    if (auto* document = m_page->mainFrame().document())
+        document->setOverrideViewportArguments(arguments);
+}
+
 // WebCore stores the page scale factor as float instead of double. When we get a scale from WebCore,
 // we need to ignore differences that are within a small rounding error on floats.
 static inline bool areEssentiallyEqualAsFloat(float a, float b)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to