Skip to content

Commit e61b612

Browse files
authored
Merge pull request #1129 from MicrosoftEdge/api-pinch-zoom-draft
Add IsPinchZoomEnabled spec (draft)
2 parents 2f527d4 + 62eaa32 commit e61b612

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

specs/IsPinchZoomEnabled.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Background
2+
3+
There are two types of zoom in Chromium: Browser Zoom and Pinch-Zoom:
4+
- Browser zoom, referred to as “Page Zoom” or “Zoom” more generally, is what we get by using Ctrl + +(plus) or – (minus) or Ctrl + Mousewheel. This changes the size of a CSS pixel relative to a device independent pixel and so it will cause page layout to change. End developers can programmatically change browser Zoom properties including [IsZoomControlEnabled](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.774.44#get_iszoomcontrolenabled) and [ZoomFactor](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.774.44#get_zoomfactor). Setting ZoomFactor property causes the layout to change and enables scroll bar which lets users interact with the zoomed in content using mouse.
5+
- Pinch-zoom, referred to as “Page Scale” zoom, is performed as a post-rendering step, it changes the page scale factor property and scales the surface the web page is rendered onto when user perfoms a pinch zooming action. It does not change the layout but rather changes the viewport and clips the web content, the content outside of the viewport isn't visible onscreen and users can't reach this content using mouse.
6+
7+
Currently, the first type of zoom control is supported in WebView2 and modifying it has no effect on page scale zoom.
8+
9+
In response to customer requests to be able to change the current functionality of page scale zoom in WebView2, the WebView2 team has introduced this Pinch Zoom API which allows end developers to disable or enable page scale zoom control via a setting.
10+
11+
In this document we describe the new setting. We'd appreciate your feedback.
12+
13+
14+
# Description
15+
The default value for `IsPinchZoomEnabled` is `true`.
16+
When this setting is set to `false`, it disables the ability of the end users to use pinching motions on touch input enabled devices to scale the web content in the WebView2 and users cannot pinch zoom.
17+
18+
19+
# Examples
20+
```cpp
21+
wil::com_ptr<ICoreWebView2> webView;
22+
void SettingsComponent::TogglePinchZooomEnabled()
23+
{
24+
// Get webView's current settings
25+
wil::com_ptr<ICoreWebView2Settings> coreWebView2Settings;
26+
CHECK_FAILURE(webView->get_Settings(&coreWebView2Settings));
27+
wil::com_ptr<ICoreWebView2Settings4> coreWebView2Settings4;
28+
coreWebView2Settings4 = coreWebView2Settings.try_query<ICoreWebView2Settings4>();
29+
30+
BOOL enabled;
31+
CHECK_FAILURE(coreWebView2Settings4->get_IsPinchZoomEnabled(&enabled));
32+
CHECK_FAILURE(coreWebView2Settings4->put_IsPinchZoomEnabled(enabled ? FALSE : TRUE));
33+
}
34+
```
35+
36+
```c#
37+
private WebView2 _webView;
38+
void TogglePinchZoomEnabled()
39+
{
40+
var coreWebView2Settings = _webView.CoreWebView2.Settings;
41+
coreWebView2Settings.IsPinchZoomEnabled = !coreWebView2Settings.IsPinchZoomEnabled;
42+
}
43+
```
44+
45+
# Remarks
46+
When `IsPinchZoomEnabled` is set to `false`, pinch zooming is disabled in WebView. This however doesn't modify the underlying page scale factor of page scale zoom.
47+
48+
# API Notes
49+
50+
See [API Details](#api-details) section below for API reference.
51+
52+
# API Details
53+
54+
## Win32 C++
55+
```cpp
56+
[uuid(B625A89E-368F-43F5-BCBA-39AA6234CCF8), object, pointer_default(unique)]
57+
interface ICoreWebView2Settings4 : ICoreWebView2Settings3 {
58+
/// The IsPinchZoomEnabled property enables or disables the ability of
59+
/// the end user to use a pinching motion on touch input enabled devices
60+
/// to scale the web content in the WebView2. It defaults to TRUE.
61+
/// When set to FALSE, the end user cannot pinch zoom.
62+
/// This API only affects the Page Scale zoom and has no effect on the
63+
/// existing browser zoom properties (IsZoomControlEnabled and ZoomFactor)
64+
/// or other end user mechanisms for zooming.
65+
///
66+
/// \snippet SettingsComponent.cpp DisablePinchZoom
67+
[propget] HRESULT IsPinchZoomEnabled([out, retval] BOOL* enabled);
68+
/// Set the IsPinchZoomEnabled property
69+
[propput] HRESULT IsPinchZoomEnabled([in] BOOL enabled);
70+
}
71+
```
72+
73+
## .NET and WinRT
74+
75+
```c#
76+
namespace Microsoft.Web.WebView2.Core
77+
{
78+
public partial class CoreWebView2Settings
79+
{
80+
///
81+
public bool IsPinchZoomEnabled { get; set; };
82+
83+
}
84+
}
85+
86+
```

0 commit comments

Comments
 (0)