mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Make InitialReflow just post a reflow event instead of doing a synchronousreflow. Bug 378975, r=dbaron and Eli Friedman, sr=dbaron
This commit is contained in:
parent
44dc756708
commit
e83c55e645
@ -893,8 +893,6 @@ nsContentSink::StartLayout(PRBool aIgnorePendingSheets)
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool deferredStart = mDeferredLayoutStart;
|
||||
|
||||
mDeferredLayoutStart = PR_TRUE;
|
||||
|
||||
if (!aIgnorePendingSheets && mPendingSheetCount > 0) {
|
||||
@ -940,12 +938,9 @@ nsContentSink::StartLayout(PRBool aIgnorePendingSheets)
|
||||
// Make shell an observer for next time
|
||||
shell->BeginObservingDocument();
|
||||
|
||||
PRBool oldInEagerStartLayout = shell->IsInEagerStartLayout();
|
||||
shell->SetInEagerStartLayout(!deferredStart);
|
||||
// Resize-reflow this time
|
||||
nsRect r = shell->GetPresContext()->GetVisibleArea();
|
||||
nsresult rv = shell->InitialReflow(r.width, r.height);
|
||||
shell->SetInEagerStartLayout(oldInEagerStartLayout);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
@ -720,13 +720,6 @@ public:
|
||||
void AddWeakFrame(nsWeakFrame* aWeakFrame);
|
||||
void RemoveWeakFrame(nsWeakFrame* aWeakFrame);
|
||||
|
||||
void SetInEagerStartLayout(PRBool aInEagerStartLayout) {
|
||||
mInEagerStartLayout = aInEagerStartLayout;
|
||||
}
|
||||
PRBool IsInEagerStartLayout() const {
|
||||
return mInEagerStartLayout;
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
|
||||
#endif
|
||||
@ -767,10 +760,6 @@ protected:
|
||||
// the dom/layout trees
|
||||
PRPackedBool mIsAccessibilityActive;
|
||||
|
||||
// True if we're under an "eager" (that is, called before there is
|
||||
// much content in the document) StartLayout call.
|
||||
PRPackedBool mInEagerStartLayout;
|
||||
|
||||
// A list of weak frames. This is a pointer to the last item in the list.
|
||||
nsWeakFrame* mWeakFrames;
|
||||
};
|
||||
|
@ -2450,6 +2450,10 @@ PresShell::GetDidInitialReflow(PRBool *aDidInitialReflow)
|
||||
NS_IMETHODIMP
|
||||
PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
if (mIsDestroying) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
|
||||
mDidInitialReflow = PR_TRUE;
|
||||
|
||||
@ -2469,22 +2473,10 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
||||
if (mCaret)
|
||||
mCaret->EraseCaret();
|
||||
|
||||
NS_ASSERTION(mViewManager, "Should have view manager");
|
||||
// Painting should be suppressed for the initial reflow, so this won't
|
||||
// really do anything right now, but it will be useful when we
|
||||
// start batching widget changes
|
||||
mViewManager->BeginUpdateViewBatch();
|
||||
|
||||
// XXX Do a full invalidate at the beginning so that invalidates along
|
||||
// the way don't have region accumulation issues?
|
||||
|
||||
WillCauseReflow();
|
||||
WillDoReflow();
|
||||
|
||||
if (mPresContext) {
|
||||
nsRect r(0, 0, aWidth, aHeight);
|
||||
mPresContext->SetVisibleArea(r);
|
||||
}
|
||||
mPresContext->SetVisibleArea(nsRect(0, 0, aWidth, aHeight));
|
||||
|
||||
nsIContent *root = mDocument ? mDocument->GetRootContent() : nsnull;
|
||||
|
||||
@ -2519,79 +2511,19 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
||||
}
|
||||
|
||||
if (rootFrame) {
|
||||
MOZ_TIMER_DEBUGLOG(("Reset and start: Reflow: PresShell::InitialReflow(), this=%p\n",
|
||||
(void*)this));
|
||||
MOZ_TIMER_RESET(mReflowWatch);
|
||||
MOZ_TIMER_START(mReflowWatch);
|
||||
// Kick off a top-down reflow
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
||||
("enter nsPresShell::InitialReflow: %d,%d", aWidth, aHeight));
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrameDebug::GetVerifyTreeEnable()) {
|
||||
nsIFrameDebug* frameDebug;
|
||||
|
||||
if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),
|
||||
(void**)&frameDebug))) {
|
||||
frameDebug->VerifyTree();
|
||||
rootFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
||||
FrameNeedsReflow(rootFrame, eResize);
|
||||
mDirtyRoots.AppendElement(rootFrame);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef DEBUG_kipp
|
||||
nsPresShell_ReflowStackPointerTop = (char*) &aWidth;
|
||||
#endif
|
||||
nsRect bounds = mPresContext->GetVisibleArea();
|
||||
nsSize maxSize(bounds.width, bounds.height);
|
||||
nsHTMLReflowMetrics desiredSize;
|
||||
nsReflowStatus status;
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow);
|
||||
mIsReflowing = PR_TRUE;
|
||||
|
||||
nsHTMLReflowState reflowState(mPresContext, rootFrame, rcx, maxSize);
|
||||
rootFrame->WillReflow(mPresContext);
|
||||
nsContainerFrame::PositionFrameView(rootFrame);
|
||||
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SetSize(nsSize(desiredSize.width, desiredSize.height));
|
||||
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
|
||||
|
||||
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, rootFrame->GetView(),
|
||||
&desiredSize.mOverflowArea);
|
||||
rootFrame->DidReflow(mPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrameDebug::GetVerifyTreeEnable()) {
|
||||
nsIFrameDebug* frameDebug;
|
||||
|
||||
if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),
|
||||
(void**)&frameDebug))) {
|
||||
frameDebug->VerifyTree();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
NS_IF_RELEASE(rcx);
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::InitialReflow"));
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Reflow: PresShell::InitialReflow(), this=%p\n", (void*)this));
|
||||
MOZ_TIMER_STOP(mReflowWatch);
|
||||
|
||||
mIsReflowing = PR_FALSE;
|
||||
}
|
||||
|
||||
DidCauseReflow();
|
||||
DidDoReflow();
|
||||
|
||||
// Restore our root scroll position now if we're getting here after EndLoad
|
||||
// got called, since this is our one chance to do it.
|
||||
// got called, since this is our one chance to do it. Note that we need not
|
||||
// have reflowed for this to work; when the scrollframe is finally reflowed
|
||||
// it'll puick up the position we store in it here.
|
||||
if (!mDocumentLoading) {
|
||||
RestoreRootScrollPosition();
|
||||
}
|
||||
|
||||
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
if (mViewManager && mCaret && !mViewEventListener) {
|
||||
nsIScrollableView* scrollingView = nsnull;
|
||||
mViewManager->GetRootScrollableView(&scrollingView);
|
||||
@ -2682,7 +2614,6 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
||||
|
||||
mDirtyRoots.RemoveElement(rootFrame);
|
||||
DoReflow(rootFrame);
|
||||
mPresContext->SetVisibleArea(nsRect(nsPoint(0, 0), rootFrame->GetSize()));
|
||||
}
|
||||
|
||||
DidCauseReflow();
|
||||
@ -6155,8 +6086,10 @@ PresShell::DoReflow(nsIFrame* target)
|
||||
// fix the computed height
|
||||
NS_ASSERTION(reflowState.mComputedMargin == nsMargin(0, 0, 0, 0),
|
||||
"reflow state should not set margin for reflow roots");
|
||||
if (size.height != NS_UNCONSTRAINEDSIZE) {
|
||||
reflowState.mComputedHeight =
|
||||
size.height - reflowState.mComputedBorderPadding.TopBottom();
|
||||
}
|
||||
NS_ASSERTION(reflowState.ComputedWidth() ==
|
||||
size.width -
|
||||
reflowState.mComputedBorderPadding.LeftRight(),
|
||||
@ -6167,8 +6100,10 @@ PresShell::DoReflow(nsIFrame* target)
|
||||
target->Reflow(mPresContext, desiredSize, reflowState, status);
|
||||
|
||||
// If an incremental reflow is initiated at a frame other than the
|
||||
// root frame, then its desired size had better not change!
|
||||
NS_ASSERTION(target == rootFrame ||
|
||||
// root frame, then its desired size had better not change! If it's
|
||||
// initiated at the root, then the size better not change unless its
|
||||
// height was unconstrained to start with.
|
||||
NS_ASSERTION((target == rootFrame && size.height == NS_UNCONSTRAINEDSIZE) ||
|
||||
(desiredSize.width == size.width &&
|
||||
desiredSize.height == size.height),
|
||||
"non-root frame's desired size changed during an "
|
||||
@ -6187,6 +6122,10 @@ PresShell::DoReflow(nsIFrame* target)
|
||||
&desiredSize.mOverflowArea);
|
||||
|
||||
target->DidReflow(mPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
||||
if (target == rootFrame && size.height == NS_UNCONSTRAINEDSIZE) {
|
||||
mPresContext->SetVisibleArea(nsRect(0, 0, desiredSize.width,
|
||||
desiredSize.height));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -6249,8 +6188,9 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
|
||||
mDocument->BeginUpdate(UPDATE_ALL);
|
||||
mDocument->EndUpdate(UPDATE_ALL);
|
||||
|
||||
// That might have executed (via XBL binding constructors). So we may no
|
||||
// longer have reflow commands. In fact, we may have had Destroy() called.
|
||||
// That might have executed JS (via XBL binding constructors). So we may
|
||||
// no longer have reflow commands. In fact, we may have had Destroy()
|
||||
// called.
|
||||
|
||||
// Scope for the reflow entry point, in addition to the |if| condition.
|
||||
if (!mIsDestroying && mDirtyRoots.Count() != 0) {
|
||||
|
@ -521,12 +521,12 @@ PRBool
|
||||
nsHTMLScrollFrame::InInitialReflow() const
|
||||
{
|
||||
// We're in an initial reflow if NS_FRAME_FIRST_REFLOW is set, unless we're a
|
||||
// root scrollframe during a non-eager StartLayout call on the presshell. In
|
||||
// that case we want to skip this clause altogether.
|
||||
return
|
||||
(GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
|
||||
(!mInner.mIsRoot ||
|
||||
PresContext()->PresShell()->IsInEagerStartLayout());
|
||||
// root scrollframe. In that case we want to skip this clause altogether.
|
||||
// The guess here is that there are lots of overflow:auto divs out there that
|
||||
// end up auto-sizing so they don't overflow, and that the root basically
|
||||
// always needs a scrollbar if it did last time we loaded this page (good
|
||||
// assumption, because our initial reflow is no longer synchronous).
|
||||
return !mInner.mIsRoot && (GetStateBits() & NS_FRAME_FIRST_REFLOW);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1939,6 +1939,9 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Process the reflow event InitialReflow posted
|
||||
aPO->mPresShell->FlushPendingNotifications(Flush_OnlyReflow);
|
||||
|
||||
nsCOMPtr<nsIPresShell> displayShell;
|
||||
aPO->mDocShell->GetPresShell(getter_AddRefs(displayShell));
|
||||
// Transfer Selection Ranges to the new Print PresShell
|
||||
|
Loading…
Reference in New Issue
Block a user