Change 'delegatesPageScaling' from a Setting to a flag on ScrollView
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Dec 2019 19:25:54 +0000 (19:25 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Dec 2019 19:25:54 +0000 (19:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205319

Reviewed by Tim Horton.

delegatesPageScaling() is never toggled at runtime (even by tests), and it should
be a flag on FrameView just like delegatesScrolling (maybe in future the flags can merge).

So remove the Setting, and have DrawingArea control whether page scaling is delegated.

In WebKit1, WebFrameLoaderClient::transitionToCommittedForNewPage() turns on delegated
page scaling for iOS.

Source/WebCore:

* page/Frame.cpp:
(WebCore::Frame::frameScaleFactor const):
* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRectWithClip):
* page/FrameView.cpp:
(WebCore::FrameView::visibleContentScaleFactor const):
* page/Page.cpp:
(WebCore::Page::setPageScaleFactor):
* page/Settings.yaml:
* platform/ScrollView.cpp:
(WebCore::ScrollView::setDelegatesPageScaling):
* platform/ScrollView.h:
(WebCore::ScrollView::delegatesPageScaling const):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::addToOverlapMap const):

Source/WebKit:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::usesDelegatedPageScaling const):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
* WebProcess/WebPage/ios/FindControllerIOS.mm:
(WebKit::FindIndicatorOverlayClientIOS::drawRect):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::transitionToCommittedForNewPage):
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp
Source/WebCore/page/FrameSnapshotting.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Settings.yaml
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebPage/DrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/mac/WebView/WebView.mm

index 8d131f3..ce9a9a5 100644 (file)
         * platform/graphics/Image.h:
         (WebCore::Image::orientation const):
 
+2019-12-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Change 'delegatesPageScaling' from a Setting to a flag on ScrollView
+        https://bugs.webkit.org/show_bug.cgi?id=205319
+
+        Reviewed by Tim Horton.
+
+        delegatesPageScaling() is never toggled at runtime (even by tests), and it should
+        be a flag on FrameView just like delegatesScrolling (maybe in future the flags can merge).
+
+        So remove the Setting, and have DrawingArea control whether page scaling is delegated.
+        
+        In WebKit1, WebFrameLoaderClient::transitionToCommittedForNewPage() turns on delegated
+        page scaling for iOS.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::frameScaleFactor const):
+        * page/FrameSnapshotting.cpp:
+        (WebCore::snapshotFrameRectWithClip):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::visibleContentScaleFactor const):
+        * page/Page.cpp:
+        (WebCore::Page::setPageScaleFactor):
+        * page/Settings.yaml:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::setDelegatesPageScaling):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::delegatesPageScaling const):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::addToOverlapMap const):
+
 2019-12-16  Ryosuke Niwa  <rniwa@webkit.org>
 
         TextManipulationController should observe newly inserted or displayed contents
index e0833dc..6f434d9 100644 (file)
@@ -919,9 +919,14 @@ float Frame::frameScaleFactor() const
     Page* page = this->page();
 
     // Main frame is scaled with respect to he container but inner frames are not scaled with respect to the main frame.
-    if (!page || &page->mainFrame() != this || settings().delegatesPageScaling())
+    if (!page || !isMainFrame())
         return 1;
 
+    if (FrameView* view = this->view()) {
+        if (view->delegatesPageScaling())
+            return 1;
+    }
+
     return page->pageScaleFactor();
 }
 
index e27c41a..0a44c2f 100644 (file)
@@ -105,7 +105,7 @@ std::unique_ptr<ImageBuffer> snapshotFrameRectWithClip(Frame& frame, const IntRe
 
     float scaleFactor = frame.page()->deviceScaleFactor();
 
-    if (frame.settings().delegatesPageScaling())
+    if (frame.view()->delegatesPageScaling())
         scaleFactor *= frame.page()->pageScaleFactor();
 
     if (options & SnapshotOptionsPaintWithIntegralScaleFactor)
index 04012f9..ea7511b 100644 (file)
@@ -3709,7 +3709,8 @@ void FrameView::invalidateScrollbarRect(Scrollbar& scrollbar, const IntRect& rec
 
 float FrameView::visibleContentScaleFactor() const
 {
-    if (!frame().isMainFrame() || !frame().settings().delegatesPageScaling())
+    // FIXME: This !delegatesPageScaling() is confusing. This function should probably be renamed to delegatedPageScaleFactor().
+    if (!frame().isMainFrame() || !delegatesPageScaling())
         return 1;
 
     Page* page = frame().page();
index 5655dc2..bf43a87 100644 (file)
@@ -1031,11 +1031,11 @@ void Page::setPageScaleFactor(float scale, const IntPoint& origin, bool inStable
     LOG(Viewports, "Page::setPageScaleFactor %.2f - inStableState %d", scale, inStableState);
 
     Document* document = mainFrame().document();
-    FrameView* view = document->view();
+    RefPtr<FrameView> view = document->view();
 
     if (scale == m_pageScaleFactor) {
         if (view && view->scrollPosition() != origin) {
-            if (!m_settings->delegatesPageScaling())
+            if (!view->delegatesPageScaling())
                 document->updateLayoutIgnorePendingStylesheets();
 
             if (!view->delegatesScrolling())
@@ -1059,7 +1059,7 @@ void Page::setPageScaleFactor(float scale, const IntPoint& origin, bool inStable
 
     m_pageScaleFactor = scale;
 
-    if (!m_settings->delegatesPageScaling()) {
+    if (!view->delegatesPageScaling()) {
         view->setNeedsLayoutAfterViewConfigurationChange();
         view->setNeedsCompositingGeometryUpdate();
 
@@ -1075,7 +1075,7 @@ void Page::setPageScaleFactor(float scale, const IntPoint& origin, bool inStable
         view->setViewportConstrainedObjectsNeedLayout();
 
     if (view && view->scrollPosition() != origin) {
-        if (!m_settings->delegatesPageScaling() && document->renderView() && document->renderView()->needsLayout() && view->didFirstLayout())
+        if (!view->delegatesPageScaling() && document->renderView() && document->renderView()->needsLayout() && view->didFirstLayout())
             view->layoutContext().layout();
 
         if (!view->delegatesScrolling())
index b329f12..a92f303 100644 (file)
@@ -379,9 +379,6 @@ windowFocusRestricted:
 diagnosticLoggingEnabled:
   initial: false
 
-delegatesPageScaling:
-  initial: false
-
 plugInSnapshottingEnabled:
   initial: false
 
index b126a9c..7d2d2e1 100644 (file)
@@ -197,6 +197,11 @@ void ScrollView::setDelegatesScrolling(bool delegatesScrolling)
     delegatesScrollingDidChange();
 }
 
+void ScrollView::setDelegatesPageScaling(bool delegatesPageScaling)
+{
+    m_delegatesPageScaling = delegatesPageScaling;
+}
+
 IntPoint ScrollView::contentsScrollPosition() const
 {
 #if PLATFORM(IOS_FAMILY)
index 430160d..2ff26d7 100644 (file)
@@ -137,6 +137,9 @@ public:
     bool delegatesScrolling() const { return m_delegatesScrolling; }
     WEBCORE_EXPORT void setDelegatesScrolling(bool);
 
+    bool delegatesPageScaling() const { return m_delegatesPageScaling; }
+    WEBCORE_EXPORT void setDelegatesPageScaling(bool);
+
     // Overridden by FrameView to create custom CSS scrollbars if applicable.
     virtual Ref<Scrollbar> createScrollbar(ScrollbarOrientation);
 
@@ -529,6 +532,8 @@ private:
 
     bool m_paintsEntireContents { false };
     bool m_delegatesScrolling { false };
+    bool m_delegatesPageScaling { false };
+
 }; // class ScrollView
 
 } // namespace WebCore
index 923261b..4d3a56d 100644 (file)
@@ -1907,8 +1907,9 @@ void RenderLayerCompositor::addToOverlapMap(LayerOverlapMap& overlapMap, const R
 
     auto clippedBounds = extent.bounds;
     if (!clipRect.isInfinite()) {
-        // On iOS, pageScaleFactor() is not applied by RenderView, so we should not scale here.
-        if (!m_renderView.settings().delegatesPageScaling())
+        // With delegated page scaling, pageScaleFactor() is not applied by RenderView, so we should not scale here.
+        auto& frameView = m_renderView.frameView();
+        if (!frameView.delegatesPageScaling())
             clipRect.scale(pageScaleFactor());
 
         clippedBounds.intersect(clipRect);
index b4dc2e2..a4dc7c3 100644 (file)
         (WebKit::NetworkResourceLoader::startWithServiceWorker):
         (WebKit::NetworkResourceLoader::serviceWorkerDidNotHandle):
 
+2019-12-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Change 'delegatesPageScaling' from a Setting to a flag on ScrollView
+        https://bugs.webkit.org/show_bug.cgi?id=205319
+
+        Reviewed by Tim Horton.
+
+        delegatesPageScaling() is never toggled at runtime (even by tests), and it should
+        be a flag on FrameView just like delegatesScrolling (maybe in future the flags can merge).
+
+        So remove the Setting, and have DrawingArea control whether page scaling is delegated.
+        
+        In WebKit1, WebFrameLoaderClient::transitionToCommittedForNewPage() turns on delegated
+        page scaling for iOS.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::usesDelegatedPageScaling const):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
+        * WebProcess/WebPage/ios/FindControllerIOS.mm:
+        (WebKit::FindIndicatorOverlayClientIOS::drawRect):
+
 2019-12-16  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         -[UIWKDocumentContext markedTextRange] is wrong when the caret is not at the start of marked text
index 03a32d3..ad1b853 100644 (file)
@@ -1517,8 +1517,10 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
 #if PLATFORM(COCOA)
     auto* drawingArea = webPage->drawingArea();
     view->setViewExposedRect(drawingArea->viewExposedRect());
-    if (isMainFrame)
+    if (isMainFrame) {
         view->setDelegatesScrolling(drawingArea->usesDelegatedScrolling());
+        view->setDelegatesPageScaling(drawingArea->usesDelegatedPageScaling());
+    }
 #endif
 
     if (webPage->scrollPinningBehavior() != DoNotPin)
index 59d78ae..16d09bf 100644 (file)
@@ -107,6 +107,7 @@ public:
 
     virtual bool supportsAsyncScrolling() const { return false; }
     virtual bool usesDelegatedScrolling() const { return false; }
+    virtual bool usesDelegatedPageScaling() const { return false; }
 
     virtual bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const { return false; }
 
index 8b690c1..ccd963f 100644 (file)
@@ -80,6 +80,7 @@ private:
 
     bool supportsAsyncScrolling() const override { return true; }
     bool usesDelegatedScrolling() const override { return true; }
+    bool usesDelegatedPageScaling() const override { return true; }
 
     void setLayerTreeStateIsFrozen(bool) override;
     bool layerTreeStateIsFrozen() const override { return m_isFlushingSuspended; }
index c87f00c..c80af5d 100644 (file)
@@ -63,9 +63,6 @@ RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea(WebPage& webPage, const W
     , m_layerFlushTimer(*this, &RemoteLayerTreeDrawingArea::flushLayers)
 {
     webPage.corePage()->settings().setForceCompositingMode(true);
-#if PLATFORM(IOS_FAMILY)
-    webPage.corePage()->settings().setDelegatesPageScaling(true);
-#endif
     m_rootLayer->setName("drawing area root");
 
     m_commitQueue = dispatch_queue_create("com.apple.WebKit.WebContent.RemoteLayerTreeDrawingArea.CommitQueue", nullptr);
index 5fa1b98..eb14a86 100644 (file)
@@ -62,7 +62,7 @@ void FindIndicatorOverlayClientIOS::drawRect(PageOverlay& overlay, GraphicsConte
 {
     float scaleFactor = m_frame.page()->deviceScaleFactor();
 
-    if (m_frame.settings().delegatesPageScaling())
+    if (m_frame.view() && m_frame.view()->delegatesPageScaling())
         scaleFactor *= m_frame.page()->pageScaleFactor();
 
     // If the page scale changed, we need to paint a new TextIndicator.
index 168167e..4293df4 100644 (file)
@@ -1,3 +1,23 @@
+2019-12-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Change 'delegatesPageScaling' from a Setting to a flag on ScrollView
+        https://bugs.webkit.org/show_bug.cgi?id=205319
+
+        Reviewed by Tim Horton.
+
+        delegatesPageScaling() is never toggled at runtime (even by tests), and it should
+        be a flag on FrameView just like delegatesScrolling (maybe in future the flags can merge).
+
+        So remove the Setting, and have DrawingArea control whether page scaling is delegated.
+        
+        In WebKit1, WebFrameLoaderClient::transitionToCommittedForNewPage() turns on delegated
+        page scaling for iOS.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::transitionToCommittedForNewPage):
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2019-12-16  Antti Koivisto  <antti@apple.com>
 
         Remove display:contents feature flag
index f148aeb..2962fe0 100644 (file)
@@ -1473,6 +1473,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
     if (isMainFrame) {
 #if PLATFORM(IOS_FAMILY)
         coreView->setDelegatesScrolling(true);
+        coreView->setDelegatesPageScaling(true);
 #endif
         coreView->setParentVisible(true);
     }
index 2945516..c2f14ce 100644 (file)
@@ -3044,7 +3044,6 @@ static bool needsSelfRetainWhileLoadingQuirk()
     settings.setPasswordEchoDurationInSeconds([preferences _passwordEchoDuration]);
 
     ASSERT_WITH_MESSAGE(settings.backForwardCacheSupportsPlugins(), "BackForwardCacheSupportsPlugins should be enabled on iOS.");
-    settings.setDelegatesPageScaling(true);
 
 #if ENABLE(TEXT_AUTOSIZING)
     settings.setMinimumZoomFontSize([preferences _minimumZoomFontSize]);