Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 4e63c1e

Browse files
committed
Bug 881832 - Make inner document reflow asynchronous. r=tnikkel
1 parent 0949e08 commit 4e63c1e

16 files changed

Lines changed: 63 additions & 33 deletions

docshell/base/nsDocShell.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5596,7 +5596,7 @@ nsDocShell::InitWindow(nativeWindow aParentNativeWindow,
55965596
int32_t aWidth, int32_t aHeight)
55975597
{
55985598
SetParentWidget(aParentWidget);
5599-
SetPositionAndSize(aX, aY, aWidth, aHeight, false);
5599+
SetPositionAndSize(aX, aY, aWidth, aHeight, 0);
56005600

56015601
return NS_OK;
56025602
}
@@ -5842,7 +5842,8 @@ nsDocShell::SetSize(int32_t aWidth, int32_t aHeight, bool aRepaint)
58425842
{
58435843
int32_t x = 0, y = 0;
58445844
GetPosition(&x, &y);
5845-
return SetPositionAndSize(x, y, aWidth, aHeight, aRepaint);
5845+
return SetPositionAndSize(x, y, aWidth, aHeight,
5846+
aRepaint ? nsIBaseWindow::eRepaint : 0);
58465847
}
58475848

58485849
NS_IMETHODIMP
@@ -5853,7 +5854,7 @@ nsDocShell::GetSize(int32_t* aWidth, int32_t* aHeight)
58535854

58545855
NS_IMETHODIMP
58555856
nsDocShell::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aWidth,
5856-
int32_t aHeight, bool aFRepaint)
5857+
int32_t aHeight, uint32_t aFlags)
58575858
{
58585859
mBounds.x = aX;
58595860
mBounds.y = aY;
@@ -5863,8 +5864,11 @@ nsDocShell::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aWidth,
58635864
// Hold strong ref, since SetBounds can make us null out mContentViewer
58645865
nsCOMPtr<nsIContentViewer> viewer = mContentViewer;
58655866
if (viewer) {
5867+
uint32_t cvflags = (aFlags & nsIBaseWindow::eDelayResize) ?
5868+
nsIContentViewer::eDelayResize : 0;
58665869
// XXX Border figured in here or is that handled elsewhere?
5867-
NS_ENSURE_SUCCESS(viewer->SetBounds(mBounds), NS_ERROR_FAILURE);
5870+
nsresult rv = viewer->SetBoundsWithFlags(mBounds, cvflags);
5871+
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
58685872
}
58695873

58705874
return NS_OK;
@@ -5878,7 +5882,7 @@ nsDocShell::GetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
58785882
// ensure size is up-to-date if window has changed resolution
58795883
LayoutDeviceIntRect r;
58805884
mParentWidget->GetClientBounds(r);
5881-
SetPositionAndSize(mBounds.x, mBounds.y, r.width, r.height, false);
5885+
SetPositionAndSize(mBounds.x, mBounds.y, r.width, r.height, 0);
58825886
}
58835887

58845888
// We should really consider just getting this information from

docshell/base/nsIContentViewer.idl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ interface nsIContentViewer : nsISupports
104104

105105
[noscript] void getBounds(in nsIntRectRef aBounds);
106106
[noscript] void setBounds([const] in nsIntRectRef aBounds);
107+
/**
108+
* The 'aFlags' argument to setBoundsWithFlags is a set of these bits.
109+
*/
110+
const unsigned long eDelayResize = 1;
111+
[noscript] void setBoundsWithFlags([const] in nsIntRectRef aBounds,
112+
in unsigned long aFlags);
107113

108114
/**
109115
* The previous content viewer, which has been |close|d but not

dom/base/nsFrameLoader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,8 @@ nsFrameLoader::UpdateBaseWindowPositionAndSize(nsSubDocumentFrame *aIFrame)
23382338

23392339
ScreenIntSize size = aIFrame->GetSubdocumentSize();
23402340

2341-
baseWindow->SetPositionAndSize(x, y, size.width, size.height, false);
2341+
baseWindow->SetPositionAndSize(x, y, size.width, size.height,
2342+
nsIBaseWindow::eDelayResize);
23422343
}
23432344
}
23442345

dom/ipc/TabChild.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
16921692
// size from the content viewer when it computes a new CSS viewport.
16931693
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
16941694
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
1695-
true);
1695+
nsIBaseWindow::eRepaint);
16961696

16971697
mPuppetWidget->Resize(screenRect.x + clientOffset.x + chromeDisp.x,
16981698
screenRect.y + clientOffset.y + chromeDisp.y,
@@ -3102,7 +3102,7 @@ TabChild::RecvUIResolutionChanged(const float& aDpi, const double& aScale)
31023102

31033103
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
31043104
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
3105-
true);
3105+
nsIBaseWindow::eRepaint);
31063106
}
31073107

31083108
return true;

dom/ipc/TabParent.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,8 @@ TabParent::RecvSetDimensions(const uint32_t& aFlags,
878878

879879
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
880880
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) {
881-
treeOwnerAsWin->SetPositionAndSize(x, y, cx, cy, true);
881+
treeOwnerAsWin->SetPositionAndSize(x, y, cx, cy,
882+
nsIBaseWindow::eRepaint);
882883
return true;
883884
}
884885

embedding/browser/nsDocShellTreeOwner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ nsDocShellTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
647647

648648
NS_IMETHODIMP
649649
nsDocShellTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX,
650-
int32_t aCY, bool aRepaint)
650+
int32_t aCY, uint32_t aFlags)
651651
{
652652
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
653653
if (ownerWin) {

embedding/browser/nsWebBrowser.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ nsWebBrowser::InitWindow(nativeWindow aParentNativeWindow,
11501150
NS_ENSURE_SUCCESS(SetParentNativeWindow(aParentNativeWindow),
11511151
NS_ERROR_FAILURE);
11521152

1153-
NS_ENSURE_SUCCESS(SetPositionAndSize(aX, aY, aCX, aCY, false),
1153+
NS_ENSURE_SUCCESS(SetPositionAndSize(aX, aY, aCX, aCY, 0),
11541154
NS_ERROR_FAILURE);
11551155

11561156
return NS_OK;
@@ -1325,7 +1325,7 @@ nsWebBrowser::SetPosition(int32_t aX, int32_t aY)
13251325

13261326
GetSize(&cx, &cy);
13271327

1328-
return SetPositionAndSize(aX, aY, cx, cy, false);
1328+
return SetPositionAndSize(aX, aY, cx, cy, 0);
13291329
}
13301330

13311331
NS_IMETHODIMP
@@ -1342,7 +1342,8 @@ nsWebBrowser::SetSize(int32_t aCX, int32_t aCY, bool aRepaint)
13421342

13431343
GetPosition(&x, &y);
13441344

1345-
return SetPositionAndSize(x, y, aCX, aCY, aRepaint);
1345+
return SetPositionAndSize(x, y, aCX, aCY,
1346+
aRepaint ? nsIBaseWindow::eRepaint : 0);
13461347
}
13471348

13481349
NS_IMETHODIMP
@@ -1353,7 +1354,7 @@ nsWebBrowser::GetSize(int32_t* aCX, int32_t* aCY)
13531354

13541355
NS_IMETHODIMP
13551356
nsWebBrowser::SetPositionAndSize(int32_t aX, int32_t aY,
1356-
int32_t aCX, int32_t aCY, bool aRepaint)
1357+
int32_t aCX, int32_t aCY, uint32_t aFlags)
13571358
{
13581359
if (!mDocShell) {
13591360
mInitInfo->x = aX;
@@ -1369,12 +1370,13 @@ nsWebBrowser::SetPositionAndSize(int32_t aX, int32_t aY,
13691370
// We also need to resize our widget then.
13701371
if (mInternalWidget) {
13711372
doc_x = doc_y = 0;
1372-
NS_ENSURE_SUCCESS(mInternalWidget->Resize(aX, aY, aCX, aCY, aRepaint),
1373+
NS_ENSURE_SUCCESS(mInternalWidget->Resize(aX, aY, aCX, aCY,
1374+
!!(aFlags & nsIBaseWindow::eRepaint)),
13731375
NS_ERROR_FAILURE);
13741376
}
13751377
// Now reposition/ resize the doc
13761378
NS_ENSURE_SUCCESS(
1377-
mDocShellAsWin->SetPositionAndSize(doc_x, doc_y, aCX, aCY, aRepaint),
1379+
mDocShellAsWin->SetPositionAndSize(doc_x, doc_y, aCX, aCY, aFlags),
13781380
NS_ERROR_FAILURE);
13791381
}
13801382

layout/base/nsDocumentViewer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ nsDocumentViewer::SetPreviousViewer(nsIContentViewer* aViewer)
19051905
}
19061906

19071907
NS_IMETHODIMP
1908-
nsDocumentViewer::SetBounds(const nsIntRect& aBounds)
1908+
nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds, uint32_t aFlags)
19091909
{
19101910
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
19111911

@@ -1920,7 +1920,8 @@ nsDocumentViewer::SetBounds(const nsIntRect& aBounds)
19201920
} else if (mPresContext && mViewManager) {
19211921
int32_t p2a = mPresContext->AppUnitsPerDevPixel();
19221922
mViewManager->SetWindowDimensions(NSIntPixelsToAppUnits(mBounds.width, p2a),
1923-
NSIntPixelsToAppUnits(mBounds.height, p2a));
1923+
NSIntPixelsToAppUnits(mBounds.height, p2a),
1924+
!!(aFlags & nsIContentViewer::eDelayResize));
19241925
}
19251926

19261927
// If there's a previous viewer, it's the one that's actually showing,
@@ -1938,6 +1939,12 @@ nsDocumentViewer::SetBounds(const nsIntRect& aBounds)
19381939
return NS_OK;
19391940
}
19401941

1942+
NS_IMETHODIMP
1943+
nsDocumentViewer::SetBounds(const nsIntRect& aBounds)
1944+
{
1945+
return SetBoundsWithFlags(aBounds, 0);
1946+
}
1947+
19411948
NS_IMETHODIMP
19421949
nsDocumentViewer::Move(int32_t aX, int32_t aY)
19431950
{

layout/xul/nsResizerFrame.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
285285
}
286286
}
287287
else {
288-
window->SetPositionAndSize(rect.x, rect.y, rect.width, rect.height, true); // do the repaint.
288+
window->SetPositionAndSize(rect.x, rect.y, rect.width, rect.height,
289+
nsIBaseWindow::eRepaint); // do the repaint.
289290
}
290291

291292
doDefault = false;

view/nsViewManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ nsViewManager::ShouldDelayResize() const
210210
}
211211

212212
void
213-
nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
213+
nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight, bool aDelayResize)
214214
{
215215
if (mRootView) {
216-
if (!ShouldDelayResize()) {
216+
if (!ShouldDelayResize() && !aDelayResize) {
217217
if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
218218
mDelayedResize != nsSize(aWidth, aHeight)) {
219219
// We have a delayed resize; that now obsolete size may already have

0 commit comments

Comments
 (0)