[iOS][WK2] Expose the viewport meta tag width on the UIProcess
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 22:55:26 +0000 (22:55 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 22:55:26 +0000 (22:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132926
<rdar://problem/16892115>

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-05-14
Reviewed by Sam Weinig.

Safari requires the viewport meta tag width for legacy stuff on WebApps. Just send it
over to the UIProcess when it changes.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
(-[WKWebView _setViewportMetaTagWidth:]):
(-[WKWebView _viewportMetaTagWidth]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didChangeViewportMetaTagWidth):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::viewportMetaTagWidthDidChange):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::viewportPropertiesDidChange):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index b1f3df5..8726e4d 100644 (file)
@@ -1,3 +1,31 @@
+2014-05-14  Benjamin Poulain  <bpoulain@apple.com>
+
+        [iOS][WK2] Expose the viewport meta tag width on the UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=132926
+        <rdar://problem/16892115>
+
+        Reviewed by Sam Weinig.
+
+        Safari requires the viewport meta tag width for legacy stuff on WebApps. Just send it
+        over to the UIProcess when it changes.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]):
+        (-[WKWebView _setViewportMetaTagWidth:]):
+        (-[WKWebView _viewportMetaTagWidth]):
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::didChangeViewportMetaTagWidth):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::viewportMetaTagWidthDidChange):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::viewportPropertiesDidChange):
+
 2014-05-13  Simon Fraser  <simon.fraser@apple.com>
 
         [iOS WK2] Make view debugging easier
index f596417..8703552 100644 (file)
     CGSize _minimumLayoutSizeOverride;
     CGSize _minimumLayoutSizeOverrideForMinimalUI;
     CGRect _inputViewBounds;
+    CGFloat _viewportMetaTagWidth;
 
     UIEdgeInsets _obscuredInsets;
     bool _isChangingObscuredInsetsInteractively;
     [_contentView layer].anchorPoint = CGPointZero;
     [_contentView setFrame:bounds];
     [_scrollView addSubview:_contentView.get()];
+    _viewportMetaTagWidth = -1;
 
     [self _frameOrBoundsChanged];
 
     [_customContentView web_setContentProviderData:data suggestedFilename:suggestedFilename];
 }
 
+- (void)_setViewportMetaTagWidth:(float)newWidth
+{
+    _viewportMetaTagWidth = newWidth;
+}
+
 - (void)_willInvokeUIScrollViewDelegateCallback
 {
     _delayUpdateVisibleContentRects = YES;
@@ -1688,6 +1695,11 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     return [(WKPDFView *)_customContentView.get() suggestedFilename];
 }
 
+- (CGFloat)_viewportMetaTagWidth
+{
+    return _viewportMetaTagWidth;
+}
+
 // FIXME: Remove this once nobody uses it.
 - (NSURL *)activeURL
 {
index 79386d7..9fa199a 100644 (file)
@@ -73,6 +73,7 @@ struct ViewSnapshot;
 
 - (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&)mimeType;
 - (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&)suggestedFilename data:(NSData *)data;
+- (void)_setViewportMetaTagWidth:(float)newWidth;
 
 - (void)_willInvokeUIScrollViewDelegateCallback;
 - (void)_didInvokeUIScrollViewDelegateCallback;
index ee7422b..af946fe 100644 (file)
@@ -109,6 +109,9 @@ typedef NS_OPTIONS(NSUInteger, _WKFindOptions) {
 // FIXME: This can be removed once WKNavigation's response property is implemented.
 @property (nonatomic, readonly) NSString *_suggestedFilenameForDisplayedPDF;
 
+// The viewport meta tag width is negative if the value is not defined.
+@property (nonatomic, readonly) CGFloat _viewportMetaTagWidth;
+
 - (void)_beginInteractiveObscuredInsetsChange;
 - (void)_endInteractiveObscuredInsetsChange;
 
index ab7721a..6bb5634 100644 (file)
@@ -256,6 +256,7 @@ public:
     virtual void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold) = 0;
     virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) = 0;
     virtual void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) = 0;
+    virtual void didChangeViewportMetaTagWidth(float) = 0;
 
 #if ENABLE(INSPECTOR)
     virtual void showInspectorIndication() = 0;
index 2a6251c..66896db 100644 (file)
@@ -626,6 +626,7 @@ public:
     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
     void commitPotentialTapFailed();
     void didNotHandleTapAsClick(const WebCore::IntPoint&);
+    void viewportMetaTagWidthDidChange(float width);
 #endif
 
     const EditorState& editorState() const { return m_editorState; }
index 2486b65..530f663 100644 (file)
@@ -171,6 +171,7 @@ messages -> WebPageProxy {
     ZoomToRect(WebCore::FloatRect rect, double minimumScale, double maximumScale)
     CommitPotentialTapFailed()
     DidNotHandleTapAsClick(WebCore::IntPoint point)
+    ViewportMetaTagWidthDidChange(float width)
 #endif
 #if PLATFORM(GTK)
     PrintFinishedCallback(WebCore::ResourceError error, uint64_t callbackID)
index 2dfd44e..2f5b269 100644 (file)
@@ -122,6 +122,7 @@ private:
     virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) override;
 
     virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
+    virtual void didChangeViewportMetaTagWidth(float) override;
 
 #if ENABLE(INSPECTOR)
     virtual void showInspectorIndication() override;
index e830f49..5d16bcc 100644 (file)
@@ -182,6 +182,11 @@ void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
     [static_cast<_WKDownload *>(download->wrapper()) setOriginatingWebView:m_webView];
 }
 
+void PageClientImpl::didChangeViewportMetaTagWidth(float newWidth)
+{
+    [m_webView _setViewportMetaTagWidth:newWidth];
+}
+
 void PageClientImpl::setCursor(const Cursor&)
 {
     notImplemented();
index ff0e0a4..37b9cbc 100644 (file)
@@ -603,6 +603,11 @@ void WebPageProxy::didNotHandleTapAsClick(const WebCore::IntPoint& point)
     m_uiClient->didNotHandleTapAsClick(point);
 }
 
+void WebPageProxy::viewportMetaTagWidthDidChange(float width)
+{
+    m_pageClient.didChangeViewportMetaTagWidth(width);
+}
+
 #if USE(QUICK_LOOK)
     
 void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
index 234f879..346200c 100644 (file)
@@ -126,8 +126,13 @@ FloatSize WebPage::availableScreenSize() const
 
 void WebPage::viewportPropertiesDidChange(const ViewportArguments& viewportArguments)
 {
+    float oldWidth = m_viewportConfiguration.viewportArguments().width;
+
     m_viewportConfiguration.setViewportArguments(viewportArguments);
     viewportConfigurationChanged();
+
+    if (oldWidth != viewportArguments.width)
+        send(Messages::WebPageProxy::ViewportMetaTagWidthDidChange(viewportArguments.width));
 }
 
 void WebPage::didReceiveMobileDocType(bool isMobileDoctype)