diff options
author | Paul Rouget <me@paulrouget.com> | 2020-03-16 12:06:09 +0100 |
---|---|---|
committer | Paul Rouget <me@paulrouget.com> | 2020-03-16 13:43:10 +0100 |
commit | 00395125f6c994a08285271d1d9f6d926f511bba (patch) | |
tree | fe07aa47e0edf74f37b2b3d4da4f160748616f74 /support | |
parent | 58ff35f5bf26994b519d1591b24aca903b051d8c (diff) | |
download | servo-00395125f6c994a08285271d1d9f6d926f511bba.tar.gz servo-00395125f6c994a08285271d1d9f6d926f511bba.zip |
UWP port: re-enable devtools
Diffstat (limited to 'support')
-rw-r--r-- | support/hololens/ServoApp/BrowserPage.cpp | 6 | ||||
-rw-r--r-- | support/hololens/ServoApp/ServoControl/Servo.cpp | 13 | ||||
-rw-r--r-- | support/hololens/ServoApp/ServoControl/Servo.h | 1 | ||||
-rw-r--r-- | support/hololens/ServoApp/ServoControl/ServoControl.cpp | 18 | ||||
-rw-r--r-- | support/hololens/ServoApp/ServoControl/ServoControl.h | 1 | ||||
-rw-r--r-- | support/hololens/ServoApp/pch.h | 2 |
6 files changed, 34 insertions, 7 deletions
diff --git a/support/hololens/ServoApp/BrowserPage.cpp b/support/hololens/ServoApp/BrowserPage.cpp index e23a593a7ac..97784d9edd2 100644 --- a/support/hololens/ServoApp/BrowserPage.cpp +++ b/support/hololens/ServoApp/BrowserPage.cpp @@ -14,6 +14,7 @@ using namespace winrt::Windows::UI::Xaml; using namespace winrt::Windows::UI::Core; using namespace winrt::Windows::UI::ViewManagement; using namespace winrt::Windows::ApplicationModel::Core; +using namespace winrt::Windows::UI::Notifications; namespace winrt::ServoApp::implementation { BrowserPage::BrowserPage() { @@ -109,7 +110,10 @@ void BrowserPage::SetTransientMode(bool transient) { void BrowserPage::SetArgs(hstring args) { servoControl().SetArgs(args); } -void BrowserPage::Shutdown() { servoControl().Shutdown(); } +void BrowserPage::Shutdown() { + ToastNotificationManager::History().Clear(); + servoControl().Shutdown(); +} /**** USER INTERACTIONS WITH UI ****/ diff --git a/support/hololens/ServoApp/ServoControl/Servo.cpp b/support/hololens/ServoApp/ServoControl/Servo.cpp index d2d04c6fa3e..8b99970976d 100644 --- a/support/hololens/ServoApp/ServoControl/Servo.cpp +++ b/support/hololens/ServoApp/ServoControl/Servo.cpp @@ -67,6 +67,12 @@ void prompt_alert(const char *message, bool trusted) { sServo->Delegate().OnServoPromptAlert(char2hstring(message), trusted); } +void on_devtools_started(Servo::DevtoolsServerState result, + const unsigned int port) { + sServo->Delegate().OnServoDevtoolsStarted( + result == Servo::DevtoolsServerState::Started, port); +} + Servo::PromptResult prompt_ok_cancel(const char *message, bool trusted) { return sServo->Delegate().OnServoPromptOkCancel(char2hstring(message), trusted); @@ -87,17 +93,12 @@ const char *prompt_input(const char *message, const char *default, } } -void on_devtools_started(Servo::DevtoolsServerState result, - const unsigned int port) { - // FIXME -} - Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height, float dpi, ServoDelegate &aDelegate) : mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) { capi::CInitOptions o; - hstring defaultPrefs = L" --pref dom.webxr.enabled"; + hstring defaultPrefs = L" --pref dom.webxr.enabled --devtools"; o.args = *hstring2char(args + defaultPrefs); o.url = *hstring2char(url); o.width = mWindowWidth; diff --git a/support/hololens/ServoApp/ServoControl/Servo.h b/support/hololens/ServoApp/ServoControl/Servo.h index 6369a05364c..1667118b499 100644 --- a/support/hololens/ServoApp/ServoControl/Servo.h +++ b/support/hololens/ServoApp/ServoControl/Servo.h @@ -95,6 +95,7 @@ public: virtual bool OnServoAllowNavigation(hstring) = 0; virtual void OnServoAnimatingChanged(bool) = 0; virtual void OnServoIMEStateChanged(bool) = 0; + virtual void OnServoDevtoolsStarted(bool, unsigned int) = 0; virtual void Flush() = 0; virtual void MakeCurrent() = 0; virtual void OnServoMediaSessionMetadata(hstring, hstring, hstring) = 0; diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.cpp b/support/hololens/ServoApp/ServoControl/ServoControl.cpp index 0ca4070dcd6..6f21ab41dc1 100644 --- a/support/hololens/ServoApp/ServoControl/ServoControl.cpp +++ b/support/hololens/ServoApp/ServoControl/ServoControl.cpp @@ -11,6 +11,8 @@ using namespace winrt::Windows::UI::Core; using namespace winrt::Windows::Foundation; using namespace winrt::Windows::System; using namespace winrt::Windows::Devices::Input; +using namespace winrt::Windows::UI::Notifications; +using namespace winrt::Windows::Data::Xml::Dom; using namespace concurrency; using namespace winrt::servo; @@ -556,6 +558,22 @@ std::optional<hstring> ServoControl::OnServoPromptInput(winrt::hstring message, return string; } +void ServoControl::OnServoDevtoolsStarted(bool success, + const unsigned int port) { + auto toastTemplate = ToastTemplateType::ToastText01; + auto toastXml = ToastNotificationManager::GetTemplateContent(toastTemplate); + auto toastTextElements = toastXml.GetElementsByTagName(L"text"); + std::wstring message; + if (success) { + message = L"DevTools server has started on port " + std::to_wstring(port); + } else { + message = L"Error: could not start DevTools"; + } + toastTextElements.Item(0).InnerText(message); + auto toast = ToastNotification(toastXml); + ToastNotificationManager::CreateToastNotifier().Show(toast); +} + template <typename Callable> void ServoControl::RunOnUIThread(Callable cb) { Dispatcher().RunAsync(CoreDispatcherPriority::High, cb); } diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.h b/support/hololens/ServoApp/ServoControl/ServoControl.h index 3b597b91be8..16b34b77349 100644 --- a/support/hololens/ServoApp/ServoControl/ServoControl.h +++ b/support/hololens/ServoApp/ServoControl/ServoControl.h @@ -114,6 +114,7 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate { virtual servo::Servo::PromptResult OnServoPromptYesNo(winrt::hstring, bool); virtual std::optional<hstring> OnServoPromptInput(winrt::hstring, winrt::hstring, bool); + virtual void OnServoDevtoolsStarted(bool success, const unsigned int port); private: winrt::event<Windows::Foundation::EventHandler<hstring>> mOnURLChangedEvent; diff --git a/support/hololens/ServoApp/pch.h b/support/hololens/ServoApp/pch.h index 32b151c124e..59a4cd3ca8a 100644 --- a/support/hololens/ServoApp/pch.h +++ b/support/hololens/ServoApp/pch.h @@ -52,3 +52,5 @@ #include <winrt/Windows.UI.Xaml.Interop.h> #include <winrt/Windows.UI.Xaml.Markup.h> #include <winrt/Windows.UI.Xaml.Navigation.h> +#include <winrt/Windows.UI.Notifications.h> +#include <winrt/Windows.Data.Xml.Dom.h> |