Skip to content

Commit 6cc8b6b

Browse files
committed
Move projects to use WebView2 SDK 1.0.774.41-prerelease
1 parent 99116b0 commit 6cc8b6b

File tree

6 files changed

+39
-33
lines changed

6 files changed

+39
-33
lines changed

SampleApps/WebView2APISample/CheckFailure.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ void CheckFailure(HRESULT hr, const std::wstring& message)
2424
}
2525
}
2626

27-
void ExperimentalFeatureNotAvailable()
27+
void FeatureNotAvailable()
2828
{
2929
MessageBox(nullptr,
30-
L"This experimental feature is not available in the browser version currently being used.",
30+
L"This feature is not available in the browser version currently being used.",
3131
L"Feature Not Available", MB_OK);
3232
}

SampleApps/WebView2APISample/CheckFailure.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ void CheckFailure(HRESULT hr, const std::wstring& message = L"Error");
2626
#define CHECK_FAILURE CHECK_FAILURE_FILE_LINE(__FILE__, __LINE__)
2727
#define CHECK_FAILURE_BOOL(value) CHECK_FAILURE((value) ? S_OK : E_UNEXPECTED)
2828

29-
// Show a message box indicating that an experimental interface isn't available in this browser version.
29+
// Show a message box indicating that an interface isn't available in this browser version.
3030
// Only call this in direct response to a specific user action.
31-
void ExperimentalFeatureNotAvailable();
31+
void FeatureNotAvailable();
3232

3333
// Wraps the above in a conditional.
34-
#define CHECK_FEATURE_RETURN(feature, ret) { if (!feature) { ExperimentalFeatureNotAvailable(); return (ret); } }
34+
#define CHECK_FEATURE_RETURN(feature) { if (!feature) { FeatureNotAvailable(); return true; } }

SampleApps/WebView2APISample/ViewComponent.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ ViewComponent::ViewComponent(
5353
&m_zoomFactorChangedToken));
5454
//! [ZoomFactorChanged]
5555

56-
m_controllerExperimental = m_controller.try_query<ICoreWebView2ExperimentalController>();
57-
if (m_controllerExperimental)
56+
m_controller3 = m_controller.try_query<ICoreWebView2Controller3>();
57+
if (m_controller3)
5858
{
5959
//! [RasterizationScaleChanged]
60-
CHECK_FAILURE(m_controllerExperimental->add_RasterizationScaleChanged(
61-
Callback<ICoreWebView2ExperimentalRasterizationScaleChangedEventHandler>(
62-
[this](ICoreWebView2ExperimentalController* sender, IUnknown* args) -> HRESULT {
60+
CHECK_FAILURE(m_controller3->add_RasterizationScaleChanged(
61+
Callback<ICoreWebView2RasterizationScaleChangedEventHandler>(
62+
[this](ICoreWebView2Controller* sender, IUnknown* args) -> HRESULT {
6363
double rasterizationScale;
64-
CHECK_FAILURE(m_controllerExperimental->get_RasterizationScale(&rasterizationScale));
64+
CHECK_FAILURE(m_controller3->get_RasterizationScale(&rasterizationScale));
6565

6666
std::wstring message = L"WebView2APISample (RasterizationScale: " +
6767
std::to_wstring(int(rasterizationScale * 100)) + L"%)";
@@ -224,29 +224,31 @@ bool ViewComponent::HandleWindowMessage(
224224
SetTransform(TransformType::kRotate60DegDiagonally);
225225
return true;
226226
case IDM_RASTERIZATION_SCALE_DEFAULT:
227-
CHECK_FEATURE_RETURN(m_controllerExperimental, true);
228-
CHECK_FAILURE(m_controllerExperimental->put_ShouldDetectMonitorScaleChanges(TRUE));
227+
CHECK_FEATURE_RETURN(m_controller3);
228+
CHECK_FAILURE(m_controller3->put_ShouldDetectMonitorScaleChanges(TRUE));
229229
return true;
230230
case IDM_RASTERIZATION_SCALE_50:
231-
CHECK_FEATURE_RETURN(m_controllerExperimental, true);
231+
CHECK_FEATURE_RETURN(m_controller3);
232232
SetRasterizationScale(0.5f);
233233
return true;
234234
case IDM_RASTERIZATION_SCALE_100:
235-
CHECK_FEATURE_RETURN(m_controllerExperimental, true);
235+
CHECK_FEATURE_RETURN(m_controller3,);
236236
SetRasterizationScale(1.0f);
237237
return true;
238238
case IDM_RASTERIZATION_SCALE_125:
239-
CHECK_FEATURE_RETURN(m_controllerExperimental, true);
239+
CHECK_FEATURE_RETURN(m_controller3);
240240
SetRasterizationScale(1.25f);
241241
return true;
242242
case IDM_RASTERIZATION_SCALE_150:
243-
CHECK_FEATURE_RETURN(m_controllerExperimental, true);
243+
CHECK_FEATURE_RETURN(m_controller3);
244244
SetRasterizationScale(1.5f);
245245
return true;
246246
case IDM_BOUNDS_MODE_RAW_PIXELS:
247+
CHECK_FEATURE_RETURN(m_controller3);
247248
SetBoundsMode(COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS);
248249
return true;
249250
case IDM_BOUNDS_MODE_VIEW_PIXELS:
251+
CHECK_FEATURE_RETURN(m_controller3);
250252
SetBoundsMode(COREWEBVIEW2_BOUNDS_MODE_USE_RASTERIZATION_SCALE);
251253
return true;
252254
case IDM_SCALE_50:
@@ -316,10 +318,10 @@ bool ViewComponent::HandleWindowMessage(
316318

317319
void ViewComponent::UpdateDpiAndTextScale()
318320
{
319-
if (m_controllerExperimental)
321+
if (m_controller3)
320322
{
321323
BOOL isWebViewDetectingScaleChanges;
322-
CHECK_FAILURE(m_controllerExperimental->get_ShouldDetectMonitorScaleChanges(
324+
CHECK_FAILURE(m_controller3->get_ShouldDetectMonitorScaleChanges(
323325
&isWebViewDetectingScaleChanges));
324326
if (!isWebViewDetectingScaleChanges)
325327
{
@@ -579,28 +581,26 @@ void ViewComponent::SetTransform(TransformType transformType)
579581
//! [RasterizationScale]
580582
void ViewComponent::SetRasterizationScale(float additionalScale)
581583
{
582-
if (m_controllerExperimental)
584+
if (m_controller3)
583585
{
584-
CHECK_FAILURE(m_controllerExperimental->put_ShouldDetectMonitorScaleChanges(FALSE));
586+
CHECK_FAILURE(m_controller3->put_ShouldDetectMonitorScaleChanges(FALSE));
585587
m_webviewAdditionalRasterizationScale = additionalScale;
586588
double rasterizationScale =
587-
#ifdef USE_WEBVIEW2_WIN10
588589
additionalScale * m_appWindow->GetDpiScale() * m_appWindow->GetTextScale();
589-
#else
590-
additionalScale;
591-
#endif
592-
CHECK_FAILURE(m_controllerExperimental->put_RasterizationScale(rasterizationScale));
590+
CHECK_FAILURE(m_controller3->put_RasterizationScale(rasterizationScale));
593591
}
594592
}
595593
//! [RasterizationScale]
596594

597595
//! [BoundsMode]
598596
void ViewComponent::SetBoundsMode(COREWEBVIEW2_BOUNDS_MODE boundsMode)
599597
{
600-
CHECK_FEATURE_RETURN(m_controllerExperimental, (void)0);
601-
m_boundsMode = boundsMode;
602-
CHECK_FAILURE(m_controllerExperimental->put_BoundsMode(boundsMode));
603-
ResizeWebView();
598+
if (m_controller3)
599+
{
600+
m_boundsMode = boundsMode;
601+
CHECK_FAILURE(m_controller3->put_BoundsMode(boundsMode));
602+
ResizeWebView();
603+
}
604604
}
605605
//! [BoundsMode]
606606

@@ -868,9 +868,9 @@ void ViewComponent::DestroyWinCompVisualTree()
868868
ViewComponent::~ViewComponent()
869869
{
870870
m_controller->remove_ZoomFactorChanged(m_zoomFactorChangedToken);
871-
if (m_controllerExperimental)
871+
if (m_controller3)
872872
{
873-
m_controllerExperimental->remove_RasterizationScaleChanged(m_rasterizationScaleChangedToken);
873+
m_controller3->remove_RasterizationScaleChanged(m_rasterizationScaleChangedToken);
874874
}
875875
if (m_dropTarget)
876876
{

SampleApps/WebView2APISample/ViewComponent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class ViewComponent : public ComponentBase
7777

7878
AppWindow* m_appWindow = nullptr;
7979
wil::com_ptr<ICoreWebView2Controller> m_controller;
80+
wil::com_ptr<ICoreWebView2Controller3> m_controller3;
8081
wil::com_ptr<ICoreWebView2> m_webView;
81-
wil::com_ptr<ICoreWebView2ExperimentalController> m_controllerExperimental;
8282

8383
bool m_isDcompTargetMode;
8484
bool m_isVisible = true;

SampleApps/WebView2WpfBrowser/MainWindow.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ found in the LICENSE file.
3535
<CommandBinding Command="{x:Static local:MainWindow.AddOrUpdateCookieCommand}" Executed="AddOrUpdateCookieCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
3636
<CommandBinding Command="{x:Static local:MainWindow.DeleteCookiesCommand}" Executed="DeleteCookiesCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
3737
<CommandBinding Command="{x:Static local:MainWindow.DeleteAllCookiesCommand}" Executed="DeleteAllCookiesCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
38+
<CommandBinding Command="{x:Static local:MainWindow.BackgroundColorCommand}" Executed="BackgroundColorCmdExecuted" CanExecute="WebViewRequiringCmdsCanExecute"/>
3839
<CommandBinding Command="{x:Static local:MainWindow.SuspendCommand}" Executed="SuspendCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
3940
<CommandBinding Command="{x:Static local:MainWindow.ResumeCommand}" Executed="ResumeCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
4041
</Window.CommandBindings>
@@ -49,6 +50,10 @@ found in the LICENSE file.
4950
<MenuItem Header="_Increase Zoom" Command="NavigationCommands.IncreaseZoom"/>
5051
<MenuItem Header="_Decrease Zoom" Command="NavigationCommands.DecreaseZoom"/>
5152
<MenuItem Header="_BackgroundColor">
53+
<MenuItem Header="White" Command="{x:Static local:MainWindow.BackgroundColorCommand}" CommandParameter="White"/>
54+
<MenuItem Header="Red" Command="{x:Static local:MainWindow.BackgroundColorCommand}" CommandParameter="Red"/>
55+
<MenuItem Header="Blue" Command="{x:Static local:MainWindow.BackgroundColorCommand}" CommandParameter="Blue"/>
56+
<MenuItem Header="Transparent" Command="{x:Static local:MainWindow.BackgroundColorCommand}" CommandParameter="Transparent"/>
5257
</MenuItem>
5358
</MenuItem>
5459
<MenuItem Header="S_ettings">

SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public partial class MainWindow : Window
3636
public static RoutedCommand GetCookiesCommand = new RoutedCommand();
3737
public static RoutedCommand SuspendCommand = new RoutedCommand();
3838
public static RoutedCommand ResumeCommand = new RoutedCommand();
39+
public static RoutedCommand BackgroundColorCommand = new RoutedCommand();
3940
public static RoutedCommand AddOrUpdateCookieCommand = new RoutedCommand();
4041
public static RoutedCommand DeleteCookiesCommand = new RoutedCommand();
4142
public static RoutedCommand DeleteAllCookiesCommand = new RoutedCommand();

0 commit comments

Comments
 (0)