WebKit Bugzilla
Attachment 347503 Details for
Bug 188746
: [GTK] Touchscreen pinch to zoom should scale the page like other platforms
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188746-20180820122441.patch (text/plain), 13.43 KB, created by
Justin Michaud
on 2018-08-20 09:24:42 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Justin Michaud
Created:
2018-08-20 09:24:42 PDT
Size:
13.43 KB
patch
obsolete
>Subversion Revision: 234846 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 91b71f7bfc9b73f757f8b74ae88fbfcb4b4f3d2a..4ef06b137c90d275ed2da2864ca1fcaa122e204d 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2018-08-20 Justin Michaud <justin@justinmichaud.com> >+ >+ [GTK] Touchscreen pinch to zoom should scale the page like other platforms >+ https://bugs.webkit.org/show_bug.cgi?id=188746 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/API/glib/WebKitWebView.cpp: >+ (webkit_web_view_scale_page): >+ (webkit_web_view_set_zoom_level): >+ * UIProcess/API/gtk/PageClientImpl.cpp: >+ (WebKit::PageClientImpl::scale): >+ * UIProcess/API/gtk/PageClientImpl.h: >+ * UIProcess/API/gtk/WebKitWebView.h: >+ * UIProcess/API/gtk/WebKitWebViewBase.cpp: >+ * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::scaleAndPanPage): >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/gtk/GestureController.cpp: >+ (WebKit::GestureController::ZoomGesture::handleZoom): >+ (WebKit::GestureController::ZoomGesture::scaleChanged): >+ * UIProcess/gtk/GestureController.h: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::scaleAndPanPage): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ > 2018-08-13 Wenson Hsieh <wenson_hsieh@apple.com> > > [WK2] [macOS] Implement a mechanism to test drag and drop >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >index 37cdfa2f4ca11dc14e9415a1710ca401e1123156..374431c0bb677a49a74777a848ad6608ba9fd4b9 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >@@ -3111,6 +3111,27 @@ WebKitWindowProperties* webkit_web_view_get_window_properties(WebKitWebView* web > return webView->priv->windowProperties.get(); > } > >+/** >+ * webkit_web_view_scale_page: >+ * @web_view: a #WebKitWebView >+ * @zoom_level: the zoom level >+ * @scaleCenterX: X coordinate of scale center in page coordinates >+ * @scaleCenterY: y coordinate of scale center in page coordinates >+ * @viewX: X coordinate where scale center should appear, in view coordinates >+ * @viewY: y coordinate where scale center should appear, in view coordinates >+ * >+ * Set the scaling level of @web_view, zooming in on (pageX, pageY) >+ * such that the point (pageX, pageY) appears at (viewX, viewY) on >+ * the web view. >+ */ >+void webkit_web_view_scale_page(WebKitWebView* webView, gdouble zoomLevel, int scaleCenterX, int scaleCenterY, int viewX, int viewY) >+{ >+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); >+ >+ auto& page = getPage(webView); >+ page.scaleAndPanPage(zoomLevel, IntPoint(scaleCenterX, scaleCenterY), IntPoint(viewX, viewY)); >+} >+ > /** > * webkit_web_view_set_zoom_level: > * @web_view: a #WebKitWebView >@@ -3131,6 +3152,7 @@ void webkit_web_view_set_zoom_level(WebKitWebView* webView, gdouble zoomLevel) > page.setTextZoomFactor(zoomLevel); > else > page.setPageZoomFactor(zoomLevel); >+ > g_object_notify(G_OBJECT(webView), "zoom-level"); > } > >diff --git a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >index ea8a737a8bf3fcf7927673f271a4989a79a69357..41a7b477102d8ad844ae42423ef882acc83646fd 100644 >--- a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >@@ -484,4 +484,16 @@ void PageClientImpl::zoom(double zoomLevel) > webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))->setPageZoomFactor(zoomLevel); > } > >+void PageClientImpl::scale(double scale, const IntPoint& scaleCenterInPageCoordinates, const IntPoint& newScaleCenterInViewCoordinates) >+{ >+ if (WEBKIT_IS_WEB_VIEW(m_viewWidget)) { >+ webkit_web_view_scale_page(WEBKIT_WEB_VIEW(m_viewWidget), scale, >+ scaleCenterInPageCoordinates.x(), scaleCenterInPageCoordinates.y(), >+ newScaleCenterInViewCoordinates.x(), newScaleCenterInViewCoordinates.y()); >+ return; >+ } >+ >+ webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))->scaleAndPanPage(scale, scaleCenterInPageCoordinates, newScaleCenterInViewCoordinates); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >index d36539f69a8f3d7d41b30668abe360e5191f1507..139917b18e20e1d021149e81c92143b2889cba9b 100644 >--- a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >+++ b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >@@ -54,6 +54,7 @@ public: > GtkWidget* viewWidget() { return m_viewWidget; } > > void zoom(double); >+ void scale(double, const WebCore::IntPoint& scaleCenterInPageCoordinates, const WebCore::IntPoint& newScaleCenterInViewCoordinates); > > private: > // PageClient >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h >index 8c219a3b008599d5641c9014d5177acd11bb60b5..e50146b0180e23b24e97a5b9451bc70fe9106cb3 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h >@@ -403,6 +403,14 @@ webkit_web_view_get_window_properties (WebKitWebView > WEBKIT_API void > webkit_web_view_set_zoom_level (WebKitWebView *web_view, > gdouble zoom_level); >+ >+WEBKIT_API void >+webkit_web_view_scale_page (WebKitWebView *web_view, >+ gdouble zoom_level, >+ int scaleCenterX, >+ int scaleCenterY, >+ int viewX, >+ int viewY); > WEBKIT_API gdouble > webkit_web_view_get_zoom_level (WebKitWebView *web_view); > >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >index 3b4e988a2a7c93fb26b3cd0d80efe818073d1789..84eb2ecec76e95efaf71021be5998beadf8d1882 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >@@ -1118,13 +1118,13 @@ private: > { > auto* page = webkitWebViewBaseGetPage(m_webView); > ASSERT(page); >- initialScale = page->pageZoomFactor(); >+ initialScale = page->pageScaleFactor(); > page->getCenterForZoomGesture(center, initialPoint); > } > >- void zoom(double scale) final >+ void zoom(double scale, const IntPoint& initialPoint, const IntPoint& centre) final > { >- m_webView->priv->pageClient->zoom(scale); >+ m_webView->priv->pageClient->scale(scale, initialPoint, centre); > } > > void longPress(GdkEventTouch* event) final >diff --git a/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt b/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt >index 3eb829860146b82caef2099af5581c135188d3b2..a2044c54882e35478ca9a0b013386cc98b6399e2 100644 >--- a/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt >+++ b/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt >@@ -196,6 +196,7 @@ webkit_web_view_get_favicon > webkit_web_view_set_settings > webkit_web_view_get_settings > webkit_web_view_get_window_properties >+webkit_web_view_scale_page > webkit_web_view_set_zoom_level > webkit_web_view_get_zoom_level > webkit_web_view_can_execute_editing_command >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 2dc0f33885b690584f47117e69deeef28c022a47..19b5f88f14ede7551195e6a7dd6117f43171b071 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -2784,6 +2784,17 @@ void WebPageProxy::scalePageInViewCoordinates(double scale, const IntPoint& cent > m_process->send(Messages::WebPage::ScalePageInViewCoordinates(scale, centerInViewCoordinates), m_pageID); > } > >+void WebPageProxy::scaleAndPanPage(double scale, WebCore::IntPoint scaleCenterInPageCoordinates, WebCore::IntPoint newScaleCenterInViewCoordinates) >+{ >+ ASSERT(scale > 0); >+ >+ if (!isValid()) >+ return; >+ >+ m_pageScaleFactor = scale; >+ m_process->send(Messages::WebPage::ScaleAndPanPage(scale, scaleCenterInPageCoordinates, newScaleCenterInViewCoordinates), m_pageID); >+} >+ > void WebPageProxy::scaleView(double scale) > { > ASSERT(scale > 0); >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 6a5b259fcaea6d8928f09889c798045eb10d8815..8965440b31a4b092b8805f58865d11357fa611ff 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -772,6 +772,7 @@ public: > > void scalePage(double scale, const WebCore::IntPoint& origin); > void scalePageInViewCoordinates(double scale, const WebCore::IntPoint& centerInViewCoordinates); >+ void scaleAndPanPage(double scale, WebCore::IntPoint scaleCenterInPageCoordinates, WebCore::IntPoint newScaleCenterInViewCoordinates); > double pageScaleFactor() const; > double viewScaleFactor() const { return m_viewScaleFactor; } > void scaleView(double scale); >diff --git a/Source/WebKit/UIProcess/gtk/GestureController.cpp b/Source/WebKit/UIProcess/gtk/GestureController.cpp >index 1dc90df7bcace3ac241f533c7426ebc300e6ecdd..4e61687fe8347255312fa567ed607efe601c61fd 100644 >--- a/Source/WebKit/UIProcess/gtk/GestureController.cpp >+++ b/Source/WebKit/UIProcess/gtk/GestureController.cpp >@@ -203,13 +203,17 @@ void GestureController::ZoomGesture::startZoom() > > void GestureController::ZoomGesture::handleZoom() > { >- m_client.zoom(m_scale); >+ m_client.zoom(m_scale, m_initialPoint, m_viewPoint); > } > > void GestureController::ZoomGesture::scaleChanged(ZoomGesture* zoomGesture, double scale, GtkGesture*) > { > zoomGesture->m_scale = zoomGesture->m_initialScale * scale; >+ if (zoomGesture->m_scale < 1.0) >+ zoomGesture->m_scale = 1.0; >+ > zoomGesture->m_viewPoint = zoomGesture->center(); >+ > if (zoomGesture->m_idle.isActive()) > return; > >diff --git a/Source/WebKit/UIProcess/gtk/GestureController.h b/Source/WebKit/UIProcess/gtk/GestureController.h >index 6250e9a64bde052188d531cf1a7a5092200c32b3..e5c942674a4283dc79faac934f764b500f77d96a 100644 >--- a/Source/WebKit/UIProcess/gtk/GestureController.h >+++ b/Source/WebKit/UIProcess/gtk/GestureController.h >@@ -51,7 +51,7 @@ public: > virtual void swipe(GdkEventTouch*, const WebCore::FloatPoint&) = 0; > > virtual void startZoom(const WebCore::IntPoint& center, double& initialScale, WebCore::IntPoint& initialPoint) = 0; >- virtual void zoom(double) = 0; >+ virtual void zoom(double scale, const WebCore::IntPoint& initialPoint, const WebCore::IntPoint& centre) = 0; > > virtual void longPress(GdkEventTouch*) = 0; > }; >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index d6b96556866d98560b0b2ef4e3da85e5573933ea..188eebba2d8a7be693b9f7b1c549f8a0e76f7090 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -1681,6 +1681,16 @@ void WebPage::scalePageInViewCoordinates(double scale, IntPoint centerInViewCoor > scalePage(scale, scrollPositionAtNewScale); > } > >+void WebPage::scaleAndPanPage(double scale, WebCore::IntPoint scaleCenterInPageCoordinates, WebCore::IntPoint newScaleCenterInViewCoordinates) >+{ >+ FloatPoint pos = scaleCenterInPageCoordinates; >+ FloatPoint moveBy = FloatPoint(newScaleCenterInViewCoordinates); >+ moveBy.scale(1 / scale); >+ pos.moveBy(-moveBy); >+ pos.scale(scale); >+ scalePage(scale, IntPoint(pos)); >+} >+ > double WebPage::totalScaleFactor() const > { > PluginView* pluginView = pluginViewForFrame(&m_page->mainFrame()); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index 408addd08e3c29829625274789c9eb591171451e..7a188fdf25efc30c93aa04ba9549add8e0f1660a 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -455,6 +455,7 @@ public: > > void scalePage(double scale, const WebCore::IntPoint& origin); > void scalePageInViewCoordinates(double scale, WebCore::IntPoint centerInViewCoordinates); >+ void scaleAndPanPage(double scale, WebCore::IntPoint scaleCenterInPageCoordinates, WebCore::IntPoint newScaleCenterInViewCoordinates); > double pageScaleFactor() const; > double totalScaleFactor() const; > double viewScaleFactor() const; >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index 1c44d77e6524d636623e4246f256a5716b1c0379..74252e8c5ba018a0acd2ffbbe35583cd7502916f 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -225,6 +225,7 @@ messages -> WebPage LegacyReceiver { > > ScalePage(double scale, WebCore::IntPoint origin) > ScalePageInViewCoordinates(double scale, WebCore::IntPoint centerInViewCoordinates) >+ ScaleAndPanPage(double scale, WebCore::IntPoint scaleCenterInPageCoordinates, WebCore::IntPoint newScaleCenterInViewCoordinates) > ScaleView(double scale) > > SetUseFixedLayout(bool fixed)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188746
:
347503
|
347520
|
347640
|
347699
|
347737
|
347756
|
347807
|
347921
|
347924
|
348004