@@ -15,7 +15,7 @@ To allow the app to control the DPI scale of WebView, we are adding a `Rasteriza
1515The RasterizationScale property controls the DPI scaling for all UI in WebView.
1616
1717In order to maintain compatibility with apps developed before this API existed,
18- WebView2 continues to detect monitor scale changes be default and will update the RasterizationScale property.
18+ WebView2 continues to detect monitor scale changes by default and will update the RasterizationScale property.
1919When the RasterizationScale property is updated, the ` RasterizationScaleChanged ` event is raised.
2020The app can tell WebView2 to stop updating the RasterizationScale property by changing
2121` ShouldDetectMonitorDpiScaleChanges ` from the default value of true, to false.
@@ -29,6 +29,8 @@ void ViewComponent::SetRasterizationScale(float additionalScale)
2929{
3030 CHECK_FAILURE(m_controller->put_ShouldDetectMonitorScaleChanges(FALSE));
3131 m_webviewAdditionalRasterizationScale = additionalScale;
32+ // RasterizationScale is typically the monitor DPI scale and text scaling, but
33+ // the app could add an additional scale for its own scenarios.
3234 double rasterizationScale =
3335 additionalScale * m_appWindow->GetDpiScale() * m_appWindow->GetTextScale();
3436 CHECK_FAILURE(m_controller->put_RasterizationScale(rasterizationScale));
@@ -52,6 +54,9 @@ public void SetRasterizationScale(double additionalScale)
5254{
5355 CoreWebView2Controller.ShouldDetectMonitorScaleChanges = false;
5456 m_webviewAdditionalRasterizationScale = additionalScale;
57+
58+ // RasterizationScale is typically the monitor DPI scale and text scaling, but
59+ // the app could add an additional scale for its own scenarios.
5560 double rasterizationScale = additionalScale * GetDpiScale() * GetTextScale();
5661 CoreWebView2Controller.RasterizationScale = rasterizationScale;
5762}
@@ -90,10 +95,12 @@ interface ICoreWebView2Controller2 : ICoreWebView2Controller {
9095 /// ShouldDetectMonitorScaleChanges property determines whether the WebView
9196 /// attempts to track monitor DPI scale changes. When true, the WebView will
9297 /// track monitor DPI scale changes, update the RasterizationScale property,
93- /// and raises RasterizationScaleChanged event. When false, the WebView will
94- /// not track monitor DPI scale changes, and the app must update the
95- /// RasterizationScale property itself. RasterizationScaleChanged event will
96- /// never raise when ShouldDetectMonitorScaleChanges is false.
98+ /// and raises RasterizationScaleChanged event. Attempting to set RasterizationScale
99+ /// while ShouldDetectMonitorScaleChanges is true will result in RasterizationScaleChanged
100+ /// being raised and the value restored to match the monitor DPI scale.
101+ /// When false, the WebView will not track monitor DPI scale changes, and the app
102+ /// must update the RasterizationScale property itself. RasterizationScaleChanged
103+ /// event will never raise when ShouldDetectMonitorScaleChanges is false.
97104 [propget ] HRESULT ShouldDetectMonitorScaleChanges ([out , retval ] BOOL* value);
98105 /// Set the ShouldDetectMonitorScaleChanges property.
99106 [propput ] HRESULT ShouldDetectMonitorScaleChanges ([in ] BOOL value );
0 commit comments