@@ -1117,34 +1117,29 @@ class CWebDiffWindow : public IWebDiffWindow
11171117 HRESULT applyHTMLLoop (
11181118 int pane,
11191119 std::shared_ptr<const std::list<ModifiedNode>> nodes,
1120- IWebDiffCallback* callback,
1121- std::list<ModifiedNode>::reverse_iterator it)
1120+ IWebDiffCallback* callback)
11221121 {
1123- if (it == nodes->rend ())
1124- {
1125- if (callback)
1126- callback->Invoke ({ S_OK, nullptr });
1127- return S_OK;
1128- }
11291122 ComPtr<IWebDiffCallback> callback2 (callback);
1130- HRESULT hr = m_webWindow[pane].SetOuterHTML (it->nodeId , it->outerHTML ,
1131- Callback<IWebDiffCallback>([this , pane, nodes, it, callback2](const WebDiffCallbackResult& result) -> HRESULT
1123+ size_t size = nodes->size ();
1124+ auto count = std::make_shared<size_t >();
1125+ for (auto it = nodes->rbegin (); it != nodes->rend (); ++it)
1126+ {
1127+ HRESULT hr = m_webWindow[pane].SetOuterHTML (it->nodeId , it->outerHTML ,
1128+ Callback<IWebDiffCallback>([this , count, size, callback2](const WebDiffCallbackResult& result)->HRESULT
11321129 {
1133- HRESULT hr = S_OK; // result.errorCode;
1134- if (SUCCEEDED (hr))
1135- {
1136- std::list<ModifiedNode>::reverse_iterator it2 (it);
1137- ++it2;
1138- if (it2 != nodes->rend ())
1139- hr = applyHTMLLoop (pane, nodes, callback2.Get (), it2);
1140- else if (callback2)
1141- return callback2->Invoke ({ hr, nullptr });
1142- }
1143- if (FAILED (hr) && callback2)
1144- return callback2->Invoke ({ hr, nullptr });
1130+ (*count)++;
1131+ if (*count == size && callback2)
1132+ callback2->Invoke ({ result.errorCode , nullptr });
11451133 return S_OK;
11461134 }).Get ());
1147- return hr;
1135+ if (FAILED (hr))
1136+ {
1137+ (*count)++;
1138+ if (*count == size && callback2)
1139+ callback2->Invoke ({ hr, nullptr });
1140+ }
1141+ }
1142+ return S_OK;
11481143 }
11491144
11501145 HRESULT applyDOMLoop (std::shared_ptr<std::vector<WDocument>> documents, IWebDiffCallback* callback, int pane = 0 )
@@ -1166,7 +1161,7 @@ class CWebDiffWindow : public IWebDiffWindow
11661161 if (FAILED (hr) && callback2)
11671162 return callback2->Invoke ({ hr, nullptr });
11681163 return hr;
1169- }).Get (), nodes-> rbegin () );
1164+ }).Get ());
11701165 return hr;
11711166 }
11721167
@@ -1237,7 +1232,7 @@ class CWebDiffWindow : public IWebDiffWindow
12371232 if (FAILED (hr) && callback2)
12381233 return callback2->Invoke ({ hr, nullptr });
12391234 return S_OK;
1240- }).Get (), nodes-> rbegin () );
1235+ }).Get ());
12411236 }
12421237 if (FAILED (hr) && callback2)
12431238 return callback2->Invoke ({ hr, nullptr });
0 commit comments