Make it possible to override the screen size
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2018 23:16:50 +0000 (23:16 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2018 23:16:50 +0000 (23:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184111
<rdar://problem/38972181>

Reviewed by Tim Horton.

Source/WebCore:

We just call screenSize() atm.

* page/Chrome.cpp:
(WebCore::Chrome::overrideScreenSize const):
* page/Chrome.h:
* page/ChromeClient.h:
* platform/HostWindow.h:
* platform/PlatformScreen.h:
* platform/ios/PlatformScreenIOS.mm:
(WebCore::screenRect):
(WebCore::overrideScreenSize):

Source/WebKit:

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::overrideScreenSize):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::overrideScreenSize const):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::overrideScreenSize const):

Source/WebKitLegacy/ios:

* WebCoreSupport/WebChromeClientIOS.h:
* WebCoreSupport/WebChromeClientIOS.mm:
(WebChromeClientIOS::overrideScreenSize const):

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

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Chrome.cpp
Source/WebCore/page/Chrome.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/platform/HostWindow.h
Source/WebCore/platform/PlatformScreen.h
Source/WebCore/platform/ios/PlatformScreenIOS.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h
Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm

index be17375..192e835 100644 (file)
@@ -1,3 +1,23 @@
+2018-03-28  Zalan Bujtas  <zalan@apple.com>
+
+        Make it possible to override the screen size
+        https://bugs.webkit.org/show_bug.cgi?id=184111
+        <rdar://problem/38972181>
+
+        Reviewed by Tim Horton.
+
+        We just call screenSize() atm.
+
+        * page/Chrome.cpp:
+        (WebCore::Chrome::overrideScreenSize const):
+        * page/Chrome.h:
+        * page/ChromeClient.h:
+        * platform/HostWindow.h:
+        * platform/PlatformScreen.h:
+        * platform/ios/PlatformScreenIOS.mm:
+        (WebCore::screenRect):
+        (WebCore::overrideScreenSize):
+
 2018-03-28  Timothy Hatcher  <timothy@apple.com>
 
         Include the 'text' color keyword as a system color.
index de6bfaa..0667491 100644 (file)
@@ -450,6 +450,11 @@ FloatSize Chrome::availableScreenSize() const
     return m_client.availableScreenSize();
 }
 
+FloatSize Chrome::overrideScreenSize() const
+{
+    return m_client.overrideScreenSize();
+}
+
 void Chrome::dispatchViewportPropertiesDidChange(const ViewportArguments& arguments) const
 {
 #if PLATFORM(IOS)
index 93e5b7c..0c707f3 100644 (file)
@@ -91,6 +91,7 @@ public:
 
     FloatSize screenSize() const override;
     FloatSize availableScreenSize() const override;
+    FloatSize overrideScreenSize() const override;
 
     void scrollRectIntoView(const IntRect&) const;
 
index 5477ecb..53413e5 100644 (file)
@@ -185,6 +185,7 @@ public:
 
     virtual FloatSize screenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }
     virtual FloatSize availableScreenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }
+    virtual FloatSize overrideScreenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }
 
     virtual void dispatchViewportPropertiesDidChange(const ViewportArguments&) const { }
 
index bd1bd3b..3a5b991 100644 (file)
@@ -78,6 +78,7 @@ public:
 
     virtual FloatSize screenSize() const = 0;
     virtual FloatSize availableScreenSize() const = 0;
+    virtual FloatSize overrideScreenSize() const = 0;
 };
 
 } // namespace WebCore
index 88331e3..9e84680 100644 (file)
@@ -101,6 +101,7 @@ WEBCORE_EXPORT void setScreenProperties(const HashMap<PlatformDisplayID, ScreenP
 float screenPPIFactor();
 WEBCORE_EXPORT FloatSize screenSize();
 WEBCORE_EXPORT FloatSize availableScreenSize();
+WEBCORE_EXPORT FloatSize overrideScreenSize();
 WEBCORE_EXPORT float screenScaleFactor(UIScreen * = nullptr);
 
 #endif
index 646dcce..3a24882 100644 (file)
@@ -96,7 +96,7 @@ FloatRect screenRect(Widget* widget)
         CGRect screenRect = { CGPointZero, [window screenSize] };
         return enclosingIntRect(screenRect);
     }
-    return enclosingIntRect(FloatRect(FloatPoint(), widget->root()->hostWindow()->screenSize()));
+    return enclosingIntRect(FloatRect(FloatPoint(), widget->root()->hostWindow()->overrideScreenSize()));
 }
 
 FloatRect screenAvailableRect(Widget* widget)
@@ -146,6 +146,11 @@ FloatSize availableScreenSize()
     return FloatSize([get_UIKit_UIScreenClass() mainScreen].bounds.size);
 }
 
+FloatSize overrideScreenSize()
+{
+    return screenSize();
+}
+
 float screenScaleFactor(UIScreen *screen)
 {
     if (!screen)
index be3bd9c..4d83dca 100644 (file)
@@ -1,3 +1,28 @@
+2018-03-28  Zalan Bujtas  <zalan@apple.com>
+
+        Make it possible to override the screen size
+        https://bugs.webkit.org/show_bug.cgi?id=184111
+        <rdar://problem/38972181>
+
+        Reviewed by Tim Horton.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::overrideScreenSize):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::overrideScreenSize const):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::overrideScreenSize const):
+
 2018-03-28  Chris Dumez  <cdumez@apple.com>
 
         Do process swap when opening a cross-origin URL via window.open(url, '_blank', 'noopener')
index c4997e3..7089da8 100644 (file)
@@ -87,6 +87,7 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
 #if PLATFORM(IOS)
     encoder << screenSize;
     encoder << availableScreenSize;
+    encoder << overrideScreenSize;
     encoder << textAutosizingWidth;
     encoder << ignoresViewportScaleLimits;
     encoder << viewportConfigurationMinimumLayoutSize;
@@ -245,6 +246,8 @@ std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::
         return std::nullopt;
     if (!decoder.decode(parameters.availableScreenSize))
         return std::nullopt;
+    if (!decoder.decode(parameters.overrideScreenSize))
+        return std::nullopt;
     if (!decoder.decode(parameters.textAutosizingWidth))
         return std::nullopt;
     if (!decoder.decode(parameters.ignoresViewportScaleLimits))
index a37a734..6bd1961 100644 (file)
@@ -144,6 +144,7 @@ struct WebPageCreationParameters {
 #if PLATFORM(IOS)
     WebCore::FloatSize screenSize;
     WebCore::FloatSize availableScreenSize;
+    WebCore::FloatSize overrideScreenSize;
     float textAutosizingWidth;
     bool ignoresViewportScaleLimits;
     WebCore::FloatSize viewportConfigurationMinimumLayoutSize;
index f8b60a0..1bc537b 100644 (file)
@@ -5869,6 +5869,7 @@ WebPageCreationParameters WebPageProxy::creationParameters()
 #if PLATFORM(IOS)
     parameters.screenSize = screenSize();
     parameters.availableScreenSize = availableScreenSize();
+    parameters.overrideScreenSize = overrideScreenSize();
     parameters.textAutosizingWidth = textAutosizingWidth();
     parameters.mimeTypesWithCustomContentProviders = m_pageClient.mimeTypesWithCustomContentProviders();
     parameters.ignoresViewportScaleLimits = m_forceAlwaysUserScalable;
index 04e5889..a6ae92b 100644 (file)
@@ -1626,6 +1626,7 @@ private:
 #if PLATFORM(IOS)
     WebCore::FloatSize screenSize();
     WebCore::FloatSize availableScreenSize();
+    WebCore::FloatSize overrideScreenSize();
     float textAutosizingWidth();
 
     void dynamicViewportUpdateChangedTarget(double newTargetScale, const WebCore::FloatPoint& newScrollPosition, uint64_t dynamicViewportSizeUpdateID);
index b88c124..afb71f1 100644 (file)
@@ -899,7 +899,12 @@ FloatSize WebPageProxy::availableScreenSize()
 {
     return WebCore::availableScreenSize();
 }
-    
+
+FloatSize WebPageProxy::overrideScreenSize()
+{
+    return WebCore::overrideScreenSize();
+}
+
 float WebPageProxy::textAutosizingWidth()
 {
     return WebCore::screenSize().width();
index a76c273..b1398bd 100644 (file)
@@ -1021,6 +1021,11 @@ FloatSize WebChromeClient::availableScreenSize() const
     return m_page.availableScreenSize();
 }
 
+FloatSize WebChromeClient::overrideScreenSize() const
+{
+    return m_page.overrideScreenSize();
+}
+
 #endif
 
 void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments& viewportArguments) const
index 66049eb..c3c29b0 100644 (file)
@@ -279,6 +279,7 @@ private:
 #if PLATFORM(IOS)
     WebCore::FloatSize screenSize() const final;
     WebCore::FloatSize availableScreenSize() const final;
+    WebCore::FloatSize overrideScreenSize() const final;
 #endif
 
     void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const final;
index 8be2d76..cd2e0ad 100644 (file)
@@ -367,6 +367,7 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
     , m_forceAlwaysUserScalable(parameters.ignoresViewportScaleLimits)
     , m_screenSize(parameters.screenSize)
     , m_availableScreenSize(parameters.availableScreenSize)
+    , m_overrideScreenSize(parameters.overrideScreenSize)
 #endif
     , m_layerVolatilityTimer(*this, &WebPage::layerVolatilityTimerFired)
     , m_activityState(parameters.activityState)
index 2251e71..5cb0912 100644 (file)
@@ -551,6 +551,7 @@ public:
 #if PLATFORM(IOS)
     WebCore::FloatSize screenSize() const;
     WebCore::FloatSize availableScreenSize() const;
+    WebCore::FloatSize overrideScreenSize() const;
     int32_t deviceOrientation() const { return m_deviceOrientation; }
     void didReceiveMobileDocType(bool);
 
@@ -1628,6 +1629,7 @@ private:
     Seconds m_estimatedLatency { 0 };
     WebCore::FloatSize m_screenSize;
     WebCore::FloatSize m_availableScreenSize;
+    WebCore::FloatSize m_overrideScreenSize;
     RefPtr<WebCore::Range> m_currentBlockSelection;
     WebCore::IntRect m_blockRectForTextSelection;
 
index df8d22a..5629db1 100644 (file)
@@ -252,6 +252,11 @@ FloatSize WebPage::availableScreenSize() const
     return m_availableScreenSize;
 }
 
+FloatSize WebPage::overrideScreenSize() const
+{
+    return m_overrideScreenSize;
+}
+
 void WebPage::didReceiveMobileDocType(bool isMobileDoctype)
 {
     resetViewportDefaultConfiguration(m_mainFrame.get(), isMobileDoctype);
index 6f035ae..60ff761 100644 (file)
@@ -1,3 +1,15 @@
+2018-03-28  Zalan Bujtas  <zalan@apple.com>
+
+        Make it possible to override the screen size
+        https://bugs.webkit.org/show_bug.cgi?id=184111
+        <rdar://problem/38972181>
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/WebChromeClientIOS.h:
+        * WebCoreSupport/WebChromeClientIOS.mm:
+        (WebChromeClientIOS::overrideScreenSize const):
+
 2018-03-25  Tim Horton  <timothy_horton@apple.com>
 
         Disable geolocation prompt in minimal simulator mode
index b172aa0..3cdc596 100644 (file)
@@ -58,6 +58,7 @@ private:
     void clearContentChangeObservers(WebCore::Frame&) final;
     WebCore::FloatSize screenSize() const final;
     WebCore::FloatSize availableScreenSize() const final;
+    WebCore::FloatSize overrideScreenSize() const final;
     void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const final;
     void notifyRevealedSelectionByScrollingFrame(WebCore::Frame&) final;
     bool isStopping() final;
index f85c8d3..631fa6f 100644 (file)
@@ -227,6 +227,11 @@ FloatSize WebChromeClientIOS::availableScreenSize() const
     return FloatSize();
 }
 
+FloatSize WebChromeClientIOS::overrideScreenSize() const
+{
+    return screenSize();
+}
+
 void WebChromeClientIOS::dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments& arguments) const
 {
     [[webView() _UIKitDelegateForwarder] webView:webView() didReceiveViewportArguments:dictionaryForViewportArguments(arguments)];