This commit is contained in:
kipp%netscape.com 1998-07-22 18:38:57 +00:00
Родитель 302ac6c6d4
Коммит 176c561856
5 изменённых файлов: 61 добавлений и 40 удалений

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

@ -1474,26 +1474,6 @@ nsCSSBlockFrame::ComputeFinalSize(nsCSSBlockReflowState& aState,
NS_ASSERTION(aDesiredRect.width < 1000000, "whoops");
}
// XXX move this somewhere else!!!
static PRBool
TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
const nsStylePosition* aPosition)
{
if (NS_STYLE_POSITION_ABSOLUTE == aPosition->mPosition) {
return PR_FALSE;
}
if (NS_STYLE_FLOAT_NONE != aDisplay->mFloats) {
return PR_FALSE;
}
switch (aDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
case NS_STYLE_DISPLAY_TABLE:
return PR_TRUE;
}
return PR_FALSE;
}
nsresult
nsCSSBlockFrame::InitialReflow(nsCSSBlockReflowState& aState)
{
@ -1680,7 +1660,8 @@ nsCSSBlockFrame::CreateNewFrames(nsIPresContext* aPresContext)
if (NS_OK != rv) {
return rv;
}
PRBool isBlock = TreatFrameAsBlock(kidDisplay, kidPosition);
PRBool isBlock =
nsCSSLineLayout::TreatFrameAsBlock(kidDisplay, kidPosition);
// If the child is an inline then add it to the lastLine (if it's
// an inline line, otherwise make a new line). If the child is a
@ -2001,7 +1982,7 @@ nsCSSBlockFrame::ReflowLine(nsCSSBlockReflowState& aState,
const nsStylePosition* position;
frame->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&) position);
PRBool isBlock = TreatFrameAsBlock(display, position);
PRBool isBlock = nsCSSLineLayout::TreatFrameAsBlock(display, position);
NS_ASSERTION(isBlock == aLine->IsBlock(), "bad line isBlock");
#endif
if (aLine->IsBlock()) {
@ -2586,7 +2567,7 @@ nsCSSBlockFrame::PullFrame(nsCSSBlockReflowState& aState,
const nsStylePosition* position;
frame->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&) position);
PRBool isBlock = TreatFrameAsBlock(display, position);
PRBool isBlock = nsCSSLineLayout::TreatFrameAsBlock(display, position);
NS_ASSERTION(isBlock == aLine->IsBlock(), "bad line isBlock");
#endif
}
@ -2987,9 +2968,10 @@ nsCSSBlockFrame::ContentInserted(nsIPresShell* aShell,
const nsStylePosition* position;
newFrame->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&) position);
PRUint16 newFrameIsBlock = TreatFrameAsBlock(display, position)
? LINE_IS_BLOCK
: 0;
PRUint16 newFrameIsBlock =
nsCSSLineLayout::TreatFrameAsBlock(display, position)
? LINE_IS_BLOCK
: 0;
// Insert/append the frame into flows line list at the right spot
LineData* newLine;

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

@ -122,6 +122,19 @@ nsCSSInlineLayout::ReflowAndPlaceFrame(nsIFrame* aFrame)
("nsCSSInlineLayout::ReflowAndPlaceFrame: frame=%p x=%d",
aFrame, mX));
// If the frame is a block frame and this is not the first frame on
// the line, we need to break before the block frame.
const nsStyleDisplay* kidDisplay;
aFrame->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&) kidDisplay);
const nsStylePosition* kidPosition;
aFrame->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&) kidPosition);
PRBool isBlock = nsCSSLineLayout::TreatFrameAsBlock(kidDisplay, kidPosition);
if (isBlock && !IsFirstChild()) {
return NS_INLINE_LINE_BREAK_BEFORE(0);/* XXX indicate never-reflowed? */
}
// Compute the maximum size of the frame. If there is no room at all
// for it, then trigger a line-break before the frame.
nsSize maxSize;
@ -187,7 +200,7 @@ nsCSSInlineLayout::ReflowAndPlaceFrame(nsIFrame* aFrame)
}
nsRect frameRect(mX, mY, metrics.width, metrics.height);
return PlaceFrame(aFrame, frameRect, metrics, margin, rs);
return PlaceFrame(aFrame, frameRect, metrics, margin, rs, isBlock);
}
// XXX RTL
@ -291,7 +304,8 @@ nsCSSInlineLayout::PlaceFrame(nsIFrame* aFrame,
nsRect& aFrameRect,
const nsReflowMetrics& aFrameMetrics,
const nsMargin& aFrameMargin,
nsInlineReflowStatus aFrameReflowStatus)
nsInlineReflowStatus aFrameReflowStatus,
PRBool aIsBlock)
{
nscoord horizontalMargins = 0;
@ -345,7 +359,7 @@ nsCSSInlineLayout::PlaceFrame(nsIFrame* aFrame,
aFrameRect.width, aFrameRect.height));
// XXX this is not right; the max-element-size of a child depends on
// it's margins which it doesn't know how to add in
// its margins which it doesn't know how to add in
// Fold in child's max-element-size information into our own
if (mComputeMaxElementSize) {
@ -369,6 +383,13 @@ nsCSSInlineLayout::PlaceFrame(nsIFrame* aFrame,
}
mFrameNum++;
if (aIsBlock) {
if (!NS_INLINE_IS_BREAK(aFrameReflowStatus)) {
aFrameReflowStatus =
NS_INLINE_LINE_BREAK_AFTER(aFrameReflowStatus & NS_FRAME_NOT_COMPLETE);
}
}
return aFrameReflowStatus;
}

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

@ -73,7 +73,8 @@ struct nsCSSInlineLayout {
nsRect& kidRect,
const nsReflowMetrics& kidMetrics,
const nsMargin& kidMargin,
nsInlineReflowStatus kidReflowStatus);
nsInlineReflowStatus kidReflowStatus,
PRBool aIsBlock);
nsresult MaybeCreateNextInFlow(nsIFrame* aFrame,
nsIFrame*& aNextInFlowResult);

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

@ -18,18 +18,9 @@
*/
#include "nsCSSLineLayout.h"
#include "nsCSSLayout.h"
#if 0
#include "nsIFontMetrics.h"
#include "nsIPresContext.h"
#include "nsIRunaround.h"
#include "nsStyleConsts.h"
#include "nsIStyleContext.h"
// XXX nsCSSIIDs.[h,cpp]
static NS_DEFINE_IID(kIInlineReflowIID, NS_IINLINE_REFLOW_IID);
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
#endif
void
nsCSSTextRun::List(FILE* out, PRInt32 aIndent)
{
@ -105,3 +96,23 @@ nsCSSLineLayout::AddText(nsIFrame* aTextFrame)
mNewTextRun->mArray.AppendElement(aTextFrame);
return NS_OK;/* XXX */
}
// XXX move this somewhere else!!!
PRBool
nsCSSLineLayout::TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
const nsStylePosition* aPosition)
{
if (NS_STYLE_POSITION_ABSOLUTE == aPosition->mPosition) {
return PR_FALSE;
}
if (NS_STYLE_FLOAT_NONE != aDisplay->mFloats) {
return PR_FALSE;
}
switch (aDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
case NS_STYLE_DISPLAY_TABLE:
return PR_TRUE;
}
return PR_FALSE;
}

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

@ -22,6 +22,9 @@
#include "nsIFrame.h"
#include "nsVoidArray.h"
struct nsStyleDisplay;
struct nsStylePosition;
// This structure represents a run of text. In mText are the
// nsIFrame's that are considered text frames.
struct nsCSSTextRun {
@ -91,6 +94,9 @@ public:
void AddFloater(nsIFrame* aFrame);
static PRBool TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
const nsStylePosition* aPosition);
nsIPresContext* mPresContext;
nsISpaceManager* mSpaceManager;