[iOS WK2] Give WebKitTestRunner a viewport configuration with initial scale=1 for...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jun 2014 02:03:34 +0000 (02:03 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jun 2014 02:03:34 +0000 (02:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133779

Reviewed by Benjamin Poulain.

Source/WebCore:

Add a "testing" viewport configuration with initial scale of 1.

* WebCore.exp.in:
* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::testingParameters):
* page/ViewportConfiguration.h:

Source/WebKit2:

Support a custom viewport configuration for testing, on iOS.

* UIProcess/API/ios/WKViewIOS.mm:
(-[WKView _frameOrBoundsChanged]): Call setViewportConfigurationMinimumLayoutSize()
just as WKWebView does.
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageSetUseTestingViewportConfiguration): New SPI to set a viewport config for testing.
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h: Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::setUseTestingViewportConfiguration):
(WebKit::WebPage::isUsingTestingViewportConfiguration):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::resetViewportDefaultConfiguration):

Tools:

Tell the WebPage to use the testing viewport configuration from the injected bundle.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessage): Code cleanup.
* WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm:
(WTR::InjectedBundlePage::platformDidStartProvisionalLoadForFrame): Call WKBundlePageSetUseTestingViewportConfiguration()
on iOS.

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/ViewportConfiguration.cpp
Source/WebCore/page/ViewportConfiguration.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm

index 566fe6c..15bfbb1 100644 (file)
@@ -1,3 +1,17 @@
+2014-06-11  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Give WebKitTestRunner a viewport configuration with initial scale=1 for testing
+        https://bugs.webkit.org/show_bug.cgi?id=133779
+
+        Reviewed by Benjamin Poulain.
+
+        Add a "testing" viewport configuration with initial scale of 1.
+
+        * WebCore.exp.in:
+        * page/ViewportConfiguration.cpp:
+        (WebCore::ViewportConfiguration::testingParameters):
+        * page/ViewportConfiguration.h:
+
 2014-06-11  Pratik Solanki  <psolanki@apple.com>
 
         Keep CFDataRefs in SharedBuffer instead of merging them
index 8719501..8622b30 100644 (file)
@@ -924,6 +924,7 @@ __ZN7WebCore21UserContentControllerD1Ev
 __ZN7WebCore21UserContentURLPattern5parseERKN3WTF6StringE
 __ZN7WebCore21ViewportConfiguration14resetMinimalUIEv
 __ZN7WebCore21ViewportConfiguration15setContentsSizeERKNS_7IntSizeE
+__ZN7WebCore21ViewportConfiguration17testingParametersEv
 __ZN7WebCore21ViewportConfiguration17webpageParametersEv
 __ZN7WebCore21ViewportConfiguration20setMinimumLayoutSizeERKNS_9FloatSizeE
 __ZN7WebCore21ViewportConfiguration20setViewportArgumentsERKNS_17ViewportArgumentsE
index 727dbcb..a934006 100644 (file)
@@ -218,6 +218,16 @@ ViewportConfiguration::Parameters ViewportConfiguration::xhtmlMobileParameters()
     return parameters;
 }
 
+ViewportConfiguration::Parameters ViewportConfiguration::testingParameters()
+{
+    Parameters parameters;
+    parameters.initialScale = 1;
+    parameters.initialScaleIsSet = true;
+    parameters.minimumScale = 1;
+    parameters.maximumScale = 5;
+    return parameters;
+}
+
 static inline bool viewportArgumentValueIsValid(float value)
 {
     return value > 0;
index c226b03..ba45ca2 100644 (file)
@@ -96,6 +96,7 @@ public:
     static Parameters textDocumentParameters();
     static Parameters imageDocumentParameters();
     static Parameters xhtmlMobileParameters();
+    static Parameters testingParameters();
     
 #ifndef NDEBUG
     WTF::CString description() const;
index 68d377d..6440651 100644 (file)
@@ -1,3 +1,26 @@
+2014-06-11  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Give WebKitTestRunner a viewport configuration with initial scale=1 for testing
+        https://bugs.webkit.org/show_bug.cgi?id=133779
+
+        Reviewed by Benjamin Poulain.
+        
+        Support a custom viewport configuration for testing, on iOS.
+
+        * UIProcess/API/ios/WKViewIOS.mm:
+        (-[WKView _frameOrBoundsChanged]): Call setViewportConfigurationMinimumLayoutSize()
+        just as WKWebView does.
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageSetUseTestingViewportConfiguration): New SPI to set a viewport config for testing.
+        * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h: Ditto.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::setUseTestingViewportConfiguration):
+        (WebKit::WebPage::isUsingTestingViewportConfiguration):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::resetViewportDefaultConfiguration):
+
 2014-06-11  Timothy Horton  <timothy_horton@apple.com>
 
         Remove unused VisibleContentRectUpdateInfo update ID
index 1986671..884c251 100644 (file)
@@ -131,7 +131,7 @@ using namespace WebKit;
 
     _allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
     
-    WebPageProxy *webPageProxy = [_contentView page];
+    WebPageProxywebPageProxy = [_contentView page];
     
     if (allowsBackForwardNavigationGestures) {
         if (!_gestureController) {
@@ -243,6 +243,13 @@ using namespace WebKit;
 - (void)_frameOrBoundsChanged
 {
     CGRect bounds = [self bounds];
+
+    WebPageProxy* webPageProxy = [_contentView page];
+    WebCore::FloatSize size(bounds.size);
+    webPageProxy->setViewportConfigurationMinimumLayoutSize(size);
+    webPageProxy->setViewportConfigurationMinimumLayoutSizeForMinimalUI(size);
+    webPageProxy->setMaximumUnobscuredSize(size);
+
     [_scrollView setFrame:bounds];
     [_contentView setMinimumSize:bounds.size];
     [self _updateVisibleContentRects];
index 4c8de95..38a2ab3 100644 (file)
@@ -565,3 +565,10 @@ bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef pageRef)
 {
     return toImpl(pageRef)->usesEphemeralSession();
 }
+
+#if TARGET_OS_IPHONE
+void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef pageRef, bool useTestingViewportConfiguration)
+{
+    toImpl(pageRef)->setUseTestingViewportConfiguration(useTestingViewportConfiguration);
+}
+#endif
index e2eeedd..c66e74c 100644 (file)
@@ -93,6 +93,10 @@ typedef unsigned WKRenderingSuppressionToken;
 WK_EXPORT WKRenderingSuppressionToken WKBundlePageExtendIncrementalRenderingSuppression(WKBundlePageRef);
 WK_EXPORT void WKBundlePageStopExtendingIncrementalRenderingSuppression(WKBundlePageRef, WKRenderingSuppressionToken);
 
+#if TARGET_OS_IPHONE
+WK_EXPORT void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef, bool);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index bf244ee..92e7b8d 100644 (file)
@@ -298,6 +298,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     , m_userHasChangedPageScaleFactor(false)
     , m_userIsInteracting(false)
     , m_hasPendingBlurNotification(false)
+    , m_useTestingViewportConfiguration(false)
     , m_screenSize(parameters.screenSize)
     , m_availableScreenSize(parameters.availableScreenSize)
     , m_deviceOrientation(0)
index 67f11ec..f7a92e7 100644 (file)
@@ -459,6 +459,9 @@ public:
     void didReceiveMobileDocType(bool);
     void restorePageState(double scale, bool userHasChangedPageScaleFactor, const WebCore::IntPoint& exposedOrigin);
 
+    void setUseTestingViewportConfiguration(bool useTestingViewport) { m_useTestingViewportConfiguration = useTestingViewport; }
+    bool isUsingTestingViewportConfiguration() const { return m_useTestingViewportConfiguration; }
+
     double minimumPageScaleFactor() const;
     double maximumPageScaleFactor() const;
     bool allowsUserScaling() const;
@@ -1220,6 +1223,7 @@ private:
     bool m_userHasChangedPageScaleFactor;
     bool m_userIsInteracting;
     bool m_hasPendingBlurNotification;
+    bool m_useTestingViewportConfiguration;
     WebCore::FloatSize m_screenSize;
     WebCore::FloatSize m_availableScreenSize;
     RefPtr<WebCore::Range> m_currentBlockSelection;
index 8d00485..7e222f1 100644 (file)
@@ -2189,6 +2189,11 @@ void WebPage::synchronizeDynamicViewportUpdate(double& newTargetScale, FloatPoin
 
 void WebPage::resetViewportDefaultConfiguration(WebFrame* frame)
 {
+    if (m_useTestingViewportConfiguration) {
+        m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::testingParameters());
+        return;
+    }
+
     if (!frame) {
         m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::webpageParameters());
         return;
index 20f8683..a8475ad 100644 (file)
@@ -1,5 +1,20 @@
 2014-06-11  Simon Fraser  <simon.fraser@apple.com>
 
+        [iOS WK2] Give WebKitTestRunner a viewport configuration with initial scale=1 for testing
+        https://bugs.webkit.org/show_bug.cgi?id=133779
+
+        Reviewed by Benjamin Poulain.
+        
+        Tell the WebPage to use the testing viewport configuration from the injected bundle.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessage): Code cleanup.
+        * WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm:
+        (WTR::InjectedBundlePage::platformDidStartProvisionalLoadForFrame): Call WKBundlePageSetUseTestingViewportConfiguration()
+        on iOS.
+
+2014-06-11  Simon Fraser  <simon.fraser@apple.com>
+
         WTR cleanup: push per-test viewport configuration into TestController, where platforms can customize it
         https://bugs.webkit.org/show_bug.cgi?id=133770
 
index 163f96c..7b1de70 100644 (file)
@@ -157,7 +157,9 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
 
         beginTesting(messageBodyDictionary);
         return;
-    } else if (WKStringIsEqualToUTF8CString(messageName, "Reset")) {
+    }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "Reset")) {
         ASSERT(messageBody);
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
@@ -178,22 +180,27 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
 
         return;
     }
+
     if (WKStringIsEqualToUTF8CString(messageName, "CallAddChromeInputFieldCallback")) {
         m_testRunner->callAddChromeInputFieldCallback();
         return;
     }
+
     if (WKStringIsEqualToUTF8CString(messageName, "CallRemoveChromeInputFieldCallback")) {
         m_testRunner->callRemoveChromeInputFieldCallback();
         return;
     }
+
     if (WKStringIsEqualToUTF8CString(messageName, "CallFocusWebViewCallback")) {
         m_testRunner->callFocusWebViewCallback();
         return;
     }
+
     if (WKStringIsEqualToUTF8CString(messageName, "CallSetBackingScaleFactorCallback")) {
         m_testRunner->callSetBackingScaleFactorCallback();
         return;
     }   
+
     if (WKStringIsEqualToUTF8CString(messageName, "WorkQueueProcessedCallback")) {
         if (!topLoadingFrame() && !m_testRunner->waitToDump())
             page()->dump();
index ac66148..1f98299 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "CrashReporterInfo.h"
 #import <WebKit/WKBundleFrame.h>
+#import <WebKit/WKBundlePagePrivate.h>
 #import <WebKit/WKURLCF.h>
 
 namespace WTR {
@@ -41,6 +42,10 @@ void InjectedBundlePage::platformDidStartProvisionalLoadForFrame(WKBundleFrameRe
 
     WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyProvisionalURL(frame));
     setCrashReportApplicationSpecificInformationToURL(mainFrameURL.get());
+
+#if PLATFORM(IOS)
+    WKBundlePageSetUseTestingViewportConfiguration(page(), true);
+#endif
 }
 
 } // namespace WTR