ReplayCreateStatus ReplayRenderer::PostCreateInit(IReplayDriver *device) { m_pDevice = device; m_pDevice->ReadLogInitialisation(); FetchPipelineState(); vector<FetchFrameRecord> fr = m_pDevice->GetFrameRecord(); m_FrameRecord.reserve(fr.size()); for(size_t i=0; i < fr.size(); i++) { m_FrameRecord.push_back(FrameRecord()); m_FrameRecord.back().frameInfo = fr[i].frameInfo; m_FrameRecord.back().m_DrawCallList = fr[i].drawcallList; SetupDrawcallPointers(fr[i].frameInfo, m_FrameRecord.back().m_DrawCallList, NULL, NULL); } return eReplayCreate_Success; }
//---------------------------------------------------------------------------- // OnBrowserBeforeNavigate2 STDMETHODIMP_(void) CAnchoRuntime::OnBrowserBeforeNavigate2(LPDISPATCH pDisp, VARIANT *pURL, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, BOOL *Cancel) { static bool bFirstRun = true; // Add the frame to the frames map so we can retrieve the IWebBrowser2 object using the URL. ATLASSERT(pURL->vt == VT_BSTR && pURL->bstrVal != NULL); CComQIPtr<IWebBrowser2> pWebBrowser(pDisp); ATLASSERT(pWebBrowser != NULL); // Workaround to ensure that first request goes through PAPP if (bFirstRun) { bFirstRun = false; *Cancel = TRUE; pWebBrowser->Stop(); pWebBrowser->Navigate2(pURL, Flags, TargetFrameName, PostData, Headers); return; } // Check if this is a new tab we are creating programmatically. // If so redirect it to the correct URL. std::wstring url(pURL->bstrVal, SysStringLen(pURL->bstrVal)); boost::wregex expression(L"(.*)://\\$\\$([0-9]+)\\$\\$(.*)"); boost::wsmatch what; //TODO - find a better way if (boost::regex_match(url, what, expression)) { int requestId = boost::lexical_cast<int>(what[2].str()); url = boost::str(boost::wformat(L"%1%://%2%") % what[1] % what[3]); _variant_t vtUrl(url.c_str()); *Cancel = TRUE; pWebBrowser->Stop(); pWebBrowser->Navigate2(&vtUrl.GetVARIANT(), Flags, TargetFrameName, PostData, Headers); mTabManager->createTabNotification(m_TabID, requestId); return; } VARIANT_BOOL isTop; if (SUCCEEDED(pWebBrowser->get_TopLevelContainer(&isTop))) { if (isTop) { // Loading the main frame so reset the frame list. m_Frames.clear(); m_NextFrameId = 0; } } CComBSTR bstrUrl; removeUrlFragment(pURL->bstrVal, &bstrUrl); m_Frames[(BSTR) bstrUrl] = FrameRecord(pWebBrowser, isTop != VARIANT_FALSE, m_NextFrameId++); pWebBrowser->PutProperty(CComBSTR(L"_anchoNavigateURL"), CComVariant(*pURL)); SHANDLE_PTR hwndBrowser = NULL; pWebBrowser->get_HWND(&hwndBrowser); if (isTop) { //Fill information about current document CComPtr<IDispatch> tmp; pWebBrowser->get_Document(&tmp); CComQIPtr<IHTMLDocument2> doc = tmp; if (doc) { CComQIPtr<IOleWindow> docWin = doc; HWND docWinHWND = NULL; if (docWin) { docWin->GetWindow(&docWinHWND); } if (docWinHWND) { gWindowDocumentMap.put(WindowDocumentRecord(docWinHWND, m_TabID, m_pWebBrowser, pWebBrowser, doc)); } } HWND tabWindow = getTabWindow(); if (tabWindow) { gWindowDocumentMap.put(WindowDocumentRecord(tabWindow, m_TabID, m_pWebBrowser, pWebBrowser, doc)); } } }