Hi, I am looking for a help from someone with deep knowledge of Ff text rendering.
I work on a product that injects DLLs into running processes. The product is a Windows automated testing tool and intercepts system calls and windows messages to record and playback user interaction. It also intercepts text rendering through function patching of system calls. We do this by issuing a refresh, Invalidate, repaint message, depending on the application technology, control is then transferred to our code through said patching. In releases prior to Ff 17 this worked fine, after Ff 17 it appears the screen is only refreshed if the page is dirty. Is there a way to force a refresh on a page and possibly some sample code to show how the new architecture will allow this without the page being dirty? At the time it needs to be refreshed I have a Handle to the window, which through the following code can produce the nsIDomWindow; HRESULT MozillaUtils::findDOMWindow( HWND hWnd, nsCOMPtr<nsIDOMWindow>& cpDOMWindow ) { nsresult nsrs = NS_OK; HRESULT rs = S_OK; nsCOMPtr<nsISimpleEnumerator> nsEnum = nsnull; // Get the Mozilla Enumerator Interface. // rs = getWindowEnumerator( (nsCOMPtr<nsISimpleEnumerator>&) nsEnum ); if( FAILED( rs ) ) { mozDIAG( _T( "MozillaUtils::findDOMWindow: Warning -- FAILED to get enumerator\n" ) ); return rs; } nsCOMPtr<nsISupports> cpWinSupports = nsnull; nsCOMPtr<nsIDOMWindow> cpDomWindowIter = nsnull; // Loop through all the windows to find the correct window. for(;;) { bool bMore; nsEnum->HasMoreElements(&bMore); if( bMore ) { nsEnum->GetNext( getter_AddRefs( cpWinSupports ) ); if( nsnull == cpWinSupports ) { mozDIAG( _T( "MozillaUtils::findDOMWindow: Warning -- FAILED to get nsISupports\n" ) ); return E_FAIL; } } else { return S_FALSE; } cpDomWindowIter = do_QueryInterface(cpWinSupports, &nsrs); if( nsnull == cpDomWindowIter ) { mozDIAG( _T( "MozillaUtils::findDOMWindow: Warning -- FAILED to get a DOMWindow\n" ) ); return E_FAIL; } if( hWnd == GetHWNDFromDOMWindow( cpDomWindowIter ) ) { cpDOMWindow = cpDomWindowIter; break; } } return S_OK; } I have tried several of the following method without success, several because the functionality is no longer available that was in previous release; if(SUCCEEDED( MozillaUtils::findDOMWindow( hWnd, cpDOMWindow ) ) && GetWindowRect(hWnd, &rect) ) { nsCOMPtr<nsPIDOMWindow> cpPIDomWindow( do_QueryInterface(cpDOMWindow) ); nsIDocShell * docShell = cpPIDomWindow->GetDocShell(); cpPIDomWindow->SizeToContent(); nsIPresShell * presShell = nsnull; presShell = docShell->GetPresShell(); nsPresContext* presContext = presShell->GetPresContext(); nsViewManager *viewManager = presShell ? presShell->GetViewManager() : nsnull; viewManager->InvalidateAllViews(); viewManager->FlushPendingInvalidates(); viewManager->ProcessPendingUpdates(); // see .\MozillaDist*\include\nsIViewManager.h // Ff24 disabled to allow link pass presShell->UnsuppressPainting(); presShell->DoReflow(presShell->GetRootFrame(), true); presShell->ResizeReflow(width, height); nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(docShell)); base_win->Repaint(true); } Here is example of code that worked in Ff 10; void MozillaTextHookObserver::onCaptureBox() { nsCOMPtr<nsIDOMElement> cpDOMElement = nsnull; nsCOMPtr<nsIDOMWindow> cpDOMWindow = nsnull; nsCOMPtr<nsIDOMWindow> cpContentWindow = nsnull; HWND hWnd = MozillaConnectorCallbackStub::instance().GetTPMozillaConnectorCallback()->GetCapturedWindowHandle(); RECT rect; GetWindowRect(hWnd, &rect); const UINT flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE; if(SUCCEEDED( MozillaUtils::findDOMWindow( hWnd, cpDOMWindow ) ) && GetWindowRect(hWnd, &rect) ) { ThVisibleWindowsPlacements tvwp; tvwp.Snapshot(); ::SetWindowPos(hWnd, NULL, 0, 0, rect.right - rect.left + 1, rect.bottom - rect.top + 1, flags); ::SetWindowPos(hWnd, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, flags); nsCOMPtr<nsPIDOMWindow> cpPIDomWindow( do_QueryInterface(cpDOMWindow) ); nsCOMPtr<nsIBaseWindow> cpBaseWindow = do_QueryInterface( cpPIDomWindow->GetDocShell() ); if ( nsnull != cpBaseWindow ) { cpDOMWindow->SizeToContent(); //invalidate window cpBaseWindow->Repaint(true); nsresult rs = NS_OK; nsCOMPtr<nsISimpleEnumerator> nsEnum = nsnull; // Get the Mozilla Enumerator Interface. // rs = MozillaUtils::getWindowEnumerator( (nsCOMPtr<nsISimpleEnumerator>&) nsEnum ); if( FAILED( rs ) ) { mozDIAG( _T( "MozillaUtils::findDOMWindow: Warning -- FAILED to get enumerator\n" ) ); return; } nsCOMPtr<nsISupports> cpWinSupports = nsnull; nsCOMPtr<nsIDOMWindow> cpDomWindowIter = nsnull; // Loop through all the windows and refresh them all. for(;;) { try { bool bMore = PR_FALSE; nsEnum->HasMoreElements(&bMore); if( bMore ) { rs = nsEnum->GetNext( getter_AddRefs( cpWinSupports ) ); if( nsnull == cpWinSupports ) { mozDIAG( _T( "MozillaUtils::findDOMWindow: Warning -- FAILED to get nsISupports\n" ) ); break; } } else { break; } cpDomWindowIter = do_QueryInterface(cpWinSupports, &rs); if( nsnull == cpDomWindowIter ) { mozDIAG( _T( "MozillaUtils::findDOMWindow: Warning -- FAILED to get a DOMWindow\n" ) ); break; } nsCOMPtr<nsPIDOMWindow> cpPIDomWindow( do_QueryInterface(cpDomWindowIter) ); nsIDocShell * docShell = cpPIDomWindow->GetDocShell(); nsIPresShell * presShell = nsnull; docShell->GetPresShell(&presShell); nsIViewManager *viewManager = presShell ? presShell->GetViewManager() : nsnull; if ( nsnull != viewManager ) { viewManager->UpdateAllViews(NS_VMREFRESH_IMMEDIATE ); // see .\MozillaDist*\include\nsIViewManager.h } nsCOMPtr<nsIBaseWindow> cpBaseWindow = do_QueryInterface( docShell ); if ( nsnull != cpBaseWindow ) { mozDIAG( _T( "MozillaTextHookObserver::onCaptureBox (0x%x): callRepaint\n" ), hWnd ); cpBaseWindow->Repaint(true); mozDIAG( _T( "MozillaTextHookObserver::onCaptureBox (0x%x): calledRepaint\n" ), hWnd ); } cpDomWindowIter->SizeToContent(); ::SetWindowPos(hWnd, NULL, 0, 0, rect.right - rect.left + 1, rect.bottom - rect.top + 1, flags); ::SetWindowPos(hWnd, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, flags); } catch (...) { } } mozDIAG( _T( "MozillaTextHookObserver::onCaptureBox (0x%x): delay start\n" ), hWnd ); winlib::PerformDelayForTextCapSync(); mozDIAG( _T( "MozillaTextHookObserver::onCaptureBox (0x%x): delay completed\n" ), hWnd ); } MoveWindow( hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE ); tvwp.Restore(); } else { mozDIAG( _T( "TPMozilla10Connector::ForceRepaint (0x%x): Warning -- FAILED to find Mozilla window\n" ), hWnd ); } } class TPSHAREDUTILS_API ThVisibleWindowsPlacements { class WindowPlacement { public: bool operator==(WindowPlacement &wp) {return (memcmp(&mWP, &(wp.mWP), sizeof(WINDOWPLACEMENT)) != 0);} // private: HWND m_hWnd; WINDOWPLACEMENT mWP; }; public: ThVisibleWindowsPlacements(); ~ThVisibleWindowsPlacements(); void Snapshot(DWORD tid = ::GetCurrentThreadId()); void Restore(bool clear=true); private: DWORD m_tid; #pragma warning( push ) #pragma warning( disable : 4251 ) // TPStdList is fully implemented in the header file. TPStdList<WindowPlacement *> m_list; #pragma warning( pop ) static BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM lParam); }; Thank you in advance, Marty Cracchiolo | Software Developer | Compuware APM marty.cracchi...@compuware.com<mailto:marty.cracchi...@compuware.com> | O: +1 313 227 6741 ............................................................................................................................... Simply Smarter APM | Compuware.com/APM<http://www.compuware.com/en_us/application-performance-management.html?utm_source=signature&utm_medium=email> | Facebook <http://www.facebook.com/CompuwareAPM> | Twitter<http://www.twitter.com/CompuwareAPM> | APMblog<http://apmblog.compuware.com/?utm_source=signature&utm_medium=email> | Google+<http://gplus.to/CompuwareAPM> <http://www.compuware.com/en_us/application-performance-management/about/leadership.html?utm_source=signature&utm_medium=email&utm_campaign=validate> _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform