Title: [169869] trunk
Revision
169869
Author
[email protected]
Date
2014-06-11 19:03:34 -0700 (Wed, 11 Jun 2014)

Log Message

[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.

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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169868 => 169869)


--- trunk/Source/WebCore/ChangeLog	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebCore/ChangeLog	2014-06-12 02:03:34 UTC (rev 169869)
@@ -1,3 +1,17 @@
+2014-06-11  Simon Fraser  <[email protected]>
+
+        [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  <[email protected]>
 
         Keep CFDataRefs in SharedBuffer instead of merging them

Modified: trunk/Source/WebCore/WebCore.exp.in (169868 => 169869)


--- trunk/Source/WebCore/WebCore.exp.in	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-06-12 02:03:34 UTC (rev 169869)
@@ -924,6 +924,7 @@
 __ZN7WebCore21UserContentURLPattern5parseERKN3WTF6StringE
 __ZN7WebCore21ViewportConfiguration14resetMinimalUIEv
 __ZN7WebCore21ViewportConfiguration15setContentsSizeERKNS_7IntSizeE
+__ZN7WebCore21ViewportConfiguration17testingParametersEv
 __ZN7WebCore21ViewportConfiguration17webpageParametersEv
 __ZN7WebCore21ViewportConfiguration20setMinimumLayoutSizeERKNS_9FloatSizeE
 __ZN7WebCore21ViewportConfiguration20setViewportArgumentsERKNS_17ViewportArgumentsE

Modified: trunk/Source/WebCore/page/ViewportConfiguration.cpp (169868 => 169869)


--- trunk/Source/WebCore/page/ViewportConfiguration.cpp	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebCore/page/ViewportConfiguration.cpp	2014-06-12 02:03:34 UTC (rev 169869)
@@ -218,6 +218,16 @@
     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;

Modified: trunk/Source/WebCore/page/ViewportConfiguration.h (169868 => 169869)


--- trunk/Source/WebCore/page/ViewportConfiguration.h	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebCore/page/ViewportConfiguration.h	2014-06-12 02:03:34 UTC (rev 169869)
@@ -96,6 +96,7 @@
     static Parameters textDocumentParameters();
     static Parameters imageDocumentParameters();
     static Parameters xhtmlMobileParameters();
+    static Parameters testingParameters();
     
 #ifndef NDEBUG
     WTF::CString description() const;

Modified: trunk/Source/WebKit2/ChangeLog (169868 => 169869)


--- trunk/Source/WebKit2/ChangeLog	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-12 02:03:34 UTC (rev 169869)
@@ -1,3 +1,26 @@
+2014-06-11  Simon Fraser  <[email protected]>
+
+        [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  <[email protected]>
 
         Remove unused VisibleContentRectUpdateInfo update ID

Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm (169868 => 169869)


--- trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm	2014-06-12 02:03:34 UTC (rev 169869)
@@ -131,7 +131,7 @@
 
     _allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
     
-    WebPageProxy *webPageProxy = [_contentView page];
+    WebPageProxy* webPageProxy = [_contentView page];
     
     if (allowsBackForwardNavigationGestures) {
         if (!_gestureController) {
@@ -243,6 +243,13 @@
 - (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];

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (169868 => 169869)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2014-06-12 02:03:34 UTC (rev 169869)
@@ -565,3 +565,10 @@
 {
     return toImpl(pageRef)->usesEphemeralSession();
 }
+
+#if TARGET_OS_IPHONE
+void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef pageRef, bool useTestingViewportConfiguration)
+{
+    toImpl(pageRef)->setUseTestingViewportConfiguration(useTestingViewportConfiguration);
+}
+#endif

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h (169868 => 169869)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h	2014-06-12 02:03:34 UTC (rev 169869)
@@ -93,6 +93,10 @@
 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

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (169868 => 169869)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-06-12 02:03:34 UTC (rev 169869)
@@ -298,6 +298,7 @@
     , m_userHasChangedPageScaleFactor(false)
     , m_userIsInteracting(false)
     , m_hasPendingBlurNotification(false)
+    , m_useTestingViewportConfiguration(false)
     , m_screenSize(parameters.screenSize)
     , m_availableScreenSize(parameters.availableScreenSize)
     , m_deviceOrientation(0)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (169868 => 169869)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-06-12 02:03:34 UTC (rev 169869)
@@ -459,6 +459,9 @@
     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 @@
     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;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (169868 => 169869)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-06-12 02:03:34 UTC (rev 169869)
@@ -2189,6 +2189,11 @@
 
 void WebPage::resetViewportDefaultConfiguration(WebFrame* frame)
 {
+    if (m_useTestingViewportConfiguration) {
+        m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::testingParameters());
+        return;
+    }
+
     if (!frame) {
         m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::webpageParameters());
         return;

Modified: trunk/Tools/ChangeLog (169868 => 169869)


--- trunk/Tools/ChangeLog	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Tools/ChangeLog	2014-06-12 02:03:34 UTC (rev 169869)
@@ -1,5 +1,20 @@
 2014-06-11  Simon Fraser  <[email protected]>
 
+        [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  <[email protected]>
+
         WTR cleanup: push per-test viewport configuration into TestController, where platforms can customize it
         https://bugs.webkit.org/show_bug.cgi?id=133770
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (169868 => 169869)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2014-06-12 02:03:34 UTC (rev 169869)
@@ -157,7 +157,9 @@
 
         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 @@
 
         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();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm (169868 => 169869)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm	2014-06-12 00:46:49 UTC (rev 169868)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm	2014-06-12 02:03:34 UTC (rev 169869)
@@ -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 @@
 
     WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyProvisionalURL(frame));
     setCrashReportApplicationSpecificInformationToURL(mainFrameURL.get());
+
+#if PLATFORM(IOS)
+    WKBundlePageSetUseTestingViewportConfiguration(page(), true);
+#endif
 }
 
 } // namespace WTR
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to