mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #25967 - paulrouget:devtoolsToast, r=Manishearth
Re-enabling devtools on UWP
This commit is contained in:
commit
fdc725925d
6 changed files with 34 additions and 7 deletions
|
@ -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 ****/
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue