Prevent synchronous paints during reflows bug 20150; r=rods@netscape.com

Call SetTextAlign within SetupDC instead of in each DrawString on WIN32. bug 26973; r=rods@netscape.com
This commit is contained in:
kmcclusk%netscape.com 2000-02-09 15:48:01 +00:00
Родитель e08c018a1c
Коммит cd6f5d237b
28 изменённых файлов: 113 добавлений и 50 удалений

Просмотреть файл

@ -468,7 +468,7 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent,
// Now trigger a refresh
if (mEnableRendering) {
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
}
@ -758,7 +758,7 @@ DocumentViewerImpl::SetEnableRendering(PRBool aOn)
mEnableRendering = aOn;
if (mViewManager) {
if (aOn) {
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
nsIView* view;
mViewManager->GetRootView(view); // views are not refCounted
if (view) {

Просмотреть файл

@ -3231,7 +3231,7 @@ HTMLContentSink::RefreshIfEnabled(nsIViewManager* vm)
PRBool enabled;
contentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_RELEASE(contentViewer);
}

Просмотреть файл

@ -315,7 +315,7 @@ nsImageDocument::StartLayout()
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
if (vm) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_RELEASE(shell);

Просмотреть файл

@ -1867,7 +1867,7 @@ nsXMLContentSink::RefreshIfEnabled(nsIViewManager* vm)
PRBool enabled;
contentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_RELEASE(contentViewer);
}

Просмотреть файл

@ -3520,7 +3520,7 @@ nsXULDocument::StartLayout(void)
PRBool enabled;
contentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
}
}

Просмотреть файл

@ -310,7 +310,7 @@ nsDocShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode)
PRBool enabled;
documentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_ENSURE_SUCCESS(vm->SetWindowDimensions(NSToCoordRound(r.width * p2t),
NSToCoordRound(r.height * p2t)),

Просмотреть файл

@ -4258,7 +4258,7 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
PRBool enabled;
documentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_ENSURE_SUCCESS(vm->SetWindowDimensions(NSToCoordRound(r.width * p2t),
NSToCoordRound(r.height * p2t)),

Просмотреть файл

@ -4383,10 +4383,10 @@ nsresult nsEditor::EndUpdateViewBatch()
if (0==mUpdateCount)
{
#ifdef HACK_FORCE_REDRAW
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
HACKForceRedraw();
#else
mViewManager->EndUpdateViewBatch();
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
#endif
presShell->EndBatchingReflows(PR_TRUE);
}

Просмотреть файл

@ -4383,10 +4383,10 @@ nsresult nsEditor::EndUpdateViewBatch()
if (0==mUpdateCount)
{
#ifdef HACK_FORCE_REDRAW
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
HACKForceRedraw();
#else
mViewManager->EndUpdateViewBatch();
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
#endif
presShell->EndBatchingReflows(PR_TRUE);
}

Просмотреть файл

@ -404,6 +404,7 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC)
::SetBkMode(aNewDC, TRANSPARENT);
::SetPolyFillMode(aNewDC, WINDING);
::SetStretchBltMode(aNewDC, COLORONCOLOR);
::SetTextAlign(aNewDC, TA_BASELINE);
if (nsnull != aOldDC)
{
@ -1760,7 +1761,6 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const char *aString, PRUint32
nscoord ascent;
mFontMetrics->GetMaxAscent(ascent);
aY += ascent;
::SetTextAlign(mDC, TA_BASELINE);
PRInt32 x = aX;
PRInt32 y = aY;
@ -1797,7 +1797,6 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUi
nscoord ascent;
mFontMetrics->GetMaxAscent(ascent);
aY += ascent;
::SetTextAlign(mDC, TA_BASELINE);
PRInt32 x = aX;
PRInt32 y = aY;
@ -2588,7 +2587,6 @@ NS_IMETHODIMP nsRenderingContextWinA :: DrawString(const PRUnichar *aString, PRU
nscoord ascent;
mFontMetrics->GetMaxAscent(ascent);
aY += ascent;
::SetTextAlign(mDC, TA_BASELINE);
PRInt32 x = aX;
PRInt32 y = aY;

Просмотреть файл

@ -7285,7 +7285,19 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext,
}
if (viewManager) {
viewManager->EndUpdateViewBatch();
nsCOMPtr<nsIPresShell> presShell;
nsresult rv = aPresContext->GetShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv)) {
PRBool isReflowLocked = PR_FALSE;
presShell->IsReflowLocked(&isReflowLocked);
if (isReflowLocked) {
viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
} else {
viewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
}
} else {
viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
}
// viewManager->Composite();
NS_RELEASE(viewManager);
}

Просмотреть файл

@ -468,7 +468,7 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent,
// Now trigger a refresh
if (mEnableRendering) {
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
}
@ -758,7 +758,7 @@ DocumentViewerImpl::SetEnableRendering(PRBool aOn)
mEnableRendering = aOn;
if (mViewManager) {
if (aOn) {
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
nsIView* view;
mViewManager->GetRootView(view); // views are not refCounted
if (view) {

Просмотреть файл

@ -383,6 +383,12 @@ public:
*/
NS_IMETHOD FlushPendingNotifications() = 0;
/**
* Determine if reflow is currently locked
* @param aIsReflowLocked returns PR_TRUE if reflow is locked, PR_FALSE otherwise
*/
NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0;
/**
* See if reflow verification is enabled. To enable reflow verification add
* "verifyreflow:1" to your NSPR_LOG_MODULES environment variable

Просмотреть файл

@ -355,6 +355,7 @@ public:
NS_IMETHOD FlushPendingNotifications();
NS_IMETHOD IsReflowLocked(PRBool* aIsLocked);
//nsIViewObserver interface
@ -2416,6 +2417,15 @@ PresShell::FlushPendingNotifications()
return NS_OK;
}
NS_IMETHODIMP
PresShell::IsReflowLocked(PRBool* aIsReflowLocked)
{
*aIsReflowLocked = (mReflowLockCount > 0);
return NS_OK;
}
NS_IMETHODIMP
PresShell::BeginBatchingReflows()
{

Просмотреть файл

@ -383,6 +383,12 @@ public:
*/
NS_IMETHOD FlushPendingNotifications() = 0;
/**
* Determine if reflow is currently locked
* @param aIsReflowLocked returns PR_TRUE if reflow is locked, PR_FALSE otherwise
*/
NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0;
/**
* See if reflow verification is enabled. To enable reflow verification add
* "verifyreflow:1" to your NSPR_LOG_MODULES environment variable

Просмотреть файл

@ -468,7 +468,7 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent,
// Now trigger a refresh
if (mEnableRendering) {
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
}
@ -758,7 +758,7 @@ DocumentViewerImpl::SetEnableRendering(PRBool aOn)
mEnableRendering = aOn;
if (mViewManager) {
if (aOn) {
mViewManager->EnableRefresh();
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
nsIView* view;
mViewManager->GetRootView(view); // views are not refCounted
if (view) {

Просмотреть файл

@ -355,6 +355,7 @@ public:
NS_IMETHOD FlushPendingNotifications();
NS_IMETHOD IsReflowLocked(PRBool* aIsLocked);
//nsIViewObserver interface
@ -2416,6 +2417,15 @@ PresShell::FlushPendingNotifications()
return NS_OK;
}
NS_IMETHODIMP
PresShell::IsReflowLocked(PRBool* aIsReflowLocked)
{
*aIsReflowLocked = (mReflowLockCount > 0);
return NS_OK;
}
NS_IMETHODIMP
PresShell::BeginBatchingReflows()
{

Просмотреть файл

@ -3231,7 +3231,7 @@ HTMLContentSink::RefreshIfEnabled(nsIViewManager* vm)
PRBool enabled;
contentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_RELEASE(contentViewer);
}

Просмотреть файл

@ -315,7 +315,7 @@ nsImageDocument::StartLayout()
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
if (vm) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_RELEASE(shell);

Просмотреть файл

@ -7285,7 +7285,19 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext,
}
if (viewManager) {
viewManager->EndUpdateViewBatch();
nsCOMPtr<nsIPresShell> presShell;
nsresult rv = aPresContext->GetShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv)) {
PRBool isReflowLocked = PR_FALSE;
presShell->IsReflowLocked(&isReflowLocked);
if (isReflowLocked) {
viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
} else {
viewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
}
} else {
viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
}
// viewManager->Composite();
NS_RELEASE(viewManager);
}

Просмотреть файл

@ -1867,7 +1867,7 @@ nsXMLContentSink::RefreshIfEnabled(nsIViewManager* vm)
PRBool enabled;
contentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_RELEASE(contentViewer);
}

Просмотреть файл

@ -3520,7 +3520,7 @@ nsXULDocument::StartLayout(void)
PRBool enabled;
contentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
}
}

Просмотреть файл

@ -379,9 +379,10 @@ public:
/**
* allow the view manager to refresh. this may cause a synchronous
* paint to occur inside the call.
* @param aUpdateFlags see bottom of nsIViewManager.h for description
* @return error status
*/
NS_IMETHOD EnableRefresh(void) = 0;
NS_IMETHOD EnableRefresh(PRUint32 aUpdateFlags) = 0;
/**
* prevents the view manager from refreshing. allows UpdateView()
@ -394,10 +395,11 @@ public:
/**
* allow the view manager to refresh any damaged areas accumulated
* after the BeginUpdateViewBatch() call. this may cause a
* synchronous paint to occur inside the call.
* synchronous paint to occur inside the call if aUpdateFlags NS_VMREFRESH_IMMEDIATE is set
* @param aUpdateFlags see bottom of nsIViewManager.h for description
* @return error status
*/
NS_IMETHOD EndUpdateViewBatch(void) = 0;
NS_IMETHOD EndUpdateViewBatch(PRUint32 aUpdateFlags) = 0;
/**
* set the view that is is considered to be the root scrollable

Просмотреть файл

@ -264,7 +264,6 @@ NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext)
}
mContext = aContext;
mDSBounds.Empty();
mTimer = nsnull;
mFrameRate = 0;
mTrueFrameRate = 0;
@ -2339,7 +2338,7 @@ NS_IMETHODIMP nsViewManager :: DisableRefresh(void)
return NS_OK;
}
NS_IMETHODIMP nsViewManager :: EnableRefresh(void)
NS_IMETHODIMP nsViewManager :: EnableRefresh(PRUint32 aUpdateFlags)
{
if (mUpdateBatchCnt > 0)
return NS_OK;
@ -2349,14 +2348,18 @@ NS_IMETHODIMP nsViewManager :: EnableRefresh(void)
if (mUpdateCnt > 0)
ProcessPendingUpdates(mRootView);
if (mTrueFrameRate > 0)
{
PRInt32 deltams = PR_IntervalToMilliseconds(PR_IntervalNow() - mLastRefresh);
if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) {
if (mTrueFrameRate > 0)
{
PRInt32 deltams = PR_IntervalToMilliseconds(PR_IntervalNow() - mLastRefresh);
if (deltams > (1000 / (PRInt32)mTrueFrameRate))
Composite();
if (deltams > (1000 / (PRInt32)mTrueFrameRate))
Composite();
}
}
return NS_OK;
}
@ -2373,7 +2376,7 @@ NS_IMETHODIMP nsViewManager :: BeginUpdateViewBatch(void)
return result;
}
NS_IMETHODIMP nsViewManager :: EndUpdateViewBatch(void)
NS_IMETHODIMP nsViewManager :: EndUpdateViewBatch(PRUint32 aUpdateFlags)
{
nsresult result = NS_OK;
@ -2388,7 +2391,7 @@ NS_IMETHODIMP nsViewManager :: EndUpdateViewBatch(void)
}
if (mUpdateBatchCnt == 0)
result = EnableRefresh();
result = EnableRefresh(aUpdateFlags);
return result;
}

Просмотреть файл

@ -114,10 +114,10 @@ public:
NS_IMETHOD SetQuality(nsContentQuality aQuality);
NS_IMETHOD DisableRefresh(void);
NS_IMETHOD EnableRefresh(void);
NS_IMETHOD EnableRefresh(PRUint32 aUpdateFlags);
NS_IMETHOD BeginUpdateViewBatch(void);
NS_IMETHOD EndUpdateViewBatch(void);
NS_IMETHOD EndUpdateViewBatch(PRUint32 aUpdateFlags);
NS_IMETHOD SetRootScrollableView(nsIScrollableView *aScrollable);
NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable);

Просмотреть файл

@ -1832,7 +1832,7 @@ NS_IMETHODIMP nsViewManager2::DisableRefresh(void)
return NS_OK;
}
NS_IMETHODIMP nsViewManager2::EnableRefresh(void)
NS_IMETHODIMP nsViewManager2::EnableRefresh(PRUint32 aUpdateFlags)
{
if (mUpdateBatchCnt > 0)
return NS_OK;
@ -1842,14 +1842,18 @@ NS_IMETHODIMP nsViewManager2::EnableRefresh(void)
if (mUpdateCnt > 0)
ProcessPendingUpdates(mRootView);
if (mTrueFrameRate > 0)
{
PRInt32 deltams = PR_IntervalToMilliseconds(PR_IntervalNow() - mLastRefresh);
if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) {
if (mTrueFrameRate > 0)
{
PRInt32 deltams = PR_IntervalToMilliseconds(PR_IntervalNow() - mLastRefresh);
if (deltams > (1000 / (PRInt32)mTrueFrameRate))
Composite();
if (deltams > (1000 / (PRInt32)mTrueFrameRate))
Composite();
}
}
return NS_OK;
}
@ -1866,7 +1870,7 @@ NS_IMETHODIMP nsViewManager2::BeginUpdateViewBatch(void)
return result;
}
NS_IMETHODIMP nsViewManager2::EndUpdateViewBatch(void)
NS_IMETHODIMP nsViewManager2::EndUpdateViewBatch(PRUint32 aUpdateFlags)
{
nsresult result = NS_OK;
@ -1881,7 +1885,7 @@ NS_IMETHODIMP nsViewManager2::EndUpdateViewBatch(void)
}
if (mUpdateBatchCnt == 0)
result = EnableRefresh();
result = EnableRefresh(aUpdateFlags);
return result;
}

Просмотреть файл

@ -115,10 +115,10 @@ public:
NS_IMETHOD SetQuality(nsContentQuality aQuality);
NS_IMETHOD DisableRefresh(void);
NS_IMETHOD EnableRefresh(void);
NS_IMETHOD EnableRefresh(PRUint32 aUpdateFlags);
NS_IMETHOD BeginUpdateViewBatch(void);
NS_IMETHOD EndUpdateViewBatch(void);
NS_IMETHOD EndUpdateViewBatch(PRUint32 aUpdateFlags);
NS_IMETHOD SetRootScrollableView(nsIScrollableView *aScrollable);
NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable);

Просмотреть файл

@ -4258,7 +4258,7 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
PRBool enabled;
documentViewer->GetEnableRendering(&enabled);
if (enabled) {
vm->EnableRefresh();
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}
NS_ENSURE_SUCCESS(vm->SetWindowDimensions(NSToCoordRound(r.width * p2t),
NSToCoordRound(r.height * p2t)),