Skip to content

Commit

Permalink
rename WebView2Wnd => WebViewWnd
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed May 30, 2024
1 parent c2bd7dd commit 0d709af
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/SimpleBrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ HWND SimpleBrowserWindow::Create(const SimpleBrowserCreateArgs& args) {
}
{
Rect rc = ClientRect(hwnd);
webView = new Webview2Wnd();
webView = new WebviewWnd();
const char* dataDir = args.dataDir;
if (!dataDir) {
dataDir = AppGenDataFilenameTemp("webViewData");
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleBrowserWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct SimpleBrowserCreateArgs {
};

struct SimpleBrowserWindow : Wnd {
Webview2Wnd* webView = nullptr;
WebviewWnd* webView = nullptr;
HWND Create(const SimpleBrowserCreateArgs&);
LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) override;
~SimpleBrowserWindow() override;
Expand Down
24 changes: 12 additions & 12 deletions src/wingui/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ class webview2_com_handler : public ICoreWebView2CreateCoreWebView2EnvironmentCo
webview2_com_handler_cb_t m_cb;
};

Webview2Wnd::Webview2Wnd() {
WebviewWnd::WebviewWnd() {
kind = kindWebView;
}

void Webview2Wnd::UpdateWebviewSize() {
void WebviewWnd::UpdateWebviewSize() {
if (controller == nullptr) {
return;
}
RECT bounds = ClientRECT(hwnd);
controller->put_Bounds(bounds);
}

void Webview2Wnd::Eval(const char* js) {
void WebviewWnd::Eval(const char* js) {
TempWStr ws = ToWStrTemp(js);
webview->ExecuteScript(ws, nullptr);
}

void Webview2Wnd::SetHtml(const char* html) {
void WebviewWnd::SetHtml(const char* html) {
#if 0
std::string s = "data:text/html,";
s += url_encode(html);
Expand All @@ -139,12 +139,12 @@ void Webview2Wnd::SetHtml(const char* html) {
#endif
}

void Webview2Wnd::Init(const char* js) {
void WebviewWnd::Init(const char* js) {
TempWStr ws = ToWStrTemp(js);
webview->AddScriptToExecuteOnDocumentCreated(ws, nullptr);
}

void Webview2Wnd::Navigate(const char* url) {
void WebviewWnd::Navigate(const char* url) {
TempWStr ws = ToWStrTemp(url);
webview->Navigate(ws);
}
Expand All @@ -161,7 +161,7 @@ void Webview2Wnd::Navigate(const char* url) {
put_IsBuiltInErrorPageEnabled(BOOL enabled)
*/

bool Webview2Wnd::Embed(WebViewMsgCb cb) {
bool WebviewWnd::Embed(WebViewMsgCb cb) {
// TODO: not sure if flag needs to be atomic i.e. is CreateCoreWebView2EnvironmentWithOptions()
// called on a different thread?
volatile LONG flag = 0;
Expand Down Expand Up @@ -200,7 +200,7 @@ bool Webview2Wnd::Embed(WebViewMsgCb cb) {
return true;
}

void Webview2Wnd::OnBrowserMessage(const char* msg) {
void WebviewWnd::OnBrowserMessage(const char* msg) {
/*
auto seq = json_parse(msg, "id", 0);
auto name = json_parse(msg, "method", 0);
Expand All @@ -214,7 +214,7 @@ void Webview2Wnd::OnBrowserMessage(const char* msg) {
log(msg);
}

HWND Webview2Wnd::Create(const CreateWebViewArgs& args) {
HWND WebviewWnd::Create(const CreateWebViewArgs& args) {
ReportIf(!dataDir);
CreateCustomArgs cargs;
cargs.parent = args.parent;
Expand All @@ -224,19 +224,19 @@ HWND Webview2Wnd::Create(const CreateWebViewArgs& args) {
return nullptr;
}

auto cb = std::bind(&Webview2Wnd::OnBrowserMessage, this, std::placeholders::_1);
auto cb = std::bind(&WebviewWnd::OnBrowserMessage, this, std::placeholders::_1);
Embed(cb);
UpdateWebviewSize();
return hwnd;
}

LRESULT Webview2Wnd::WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
LRESULT WebviewWnd::WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
if (msg == WM_SIZE) {
UpdateWebviewSize();
}
return WndProcDefault(hwnd, msg, wparam, lparam);
}

Webview2Wnd::~Webview2Wnd() {
WebviewWnd::~WebviewWnd() {
str::Free(dataDir);
}
6 changes: 3 additions & 3 deletions src/wingui/WebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ struct CreateWebViewArgs {
Rect pos;
};

struct Webview2Wnd : Wnd {
Webview2Wnd();
~Webview2Wnd() override;
struct WebviewWnd : Wnd {
WebviewWnd();
~WebviewWnd() override;

HWND Create(const CreateWebViewArgs&);

Expand Down

0 comments on commit 0d709af

Please sign in to comment.