Skip to content

Commit

Permalink
Webpage Compare: synchronize events (#2111)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka authored Nov 19, 2023
1 parent f44c06a commit 3255dc3
Show file tree
Hide file tree
Showing 49 changed files with 838 additions and 15 deletions.
6 changes: 3 additions & 3 deletions DownloadDeps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ https://github.com/WinMerge/winimerge/releases/download/v1.0.41/winimerge-1.0.41
https://github.com/WinMerge/winimerge/releases/download/v1.0.41/winimerge-1.0.41.0-x64.zip!Build\x64\Release ^
https://github.com/WinMerge/winimerge/releases/download/v1.0.41/winimerge-1.0.41.0-ARM.zip!Build\ARM\Release ^
https://github.com/WinMerge/winimerge/releases/download/v1.0.41/winimerge-1.0.41.0-ARM64.zip!Build\ARM64\Release ^
https://github.com/WinMerge/winwebdiff/releases/download/v1.0.7/winwebdiff-1.0.7.0-x86.zip!Build\x86\Release ^
https://github.com/WinMerge/winwebdiff/releases/download/v1.0.7/winwebdiff-1.0.7.0-x64.zip!Build\x64\Release ^
https://github.com/WinMerge/winwebdiff/releases/download/v1.0.7/winwebdiff-1.0.7.0-ARM64.zip!Build\ARM64\Release ^
https://github.com/WinMerge/winwebdiff/releases/download/v1.0.8/winwebdiff-1.0.8.0-x86.zip!Build\x86\Release ^
https://github.com/WinMerge/winwebdiff/releases/download/v1.0.8/winwebdiff-1.0.8.0-x64.zip!Build\x64\Release ^
https://github.com/WinMerge/winwebdiff/releases/download/v1.0.8/winwebdiff-1.0.8.0-ARM64.zip!Build\ARM64\Release ^
https://github.com/htacg/tidy-html5/releases/download/5.4.0/tidy-5.4.0-w32-mt-XP.zip!Build\tidy-html5 ^
https://github.com/htacg/tidy-html5/archive/refs/tags/5.4.0.zip!Build\tidy-html5 ^
https://github.com/jqlang/jq/releases/download/jq-1.7/jq-win32.exe!Build\jq ^
Expand Down
2 changes: 1 addition & 1 deletion Externals/versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This file lists versions of the external components we are using.
- WinIMerge: 1.0.41.0
- freeimage: 3.18.0
- LibXDiff: 611e42a on Nov 2, 2018 (https://github.com/git/git/tree/master/xdiff)
- WinWebDiff: 1.0.7.0
- WinWebDiff: 1.0.8.0
- WebView2: 1.0.1518.46
- wil: 1.0.191107.2
- rapidjson: 1.1.1
Expand Down
25 changes: 24 additions & 1 deletion Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ BEGIN
MENUITEM "1280x800", ID_WEB_SIZE_1280x800
MENUITEM "1440x900", ID_WEB_SIZE_1440x900
END
POPUP "&Event Synchronization"
BEGIN
MENUITEM "&Enabled", ID_WEB_SYNC_ENABLED
MENUITEM SEPARATOR
MENUITEM "&Scroll", ID_WEB_SYNC_SCROLL
MENUITEM "&Click", ID_WEB_SYNC_CLICK
MENUITEM "&Input", ID_WEB_SYNC_INPUT
MENUITEM "&GoBack/Forward", ID_WEB_SYNC_GOBACKFORWARD
END
POPUP "Clear &Browsing Data"
BEGIN
MENUITEM "&Disk Cache", ID_WEB_CLEAR_DISK_CACHE
Expand Down Expand Up @@ -1154,6 +1163,19 @@ BEGIN
END
END

IDR_POPUP_WEBPAGE_SYNC_EVENTS MENU
BEGIN
POPUP "_POPUP_"
BEGIN
MENUITEM "&Enabled", ID_WEB_SYNC_ENABLED
MENUITEM SEPARATOR
MENUITEM "&Scroll", ID_WEB_SYNC_SCROLL
MENUITEM "&Click", ID_WEB_SYNC_CLICK
MENUITEM "&Input", ID_WEB_SYNC_INPUT
MENUITEM "&GoBack/Forward", ID_WEB_SYNC_GOBACKFORWARD
END
END


/////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -2332,7 +2354,8 @@ BEGIN
EDITTEXT IDC_ZOOM,178,2,32,14,ES_AUTOHSCROLL,WS_EX_RIGHT
LTEXT "UA:",-1,214,4,16,10
EDITTEXT IDC_USERAGENT,230,2,128,14,ES_AUTOHSCROLL
CONTROL "View &Differences",IDC_SHOWDIFFERENCES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,362,2,96,14
CONTROL "&Event Synchronization",IDC_SYNC_EVENTS,"Button",BS_SPLITBUTTON | WS_TABSTOP,362,2,106,14
CONTROL "View &Differences",IDC_SHOWDIFFERENCES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,472,2,96,14
END


Expand Down
2 changes: 1 addition & 1 deletion Src/MergeFrameCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void CMergeFrameCommon::RemoveBarBorder()
*/
void CMergeFrameCommon::SetLastCompareResult(int nResult)
{
HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
HICON hReplace = (nResult == 0) ? m_hIdentical : ((nResult < 0) ? nullptr : m_hDifferent);

if (m_hCurrent != hReplace)
{
Expand Down
2 changes: 2 additions & 0 deletions Src/OptionsDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ inline const String OPT_CMP_WEB_VIEW_WIDTH {_T("Settings/WebPageViewWidth"s)};
inline const String OPT_CMP_WEB_VIEW_HEIGHT {_T("Settings/WebPageViewHeight"s)};
inline const String OPT_CMP_WEB_ZOOM {_T("Settings/WebZoom"s)};
inline const String OPT_CMP_WEB_USER_AGENT {_T("Settings/WebUserAgent"s)};
inline const String OPT_CMP_WEB_SYNC_EVENTS {_T("Settings/WebSyncEvents"s)};
inline const String OPT_CMP_WEB_SYNC_EVENT_FLAGS {_T("Settings/WebSyncEventFlags"s)};
inline const String OPT_CMP_WEB_URL_PATTERN_TO_INCLUDE {_T("Settings/WebPageURLPatternToInclude"s)};
inline const String OPT_CMP_WEB_URL_PATTERN_TO_EXCLUDE {_T("Settings/WebPageURLPatternToExclude"s)};

Expand Down
2 changes: 2 additions & 0 deletions Src/OptionsInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ void Init(COptionsMgr *pOptions)
pOptions->InitOption(OPT_CMP_WEB_USER_AGENT, _T(""));
pOptions->InitOption(OPT_CMP_WEB_URL_PATTERN_TO_INCLUDE, _T(""));
pOptions->InitOption(OPT_CMP_WEB_URL_PATTERN_TO_EXCLUDE, _T(""));
pOptions->InitOption(OPT_CMP_WEB_SYNC_EVENTS, false);
pOptions->InitOption(OPT_CMP_WEB_SYNC_EVENT_FLAGS, 0xff);

pOptions->InitOption(OPT_PROJECTS_PATH, _T(""));
pOptions->InitOption(OPT_USE_SYSTEM_TEMP_PATH, true);
Expand Down
82 changes: 81 additions & 1 deletion Src/WebPageDiffFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ BEGIN_MESSAGE_MAP(CWebPageDiffFrame, CMergeFrameCommon)
ON_COMMAND(ID_WEB_COMPARE_HTMLS, OnWebCompareHTMLs)
ON_COMMAND(ID_WEB_COMPARE_TEXTS, OnWebCompareTexts)
ON_COMMAND(ID_WEB_COMPARE_RESOURCETREES, OnWebCompareResourceTrees)
ON_COMMAND_RANGE(ID_WEB_SYNC_ENABLED, ID_WEB_SYNC_GOBACKFORWARD, OnWebSyncEvent)
ON_UPDATE_COMMAND_UI_RANGE(ID_WEB_SYNC_ENABLED, ID_WEB_SYNC_GOBACKFORWARD, OnUpdateWebSyncEvent)
ON_COMMAND_RANGE(ID_WEB_CLEAR_DISK_CACHE, ID_WEB_CLEAR_ALL_PROFILE, OnWebClear)
// [Tools] menu
ON_COMMAND(ID_TOOLS_GENERATEREPORT, OnToolsGenerateReport)
Expand All @@ -129,6 +131,7 @@ BEGIN_MESSAGE_MAP(CWebPageDiffFrame, CMergeFrameCommon)
ON_BN_CLICKED(IDC_FITTOWINDOW, OnBnClickedFitToWindow)
ON_BN_CLICKED(IDC_SHOWDIFFERENCES, OnBnClickedShowDifferences)
ON_BN_CLICKED(IDC_COMPARE, OnBnClickedCompare)
ON_BN_CLICKED(IDC_SYNC_EVENTS, OnBnClickedSyncEvents)
ON_EN_CHANGE(IDC_WIDTH, OnEnChangeWidth)
ON_EN_CHANGE(IDC_HEIGHT, OnEnChangeHeight)
ON_EN_CHANGE(IDC_ZOOM, OnEnChangeZoom)
Expand All @@ -138,6 +141,7 @@ BEGIN_MESSAGE_MAP(CWebPageDiffFrame, CMergeFrameCommon)
ON_EN_KILLFOCUS(IDC_ZOOM, OnKillFocusBarControls)
ON_EN_KILLFOCUS(IDC_USERAGENT, OnKillFocusBarControls)
ON_NOTIFY(BCN_DROPDOWN, IDC_COMPARE, OnDropDownCompare)
ON_NOTIFY(BCN_DROPDOWN, IDC_SYNC_EVENTS, OnDropDownSyncEvents)
// Status bar
ON_UPDATE_COMMAND_UI(ID_STATUS_DIFFNUM, OnUpdateStatusNum)
//}}AFX_MSG_MAP
Expand Down Expand Up @@ -338,6 +342,9 @@ void CWebPageDiffFrame::OnWebDiffEvent(const WebDiffEvent& event)
case WebDiffEvent::ZoomFactorChanged:
UpdateWebPageDiffBar();
break;
case WebDiffEvent::CompareStateChanged:
UpdateLastCompareResult();
break;
}
}

Expand Down Expand Up @@ -614,6 +621,8 @@ void CWebPageDiffFrame::LoadOptions()
m_pWebDiffWindow->SetShowDifferences(GetOptionsMgr()->GetBool(OPT_CMP_WEB_SHOWDIFFERENCES));
m_pWebDiffWindow->SetShowWordDifferences(GetOptionsMgr()->GetBool(OPT_WORDDIFF_HIGHLIGHT));
m_pWebDiffWindow->SetUserAgent(GetOptionsMgr()->GetString(OPT_CMP_WEB_USER_AGENT).c_str());
m_pWebDiffWindow->SetSyncEvents(GetOptionsMgr()->GetBool(OPT_CMP_WEB_SYNC_EVENTS));
m_pWebDiffWindow->SetSyncEventFlags(GetOptionsMgr()->GetInt(OPT_CMP_WEB_SYNC_EVENT_FLAGS));
COLORSETTINGS colors;
IWebDiffWindow::ColorSettings colorSettings;
Options::DiffColors::Load(GetOptionsMgr(), colors);
Expand Down Expand Up @@ -871,7 +880,7 @@ int CWebPageDiffFrame::UpdateLastCompareResult()
int result = -1;
if (m_bCompareCompleted)
{
result = m_pWebDiffWindow->GetDiffCount() > 0 ? 1 : 0;
result = (m_pWebDiffWindow->GetCompareState() == IWebDiffWindow::COMPARED) ? (m_pWebDiffWindow->GetDiffCount() > 0 ? 1 : 0) : -1;
SetLastCompareResult(result);
}
return result;
Expand Down Expand Up @@ -1076,6 +1085,24 @@ void CWebPageDiffFrame::OnDropDownCompare(NMHDR *pNMHDR, LRESULT *pResult)
point.x, point.y, AfxGetMainWnd());
}

void CWebPageDiffFrame::OnBnClickedSyncEvents()
{
CRect rc;
m_wndWebPageDiffBar.GetDlgItem(IDC_SYNC_EVENTS)->GetWindowRect(&rc);
CPoint point { rc.left, rc.bottom };
BCMenu menuPopup;
menuPopup.LoadMenu(MAKEINTRESOURCE(IDR_POPUP_WEBPAGE_SYNC_EVENTS));
theApp.TranslateMenu(menuPopup.m_hMenu);
BCMenu* pPopup = (BCMenu*)menuPopup.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, AfxGetMainWnd());
}

void CWebPageDiffFrame::OnDropDownSyncEvents(NMHDR *pNMHDR, LRESULT *pResult)
{
OnBnClickedSyncEvents();
}

void CWebPageDiffFrame::OnEnChangeWidth()
{
if (m_bInUpdateWebPageDiffBar)
Expand Down Expand Up @@ -1576,6 +1603,59 @@ void CWebPageDiffFrame::OnWebCompareResourceTrees()
}));
}

void CWebPageDiffFrame::OnWebSyncEvent(UINT nID)
{
switch (nID)
{
case ID_WEB_SYNC_ENABLED:
m_pWebDiffWindow->SetSyncEvents(!m_pWebDiffWindow->GetSyncEvents());
GetOptionsMgr()->SaveOption(OPT_CMP_WEB_SYNC_EVENTS, m_pWebDiffWindow->GetSyncEvents());
break;
case ID_WEB_SYNC_SCROLL:
m_pWebDiffWindow->SetSyncEventFlag(IWebDiffWindow::EVENT_SCROLL,
!m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_SCROLL));
GetOptionsMgr()->SaveOption(OPT_CMP_WEB_SYNC_EVENT_FLAGS, m_pWebDiffWindow->GetSyncEventFlags());
break;
case ID_WEB_SYNC_CLICK:
m_pWebDiffWindow->SetSyncEventFlag(IWebDiffWindow::EVENT_CLICK,
!m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_CLICK));
GetOptionsMgr()->SaveOption(OPT_CMP_WEB_SYNC_EVENT_FLAGS, m_pWebDiffWindow->GetSyncEventFlags());
break;
case ID_WEB_SYNC_INPUT:
m_pWebDiffWindow->SetSyncEventFlag(IWebDiffWindow::EVENT_INPUT,
!m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_INPUT));
GetOptionsMgr()->SaveOption(OPT_CMP_WEB_SYNC_EVENT_FLAGS, m_pWebDiffWindow->GetSyncEventFlags());
break;
case ID_WEB_SYNC_GOBACKFORWARD:
m_pWebDiffWindow->SetSyncEventFlag(IWebDiffWindow::EVENT_GOBACKFORWARD,
!m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_GOBACKFORWARD));
GetOptionsMgr()->SaveOption(OPT_CMP_WEB_SYNC_EVENT_FLAGS, m_pWebDiffWindow->GetSyncEventFlags());
break;
}
}

void CWebPageDiffFrame::OnUpdateWebSyncEvent(CCmdUI* pCmdUI)
{
switch (pCmdUI->m_nID)
{
case ID_WEB_SYNC_ENABLED:
pCmdUI->SetCheck(m_pWebDiffWindow->GetSyncEvents());
break;
case ID_WEB_SYNC_SCROLL:
pCmdUI->SetCheck(m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_SCROLL));
break;
case ID_WEB_SYNC_CLICK:
pCmdUI->SetCheck(m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_CLICK));
break;
case ID_WEB_SYNC_INPUT:
pCmdUI->SetCheck(m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_INPUT));
break;
case ID_WEB_SYNC_GOBACKFORWARD:
pCmdUI->SetCheck(m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_GOBACKFORWARD));
break;
}
}

void CWebPageDiffFrame::OnWebClear(UINT nID)
{
IWebDiffWindow::BrowsingDataType dataKinds;
Expand Down
4 changes: 4 additions & 0 deletions Src/WebPageDiffFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class CWebPageDiffFrame : public CMergeFrameCommon,public IMergeDoc
afx_msg void OnWebCompareHTMLs();
afx_msg void OnWebCompareTexts();
afx_msg void OnWebCompareResourceTrees();
afx_msg void OnWebSyncEvent(UINT nID);
afx_msg void OnUpdateWebSyncEvent(CCmdUI* pCmdUI);
afx_msg void OnWebClear(UINT nID);
afx_msg void OnToolsGenerateReport();
afx_msg void OnRefresh();
Expand All @@ -198,12 +200,14 @@ class CWebPageDiffFrame : public CMergeFrameCommon,public IMergeDoc
afx_msg void OnBnClickedFitToWindow();
afx_msg void OnBnClickedShowDifferences();
afx_msg void OnBnClickedCompare();
afx_msg void OnBnClickedSyncEvents();
afx_msg void OnEnChangeWidth();
afx_msg void OnEnChangeHeight();
afx_msg void OnEnChangeZoom();
afx_msg void OnEnChangeUserAgent();
afx_msg void OnKillFocusBarControls();
afx_msg void OnDropDownCompare(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDropDownSyncEvents(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
23 changes: 22 additions & 1 deletion Src/WinWebDiffLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

struct WebDiffEvent
{
enum EVENT_TYPE { ZoomFactorChanged, NewWindowRequested, WindowCloseRequested, NavigationStarting, HistoryChanged, SourceChanged, DocumentTitleChanged, NavigationCompleted, WebMessageReceived, TabChanged, HSCROLL, VSCROLL };
enum EVENT_TYPE { ZoomFactorChanged, NewWindowRequested, WindowCloseRequested, NavigationStarting, FrameNavigationStarting, HistoryChanged, SourceChanged, DocumentTitleChanged, NavigationCompleted, FrameNavigationCompleted, WebMessageReceived, FrameWebMessageReceived, TabChanged, HSCROLL, VSCROLL, CompareStateChanged };
EVENT_TYPE type;
int pane;
};
Expand Down Expand Up @@ -55,6 +55,20 @@ struct IWebDiffWindow
SETTINGS = ( 1 << 13 ),
ALL_PROFILE = ( 1 << 14 )
};
enum EventType
{
EVENT_NONE = 0,
EVENT_SCROLL = ( 1 << 0 ),
EVENT_CLICK = ( 1 << 1 ),
EVENT_INPUT = ( 1 << 2 ),
EVENT_GOBACKFORWARD = ( 1 << 3 ),
};
enum CompareState
{
NOT_COMPARED,
COMPARING,
COMPARED,
};
struct DiffOptions
{
enum DiffAlgorithm {
Expand Down Expand Up @@ -170,6 +184,13 @@ struct IWebDiffWindow
virtual bool CanRedo() = 0;
virtual const DiffOptions& GetDiffOptions() const = 0;
virtual void SetDiffOptions(const DiffOptions& diffOptions) = 0;
virtual bool GetSyncEvents() const = 0;
virtual void SetSyncEvents(bool syncEvents) = 0;
virtual unsigned GetSyncEventFlags() const = 0;
virtual void SetSyncEventFlags(unsigned flags) = 0;
virtual bool GetSyncEventFlag(EventType event) const = 0;
virtual void SetSyncEventFlag(EventType event, bool flag) = 0;
virtual CompareState GetCompareState() const = 0;
};

extern "C"
Expand Down
15 changes: 11 additions & 4 deletions Src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define IDR_POPUP_IMG_CTXT 121
#define IDR_POPUP_PROJECT_DIFF_OPTIONS 122
#define IDR_POPUP_WEBPAGE_COMPARE 123
#define IDR_POPUP_WEBPAGE_SYNC_EVENTS 124
#define IDD_ABOUTBOX 200
#define IDD_OPEN 202
#define IDD_SAVECLOSING 203
Expand Down Expand Up @@ -624,6 +625,7 @@
#define IDC_USERAGENT 1628
#define IDC_COMPARE 1630
#define IDC_SHOWDIFFERENCES 1631
#define IDC_SYNC_EVENTS 1632
#define IDC_EDIT_WHOLE_WORD 8603
#define IDC_EDIT_MATCH_CASE 8604
#define IDC_EDIT_FINDTEXT 8605
Expand Down Expand Up @@ -1058,10 +1060,15 @@
#define ID_WEB_COMPARE_HTMLS 33762
#define ID_WEB_COMPARE_TEXTS 33763
#define ID_WEB_COMPARE_RESOURCETREES 33764
#define ID_WEB_CLEAR_DISK_CACHE 33765
#define ID_WEB_CLEAR_COOKIES 33766
#define ID_WEB_CLEAR_BROWSING_HISTORY 33767
#define ID_WEB_CLEAR_ALL_PROFILE 33768
#define ID_WEB_SYNC_ENABLED 33765
#define ID_WEB_SYNC_SCROLL 33766
#define ID_WEB_SYNC_CLICK 33767
#define ID_WEB_SYNC_INPUT 33768
#define ID_WEB_SYNC_GOBACKFORWARD 33769
#define ID_WEB_CLEAR_DISK_CACHE 33780
#define ID_WEB_CLEAR_COOKIES 33781
#define ID_WEB_CLEAR_BROWSING_HISTORY 33782
#define ID_WEB_CLEAR_ALL_PROFILE 33783
#define ID_FILE_NEW_TABLE 34164
#define ID_FILE_NEW_HEX 34165
#define ID_FILE_NEW_IMAGE 34166
Expand Down
18 changes: 18 additions & 0 deletions Translations/WinMerge/Arabic.po
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ msgstr ""
msgid "Fit to Window"
msgstr ""

msgid "&Event Synchronization"
msgstr ""

msgid "&Enabled"
msgstr ""

msgid "&Scroll"
msgstr ""

msgid "&Click"
msgstr ""

msgid "&Input"
msgstr ""

msgid "&GoBack/Forward"
msgstr ""

msgid "Clear &Browsing Data"
msgstr ""

Expand Down
18 changes: 18 additions & 0 deletions Translations/WinMerge/Basque.po
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ msgstr ""
msgid "Fit to Window"
msgstr ""

msgid "&Event Synchronization"
msgstr ""

msgid "&Enabled"
msgstr ""

msgid "&Scroll"
msgstr ""

msgid "&Click"
msgstr ""

msgid "&Input"
msgstr ""

msgid "&GoBack/Forward"
msgstr ""

msgid "Clear &Browsing Data"
msgstr ""

Expand Down
Loading

0 comments on commit 3255dc3

Please sign in to comment.