Skip to content

Commit aef2efc

Browse files
committed
WIP (43)
1 parent b412e16 commit aef2efc

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/WinWebDiff/WinWebDiff.rc

0 Bytes
Binary file not shown.

src/WinWebDiffLib/WebDiffWindow.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ class CWebDiffWindow : public IWebDiffWindow
513513

514514
double GetZoom() const
515515
{
516-
if (m_nPanes == 0)
517-
return m_zoom;
518-
return m_webWindow[0].GetZoom();
516+
return m_zoom;
519517
}
520518

521519
void SetZoom(double zoom)

src/WinWebDiffLib/WebWindow.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class CWebWindow
295295

296296
HRESULT Navigate(const std::wstring& url)
297297
{
298-
if (m_activeTab < 0)
298+
if (!GetActiveWebView())
299299
return E_FAIL;
300300
HRESULT hr = GetActiveWebView()->Navigate(url.c_str());
301301
if (hr == E_INVALIDARG)
@@ -309,14 +309,14 @@ class CWebWindow
309309

310310
HRESULT Reload()
311311
{
312-
if (m_activeTab < 0)
312+
if (!GetActiveWebView())
313313
return E_FAIL;
314314
return GetActiveWebView()->Reload();
315315
}
316316

317317
const wchar_t *GetCurrentUrl()
318318
{
319-
if (m_activeTab < 0)
319+
if (!GetActiveWebView())
320320
return L"";
321321
wil::unique_cotaskmem_string uri;
322322
GetActiveWebView()->get_Source(&uri);
@@ -326,7 +326,7 @@ class CWebWindow
326326

327327
void CloseActiveTab()
328328
{
329-
if (m_activeTab < 0)
329+
if (!GetActiveWebView())
330330
return;
331331
CloseTab(m_activeTab);
332332
}
@@ -401,7 +401,7 @@ class CWebWindow
401401

402402
std::wstring GetUserAgent() const
403403
{
404-
if (m_activeTab < 0)
404+
if (!GetActiveWebView())
405405
return L"";
406406
wil::com_ptr_t<ICoreWebView2Settings> settings;
407407
wil::unique_cotaskmem_string userAgent;
@@ -414,7 +414,7 @@ class CWebWindow
414414

415415
void SetUserAgent(const std::wstring& userAgent)
416416
{
417-
if (m_activeTab < 0)
417+
if (!GetActiveWebView())
418418
return;
419419
wil::com_ptr_t<ICoreWebView2Settings> settings;
420420
GetActiveWebView()->get_Settings(&settings);
@@ -463,7 +463,7 @@ class CWebWindow
463463

464464
HRESULT SaveScreenshot(const std::wstring& filename, bool fullSize, IWebDiffCallback* callback)
465465
{
466-
if (m_activeTab < 0)
466+
if (!GetActiveWebView())
467467
return E_FAIL;
468468
ComPtr<IWebDiffCallback> callback2(callback);
469469
HRESULT hr = GetActiveWebView()->CallDevToolsProtocolMethod(L"Page.getLayoutMetrics", L"{}",
@@ -514,7 +514,7 @@ class CWebWindow
514514

515515
HRESULT SaveHTML(const std::wstring& filename, IWebDiffCallback* callback)
516516
{
517-
if (m_activeTab < 0)
517+
if (!GetActiveWebView())
518518
return E_FAIL;
519519
const wchar_t *script = L"document.documentElement.outerHTML";
520520
ComPtr<IWebDiffCallback> callback2(callback);
@@ -538,7 +538,7 @@ class CWebWindow
538538

539539
HRESULT SaveFrameHTML(const std::wstring& frameId, const std::wstring& dirname, IWebDiffCallback* callback)
540540
{
541-
if (m_activeTab < 0)
541+
if (!GetActiveWebView())
542542
return E_FAIL;
543543
ComPtr<IWebDiffCallback> callback2(callback);
544544
std::wstring params = L"{ \"frameId\": \"" + frameId + L"\" }";
@@ -596,7 +596,7 @@ class CWebWindow
596596

597597
HRESULT SaveResourceContent(const std::wstring& frameId, const WValue& resource, const std::wstring& dirname, IWebDiffCallback* callback)
598598
{
599-
if (m_activeTab < 0)
599+
if (!GetActiveWebView())
600600
return E_FAIL;
601601
std::wstring url(resource[L"url"].GetString());
602602
std::wstring mimeType(resource[L"mimeType"].GetString());
@@ -726,7 +726,7 @@ class CWebWindow
726726

727727
HRESULT SaveResourceTree(const std::wstring& dirname, IWebDiffCallback* callback)
728728
{
729-
if (m_activeTab < 0)
729+
if (!GetActiveWebView())
730730
return E_FAIL;
731731
ComPtr<IWebDiffCallback> callback2(callback);
732732
HRESULT hr = GetActiveWebView()->CallDevToolsProtocolMethod(L"Page.getResourceTree", L"{}",
@@ -763,7 +763,7 @@ class CWebWindow
763763

764764
HRESULT CallDevToolsProtocolMethod(const wchar_t* methodName, const wchar_t* params, IWebDiffCallback *callback)
765765
{
766-
if (m_activeTab < 0)
766+
if (!GetActiveWebView())
767767
return E_FAIL;
768768
ComPtr<IWebDiffCallback> callback2(callback);
769769
HRESULT hr = GetActiveWebView()->CallDevToolsProtocolMethod(methodName, params,
@@ -778,7 +778,7 @@ class CWebWindow
778778

779779
HRESULT ExecuteScript(const wchar_t* script, IWebDiffCallback *callback)
780780
{
781-
if (m_activeTab < 0)
781+
if (!GetActiveWebView())
782782
return E_FAIL;
783783
ComPtr<IWebDiffCallback> callback2(callback);
784784
HRESULT hr = GetActiveWebView()->ExecuteScript(script,
@@ -793,7 +793,7 @@ class CWebWindow
793793

794794
HRESULT ClearBrowsingData(IWebDiffWindow::BrowsingDataKinds dataKinds)
795795
{
796-
if (m_activeTab < 0)
796+
if (!GetActiveWebView())
797797
return E_FAIL;
798798
auto webView2Experimental8 = GetActiveTab()->m_webview.try_query<ICoreWebView2Experimental8>();
799799
if (!webView2Experimental8)

0 commit comments

Comments
 (0)