@@ -53,10 +53,11 @@ ScenarioNonClientRegionSupport::ScenarioNonClientRegionSupport(AppWindow* appWin
53
53
wil::com_ptr<ICoreWebView2Settings > m_settings;
54
54
CHECK_FAILURE(m_webView->get_Settings(&m_settings));
55
55
wil::com_ptr<ICoreWebView2Settings12 > coreWebView2Settings12;
56
- coreWebView2Settings12 = m_settings.try_query<ICoreWebView2Settings12();
56
+ coreWebView2Settings12 = m_settings.try_query<ICoreWebView2Settings12 > ();
57
57
CHECK_FEATURE_RETURN(coreWebView2Settings12);
58
58
59
59
bool trusted = _ wcsicmp(domain.get(), allowedHostName) == 0;
60
+ // This change will take affect after this navitation event completes
60
61
CHECK_FAILURE(coreWebView2Settings12->put_IsNonClientRegionSupportEnabled(trusted));
61
62
62
63
return S_OK;
@@ -81,30 +82,24 @@ private void SetNonClientRegionSupport(CoreWebView2 sender, CoreWebView2Navigati
81
82
var urlCompareExample = "www.microsoft.com";
82
83
var uri = new Uri(args.Uri);
83
84
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
94
87
}
95
88
```
96
89
97
90
## 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 ` .
100
93
* ` 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
103
96
``` html
104
97
<!DOCTYPE html>
105
98
<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 >
108
103
</body >
109
104
<html >
110
105
```
@@ -126,23 +121,25 @@ See [API Details](#api-details) section below for API reference.
126
121
interface ICoreWebView2Settings12 : ICoreWebView2Settings11 {
127
122
/// The ` IsNonClientRegionSupportEnabled ` property enables web pages to use the
128
123
/// ` 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 ` .
130
126
///
131
127
/// When this property is ` TRUE ` , then all the following non-client region support
132
128
/// will be enabled:
133
129
/// 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
136
132
/// ` drag ` , these regions will be treated like the window's title bar, supporting
137
133
/// dragging of the entire WebView and its host app window, the title bar context menu
138
134
/// upon right click, and the maximizing to fill the window and restoring the window size
139
135
/// upon double click of the html element.
140
136
///
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);
144
141
/// Set the IsNonClientRegionSupportEnabled property
145
- [ propput] HRESULT IsNonClientRegionSupportEnabled([ in] BOOL enabled );
142
+ [ propput] HRESULT IsNonClientRegionSupportEnabled([ in] BOOL value );
146
143
}
147
144
```
148
145
0 commit comments