WebKit Bugzilla
Attachment 347807 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-20180822123112.patch (text/plain), 9.27 KB, created by
Justin Michaud
on 2018-08-22 09:31:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Justin Michaud
Created:
2018-08-22 09:31:13 PDT
Size:
9.27 KB
patch
obsolete
>Subversion Revision: 234846 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 91b71f7bfc9b73f757f8b74ae88fbfcb4b4f3d2a..b5c8719e5034241861f40dfc42ada9bc4e01b214 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,27 @@ >+2018-08-22 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 >+ >+ Changes the pinch-to-zoom gesture to magnify/scale the page, rather than zooming in. Also adds new public >+ api functions webkit_web_view_set_page_scale and webkit_web_view_get_page_scale. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/API/glib/WebKitWebView.cpp: >+ (webkit_web_view_set_page_scale): >+ (webkit_web_view_get_page_scale): >+ * UIProcess/API/gtk/PageClientImpl.cpp: >+ (WebKit::PageClientImpl::zoom): Deleted. >+ * 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/gtk/GestureController.cpp: >+ (WebKit::GestureController::ZoomGesture::handleZoom): >+ (WebKit::GestureController::ZoomGesture::scaleChanged): >+ * UIProcess/gtk/GestureController.h: >+ > 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..830befeb2645cf0ea5b3802293a843944dc7c117 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >@@ -3152,6 +3152,48 @@ gdouble webkit_web_view_get_zoom_level(WebKitWebView* webView) > return zoomTextOnly ? page.textZoomFactor() : page.pageZoomFactor(); > } > >+/** >+ * webkit_web_view_set_page_scale: >+ * @web_view: a #WebKitWebView >+ * @scale_level: the page scale >+ * @origin_x: the x coordinate for the origin >+ * @origin_y: the y coordinate for the origin >+ * >+ * Set the page scale of @web_view, such that (origin_x, origin_y) >+ * is the new scroll position of the viewport after scaling. The >+ * page scale magnifies the page without changing the layout (for >+ * example, a pinch-to-zoom touch gesture). The point (origin_x, origin_y) >+ * should be in page coordinates, scaled by the new scale factor. >+ * >+ * Since 2.24 >+ */ >+void webkit_web_view_set_page_scale(WebKitWebView* webView, gdouble scaleLevel, gint originX, gint originY) >+{ >+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); >+ >+ auto& page = getPage(webView); >+ page.scalePage(scaleLevel, IntPoint(originX, originY)); >+} >+ >+/** >+ * webkit_web_view_get_zoom_level: >+ * @web_view: a #WebKitWebView >+ * >+ * Get the zoom level of @web_view, i.e. the factor by which the >+ * view contents are magnified. >+ * >+ * Returns: the current page scale of @web_view >+ * >+ * Since 2.24 >+ */ >+gdouble webkit_web_view_get_page_scale(WebKitWebView* webView) >+{ >+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1); >+ >+ auto& page = getPage(webView); >+ return page.pageScaleFactor(); >+} >+ > /** > * webkit_web_view_can_execute_editing_command: > * @web_view: a #WebKitWebView >diff --git a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >index ea8a737a8bf3fcf7927673f271a4989a79a69357..87e0ebbf6e4e0aa1878968dd7be043f0a67a4ce5 100644 >--- a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >@@ -474,14 +474,4 @@ bool PageClientImpl::decidePolicyForInstallMissingMediaPluginsPermissionRequest( > } > #endif > >-void PageClientImpl::zoom(double zoomLevel) >-{ >- if (WEBKIT_IS_WEB_VIEW(m_viewWidget)) { >- webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(m_viewWidget), zoomLevel); >- return; >- } >- >- webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))->setPageZoomFactor(zoomLevel); >-} >- > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >index d36539f69a8f3d7d41b30668abe360e5191f1507..04ebf34dbe75cd50e42aa5e4d73e4d8f79700b2e 100644 >--- a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >+++ b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >@@ -53,8 +53,6 @@ public: > > GtkWidget* viewWidget() { return m_viewWidget; } > >- void zoom(double); >- > private: > // PageClient > std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override; >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h >index 8c219a3b008599d5641c9014d5177acd11bb60b5..1db8c541da99f483a0f7270a39a08def86b470e0 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h >@@ -406,6 +406,14 @@ webkit_web_view_set_zoom_level (WebKitWebView > WEBKIT_API gdouble > webkit_web_view_get_zoom_level (WebKitWebView *web_view); > >+WEBKIT_API void >+webkit_web_view_set_page_scale (WebKitWebView *web_view, >+ gdouble scale_level, >+ gint origin_x, >+ gint origin_y); >+WEBKIT_API gdouble >+webkit_web_view_get_page_scale (WebKitWebView *web_view); >+ > WEBKIT_API void > webkit_web_view_can_execute_editing_command (WebKitWebView *web_view, > const gchar *command, >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >index 3b4e988a2a7c93fb26b3cd0d80efe818073d1789..3d2dac9681dd1a5bcae5c50b826241bf2259bfcd 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >@@ -1116,15 +1116,18 @@ private: > > void startZoom(const IntPoint& center, double& initialScale, IntPoint& initialPoint) final > { >- auto* page = webkitWebViewBaseGetPage(m_webView); >+ auto* page = m_webView->priv->pageProxy.get(); > ASSERT(page); >- initialScale = page->pageZoomFactor(); >+ initialScale = page->pageScaleFactor(); > page->getCenterForZoomGesture(center, initialPoint); > } > >- void zoom(double scale) final >+ void zoom(double scale, const IntPoint& origin) final > { >- m_webView->priv->pageClient->zoom(scale); >+ auto* page = m_webView->priv->pageProxy.get(); >+ ASSERT(page); >+ >+ page->scalePage(scale, origin); > } > > 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..d187423e77e4af3050789d04539093325a0b8a6c 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 >@@ -198,6 +198,8 @@ webkit_web_view_get_settings > webkit_web_view_get_window_properties > webkit_web_view_set_zoom_level > webkit_web_view_get_zoom_level >+webkit_web_view_set_page_scale >+webkit_web_view_get_page_scale > webkit_web_view_can_execute_editing_command > webkit_web_view_can_execute_editing_command_finish > webkit_web_view_execute_editing_command >diff --git a/Source/WebKit/UIProcess/gtk/GestureController.cpp b/Source/WebKit/UIProcess/gtk/GestureController.cpp >index 1dc90df7bcace3ac241f533c7426ebc300e6ecdd..3d27d6bfa5f8441a95dd5d03a31d1302df5c0da3 100644 >--- a/Source/WebKit/UIProcess/gtk/GestureController.cpp >+++ b/Source/WebKit/UIProcess/gtk/GestureController.cpp >@@ -203,13 +203,20 @@ void GestureController::ZoomGesture::startZoom() > > void GestureController::ZoomGesture::handleZoom() > { >- m_client.zoom(m_scale); >+ FloatPoint scaledZoomCenter(m_initialPoint); >+ scaledZoomCenter.scale(m_scale); >+ >+ m_client.zoom(m_scale, WebCore::roundedIntPoint(FloatPoint(scaledZoomCenter - 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..bbd338a5900cefa22395163371b865695d91da7e 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& origin) = 0; > > virtual void longPress(GdkEventTouch*) = 0; > };
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