Handle servo:// url

This commit is contained in:
Paul Rouget 2019-08-20 07:28:00 +02:00
parent 5f89dc87bd
commit 5c1d130217
10 changed files with 91 additions and 40 deletions

View file

@ -32,12 +32,13 @@ void on_panic(const char *backtrace) {
throw hresult_error(E_FAIL, char2hstring(backtrace));
}
Servo::Servo(GLsizei width, GLsizei height, ServoDelegate &aDelegate)
Servo::Servo(hstring url, GLsizei width, GLsizei height,
ServoDelegate &aDelegate)
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
capi::CInitOptions o;
o.args = "--pref dom.webxr.enabled";
o.url = "https://servo.org";
o.url = *hstring2char(url);
o.width = mWindowWidth;
o.height = mWindowHeight;
o.density = 1.0;
@ -78,4 +79,13 @@ winrt::hstring char2hstring(const char *c_str) {
return str3;
}
std::unique_ptr<char *> hstring2char(hstring hstr) {
const wchar_t *wc = hstr.c_str();
size_t size = hstr.size() + 1;
char *str = new char[size];
size_t converted = 0;
wcstombs_s(&converted, str, size, wc, hstr.size());
return std::make_unique<char*>(str);
}
} // namespace winrt::servo