Bug 881832 - Make inner document reflow asynchronous. r=tnikkel

--HG--
extra : rebase_source : 9987e19e3318d5bc58ac8214496893041bc1775c
This commit is contained in:
Mats Palmgren 2016-05-12 12:07:45 +12:00
parent a93f3b746c
commit e04a74ec14
16 changed files with 63 additions and 33 deletions

View File

@ -5592,7 +5592,7 @@ nsDocShell::InitWindow(nativeWindow aParentNativeWindow,
int32_t aWidth, int32_t aHeight) int32_t aWidth, int32_t aHeight)
{ {
SetParentWidget(aParentWidget); SetParentWidget(aParentWidget);
SetPositionAndSize(aX, aY, aWidth, aHeight, false); SetPositionAndSize(aX, aY, aWidth, aHeight, 0);
return NS_OK; return NS_OK;
} }
@ -5838,7 +5838,8 @@ nsDocShell::SetSize(int32_t aWidth, int32_t aHeight, bool aRepaint)
{ {
int32_t x = 0, y = 0; int32_t x = 0, y = 0;
GetPosition(&x, &y); GetPosition(&x, &y);
return SetPositionAndSize(x, y, aWidth, aHeight, aRepaint); return SetPositionAndSize(x, y, aWidth, aHeight,
aRepaint ? nsIBaseWindow::eRepaint : 0);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -5849,7 +5850,7 @@ nsDocShell::GetSize(int32_t* aWidth, int32_t* aHeight)
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aWidth, nsDocShell::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aWidth,
int32_t aHeight, bool aFRepaint) int32_t aHeight, uint32_t aFlags)
{ {
mBounds.x = aX; mBounds.x = aX;
mBounds.y = aY; mBounds.y = aY;
@ -5859,8 +5860,11 @@ nsDocShell::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aWidth,
// Hold strong ref, since SetBounds can make us null out mContentViewer // Hold strong ref, since SetBounds can make us null out mContentViewer
nsCOMPtr<nsIContentViewer> viewer = mContentViewer; nsCOMPtr<nsIContentViewer> viewer = mContentViewer;
if (viewer) { if (viewer) {
uint32_t cvflags = (aFlags & nsIBaseWindow::eDelayResize) ?
nsIContentViewer::eDelayResize : 0;
// XXX Border figured in here or is that handled elsewhere? // XXX Border figured in here or is that handled elsewhere?
NS_ENSURE_SUCCESS(viewer->SetBounds(mBounds), NS_ERROR_FAILURE); nsresult rv = viewer->SetBoundsWithFlags(mBounds, cvflags);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
} }
return NS_OK; return NS_OK;
@ -5874,7 +5878,7 @@ nsDocShell::GetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
// ensure size is up-to-date if window has changed resolution // ensure size is up-to-date if window has changed resolution
LayoutDeviceIntRect r; LayoutDeviceIntRect r;
mParentWidget->GetClientBounds(r); mParentWidget->GetClientBounds(r);
SetPositionAndSize(mBounds.x, mBounds.y, r.width, r.height, false); SetPositionAndSize(mBounds.x, mBounds.y, r.width, r.height, 0);
} }
// We should really consider just getting this information from // We should really consider just getting this information from

View File

@ -104,6 +104,12 @@ interface nsIContentViewer : nsISupports
[noscript] void getBounds(in nsIntRectRef aBounds); [noscript] void getBounds(in nsIntRectRef aBounds);
[noscript] void setBounds([const] in nsIntRectRef aBounds); [noscript] void setBounds([const] in nsIntRectRef aBounds);
/**
* The 'aFlags' argument to setBoundsWithFlags is a set of these bits.
*/
const unsigned long eDelayResize = 1;
[noscript] void setBoundsWithFlags([const] in nsIntRectRef aBounds,
in unsigned long aFlags);
/** /**
* The previous content viewer, which has been |close|d but not * The previous content viewer, which has been |close|d but not

View File

@ -2311,7 +2311,8 @@ nsFrameLoader::UpdateBaseWindowPositionAndSize(nsSubDocumentFrame *aIFrame)
ScreenIntSize size = aIFrame->GetSubdocumentSize(); ScreenIntSize size = aIFrame->GetSubdocumentSize();
baseWindow->SetPositionAndSize(x, y, size.width, size.height, false); baseWindow->SetPositionAndSize(x, y, size.width, size.height,
nsIBaseWindow::eDelayResize);
} }
} }

View File

@ -1694,7 +1694,7 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
// size from the content viewer when it computes a new CSS viewport. // size from the content viewer when it computes a new CSS viewport.
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation()); nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
true); nsIBaseWindow::eRepaint);
mPuppetWidget->Resize(screenRect.x + clientOffset.x + chromeDisp.x, mPuppetWidget->Resize(screenRect.x + clientOffset.x + chromeDisp.x,
screenRect.y + clientOffset.y + chromeDisp.y, screenRect.y + clientOffset.y + chromeDisp.y,
@ -3059,7 +3059,7 @@ TabChild::RecvUIResolutionChanged(const float& aDpi, const double& aScale)
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation()); nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
true); nsIBaseWindow::eRepaint);
} }
return true; return true;

View File

@ -870,7 +870,8 @@ TabParent::RecvSetDimensions(const uint32_t& aFlags,
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION && if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) { aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) {
treeOwnerAsWin->SetPositionAndSize(x, y, cx, cy, true); treeOwnerAsWin->SetPositionAndSize(x, y, cx, cy,
nsIBaseWindow::eRepaint);
return true; return true;
} }

View File

@ -647,7 +647,7 @@ nsDocShellTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
NS_IMETHODIMP NS_IMETHODIMP
nsDocShellTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX, nsDocShellTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX,
int32_t aCY, bool aRepaint) int32_t aCY, uint32_t aFlags)
{ {
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin(); nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
if (ownerWin) { if (ownerWin) {

View File

@ -1150,7 +1150,7 @@ nsWebBrowser::InitWindow(nativeWindow aParentNativeWindow,
NS_ENSURE_SUCCESS(SetParentNativeWindow(aParentNativeWindow), NS_ENSURE_SUCCESS(SetParentNativeWindow(aParentNativeWindow),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(SetPositionAndSize(aX, aY, aCX, aCY, false), NS_ENSURE_SUCCESS(SetPositionAndSize(aX, aY, aCX, aCY, 0),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
@ -1325,7 +1325,7 @@ nsWebBrowser::SetPosition(int32_t aX, int32_t aY)
GetSize(&cx, &cy); GetSize(&cx, &cy);
return SetPositionAndSize(aX, aY, cx, cy, false); return SetPositionAndSize(aX, aY, cx, cy, 0);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1342,7 +1342,8 @@ nsWebBrowser::SetSize(int32_t aCX, int32_t aCY, bool aRepaint)
GetPosition(&x, &y); GetPosition(&x, &y);
return SetPositionAndSize(x, y, aCX, aCY, aRepaint); return SetPositionAndSize(x, y, aCX, aCY,
aRepaint ? nsIBaseWindow::eRepaint : 0);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1353,7 +1354,7 @@ nsWebBrowser::GetSize(int32_t* aCX, int32_t* aCY)
NS_IMETHODIMP NS_IMETHODIMP
nsWebBrowser::SetPositionAndSize(int32_t aX, int32_t aY, nsWebBrowser::SetPositionAndSize(int32_t aX, int32_t aY,
int32_t aCX, int32_t aCY, bool aRepaint) int32_t aCX, int32_t aCY, uint32_t aFlags)
{ {
if (!mDocShell) { if (!mDocShell) {
mInitInfo->x = aX; mInitInfo->x = aX;
@ -1369,12 +1370,13 @@ nsWebBrowser::SetPositionAndSize(int32_t aX, int32_t aY,
// We also need to resize our widget then. // We also need to resize our widget then.
if (mInternalWidget) { if (mInternalWidget) {
doc_x = doc_y = 0; doc_x = doc_y = 0;
NS_ENSURE_SUCCESS(mInternalWidget->Resize(aX, aY, aCX, aCY, aRepaint), NS_ENSURE_SUCCESS(mInternalWidget->Resize(aX, aY, aCX, aCY,
!!(aFlags & nsIBaseWindow::eRepaint)),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
} }
// Now reposition/ resize the doc // Now reposition/ resize the doc
NS_ENSURE_SUCCESS( NS_ENSURE_SUCCESS(
mDocShellAsWin->SetPositionAndSize(doc_x, doc_y, aCX, aCY, aRepaint), mDocShellAsWin->SetPositionAndSize(doc_x, doc_y, aCX, aCY, aFlags),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
} }

View File

@ -1909,7 +1909,7 @@ nsDocumentViewer::SetPreviousViewer(nsIContentViewer* aViewer)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocumentViewer::SetBounds(const nsIntRect& aBounds) nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds, uint32_t aFlags)
{ {
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
@ -1924,7 +1924,8 @@ nsDocumentViewer::SetBounds(const nsIntRect& aBounds)
} else if (mPresContext && mViewManager) { } else if (mPresContext && mViewManager) {
int32_t p2a = mPresContext->AppUnitsPerDevPixel(); int32_t p2a = mPresContext->AppUnitsPerDevPixel();
mViewManager->SetWindowDimensions(NSIntPixelsToAppUnits(mBounds.width, p2a), mViewManager->SetWindowDimensions(NSIntPixelsToAppUnits(mBounds.width, p2a),
NSIntPixelsToAppUnits(mBounds.height, p2a)); NSIntPixelsToAppUnits(mBounds.height, p2a),
!!(aFlags & nsIContentViewer::eDelayResize));
} }
// If there's a previous viewer, it's the one that's actually showing, // If there's a previous viewer, it's the one that's actually showing,
@ -1942,6 +1943,12 @@ nsDocumentViewer::SetBounds(const nsIntRect& aBounds)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDocumentViewer::SetBounds(const nsIntRect& aBounds)
{
return SetBoundsWithFlags(aBounds, 0);
}
NS_IMETHODIMP NS_IMETHODIMP
nsDocumentViewer::Move(int32_t aX, int32_t aY) nsDocumentViewer::Move(int32_t aX, int32_t aY)
{ {

View File

@ -285,7 +285,8 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
} }
} }
else { else {
window->SetPositionAndSize(rect.x, rect.y, rect.width, rect.height, true); // do the repaint. window->SetPositionAndSize(rect.x, rect.y, rect.width, rect.height,
nsIBaseWindow::eRepaint); // do the repaint.
} }
doDefault = false; doDefault = false;

View File

@ -212,10 +212,10 @@ nsViewManager::ShouldDelayResize() const
} }
void void
nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight, bool aDelayResize)
{ {
if (mRootView) { if (mRootView) {
if (!ShouldDelayResize()) { if (!ShouldDelayResize() && !aDelayResize) {
if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
mDelayedResize != nsSize(aWidth, aHeight)) { mDelayedResize != nsSize(aWidth, aHeight)) {
// We have a delayed resize; that now obsolete size may already have // We have a delayed resize; that now obsolete size may already have

View File

@ -89,7 +89,8 @@ public:
* @param aWidth of window in twips * @param aWidth of window in twips
* @param aHeight of window in twips * @param aHeight of window in twips
*/ */
void SetWindowDimensions(nscoord aWidth, nscoord aHeight); void SetWindowDimensions(nscoord aWidth, nscoord aHeight,
bool aDelayResize = false);
/** /**
* Do any resizes that are pending. * Do any resizes that are pending.

View File

@ -113,12 +113,18 @@ interface nsIBaseWindow : nsISupports
*/ */
void getSize(out long cx, out long cy); void getSize(out long cx, out long cy);
/**
* The 'flags' argument to setPositionAndSize is a set of these bits.
*/
const unsigned long eRepaint = 1;
const unsigned long eDelayResize = 2;
/* /*
Convenience function combining the SetPosition and SetSize into one call. Convenience function combining the SetPosition and SetSize into one call.
Also is more efficient than calling both. Also is more efficient than calling both.
*/ */
void setPositionAndSize(in long x, in long y, in long cx, in long cy, void setPositionAndSize(in long x, in long y, in long cx, in long cy,
in boolean fRepaint); in unsigned long flags);
/* /*
Convenience function combining the GetPosition and GetSize into one call. Convenience function combining the GetPosition and GetSize into one call.

View File

@ -357,7 +357,7 @@ NS_IMETHODIMP nsChromeTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy) nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy)
{ {
// Ignore widget parents for now. Don't think those are a vaild thing to call. // Ignore widget parents for now. Don't think those are a vaild thing to call.
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, false), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, 0), NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
} }
@ -417,10 +417,10 @@ NS_IMETHODIMP nsChromeTreeOwner::GetSize(int32_t* cx, int32_t* cy)
} }
NS_IMETHODIMP nsChromeTreeOwner::SetPositionAndSize(int32_t x, int32_t y, int32_t cx, NS_IMETHODIMP nsChromeTreeOwner::SetPositionAndSize(int32_t x, int32_t y, int32_t cx,
int32_t cy, bool fRepaint) int32_t cy, uint32_t aFlags)
{ {
NS_ENSURE_STATE(mXULWindow); NS_ENSURE_STATE(mXULWindow);
return mXULWindow->SetPositionAndSize(x, y, cx, cy, fRepaint); return mXULWindow->SetPositionAndSize(x, y, cx, cy, aFlags);
} }
NS_IMETHODIMP nsChromeTreeOwner::GetPositionAndSize(int32_t* x, int32_t* y, int32_t* cx, NS_IMETHODIMP nsChromeTreeOwner::GetPositionAndSize(int32_t* x, int32_t* y, int32_t* cx,

View File

@ -599,7 +599,7 @@ NS_IMETHODIMP nsContentTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy) nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy)
{ {
// Ignore wigdet parents for now. Don't think those are a vaild thing to call. // Ignore wigdet parents for now. Don't think those are a vaild thing to call.
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, false), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, 0), NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
} }
@ -659,10 +659,10 @@ NS_IMETHODIMP nsContentTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
} }
NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY, NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY,
int32_t aCX, int32_t aCY, bool aRepaint) int32_t aCX, int32_t aCY, uint32_t aFlags)
{ {
NS_ENSURE_STATE(mXULWindow); NS_ENSURE_STATE(mXULWindow);
return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aRepaint); return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aFlags);
} }
NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY, NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY,
@ -1058,7 +1058,8 @@ nsSiteWindow::SetDimensions(uint32_t aFlags,
int32_t aX, int32_t aY, int32_t aCX, int32_t aCY) int32_t aX, int32_t aY, int32_t aCX, int32_t aCY)
{ {
// XXX we're ignoring aFlags // XXX we're ignoring aFlags
return mAggregator->SetPositionAndSize(aX, aY, aCX, aCY, true); return mAggregator->SetPositionAndSize(aX, aY, aCX, aCY,
nsIBaseWindow::eRepaint);
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -281,7 +281,7 @@ nsWebShellWindow::WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHei
{ {
nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(mDocShell)); nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(mDocShell));
if (shellAsWin) { if (shellAsWin) {
shellAsWin->SetPositionAndSize(0, 0, aWidth, aHeight, false); shellAsWin->SetPositionAndSize(0, 0, aWidth, aHeight, 0);
} }
// Persist size, but not immediately, in case this OS is firing // Persist size, but not immediately, in case this OS is firing
// repeated size events as the user drags the sizing handle // repeated size events as the user drags the sizing handle

View File

@ -641,7 +641,7 @@ NS_IMETHODIMP nsXULWindow::GetSize(int32_t* aCX, int32_t* aCY)
} }
NS_IMETHODIMP nsXULWindow::SetPositionAndSize(int32_t aX, int32_t aY, NS_IMETHODIMP nsXULWindow::SetPositionAndSize(int32_t aX, int32_t aY,
int32_t aCX, int32_t aCY, bool aRepaint) int32_t aCX, int32_t aCY, uint32_t aFlags)
{ {
/* any attempt to set the window's size or position overrides the window's /* any attempt to set the window's size or position overrides the window's
zoom state. this is important when these two states are competing while zoom state. this is important when these two states are competing while
@ -653,7 +653,7 @@ NS_IMETHODIMP nsXULWindow::SetPositionAndSize(int32_t aX, int32_t aY,
DesktopToLayoutDeviceScale scale = mWindow->GetDesktopToDeviceScale(); DesktopToLayoutDeviceScale scale = mWindow->GetDesktopToDeviceScale();
DesktopRect rect = LayoutDeviceIntRect(aX, aY, aCX, aCY) / scale; DesktopRect rect = LayoutDeviceIntRect(aX, aY, aCX, aCY) / scale;
nsresult rv = mWindow->Resize(rect.x, rect.y, rect.width, rect.height, nsresult rv = mWindow->Resize(rect.x, rect.y, rect.width, rect.height,
aRepaint); !!(aFlags & nsIBaseWindow::eRepaint));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
if (!mChromeLoaded) { if (!mChromeLoaded) {
// If we're called before the chrome is loaded someone obviously wants this // If we're called before the chrome is loaded someone obviously wants this