Skip to content

Commit c11aad4

Browse files
committed
Revert "WIP"
This reverts commit 5eae0e1.
1 parent 5eae0e1 commit c11aad4

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/WinWebDiffLib/WebDiffWindow.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CWebDiffWindow : public IWebDiffWindow
8585
std::wstring userDataFolder = GetUserDataFolderPath(i);
8686
ComPtr<IWebDiffCallback> callback2(callback);
8787
hr = m_webWindow[i].Create(m_hInstance, m_hWnd, urls[i], userDataFolder.c_str(),
88-
m_size, m_fitToWindow, m_zoom, m_userAgent, GetScriptOnLoad(), nullptr,
88+
m_size, m_fitToWindow, m_zoom, m_userAgent, nullptr,
8989
[this, i, callback2](WebDiffEvent::EVENT_TYPE event, IUnknown* sender, IUnknown* args)
9090
{
9191
WebDiffEvent ev{};
@@ -131,6 +131,7 @@ class CWebDiffWindow : public IWebDiffWindow
131131
}
132132
else if (event == WebDiffEvent::NavigationCompleted)
133133
{
134+
addEventListener(sender, ev.pane, nullptr);
134135
m_documentLoaded[ev.pane] = true;
135136
if ((std::count(m_documentLoaded, m_documentLoaded + m_nPanes, true) == m_nPanes) &&
136137
(std::count(m_urlChanged, m_urlChanged + m_nPanes, true) == m_nPanes))
@@ -141,6 +142,7 @@ class CWebDiffWindow : public IWebDiffWindow
141142
}
142143
else if (event == WebDiffEvent::FrameNavigationCompleted)
143144
{
145+
addEventListener(sender,ev.pane, nullptr);
144146
}
145147
else if (event == WebDiffEvent::GoBacked)
146148
{
@@ -852,6 +854,11 @@ class CWebDiffWindow : public IWebDiffWindow
852854
return hr;
853855
}
854856

857+
HRESULT addEventListener(IUnknown* sender, int pane, IWebDiffCallback* callback)
858+
{
859+
return m_webWindow[pane].ExecuteScript(sender, GetScriptOnLoad(), callback);
860+
}
861+
855862
HRESULT syncEvent(int srcPane, const std::wstring& json)
856863
{
857864
for (int pane = 0; pane < m_nPanes; ++pane)

src/WinWebDiffLib/WebWindow.hpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ class CWebWindow
100100
settings2->put_UserAgent(userAgent.c_str());
101101
}
102102

103-
m_webview->AddScriptToExecuteOnDocumentCreated(m_parent->GetScriptOnLoad(), nullptr);
104-
105103
m_webview->add_NewWindowRequested(
106104
Callback<ICoreWebView2NewWindowRequestedEventHandler>(
107105
[this](ICoreWebView2* sender, ICoreWebView2NewWindowRequestedEventArgs* args) {
@@ -270,10 +268,9 @@ class CWebWindow
270268
}
271269

272270
HRESULT Create(HINSTANCE hInstance, HWND hWndParent, const wchar_t* url, const wchar_t* userDataFolder,
273-
const SIZE& size, bool fitToWindow, double zoom, std::wstring& userAgent, const wchar_t* scriptOnLoad,
271+
const SIZE& size, bool fitToWindow, double zoom, std::wstring& userAgent,
274272
IWebDiffCallback* callback, std::function<void(WebDiffEvent::EVENT_TYPE, IUnknown*, IUnknown*)> eventHandler)
275273
{
276-
m_scriptOnLoad = scriptOnLoad;
277274
m_fitToWindow = fitToWindow;
278275
m_size = size;
279276
m_eventHandler = eventHandler;
@@ -426,11 +423,6 @@ class CWebWindow
426423
return m_currentUrl.c_str();
427424
}
428425

429-
const wchar_t* GetScriptOnLoad() const
430-
{
431-
return m_scriptOnLoad;
432-
}
433-
434426
void CloseActiveTab()
435427
{
436428
if (!GetActiveWebView())
@@ -2092,7 +2084,6 @@ class CWebWindow
20922084
std::wstring m_toolTipText = L"test";
20932085
bool m_showToolTip = false;
20942086
std::wstring m_webmessage;
2095-
const wchar_t* m_scriptOnLoad;
20962087
inline static const auto GetDpiForWindowFunc = []() {
20972088
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
20982089
return reinterpret_cast<decltype(&::GetDpiForWindow)>(

0 commit comments

Comments
 (0)