Implement ReflowChild directly so that it uses nsIInlineFrame is available

This commit is contained in:
kipp 1998-06-09 17:40:21 +00:00
Родитель a276d8c409
Коммит 565dbd1fbe
3 изменённых файлов: 116 добавлений и 8 удалений

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

@ -69,6 +69,7 @@ public:
nsLineLayout* lineLayout; nsLineLayout* lineLayout;
PRBool atBreakPoint; PRBool atBreakPoint;
const nsReflowState& reflowState; const nsReflowState& reflowState;
PRBool mNoWrap;
// Constructor // Constructor
nsInlineState(nsIPresContext* aPresContext, nsInlineState(nsIPresContext* aPresContext,
@ -112,6 +113,7 @@ public:
ascents = ascentBuf; ascents = ascentBuf;
maxAscent = 0; maxAscent = 0;
maxDescent = 0; maxDescent = 0;
mNoWrap = PR_FALSE;
} }
void SetNumAscents(PRIntn aNumAscents) { void SetNumAscents(PRIntn aNumAscents) {
@ -162,6 +164,47 @@ nsInlineFrame::~nsInlineFrame()
{ {
} }
nsReflowStatus
nsInlineFrame::ReflowChild(nsInlineState& aState,
nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState)
{
nsReflowStatus status;
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
#ifdef NS_DEBUG
nsFrameState kidFrameState;
aKidFrame->GetFrameState(kidFrameState);
NS_ASSERTION(kidFrameState & NS_FRAME_IN_REFLOW, "kid frame is not in reflow");
#endif
nsIInlineFrame* iif;
if (NS_OK == aKidFrame->QueryInterface(kIInlineFrameIID, (void**)&iif)) {
iif->ReflowInline(*aState.lineLayout, aDesiredSize, aReflowState, status);
}
else {
aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState, status);
}
if (NS_FRAME_IS_COMPLETE(status)) {
nsIFrame* kidNextInFlow;
aKidFrame->GetNextInFlow(kidNextInFlow);
if (nsnull != kidNextInFlow) {
// Remove all of the childs next-in-flows. Make sure that we ask
// the right parent to do the removal (it's possible that the
// parent is not this because we are executing pullup code)
nsIFrame* parent;
aKidFrame->GetGeometricParent(parent);
DeleteNextInFlowsFor((nsContainerFrame*)parent, aKidFrame);
}
}
return status;
}
void nsInlineFrame::PlaceChild(nsIFrame* aChild, void nsInlineFrame::PlaceChild(nsIFrame* aChild,
PRInt32 aIndex, PRInt32 aIndex,
nsInlineState& aState, nsInlineState& aState,
@ -318,7 +361,7 @@ nsInlineFrame::ReflowMappedChildrenFrom(nsIPresContext* aPresContext,
PRBool room = CanFitChild(aPresContext, aState, kidFrame); PRBool room = CanFitChild(aPresContext, aState, kidFrame);
if (room) { if (room) {
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(aState, kidFrame, aPresContext, kidSize, kidReflowState);
} }
// Did the child fit? // Did the child fit?
@ -516,7 +559,7 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize); eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(aState, kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit? // Did the child fit?
if (!DidFitChild(aPresContext, aState, kidFrame, kidSize)) { if (!DidFitChild(aPresContext, aState, kidFrame, kidSize)) {
@ -777,7 +820,7 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize); eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize, nsReflowStatus status = ReflowChild(aState, kidFrame, aPresContext, kidSize,
kidReflowState); kidReflowState);
// Did the child fit? // Did the child fit?
@ -879,6 +922,8 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Font); mStyleContext->GetStyleData(eStyleStruct_Font);
const nsStyleSpacing* styleSpacing = (const nsStyleSpacing*) const nsStyleSpacing* styleSpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing); mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleText* styleText = (const nsStyleText*)
mStyleContext->GetStyleData(eStyleStruct_Text);
// Check for an overflow list // Check for an overflow list
if (eReflowReason_Incremental != aReflowState.reason) { if (eReflowReason_Incremental != aReflowState.reason) {
@ -893,6 +938,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
aReflowState, aDesiredSize.maxElementSize); aReflowState, aDesiredSize.maxElementSize);
InitializeState(aPresContext, aReflowState, state); InitializeState(aPresContext, aReflowState, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset); state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
state.mNoWrap = NS_STYLE_WHITESPACE_NORMAL != styleText->mWhiteSpace;
if (eReflowReason_Incremental == aReflowState.reason) { if (eReflowReason_Incremental == aReflowState.reason) {
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command"); NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
@ -928,7 +974,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
// Reflow the child into the available space // Reflow the child into the available space
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
aStatus = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); aStatus = ReflowChild(state, kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit? // Did the child fit?
if (!DidFitChild(aPresContext, state, kidFrame, kidSize)) { if (!DidFitChild(aPresContext, state, kidFrame, kidSize)) {
@ -1079,6 +1125,11 @@ nsInlineFrame::ComputeFinalSize(nsIPresContext* aPresContext,
aDesiredSize.height = aState.borderPadding.top + aState.mStyleSize.height + aDesiredSize.height = aState.borderPadding.top + aState.mStyleSize.height +
aState.borderPadding.bottom; aState.borderPadding.bottom;
} }
if ((nsnull != aDesiredSize.maxElementSize) && aState.mNoWrap) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

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

@ -91,6 +91,12 @@ protected:
nsInlineState& aState, nsInlineState& aState,
nsIFrame* aChildFrame, nsIFrame* aChildFrame,
PRInt32 aChildIndex); PRInt32 aChildIndex);
nsReflowStatus ReflowChild(nsInlineState& aState,
nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState);
}; };
#endif /* nsInlineFrame_h___ */ #endif /* nsInlineFrame_h___ */

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

@ -69,6 +69,7 @@ public:
nsLineLayout* lineLayout; nsLineLayout* lineLayout;
PRBool atBreakPoint; PRBool atBreakPoint;
const nsReflowState& reflowState; const nsReflowState& reflowState;
PRBool mNoWrap;
// Constructor // Constructor
nsInlineState(nsIPresContext* aPresContext, nsInlineState(nsIPresContext* aPresContext,
@ -112,6 +113,7 @@ public:
ascents = ascentBuf; ascents = ascentBuf;
maxAscent = 0; maxAscent = 0;
maxDescent = 0; maxDescent = 0;
mNoWrap = PR_FALSE;
} }
void SetNumAscents(PRIntn aNumAscents) { void SetNumAscents(PRIntn aNumAscents) {
@ -162,6 +164,47 @@ nsInlineFrame::~nsInlineFrame()
{ {
} }
nsReflowStatus
nsInlineFrame::ReflowChild(nsInlineState& aState,
nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState)
{
nsReflowStatus status;
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
#ifdef NS_DEBUG
nsFrameState kidFrameState;
aKidFrame->GetFrameState(kidFrameState);
NS_ASSERTION(kidFrameState & NS_FRAME_IN_REFLOW, "kid frame is not in reflow");
#endif
nsIInlineFrame* iif;
if (NS_OK == aKidFrame->QueryInterface(kIInlineFrameIID, (void**)&iif)) {
iif->ReflowInline(*aState.lineLayout, aDesiredSize, aReflowState, status);
}
else {
aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState, status);
}
if (NS_FRAME_IS_COMPLETE(status)) {
nsIFrame* kidNextInFlow;
aKidFrame->GetNextInFlow(kidNextInFlow);
if (nsnull != kidNextInFlow) {
// Remove all of the childs next-in-flows. Make sure that we ask
// the right parent to do the removal (it's possible that the
// parent is not this because we are executing pullup code)
nsIFrame* parent;
aKidFrame->GetGeometricParent(parent);
DeleteNextInFlowsFor((nsContainerFrame*)parent, aKidFrame);
}
}
return status;
}
void nsInlineFrame::PlaceChild(nsIFrame* aChild, void nsInlineFrame::PlaceChild(nsIFrame* aChild,
PRInt32 aIndex, PRInt32 aIndex,
nsInlineState& aState, nsInlineState& aState,
@ -318,7 +361,7 @@ nsInlineFrame::ReflowMappedChildrenFrom(nsIPresContext* aPresContext,
PRBool room = CanFitChild(aPresContext, aState, kidFrame); PRBool room = CanFitChild(aPresContext, aState, kidFrame);
if (room) { if (room) {
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(aState, kidFrame, aPresContext, kidSize, kidReflowState);
} }
// Did the child fit? // Did the child fit?
@ -516,7 +559,7 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize); eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); status = ReflowChild(aState, kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit? // Did the child fit?
if (!DidFitChild(aPresContext, aState, kidFrame, kidSize)) { if (!DidFitChild(aPresContext, aState, kidFrame, kidSize)) {
@ -777,7 +820,7 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
eReflowReason_Resize); eReflowReason_Resize);
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
nsReflowStatus status = ReflowChild(kidFrame, aPresContext, kidSize, nsReflowStatus status = ReflowChild(aState, kidFrame, aPresContext, kidSize,
kidReflowState); kidReflowState);
// Did the child fit? // Did the child fit?
@ -879,6 +922,8 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Font); mStyleContext->GetStyleData(eStyleStruct_Font);
const nsStyleSpacing* styleSpacing = (const nsStyleSpacing*) const nsStyleSpacing* styleSpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing); mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleText* styleText = (const nsStyleText*)
mStyleContext->GetStyleData(eStyleStruct_Text);
// Check for an overflow list // Check for an overflow list
if (eReflowReason_Incremental != aReflowState.reason) { if (eReflowReason_Incremental != aReflowState.reason) {
@ -893,6 +938,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
aReflowState, aDesiredSize.maxElementSize); aReflowState, aDesiredSize.maxElementSize);
InitializeState(aPresContext, aReflowState, state); InitializeState(aPresContext, aReflowState, state);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset); state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
state.mNoWrap = NS_STYLE_WHITESPACE_NORMAL != styleText->mWhiteSpace;
if (eReflowReason_Incremental == aReflowState.reason) { if (eReflowReason_Incremental == aReflowState.reason) {
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command"); NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
@ -928,7 +974,7 @@ NS_METHOD nsInlineFrame::Reflow(nsIPresContext* aPresContext,
// Reflow the child into the available space // Reflow the child into the available space
kidFrame->WillReflow(*aPresContext); kidFrame->WillReflow(*aPresContext);
aStatus = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); aStatus = ReflowChild(state, kidFrame, aPresContext, kidSize, kidReflowState);
// Did the child fit? // Did the child fit?
if (!DidFitChild(aPresContext, state, kidFrame, kidSize)) { if (!DidFitChild(aPresContext, state, kidFrame, kidSize)) {
@ -1079,6 +1125,11 @@ nsInlineFrame::ComputeFinalSize(nsIPresContext* aPresContext,
aDesiredSize.height = aState.borderPadding.top + aState.mStyleSize.height + aDesiredSize.height = aState.borderPadding.top + aState.mStyleSize.height +
aState.borderPadding.bottom; aState.borderPadding.bottom;
} }
if ((nsnull != aDesiredSize.maxElementSize) && aState.mNoWrap) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////