When reflowing a frame (such as text controls) that jumps from HTML layout into XUL layout and then jumps back to HTML on the child frame, link the parent reflow state chain correctly. (Bug 627842, patch 3) r=roc

This commit is contained in:
L. David Baron 2011-11-23 18:48:23 -08:00
parent 5aaee7d865
commit 4279e50916
4 changed files with 28 additions and 4 deletions

View File

@ -7509,8 +7509,21 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState,
// Construct the parent chain manually since constructing it normally // Construct the parent chain manually since constructing it normally
// messes up dimensions. // messes up dimensions.
const nsHTMLReflowState *outerReflowState = aState.OuterReflowState();
NS_ASSERTION(!outerReflowState || outerReflowState->frame != this,
"in and out of XUL on a single frame?");
if (outerReflowState && outerReflowState->frame == parentFrame) {
// We're a frame (such as a text control frame) that jumps into
// box reflow and then straight out of it on the child frame.
// This means we actually have a real parent reflow state.
// nsLayoutUtils::InflationMinFontSizeFor needs this to be linked
// up correctly for text control frames, so do so here).
reflowState.parentReflowState = outerReflowState;
reflowState.mCBReflowState = outerReflowState;
} else {
reflowState.parentReflowState = &parentReflowState; reflowState.parentReflowState = &parentReflowState;
reflowState.mCBReflowState = &parentReflowState; reflowState.mCBReflowState = &parentReflowState;
}
reflowState.mReflowDepth = aState.GetReflowDepth(); reflowState.mReflowDepth = aState.GetReflowDepth();
// mComputedWidth and mComputedHeight are content-box, not // mComputedWidth and mComputedHeight are content-box, not

View File

@ -676,7 +676,7 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
// create the layout state // create the layout state
nsBoxLayoutState state(aPresContext, aReflowState.rendContext, nsBoxLayoutState state(aPresContext, aReflowState.rendContext,
aReflowState.mReflowDepth); &aReflowState, aReflowState.mReflowDepth);
nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.ComputedHeight()); nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.ComputedHeight());

View File

@ -46,9 +46,11 @@
nsBoxLayoutState::nsBoxLayoutState(nsPresContext* aPresContext, nsBoxLayoutState::nsBoxLayoutState(nsPresContext* aPresContext,
nsRenderingContext* aRenderingContext, nsRenderingContext* aRenderingContext,
const nsHTMLReflowState* aOuterReflowState,
PRUint16 aReflowDepth) PRUint16 aReflowDepth)
: mPresContext(aPresContext) : mPresContext(aPresContext)
, mRenderingContext(aRenderingContext) , mRenderingContext(aRenderingContext)
, mOuterReflowState(aOuterReflowState)
, mLayoutFlags(0) , mLayoutFlags(0)
, mReflowDepth(aReflowDepth) , mReflowDepth(aReflowDepth)
, mPaintingDisabled(false) , mPaintingDisabled(false)
@ -59,6 +61,7 @@ nsBoxLayoutState::nsBoxLayoutState(nsPresContext* aPresContext,
nsBoxLayoutState::nsBoxLayoutState(const nsBoxLayoutState& aState) nsBoxLayoutState::nsBoxLayoutState(const nsBoxLayoutState& aState)
: mPresContext(aState.mPresContext) : mPresContext(aState.mPresContext)
, mRenderingContext(aState.mRenderingContext) , mRenderingContext(aState.mRenderingContext)
, mOuterReflowState(aState.mOuterReflowState)
, mLayoutFlags(aState.mLayoutFlags) , mLayoutFlags(aState.mLayoutFlags)
, mReflowDepth(aState.mReflowDepth + 1) , mReflowDepth(aState.mReflowDepth + 1)
, mPaintingDisabled(aState.mPaintingDisabled) , mPaintingDisabled(aState.mPaintingDisabled)

View File

@ -59,7 +59,10 @@ class nsHTMLReflowCommand;
class NS_STACK_CLASS nsBoxLayoutState class NS_STACK_CLASS nsBoxLayoutState
{ {
public: public:
nsBoxLayoutState(nsPresContext* aPresContext, nsRenderingContext* aRenderingContext = nsnull, nsBoxLayoutState(nsPresContext* aPresContext,
nsRenderingContext* aRenderingContext = nsnull,
// see OuterReflowState() below
const nsHTMLReflowState* aOuterReflowState = nsnull,
PRUint16 aReflowDepth = 0) NS_HIDDEN; PRUint16 aReflowDepth = 0) NS_HIDDEN;
nsBoxLayoutState(const nsBoxLayoutState& aState) NS_HIDDEN; nsBoxLayoutState(const nsBoxLayoutState& aState) NS_HIDDEN;
@ -84,11 +87,16 @@ public:
void* AllocateStackMemory(size_t aSize) void* AllocateStackMemory(size_t aSize)
{ return PresShell()->AllocateStackMemory(aSize); } { return PresShell()->AllocateStackMemory(aSize); }
// The HTML reflow state that lives outside the box-block boundary.
// May not be set reliably yet.
const nsHTMLReflowState* OuterReflowState() { return mOuterReflowState; }
PRUint16 GetReflowDepth() { return mReflowDepth; } PRUint16 GetReflowDepth() { return mReflowDepth; }
private: private:
nsRefPtr<nsPresContext> mPresContext; nsRefPtr<nsPresContext> mPresContext;
nsRenderingContext *mRenderingContext; nsRenderingContext *mRenderingContext;
const nsHTMLReflowState *mOuterReflowState;
PRUint32 mLayoutFlags; PRUint32 mLayoutFlags;
PRUint16 mReflowDepth; PRUint16 mReflowDepth;
bool mPaintingDisabled; bool mPaintingDisabled;