Skip to content

Commit

Permalink
holy butts, WebView2 works again!
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed May 9, 2023
1 parent 99668f9 commit 497fea8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 41 deletions.
44 changes: 17 additions & 27 deletions scratch/ScratchIslandApp/SampleApp/MyPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ namespace winrt::SampleApp::implementation
auto extnList = co_await findOperation;
for (const auto& extn : extnList)
{
extn;
auto name = extn.DisplayName();
name;
auto pfn = extn.Package().Id().FamilyName();
pfn;

DynamicDependency dynDep{};
auto hr = dynDep.Create(extn);

Expand All @@ -103,27 +97,6 @@ namespace winrt::SampleApp::implementation
_connection.WriteInput(dynDep._pfn);
_connection.WriteInput(L"\r\n");
}
// PWSTR id;
// hr = TryCreatePackageDependency(nullptr, pfn.c_str(), PACKAGE_VERSION{}, PackageDependencyProcessorArchitectures_None, PackageDependencyLifetimeKind_Process, nullptr, CreatePackageDependencyOptions_None, &id);
// LOG_IF_FAILED(hr);
// if (FAILED(hr))
// {
// _connection.WriteInput(L"Failed to create package dependency\r\n");
// continue;
// }
// PACKAGEDEPENDENCY_CONTEXT ctx;
// PWSTR packageFullName;
// hr = AddPackageDependency(id, 1, AddPackageDependencyOptions_None, &ctx, &packageFullName);
// LOG_IF_FAILED(hr);
// if (FAILED(hr))
// {
// _connection.WriteInput(L"Failed to add package dependency\r\n");
// continue;
// }

/*_connection.WriteInput(L"Successfully added package dependency to ");
_connection.WriteInput(pfn);
_connection.WriteInput(L"\r\n");*/
}
}
catch (...)
Expand Down Expand Up @@ -163,4 +136,21 @@ namespace winrt::SampleApp::implementation
_connection.WriteInput(L"Failed to activate instance \r\n");
}
}

winrt::fire_and_forget MyPage::MakeWebViewHandler(Windows::Foundation::IInspectable const&, Windows::UI::Xaml::RoutedEventArgs const&)
{
winrt::MUX::Controls::WebView2 wv{ nullptr };
wv = winrt::MUX::Controls::WebView2();
wv.HorizontalAlignment(WUX::HorizontalAlignment::Stretch);
// wv.Width(256);
wv.Height(300);
OutOfProcContent().Children().Append(wv);

co_await wv.EnsureCoreWebView2Async();

// wv.NavigateToString(L"<html>hello world</html>");
//wv.Source(winrt::Windows::Foundation::Uri(L"https://www.bing.com"));
// wv.Navigate(winrt::Windows::Foundation::Uri(L"https://www.bing.com"));
wv.CoreWebView2().Navigate(L"https://www.bing.com");
}
}
11 changes: 6 additions & 5 deletions scratch/ScratchIslandApp/SampleApp/MyPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace winrt::SampleApp::implementation
if (const auto& s{ properties.TryLookup(L"Implementation") })
{
// s is another property set, so look it up in that instead
if (const auto& asSet {s.try_as<winrt::Windows::Foundation::Collections::IPropertySet>()})
if (const auto& asSet{ s.try_as<winrt::Windows::Foundation::Collections::IPropertySet>() })
{
_implementationClassName = asSet.TryLookup(L"#text").as<winrt::hstring>();
co_return true;
Expand All @@ -54,10 +54,10 @@ namespace winrt::SampleApp::implementation
}
~DynamicDependency() noexcept
{
//if (_dependencyContext)
//{
// RemovePackageDependency(_dependencyContext);
//}
//if (_dependencyContext)
//{
// RemovePackageDependency(_dependencyContext);
//}
}
};

Expand All @@ -72,6 +72,7 @@ namespace winrt::SampleApp::implementation

void ClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
void ActivateInstanceButtonHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
winrt::fire_and_forget MakeWebViewHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);

private:
friend struct MyPageT<MyPage>; // for Xaml to bind events
Expand Down
18 changes: 11 additions & 7 deletions scratch/ScratchIslandApp/SampleApp/MyPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
Click="ActivateInstanceButtonHandler">
RoActivateInstance
</Button>
<Button Grid.Row="0"
Click="MakeWebViewHandler">
Make Webview
</Button>

</StackPanel>

Expand All @@ -51,13 +55,13 @@
VerticalAlignment="Stretch"
Background="#ff0000" />

<Grid x:Name="OutOfProcContent"
Grid.Column="1"
Padding="16"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="#0000ff" />

<StackPanel x:Name="OutOfProcContent"
Grid.Column="1"
Padding="16"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="#0000ff"
Orientation="Vertical" />


</Grid>
Expand Down
2 changes: 2 additions & 0 deletions scratch/ScratchIslandApp/SampleApp/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h>
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>

#include <winrt/Microsoft.Web.WebView2.Core.h>

#include <winrt/Windows.System.h>

// Including TraceLogging essentials for the binary
Expand Down
5 changes: 3 additions & 2 deletions src/common.nugetversions.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<!--===============================================================================================================
SPECIAL SAUCE
===================================================================================================================
===================================================================================================================
This section contains any special sauce needed to implement Global NuGet Management.-->

<!--Since Global NuGet Management requires having a single [packages.config] file that's located in a special
Expand Down Expand Up @@ -58,7 +58,8 @@
See Microsoft.UI.Xaml.Additional.targets for more info.
Make sure to update WebView2PackageRoot above to match the WebView2 dependency version.
-->
<Import Project="$(MSBuildThisFileDirectory)..\build\rules\Microsoft.UI.Xaml.Additional.targets" Condition="'$(TerminalMUX)' == 'true'" />
<!-- <Import Project="$(MSBuildThisFileDirectory)..\build\rules\Microsoft.UI.Xaml.Additional.targets" Condition="'$(TerminalMUX)' == 'true'" /> -->
<Import Project="$(MSBuildThisFileDirectory)..\packages\Microsoft.Web.WebView2.1.0.1661.34\build\native\Microsoft.Web.WebView2.targets" Condition="'$(TerminalMUX)' == 'true' and Exists('$(MSBuildThisFileDirectory)..\packages\Microsoft.Web.WebView2.1.0.1661.34\build\native\Microsoft.Web.WebView2.targets')" />

<!-- WIL (so widely used that this one does not have a TerminalWIL opt-in property; it is automatic) -->
<Import Project="$(MSBuildThisFileDirectory)..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('$(MSBuildThisFileDirectory)..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
Expand Down

1 comment on commit 497fea8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (4)

debugbreak
impelentation
PACKAGEDEPENDENCY
restrictederrorinfo

Previously acknowledged words that are now absent Hirots NULs spand xwwyzz xxyyzz :arrow_right:
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/migrie/fhl/dyndep branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/4929108515/attempts/1'
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. If it doesn't work for you, you can manually add (one word per line) / remove items to expect.txt and the excludes.txt files.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.