log and format for wstrings.

This commit is contained in:
Paul Rouget 2020-06-08 12:32:00 +02:00
parent 60ee588c71
commit 805b79b32c
10 changed files with 37 additions and 57 deletions

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#include "pch.h"
#include "logs.h"
#include "strutils.h"
#include "OpenGLES.h"
using namespace winrt::Windows::UI::Xaml::Controls;
@ -13,7 +13,7 @@ using namespace winrt::Windows::Foundation::Collections;
OpenGLES::OpenGLES()
: mEglConfig(nullptr), mEglDisplay(EGL_NO_DISPLAY),
mEglContext(EGL_NO_CONTEXT) {
log("OpenGLES::OpenGLES()");
log(L"OpenGLES::OpenGLES()");
Initialize();
}

View file

@ -178,7 +178,7 @@ Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
} else if (type == Windows::Foundation::PropertyType::Empty) {
pref.pref_type = capi::CPrefType::Missing;
} else {
log("skipping pref %s. Unknown type", key);
log(L"skipping pref %s. Unknown type", key);
continue;
}
cprefs.push_back(pref);

View file

@ -6,7 +6,7 @@
#include "pch.h"
#include <EGL/egl.h>
#include "logs.h"
#include "strutils.h"
#include <stdlib.h>
namespace winrt::servo {

View file

@ -1,4 +1,5 @@
#include "pch.h"
#include "strutils.h"
#include "ServoControl.h"
#include "ServoControl.g.cpp"
#include "Pref.g.cpp"
@ -277,16 +278,9 @@ hstring ServoControl::LoadURIOrSearch(hstring input) {
// Doesn't look like a URI. Let's search for the string.
auto escapedInput = Uri::EscapeComponent(input);
std::wstring searchUri =
unbox_value<hstring>(std::get<1>(Servo::GetPref(L"shell.searchpage")))
.c_str();
std::wstring keyword = L"%s";
size_t start_pos = searchUri.find(keyword);
if (start_pos == std::string::npos)
searchUri = searchUri + escapedInput;
else
searchUri.replace(start_pos, keyword.length(), escapedInput);
hstring finalUri{searchUri};
std::wstring searchUri = unbox_value<hstring>(std::get<1>(Servo::GetPref(L"shell.searchpage"))).c_str();
std::wstring formated = format(searchUri, escapedInput.c_str());
hstring finalUri{formated};
TryLoadUri(finalUri);
return finalUri;
}
@ -323,10 +317,10 @@ void ServoControl::RunOnGLThread(std::function<void()> task) {
/**** GL THREAD LOOP ****/
void ServoControl::Loop() {
log("BrowserPage::Loop(). GL thread: %i", GetCurrentThreadId());
log(L"BrowserPage::Loop(). GL thread: %i", GetCurrentThreadId());
if (mServo == nullptr) {
log("Entering loop");
log(L"Entering loop");
ServoDelegate *sd = static_cast<ServoDelegate *>(this);
EGLNativeWindowType win = GetNativeWindow();
mServo = std::make_unique<Servo>(mInitialURL, mArgs, mPanelWidth,
@ -367,7 +361,7 @@ void ServoControl::StartRenderLoop() {
#endif
}
mLooping = true;
log("BrowserPage::StartRenderLoop(). UI thread: %i", GetCurrentThreadId());
log(L"BrowserPage::StartRenderLoop(). UI thread: %i", GetCurrentThreadId());
auto task = Concurrency::create_task([=] { Loop(); });
mLoopTask = std::make_unique<Concurrency::task<void>>(task);
}