mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
UWP: allow servo's initial URL to be set before Servo starts
This commit is contained in:
parent
d93e67a0bf
commit
79ecc7e216
5 changed files with 26 additions and 13 deletions
|
@ -4,5 +4,5 @@
|
||||||
|
|
||||||
// For development purpose.
|
// For development purpose.
|
||||||
// Will override DEFAULT_URL_PROD or any locally stored preferences.
|
// Will override DEFAULT_URL_PROD or any locally stored preferences.
|
||||||
// #define OVERRIDE_DEFAULT_URL "data:text/html,<input>"
|
// #define OVERRIDE_DEFAULT_URL L"data:text/html,<input>"
|
||||||
// #define OVERRIDE_DEFAULT_URL "http://localhost:8000/test.html"
|
// #define OVERRIDE_DEFAULT_URL L"http://localhost:8000/test.html"
|
||||||
|
|
|
@ -134,8 +134,8 @@ const char *prompt_input(const char *message, const char *default,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Servo::Servo(hstring args, GLsizei width, GLsizei height,
|
Servo::Servo(std::optional<hstring> initUrl, hstring args, GLsizei width,
|
||||||
EGLNativeWindowType eglNativeWindow, float dpi,
|
GLsizei height, EGLNativeWindowType eglNativeWindow, float dpi,
|
||||||
ServoDelegate &aDelegate)
|
ServoDelegate &aDelegate)
|
||||||
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
|
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
|
||||||
ApplicationDataContainer localSettings =
|
ApplicationDataContainer localSettings =
|
||||||
|
@ -172,13 +172,22 @@ Servo::Servo(hstring args, GLsizei width, GLsizei height,
|
||||||
auto val = unbox_value<bool>(value);
|
auto val = unbox_value<bool>(value);
|
||||||
cpref.value = &val;
|
cpref.value = &val;
|
||||||
} else if (type == Windows::Foundation::PropertyType::String) {
|
} else if (type == Windows::Foundation::PropertyType::String) {
|
||||||
cpref.pref_type = capi::CPrefType::Str;
|
hstring strValue;
|
||||||
cpref.value = *hstring2char(unbox_value<hstring>(value));
|
|
||||||
#ifdef OVERRIDE_DEFAULT_URL
|
|
||||||
if (pref.Key() == L"shell.homepage") {
|
if (pref.Key() == L"shell.homepage") {
|
||||||
cpref.value = OVERRIDE_DEFAULT_URL;
|
if (initUrl.has_value()) {
|
||||||
}
|
strValue = *initUrl;
|
||||||
|
} else {
|
||||||
|
#ifdef OVERRIDE_DEFAULT_URL
|
||||||
|
strValue = OVERRIDE_DEFAULT_URL;
|
||||||
|
#else
|
||||||
|
strValue = unbox_value<hstring>(value);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strValue = unbox_value<hstring>(value);
|
||||||
|
}
|
||||||
|
cpref.pref_type = capi::CPrefType::Str;
|
||||||
|
cpref.value = *hstring2char(strValue);
|
||||||
} else if (type == Windows::Foundation::PropertyType::Int64) {
|
} else if (type == Windows::Foundation::PropertyType::Int64) {
|
||||||
cpref.pref_type = capi::CPrefType::Int;
|
cpref.pref_type = capi::CPrefType::Int;
|
||||||
auto val = unbox_value<int64_t>(value);
|
auto val = unbox_value<int64_t>(value);
|
||||||
|
@ -200,7 +209,7 @@ Servo::Servo(hstring args, GLsizei width, GLsizei height,
|
||||||
|
|
||||||
capi::CInitOptions o;
|
capi::CInitOptions o;
|
||||||
o.prefs = &prefsList;
|
o.prefs = &prefsList;
|
||||||
o.args = *hstring2char(args + L"--devtools");
|
o.args = *hstring2char(args + L" --devtools");
|
||||||
o.width = mWindowWidth;
|
o.width = mWindowWidth;
|
||||||
o.height = mWindowHeight;
|
o.height = mWindowHeight;
|
||||||
o.density = dpi;
|
o.density = dpi;
|
||||||
|
|
|
@ -26,7 +26,8 @@ class ServoDelegate;
|
||||||
|
|
||||||
class Servo {
|
class Servo {
|
||||||
public:
|
public:
|
||||||
Servo(hstring, GLsizei, GLsizei, EGLNativeWindowType, float, ServoDelegate &);
|
Servo(std::optional<hstring>, hstring, GLsizei, GLsizei, EGLNativeWindowType,
|
||||||
|
float, ServoDelegate &);
|
||||||
~Servo();
|
~Servo();
|
||||||
ServoDelegate &Delegate() { return mDelegate; }
|
ServoDelegate &Delegate() { return mDelegate; }
|
||||||
|
|
||||||
|
|
|
@ -379,6 +379,8 @@ void ServoControl::TryLoadUri(hstring input) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
mInitUrl = input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,8 +400,8 @@ void ServoControl::Loop() {
|
||||||
log(L"Entering loop");
|
log(L"Entering loop");
|
||||||
ServoDelegate *sd = static_cast<ServoDelegate *>(this);
|
ServoDelegate *sd = static_cast<ServoDelegate *>(this);
|
||||||
EGLNativeWindowType win = GetNativeWindow();
|
EGLNativeWindowType win = GetNativeWindow();
|
||||||
mServo = std::make_unique<Servo>(mArgs, mPanelWidth, mPanelHeight, win,
|
mServo = std::make_unique<Servo>(mInitUrl, mArgs, mPanelWidth, mPanelHeight,
|
||||||
mDPI, *sd);
|
win, mDPI, *sd);
|
||||||
} else {
|
} else {
|
||||||
// FIXME: this will fail since create_task didn't pick the thread
|
// FIXME: this will fail since create_task didn't pick the thread
|
||||||
// where Servo was running initially.
|
// where Servo was running initially.
|
||||||
|
|
|
@ -217,6 +217,7 @@ private:
|
||||||
float mDPI = 1;
|
float mDPI = 1;
|
||||||
hstring mCurrentUrl = L"";
|
hstring mCurrentUrl = L"";
|
||||||
bool mTransient = false;
|
bool mTransient = false;
|
||||||
|
std::optional<hstring> mInitUrl = {};
|
||||||
|
|
||||||
Windows::UI::Xaml::Controls::SwapChainPanel ServoControl::Panel();
|
Windows::UI::Xaml::Controls::SwapChainPanel ServoControl::Panel();
|
||||||
void CreateNativeWindow();
|
void CreateNativeWindow();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue