Skip to content

Commit 265a204

Browse files
Resolved API Review Feedback
2 parents 4146206 + b9fa01a commit 265a204

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

specs/IsNonClientRegionSupportEnabled.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ ScenarioNonClientRegionSupport::ScenarioNonClientRegionSupport(AppWindow* appWin
5353
wil::com_ptr<ICoreWebView2Settings> m_settings;
5454
CHECK_FAILURE(m_webView->get_Settings(&m_settings));
5555
wil::com_ptr<ICoreWebView2Settings12> coreWebView2Settings12;
56-
coreWebView2Settings12 = m_settings.try_query<ICoreWebView2Settings12();
56+
coreWebView2Settings12 = m_settings.try_query<ICoreWebView2Settings12>();
5757
CHECK_FEATURE_RETURN(coreWebView2Settings12);
5858

5959
bool trusted = _wcsicmp(domain.get(), allowedHostName) == 0;
60+
// This change will take affect after this navitation event completes
6061
CHECK_FAILURE(coreWebView2Settings12->put_IsNonClientRegionSupportEnabled(trusted));
6162

6263
return S_OK;
@@ -81,30 +82,24 @@ private void SetNonClientRegionSupport(CoreWebView2 sender, CoreWebView2Navigati
8182
var urlCompareExample = "www.microsoft.com";
8283
var uri = new Uri(args.Uri);
8384
84-
if (String.Equals(uri.Host, urlCompareExample, StringComparison.OrdinalIgnoreCase) &&
85-
!coreWebView2Settings.IsNonClientRegionSupportEnabled)
86-
{
87-
coreWebView2Settings.IsNonClientRegionSupportEnabled = true;
88-
}
89-
else if (!String.Equals(uri.Host, urlCompareExample, StringComparison.OrdinalIgnoreCase) &&
90-
coreWebView2Settings.IsNonClientRegionSupportEnabled)
91-
{
92-
coreWebView2Settings.IsNonClientRegionSupportEnabled = false;
93-
}
85+
bool trusted = String.Equals(uri.Host, urlCompareExample, StringComparison.OrdinalIgnoreCase);
86+
coreWebView2Settings.IsNonClientRegionSupportEnabled = trusted
9487
}
9588
```
9689

9790
## Declaring Non-client App Regions
98-
Non-client regions are HTML elements that are marked with the css style `app-region`.
99-
* Draggable regions can be declared through the values `drag` or `no-drag`.
91+
The value of the app-region CSS property can be used to indicate which HTML elements are treated as non-client regions.
92+
* Draggable regions can be controlled through the values `drag` or `no-drag`.
10093
* `app-region: drag` will support [draggable region functionality](#description) for the html element.
101-
* `app-region: no-drag` will change cursor to I-bar, with text highlighting enabled.
102-
Elements with this style will not support draggable region functionality.
94+
* `app-region: no-drag` will unmark the html element as a drag region, reverting it to all it's default behaviors.
95+
The app-region CSS property inherits. The initial value is no-drag
10396
```html
10497
<!DOCTYPE html>
10598
<body>
106-
<div style="app-region:drag">Drag Region</div>
107-
<div style="app-region:no-drag">No-drag Region</div>
99+
<div style="app-region:drag">
100+
Drag Region
101+
<div style="app-region:no-drag">No-drag Region</div>
102+
</div>
108103
</body>
109104
<html>
110105
```
@@ -126,23 +121,25 @@ See [API Details](#api-details) section below for API reference.
126121
interface ICoreWebView2Settings12 : ICoreWebView2Settings11 {
127122
/// The `IsNonClientRegionSupportEnabled` property enables web pages to use the
128123
/// `app-region` CSS style. Changing the `IsNonClientRegionSupportEnabled` property
129-
/// takes effect after the next navigation of the top level document. Defaults to `FALSE`.
124+
/// take effect at the completion of the NavigationStarting event for the next
125+
/// top-level navigation. Defaults to `FALSE`.
130126
///
131127
/// When this property is `TRUE`, then all the following non-client region support
132128
/// will be enabled:
133129
/// 1. Draggable Regions will be enabled and treated as a window's title bar.
134-
/// Draggable Regions are non-client regions on a webpage that are exposed through the css
135-
/// attribute `app-region` and can take the values `drag` or `no-drag`. When set to
130+
/// Draggable Regions are regions on a webpage that are exposed through the css
131+
/// attribute `app-region` with the value `drag`. When set to
136132
/// `drag`, these regions will be treated like the window's title bar, supporting
137133
/// dragging of the entire WebView and its host app window, the title bar context menu
138134
/// upon right click, and the maximizing to fill the window and restoring the window size
139135
/// upon double click of the html element.
140136
///
141-
/// When set to `FALSE`, then all non-client region support will be disabled. Web
142-
/// pages will not be able to use the `app-region` CSS style.
143-
[propget] HRESULT IsNonClientRegionSupportEnabled([out, retval] BOOL* enabled);
137+
/// When set to `FALSE`, values of the `app-region` CSS style will be ignored. The only
138+
/// exception is `app-region: drag` when the feature flag (msWebView2EnableDraggableRegions)
139+
/// is enabled.
140+
[propget] HRESULT IsNonClientRegionSupportEnabled([out, retval] BOOL* value);
144141
/// Set the IsNonClientRegionSupportEnabled property
145-
[propput] HRESULT IsNonClientRegionSupportEnabled([in] BOOL enabled);
142+
[propput] HRESULT IsNonClientRegionSupportEnabled([in] BOOL value);
146143
}
147144
```
148145

0 commit comments

Comments
 (0)