1998-09-15 04:19:49 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS"
|
|
|
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
* the License for the specific language governing rights and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
|
|
* Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
*/
|
1998-11-16 20:11:12 +03:00
|
|
|
#include "nsBlockFrame.h"
|
1998-12-05 19:02:08 +03:00
|
|
|
#include "nsBlockReflowContext.h"
|
1998-12-09 00:43:15 +03:00
|
|
|
#include "nsBlockBandData.h"
|
1998-12-05 19:02:08 +03:00
|
|
|
#include "nsBulletFrame.h"
|
|
|
|
#include "nsLineBox.h"
|
|
|
|
|
1998-09-24 00:10:40 +04:00
|
|
|
#include "nsFrameReflowState.h"
|
1998-09-15 04:19:49 +04:00
|
|
|
#include "nsLineLayout.h"
|
1998-09-23 06:25:26 +04:00
|
|
|
#include "nsInlineReflow.h"
|
1998-09-29 03:24:37 +04:00
|
|
|
#include "nsAbsoluteFrame.h"
|
1998-09-15 04:19:49 +04:00
|
|
|
#include "nsPlaceholderFrame.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIReflowCommand.h"
|
1998-09-24 00:10:40 +04:00
|
|
|
#include "nsISpaceManager.h"
|
1998-09-15 04:19:49 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
1998-09-23 06:25:26 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsHTMLValue.h"
|
1998-11-15 00:01:26 +03:00
|
|
|
#include "nsDOMEvent.h"
|
1998-09-24 00:10:40 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-11-15 00:01:26 +03:00
|
|
|
#include "prprf.h"
|
1998-12-09 08:30:17 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-11-05 22:33:01 +03:00
|
|
|
// XXX temporary for :first-letter support
|
|
|
|
#include "nsITextContent.h"
|
|
|
|
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);/* XXX */
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
#undef NOISY_FIRST_LINE
|
|
|
|
#undef REALLY_NOISY_FIRST_LINE
|
1998-11-15 00:01:26 +03:00
|
|
|
#undef NOISY_FIRST_LETTER
|
1998-11-09 20:54:37 +03:00
|
|
|
#undef NOISY_MAX_ELEMENT_SIZE
|
1998-11-11 06:55:55 +03:00
|
|
|
#undef NOISY_RUNIN
|
1998-11-18 01:28:51 +03:00
|
|
|
#undef NOISY_FLOATER_CLEARING
|
1998-12-05 19:02:08 +03:00
|
|
|
#undef NOISY_INCREMENTAL_REFLOW
|
|
|
|
#undef REFLOW_STATUS_COVERAGE
|
1998-11-05 22:33:01 +03:00
|
|
|
#else
|
|
|
|
#undef NOISY_FIRST_LINE
|
1998-11-09 20:54:37 +03:00
|
|
|
#undef REALLY_NOISY_FIRST_LINE
|
1998-11-12 19:32:56 +03:00
|
|
|
#undef NOISY_FIRST_LETTER
|
1998-11-09 20:54:37 +03:00
|
|
|
#undef NOISY_MAX_ELEMENT_SIZE
|
1998-11-11 06:55:55 +03:00
|
|
|
#undef NOISY_RUNIN
|
1998-11-18 01:28:51 +03:00
|
|
|
#undef NOISY_FLOATER_CLEARING
|
1998-12-05 19:02:08 +03:00
|
|
|
#undef NOISY_INCREMENTAL_REFLOW
|
|
|
|
#undef REFLOW_STATUS_COVERAGE
|
1998-11-05 22:33:01 +03:00
|
|
|
#endif
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//----------------------------------------------------------------------
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Debugging support code
|
|
|
|
|
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
static PRInt32 gNoiseIndent;
|
|
|
|
static const char* kReflowCommandType[] = {
|
|
|
|
"FrameAppended",
|
|
|
|
"FrameInserted",
|
|
|
|
"FrameRemoved",
|
|
|
|
"ContentChanged",
|
|
|
|
"StyleChanged",
|
|
|
|
"PullupReflow",
|
|
|
|
"PushReflow",
|
|
|
|
"CheckPullupReflow",
|
|
|
|
"UserDefined",
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REALLY_NOISY_FIRST_LINE
|
|
|
|
static void
|
|
|
|
DumpStyleGeneaology(nsIFrame* aFrame, const char* gap)
|
|
|
|
{
|
|
|
|
fputs(gap, stdout);
|
|
|
|
aFrame->ListTag(stdout);
|
|
|
|
fputs(name, out);
|
|
|
|
printf(": ");
|
|
|
|
nsIStyleContext* sc;
|
|
|
|
aFrame->GetStyleContext(sc);
|
|
|
|
while (nsnull != sc) {
|
|
|
|
nsIStyleContext* psc;
|
|
|
|
printf("%p ", sc);
|
|
|
|
psc = sc->GetParent();
|
|
|
|
NS_RELEASE(sc);
|
|
|
|
sc = psc;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
static void
|
|
|
|
VerifyLineLength(nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
PRInt32 n = aLine->mChildCount;
|
|
|
|
while (--n >= 0) {
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REFLOW_STATUS_COVERAGE
|
|
|
|
static void
|
|
|
|
RecordReflowStatus(PRBool aIsBlock,
|
|
|
|
PRBool aChildIsBlock,
|
|
|
|
nsReflowStatus aFrameReflowStatus)
|
|
|
|
{
|
|
|
|
static PRUint32 record[4];
|
|
|
|
|
|
|
|
// 0: is-block,child-is-block
|
|
|
|
// 1: is-block,child-is-inline
|
|
|
|
// 2: is-inline,child-is-block
|
|
|
|
// 3: is-inline,child-is-inline
|
|
|
|
PRIntn index = 0;
|
|
|
|
if (!aChildIsBlock) index |= 1;
|
|
|
|
if (!aIsBlock) index |= 2;
|
|
|
|
|
|
|
|
// Compute new status
|
|
|
|
PRUint32 newS = record[index];
|
|
|
|
if (NS_INLINE_IS_BREAK(aFrameReflowStatus)) {
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus)) {
|
|
|
|
newS |= 1;
|
|
|
|
}
|
|
|
|
else if (NS_FRAME_IS_NOT_COMPLETE(aFrameReflowStatus)) {
|
|
|
|
newS |= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newS |= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NS_FRAME_IS_NOT_COMPLETE(aFrameReflowStatus)) {
|
|
|
|
newS |= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newS |= 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Log updates to the status that yield different values
|
|
|
|
if (record[index] != newS) {
|
|
|
|
record[index] = newS;
|
|
|
|
printf("record(%d): %02x %02x %02x %02x\n", index,
|
|
|
|
record[0], record[1], record[2], record[3]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsBlockReflowState : public nsFrameReflowState {
|
|
|
|
public:
|
1998-09-24 00:10:40 +04:00
|
|
|
nsBlockReflowState(nsIPresContext& aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-12-05 19:02:08 +03:00
|
|
|
const nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsLineLayout* aLineLayout);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
|
|
|
~nsBlockReflowState();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the mCurrentBand data based on the current mY position.
|
|
|
|
*/
|
|
|
|
void GetAvailableSpace();
|
|
|
|
|
1998-11-10 21:03:29 +03:00
|
|
|
void InitFloater(nsPlaceholderFrame* aPlaceholderFrame);
|
|
|
|
|
1998-09-24 00:10:40 +04:00
|
|
|
void AddFloater(nsPlaceholderFrame* aPlaceholderFrame);
|
|
|
|
|
1998-10-10 02:58:25 +04:00
|
|
|
void PlaceFloater(nsPlaceholderFrame* aFloater, PRBool& aIsLeftFloater);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-11-05 22:33:01 +03:00
|
|
|
void PlaceFloaters(nsVoidArray* aFloaters, PRBool aAllOfThem);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void ClearFloaters(nscoord aY, PRUint8 aBreakType);
|
|
|
|
|
1998-09-24 00:10:40 +04:00
|
|
|
PRBool IsLeftMostChild(nsIFrame* aFrame);
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool IsAdjacentWithTop() const {
|
|
|
|
return mY == mBorderPadding.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool ShouldApplyTopMargin() const {
|
|
|
|
return mIsMarginRoot || !IsAdjacentWithTop();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLineLayout* mLineLayout;
|
1998-09-24 00:10:40 +04:00
|
|
|
nsInlineReflow* mInlineReflow;
|
|
|
|
|
|
|
|
nsISpaceManager* mSpaceManager;
|
1998-09-28 22:50:59 +04:00
|
|
|
nscoord mSpaceManagerX, mSpaceManagerY;
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame* mBlock;
|
|
|
|
nsBaseIBFrame* mNextInFlow;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsReflowStatus mReflowStatus;
|
|
|
|
PRBool mLimitToOneLine;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame* mRunInFromFrame;
|
|
|
|
nsBaseIBFrame* mRunInToFrame;
|
1998-11-11 06:55:55 +03:00
|
|
|
|
1998-09-24 00:10:40 +04:00
|
|
|
PRUint8 mTextAlign;
|
1998-11-01 01:53:00 +03:00
|
|
|
|
|
|
|
PRUintn mPrevMarginFlags;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
|
|
|
nscoord mBottomEdge; // maximum Y
|
|
|
|
|
|
|
|
PRBool mUnconstrainedWidth;
|
|
|
|
PRBool mUnconstrainedHeight;
|
|
|
|
nscoord mY;
|
|
|
|
nscoord mKidXMost;
|
1998-12-05 19:02:08 +03:00
|
|
|
nscoord mAscent, mDescent;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Previous child. This is used when pulling up a frame to update
|
|
|
|
// the sibling list.
|
1998-09-24 00:10:40 +04:00
|
|
|
nsIFrame* mPrevChild;
|
|
|
|
|
|
|
|
nsVoidArray mPendingFloaters;
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsLineBox* mCurrentLine;
|
|
|
|
nsLineBox* mPrevLine;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
|
|
|
// The next list ordinal for counting list bullets
|
|
|
|
PRInt32 mNextListOrdinal;
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockBandData mCurrentBand;
|
1998-12-09 00:43:15 +03:00
|
|
|
nsRect mAvailSpaceRect;
|
1998-09-24 00:10:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// XXX This is vile. Make it go away
|
|
|
|
void
|
1998-11-10 21:03:29 +03:00
|
|
|
nsLineLayout::InitFloater(nsPlaceholderFrame* aFrame)
|
|
|
|
{
|
|
|
|
mBlockReflowState->InitFloater(aFrame);
|
|
|
|
}
|
|
|
|
void
|
1998-09-24 00:10:40 +04:00
|
|
|
nsLineLayout::AddFloater(nsPlaceholderFrame* aFrame)
|
|
|
|
{
|
|
|
|
mBlockReflowState->AddFloater(aFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsLineLayout* aLineLayout)
|
|
|
|
: nsFrameReflowState(aPresContext, aReflowState, aMetrics)
|
1998-11-15 00:01:26 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
mInlineReflow = nsnull;
|
1998-11-15 00:01:26 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mLineLayout = aLineLayout;
|
1998-11-15 00:01:26 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mSpaceManager = aReflowState.spaceManager;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Translate into our content area and then save the
|
|
|
|
// coordinate system origin for later.
|
|
|
|
mSpaceManager->Translate(mBorderPadding.left, mBorderPadding.top);
|
|
|
|
mSpaceManager->GetTranslation(mSpaceManagerX, mSpaceManagerY);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mReflowStatus = NS_FRAME_COMPLETE;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mPresContext = aPresContext;
|
|
|
|
mBlock = (nsBaseIBFrame*) frame;
|
|
|
|
mBlock->GetNextInFlow((nsIFrame*&)mNextInFlow);
|
|
|
|
mKidXMost = 0;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mLimitToOneLine = PR_FALSE;
|
|
|
|
if (BLOCK_IS_INLINE & mBlock->mFlags) {
|
|
|
|
mLimitToOneLine = PR_TRUE;
|
|
|
|
#if XXX_fix_me
|
|
|
|
// XXX The issue here is that we want to allow an inline frame
|
|
|
|
// that contains several blocks to not be split across each
|
|
|
|
// block. Otherwise things like run-in and compact won't work
|
|
|
|
// right.
|
|
|
|
if ((nsnull == lineLayout) || (0 != lineLayout->GetPlacedFrames())) {
|
|
|
|
// When the inline frame is in a line-layout situation and it's
|
|
|
|
// not the first placed frame on the line then it needs to limit
|
|
|
|
// itself to one line.
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mRunInFromFrame = nsnull;
|
|
|
|
mRunInToFrame = nsnull;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mY = mAscent = mDescent = 0;
|
|
|
|
mUnconstrainedWidth = maxSize.width == NS_UNCONSTRAINEDSIZE;
|
|
|
|
mUnconstrainedHeight = maxSize.height == NS_UNCONSTRAINEDSIZE;
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
if (!mUnconstrainedWidth && (maxSize.width > 100000)) {
|
|
|
|
mBlock->ListTag(stdout);
|
|
|
|
printf(": bad parent: maxSize WAS %d,%d\n",
|
|
|
|
maxSize.width, maxSize.height);
|
1998-12-11 18:49:07 +03:00
|
|
|
if (maxSize.width > 100000) {
|
|
|
|
maxSize.width = NS_UNCONSTRAINEDSIZE;
|
|
|
|
mUnconstrainedWidth = PR_TRUE;
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
if (!mUnconstrainedHeight && (maxSize.height > 100000)) {
|
|
|
|
mBlock->ListTag(stdout);
|
|
|
|
printf(": bad parent: maxSize WAS %d,%d\n",
|
|
|
|
maxSize.width, maxSize.height);
|
1998-12-11 18:49:07 +03:00
|
|
|
if (maxSize.height > 100000) {
|
|
|
|
maxSize.height = NS_UNCONSTRAINEDSIZE;
|
|
|
|
mUnconstrainedHeight = PR_TRUE;
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
#endif
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mTextAlign = mStyleText->mTextAlign;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nscoord lr = mBorderPadding.left + mBorderPadding.right;
|
|
|
|
mY = mBorderPadding.top;
|
|
|
|
if (eHTMLFrameConstraint_FixedContent == widthConstraint) {
|
|
|
|
// The CSS2 spec says that the width attribute defines the width
|
|
|
|
// of the "content area" which does not include the border
|
|
|
|
// padding. So we add those back in.
|
|
|
|
mBorderArea.width = minWidth + lr;
|
|
|
|
mContentArea.width = minWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (mUnconstrainedWidth) {
|
|
|
|
mBorderArea.width = NS_UNCONSTRAINEDSIZE;
|
|
|
|
mContentArea.width = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mBorderArea.width = maxSize.width;
|
|
|
|
mContentArea.width = maxSize.width - lr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mBorderArea.height = maxSize.height;
|
|
|
|
mContentArea.height = maxSize.height;
|
|
|
|
mBottomEdge = maxSize.height;
|
|
|
|
if (!mUnconstrainedHeight) {
|
|
|
|
mBottomEdge -= mBorderPadding.bottom;
|
|
|
|
}
|
1998-12-09 00:43:15 +03:00
|
|
|
mCurrentBand.Init(mSpaceManager, mContentArea);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
mPrevChild = nsnull;
|
|
|
|
mPrevLine = nsnull;
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockReflowState::~nsBlockReflowState()
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Restore the coordinate system
|
|
|
|
mSpaceManager->Translate(-mBorderPadding.left, -mBorderPadding.top);
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get the available reflow space for the current y coordinate. The
|
|
|
|
// available space is relative to our coordinate system (0,0) is our
|
|
|
|
// upper left corner.
|
|
|
|
void
|
|
|
|
nsBlockReflowState::GetAvailableSpace()
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsISpaceManager* sm = mSpaceManager;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
// Verify that the caller setup the coordinate system properly
|
|
|
|
nscoord wx, wy;
|
|
|
|
sm->GetTranslation(wx, wy);
|
|
|
|
NS_ASSERTION((wx == mSpaceManagerX) && (wy == mSpaceManagerY),
|
|
|
|
"bad coord system");
|
|
|
|
#endif
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-09 00:43:15 +03:00
|
|
|
mCurrentBand.GetAvailableSpace(mY - mBorderPadding.top, mAvailSpaceRect);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBlockReflowState::GetAvailableSpace: band={%d,%d,%d,%d} count=%d",
|
1998-12-09 00:43:15 +03:00
|
|
|
mAvailSpaceRect.x, mAvailSpaceRect.y,
|
|
|
|
mAvailSpaceRect.width, mAvailSpaceRect.height,
|
|
|
|
mCurrentBand.GetTrapezoidCount()));
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (reason == eReflowReason_Incremental) {
|
|
|
|
nsFrame::IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("GetAvailableSpace: band=%d,%d,%d,%d count=%d\n",
|
1998-12-09 00:43:15 +03:00
|
|
|
mAvailSpaceRect.x, mAvailSpaceRect.y,
|
|
|
|
mAvailSpaceRect.width, mAvailSpaceRect.height,
|
|
|
|
mCurrentBand.GetTrapezoidCount());
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//----------------------------------------------------------------------
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/* 52b33130-0b99-11d2-932e-00805f8add32 */
|
|
|
|
#define NS_BLOCK_FRAME_CID \
|
|
|
|
{ 0x52b33130, 0x0b99, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
static const nsIID kBlockFrameCID = NS_BLOCK_FRAME_CID;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::nsBaseIBFrame()
|
|
|
|
{
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::~nsBaseIBFrame()
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::DeleteFrame(nsIPresContext& aPresContext)
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsLineBox::DeleteLineList(aPresContext, mLines);
|
|
|
|
nsLineBox::DeleteLineList(aPresContext, mOverflowLines);
|
|
|
|
return nsBaseIBFrameSuper::DeleteFrame(aPresContext);
|
|
|
|
}
|
1998-09-27 00:05:09 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return nsBaseIBFrameSuper::QueryInterface(aIID, aInstancePtr);
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
return AppendNewFrames(aPresContext, aChildList);
|
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-09-26 22:36:01 +04:00
|
|
|
static nsresult
|
1998-12-05 19:02:08 +03:00
|
|
|
ReResolveLineList(nsIPresContext* aPresContext,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIStyleContext* aStyleContext)
|
1998-09-26 22:36:01 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
1998-12-05 19:02:08 +03:00
|
|
|
while (nsnull != aLine) {
|
|
|
|
nsIFrame* child = aLine->mFirstChild;
|
|
|
|
PRInt32 n = aLine->mChildCount;
|
|
|
|
while ((--n >= 0) && NS_SUCCEEDED(rv)) {
|
|
|
|
rv = child->ReResolveStyleContext(aPresContext, aStyleContext);
|
|
|
|
child->GetNextSibling(child);
|
1998-09-26 22:36:01 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aLine = aLine->mNext;
|
1998-09-26 22:36:01 +04:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
|
|
|
|
nsIStyleContext* aParentContext)
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIStyleContext* oldContext = mStyleContext;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// NOTE: using nsFrame's ReResolveStyleContext method to avoid useless
|
|
|
|
// version in nsContainerFrame
|
|
|
|
nsresult rv = nsFrame::ReResolveStyleContext(aPresContext, aParentContext);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (oldContext != mStyleContext) {
|
|
|
|
if (nsnull != mLines) {
|
|
|
|
rv = ReResolveLineList(aPresContext, mLines, mStyleContext);
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != mOverflowLines)) {
|
|
|
|
rv = ReResolveLineList(aPresContext, mOverflowLines, mStyleContext);
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != mPrevInFlow)) {
|
|
|
|
nsLineBox* lines = ((nsBaseIBFrame*)mPrevInFlow)->mOverflowLines;
|
|
|
|
if (nsnull != lines) {
|
|
|
|
rv = ReResolveLineList(aPresContext, lines, mStyleContext);
|
|
|
|
}
|
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return rv;
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::IsSplittable(nsSplittableType& aIsSplittable) const
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
aIsSplittable = NS_FRAME_SPLITTABLE_NON_RECTANGULAR;
|
1998-10-03 08:28:05 +04:00
|
|
|
return NS_OK;
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsBaseIBFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
|
|
|
{
|
|
|
|
// if a filter is present, only output this frame if the filter says
|
|
|
|
// we should
|
|
|
|
nsAutoString tagString;
|
|
|
|
if (nsnull != mContent) {
|
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (tag != nsnull) {
|
|
|
|
tag->ToString(tagString);
|
|
|
|
NS_RELEASE(tag);
|
|
|
|
}
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool outputMe = (nsnull == aFilter) || aFilter->OutputTag(&tagString);
|
|
|
|
if (outputMe) {
|
|
|
|
// Indent
|
|
|
|
IndentBy(stdout, aIndent);
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the tag
|
|
|
|
ListTag(out);
|
|
|
|
nsIView* view;
|
|
|
|
GetView(view);
|
|
|
|
if (nsnull != view) {
|
|
|
|
fprintf(out, " [view=%p]", view);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the flow linkage
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
fprintf(out, " prev-in-flow=%p", mPrevInFlow);
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
fprintf(out, " next-in-flow=%p", mNextInFlow);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the rect and state
|
|
|
|
out << mRect;
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
fputs("<\n", out);
|
|
|
|
aIndent++;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the lines
|
|
|
|
if (nsnull != mLines) {
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
line->List(out, aIndent, aFilter, outputMe);
|
|
|
|
line = line->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the text-runs
|
|
|
|
if (outputMe) {
|
|
|
|
aIndent--;
|
|
|
|
IndentBy(stdout, aIndent);
|
|
|
|
fputs(">\n", out);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const
|
|
|
|
{
|
|
|
|
if (nsnull == aListName) {
|
|
|
|
aFirstChild = (nsnull != mLines) ? mLines->mFirstChild : nsnull;
|
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aFirstChild = nsnull;
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Reflow methods
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsBaseIBFrame::Reflow: maxSize=%d,%d reason=%d",
|
|
|
|
aReflowState.maxSize.width,
|
|
|
|
aReflowState.maxSize.height,
|
|
|
|
aReflowState.reason));
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX subclass!
|
|
|
|
// Replace parent provided reflow state with our own significantly
|
|
|
|
// more extensive version.
|
|
|
|
nsLineLayout ll(aPresContext, aReflowState.spaceManager);
|
|
|
|
nsLineLayout* lineLayout = ≪
|
|
|
|
if (BLOCK_IS_INLINE & mFlags) {
|
|
|
|
// Use parent's line-layout
|
|
|
|
lineLayout = aReflowState.lineLayout;
|
|
|
|
if (nsnull == lineLayout) {
|
|
|
|
// If parent didn't provide, we will use our own. Note: this
|
|
|
|
// will not lead to correct reflow behavior, but at least we
|
|
|
|
// won't crash!
|
|
|
|
lineLayout = ≪
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsBlockReflowState state(aPresContext, aReflowState, aMetrics, lineLayout);
|
|
|
|
if (NS_BODY_THE_BODY & mFlags) {
|
|
|
|
// Because we use padding to provide some empty space around the
|
|
|
|
// outside of the html body, we need to disable margin application
|
|
|
|
// at the top and bottom.
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX revisit this when the HTML element is no longer the root of
|
|
|
|
// the frame tree
|
|
|
|
state.mIsMarginRoot = PR_FALSE;
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
if (lineLayout == &ll) {
|
|
|
|
lineLayout->Init(&state);
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Prepare inline-reflow engine
|
|
|
|
nsInlineReflow inlineReflow(*lineLayout, state, this,
|
|
|
|
(0 == (BLOCK_IS_INLINE & mFlags)));
|
|
|
|
state.mInlineReflow = &inlineReflow;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Note: If this is an inline frame, then we are pushing our
|
|
|
|
// subordinate inline reflow on the parent line-layout's stack.
|
|
|
|
lineLayout->PushInline(&inlineReflow);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIFrame* target;
|
|
|
|
switch (state.reason) {
|
|
|
|
case eReflowReason_Initial:
|
|
|
|
rv = PrepareInitialReflow(state);
|
|
|
|
mState &= ~NS_FRAME_FIRST_REFLOW;
|
|
|
|
break;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
case eReflowReason_Incremental:
|
|
|
|
state.reflowCommand->GetTarget(target);
|
|
|
|
if (this == target) {
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
state.reflowCommand->GetType(type);
|
|
|
|
switch (type) {
|
|
|
|
case nsIReflowCommand::FrameAppended:
|
|
|
|
rv = PrepareFrameAppendedReflow(state);
|
|
|
|
break;
|
|
|
|
case nsIReflowCommand::FrameInserted:
|
|
|
|
rv = PrepareFrameInsertedReflow(state);
|
|
|
|
break;
|
|
|
|
case nsIReflowCommand::FrameRemoved:
|
|
|
|
rv = PrepareFrameRemovedReflow(state);
|
|
|
|
break;
|
|
|
|
case nsIReflowCommand::StyleChanged:
|
|
|
|
rv = PrepareStyleChangedReflow(state);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Map any other incremental operations into full reflows
|
|
|
|
rv = PrepareResizeReflow(state);
|
|
|
|
break;
|
|
|
|
}
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// Get next frame in reflow command chain
|
|
|
|
state.reflowCommand->GetNext(state.mNextRCFrame);
|
1998-10-06 04:38:56 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now do the reflow
|
|
|
|
rv = PrepareChildIncrementalReflow(state);
|
1998-10-17 00:22:39 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Resize:
|
|
|
|
default:
|
|
|
|
DrainOverflowLines();
|
|
|
|
rv = PrepareResizeReflow(state);
|
|
|
|
break;
|
1998-10-17 00:22:39 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now reflow...
|
|
|
|
rv = ReflowDirtyLines(state);
|
|
|
|
aStatus = state.mReflowStatus;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute our final size
|
|
|
|
ComputeFinalSize(state, aMetrics);
|
|
|
|
lineLayout->PopInline();
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsBaseIBFrame::Reflow: size=%d,%d reflowStatus=%d rv=%x",
|
|
|
|
aMetrics.width, aMetrics.height, aStatus, rv));
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX make this virtual
|
1998-12-08 01:28:55 +03:00
|
|
|
// XXX factor into its component pieces
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX handle floater problems this way...
|
|
|
|
PRBool isFixedWidth =
|
|
|
|
eHTMLFrameConstraint_FixedContent == aState.widthConstraint;
|
|
|
|
PRBool isFixedHeight =
|
|
|
|
eHTMLFrameConstraint_FixedContent == aState.heightConstraint;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#if 0
|
|
|
|
if (NS_BODY_SHRINK_WRAP & mFlags) {
|
|
|
|
isFixedWidth = PR_FALSE;
|
|
|
|
isFixedHeight = PR_FALSE;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute final width
|
|
|
|
if (isFixedWidth) {
|
|
|
|
// Use style defined width
|
|
|
|
aMetrics.width = aState.mBorderPadding.left +
|
|
|
|
aState.minWidth + aState.mBorderPadding.right;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
nscoord computedWidth = aState.mKidXMost + aState.mBorderPadding.right;
|
|
|
|
PRBool compact = PR_FALSE;
|
|
|
|
if (NS_STYLE_DISPLAY_COMPACT == aState.mStyleDisplay->mDisplay) {
|
|
|
|
// If we are display: compact AND we have no lines or we have
|
|
|
|
// exactly one line and that line is not a block line AND that
|
|
|
|
// line doesn't end in a BR of any sort THEN we remain a compact
|
|
|
|
// frame.
|
|
|
|
if ((nsnull == mLines) ||
|
|
|
|
((nsnull == mLines->mNext) && !mLines->IsBlock() &&
|
|
|
|
(NS_STYLE_CLEAR_NONE == mLines->mBreakType) &&
|
|
|
|
(computedWidth <= aState.mCompactMarginWidth))) {
|
|
|
|
compact = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// There are two options here. We either shrink wrap around our
|
|
|
|
// contents or we fluff out to the maximum available width. Note:
|
|
|
|
// We always shrink wrap when given an unconstrained width.
|
|
|
|
if ((0 == (NS_BODY_SHRINK_WRAP & mFlags)) &&
|
|
|
|
!aState.mUnconstrainedWidth &&
|
|
|
|
!compact) {
|
|
|
|
// Fluff out to the max width if we aren't already that wide
|
|
|
|
if (0 == (BLOCK_IS_INLINE & mFlags)) {
|
|
|
|
if (computedWidth < aState.maxSize.width) {
|
|
|
|
computedWidth = aState.maxSize.width;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aMetrics.width = computedWidth;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute final height
|
|
|
|
if (isFixedHeight) {
|
|
|
|
// Use style defined height
|
|
|
|
aMetrics.height = aState.mBorderPadding.top +
|
|
|
|
aState.minHeight + aState.mBorderPadding.bottom;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// Shrink wrap our height around our contents.
|
|
|
|
if (aState.mIsMarginRoot) {
|
|
|
|
// When we are a margin root make sure that our last childs
|
|
|
|
// bottom margin is fully applied.
|
|
|
|
// XXX check for a fit
|
|
|
|
aState.mY += aState.mPrevBottomMargin;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aState.mY += aState.mBorderPadding.bottom;
|
|
|
|
aMetrics.height = aState.mY;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Return top and bottom margin information
|
|
|
|
if (aState.mIsMarginRoot) {
|
|
|
|
aMetrics.mCarriedOutTopMargin = 0;
|
|
|
|
aMetrics.mCarriedOutBottomMargin = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aMetrics.mCarriedOutTopMargin = aState.mCarriedOutTopMargin;
|
|
|
|
aMetrics.mCarriedOutBottomMargin = aState.mPrevBottomMargin;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Special check for zero sized content: If our content is zero
|
|
|
|
// sized then we collapse into nothingness.
|
|
|
|
if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) &&
|
|
|
|
(eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) &&
|
|
|
|
((0 == aState.mKidXMost - aState.mBorderPadding.left) &&
|
|
|
|
(0 == aState.mY - aState.mBorderPadding.top))) {
|
|
|
|
aMetrics.width = 0;
|
|
|
|
aMetrics.height = 0;
|
|
|
|
aState.mAscent = 0;
|
|
|
|
aState.mDescent = 0;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (0 == (BLOCK_IS_INLINE & mFlags)) {
|
|
|
|
aMetrics.ascent = aMetrics.height;
|
|
|
|
aMetrics.descent = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aMetrics.ascent = aState.mAscent;
|
|
|
|
aMetrics.descent = aState.mDescent;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX this needs ALOT OF REWORKING
|
|
|
|
if (aState.mComputeMaxElementSize) {
|
|
|
|
nscoord maxWidth, maxHeight;
|
|
|
|
|
|
|
|
if (aState.mNoWrap) {
|
|
|
|
maxWidth = 0;
|
|
|
|
maxHeight = 0;
|
|
|
|
|
|
|
|
// Find the maximum line-box width and use that as the
|
|
|
|
// max-element width
|
|
|
|
nsLineBox* line = mLines;
|
1998-09-15 04:19:49 +04:00
|
|
|
while (nsnull != line) {
|
1998-12-05 19:02:08 +03:00
|
|
|
nscoord xm = line->mBounds.XMost();
|
|
|
|
if (xm > maxWidth) {
|
|
|
|
maxWidth = xm;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
line = line->mNext;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX winging it!
|
|
|
|
maxHeight = aState.mMaxElementSize.height +
|
|
|
|
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
maxWidth = aState.mMaxElementSize.width +
|
|
|
|
aState.mBorderPadding.left + aState.mBorderPadding.right;
|
|
|
|
maxHeight = aState.mMaxElementSize.height +
|
|
|
|
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX This is still an approximation of the truth:
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// 1. it doesn't take into account that after a floater is
|
|
|
|
// placed we always place at least *something* on the line.
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// 2. if a floater doesn't start at the left margin (because
|
|
|
|
// it's placed relative to a floater on a preceeding line, say),
|
|
|
|
// then we get the wrong answer.
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (nsnull != line->mFloaters) {
|
|
|
|
nsRect r;
|
|
|
|
nsMargin floaterMargin;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Sum up the widths of the floaters on this line
|
|
|
|
PRInt32 sum = 0;
|
|
|
|
PRInt32 n = line->mFloaters->Count();
|
|
|
|
for (PRInt32 i = 0; i < n; i++) {
|
|
|
|
nsPlaceholderFrame* placeholder = (nsPlaceholderFrame*)
|
|
|
|
line->mFloaters->ElementAt(i);
|
|
|
|
nsIFrame* floater = placeholder->GetAnchoredItem();
|
|
|
|
floater->GetRect(r);
|
|
|
|
const nsStyleDisplay* floaterDisplay;
|
|
|
|
const nsStyleSpacing* floaterSpacing;
|
|
|
|
floater->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&)floaterDisplay);
|
|
|
|
floater->GetStyleData(eStyleStruct_Spacing,
|
|
|
|
(const nsStyleStruct*&)floaterSpacing);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute the margin for the floater (again!)
|
|
|
|
nsHTMLReflowState::ComputeMarginFor(floater, &aState,
|
|
|
|
floaterMargin);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nscoord width = r.width + floaterMargin.left + floaterMargin.right;
|
|
|
|
NS_ASSERTION((NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) ||
|
|
|
|
(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats),
|
|
|
|
"invalid float type");
|
|
|
|
sum += width;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// See if we need a larger max-element width
|
|
|
|
if (sum > maxWidth) {
|
|
|
|
maxWidth = sum;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
line = line->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Store away the final value
|
|
|
|
aMetrics.maxElementSize->width = maxWidth;
|
|
|
|
aMetrics.maxElementSize->height = maxHeight;
|
|
|
|
#ifdef NOISY_MAX_ELEMENT_SIZE
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": max-element-size:%d,%d desired:%d,%d\n",
|
|
|
|
maxWidth, maxHeight, aMetrics.width, aMetrics.height);
|
|
|
|
#endif
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute the combined area of our children
|
|
|
|
// XXX take into account the overflow->clip property!
|
|
|
|
nscoord x0 = 0, y0 = 0, x1 = aMetrics.width, y1 = aMetrics.height;
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
// Compute min and max x/y values for the reflowed frame's
|
|
|
|
// combined areas
|
|
|
|
nscoord x = line->mCombinedArea.x;
|
|
|
|
nscoord y = line->mCombinedArea.y;
|
|
|
|
nscoord xmost = x + line->mCombinedArea.width;
|
|
|
|
nscoord ymost = y + line->mCombinedArea.height;
|
|
|
|
if (x < x0) x0 = x;
|
|
|
|
if (xmost > x1) x1 = xmost;
|
|
|
|
if (y < y0) y0 = y;
|
|
|
|
if (ymost > y1) y1 = ymost;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If the line has floaters, factor those in as well
|
|
|
|
nsVoidArray* floaters = line->mFloaters;
|
|
|
|
if (nsnull != floaters) {
|
|
|
|
PRInt32 i, n = floaters->Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
|
|
|
|
nsIFrame* frame = ph->GetAnchoredItem();
|
|
|
|
// XXX This is wrong! The floater may have a combined area
|
|
|
|
// that exceeds its bounding box!
|
|
|
|
nsRect r;
|
|
|
|
frame->GetRect(r);
|
|
|
|
if (r.x < x0) x0 = r.x;
|
|
|
|
if (r.XMost() > x1) x1 = r.XMost();
|
|
|
|
if (r.y < y0) y0 = r.y;
|
|
|
|
if (r.YMost() > y1) y1 = r.YMost();
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
line = line->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aMetrics.mCombinedArea.x = x0;
|
|
|
|
aMetrics.mCombinedArea.y = y0;
|
|
|
|
aMetrics.mCombinedArea.width = x1 - x0;
|
|
|
|
aMetrics.mCombinedArea.height = y1 - y0;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If the combined area of our children exceeds our bounding box
|
|
|
|
// then set the NS_FRAME_OUTSIDE_CHILDREN flag, otherwise clear it.
|
|
|
|
if ((aMetrics.mCombinedArea.x < 0) ||
|
|
|
|
(aMetrics.mCombinedArea.y < 0) ||
|
|
|
|
(aMetrics.mCombinedArea.XMost() > aMetrics.width) ||
|
|
|
|
(aMetrics.mCombinedArea.YMost() > aMetrics.height)) {
|
|
|
|
mState |= NS_FRAME_OUTSIDE_CHILDREN;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
|
|
|
|
}
|
|
|
|
#if XXX
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": => carried=%d,%d\n", aMetrics.mCarriedOutTopMargin, aMetrics.mCarriedOutBottomMargin);
|
|
|
|
#endif
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::AppendNewFrames(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aNewFrame)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get our last line and then get its last child
|
|
|
|
nsIFrame* lastFrame;
|
|
|
|
nsLineBox* lastLine = nsLineBox::LastLine(mLines);
|
|
|
|
if (nsnull != lastLine) {
|
|
|
|
lastFrame = lastLine->LastChild();
|
|
|
|
} else {
|
|
|
|
lastFrame = nsnull;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Add the new frames to the sibling list; wrap any frames that
|
|
|
|
// require wrapping
|
|
|
|
if (nsnull != lastFrame) {
|
|
|
|
lastFrame->SetNextSibling(aNewFrame);
|
|
|
|
}
|
|
|
|
nsresult rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Make sure that new inlines go onto the end of the lastLine when
|
|
|
|
// the lastLine is mapping inline frames.
|
|
|
|
PRInt32 pendingInlines = 0;
|
|
|
|
if (nsnull != lastLine) {
|
|
|
|
if (!lastLine->IsBlock()) {
|
|
|
|
pendingInlines = 1;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now create some lines for the new frames
|
|
|
|
nsIFrame* prevFrame = lastFrame;
|
|
|
|
for (nsIFrame* frame = aNewFrame; nsnull != frame; frame->GetNextSibling(frame)) {
|
|
|
|
// See if the child is a block or non-block
|
|
|
|
const nsStyleDisplay* kidDisplay;
|
|
|
|
rv = frame->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&) kidDisplay);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
const nsStylePosition* kidPosition;
|
|
|
|
rv = frame->GetStyleData(eStyleStruct_Position,
|
|
|
|
(const nsStyleStruct*&) kidPosition);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
PRBool isBlock =
|
|
|
|
nsLineLayout::TreatFrameAsBlock(kidDisplay, kidPosition);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// See if we need to move the frame outside of the flow, and insert a
|
|
|
|
// placeholder frame in its place
|
|
|
|
nsIFrame* placeholder;
|
|
|
|
if (MoveFrameOutOfFlow(aPresContext, frame, kidDisplay, kidPosition,
|
|
|
|
placeholder)) {
|
|
|
|
// Reset the previous frame's next sibling pointer
|
|
|
|
if (nsnull != prevFrame) {
|
|
|
|
prevFrame->SetNextSibling(placeholder);
|
|
|
|
}
|
1998-11-11 06:55:55 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// The placeholder frame is always inline
|
|
|
|
frame = placeholder;
|
|
|
|
isBlock = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Wrap the frame in a view if necessary
|
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
frame->GetStyleContext(kidSC);
|
|
|
|
rv = CreateViewForFrame(aPresContext, frame, kidSC, PR_FALSE);
|
|
|
|
NS_RELEASE(kidSC);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// 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
|
|
|
|
// block then make a new line and put the child in that line.
|
|
|
|
if (isBlock) {
|
|
|
|
// If the previous line has pending inline data to be reflowed,
|
|
|
|
// do so now.
|
|
|
|
if (0 != pendingInlines) {
|
|
|
|
// Set this to true in case we don't end up reflowing all of the
|
|
|
|
// frames on the line (because they end up being pushed).
|
|
|
|
lastLine->MarkDirty();
|
|
|
|
pendingInlines = 0;
|
|
|
|
}
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Create a line for the block
|
|
|
|
nsLineBox* line = new nsLineBox(frame, 1, LINE_IS_BLOCK);
|
|
|
|
if (nsnull == line) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
if (nsnull == lastLine) {
|
|
|
|
mLines = line;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastLine->mNext = line;
|
|
|
|
}
|
|
|
|
lastLine = line;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-12-05 19:02:08 +03:00
|
|
|
// Queue up the inlines for reflow later on
|
|
|
|
if (0 == pendingInlines) {
|
|
|
|
nsLineBox* line = new nsLineBox(frame, 0, 0);
|
|
|
|
if (nsnull == line) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
if (nsnull == lastLine) {
|
|
|
|
mLines = line;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastLine->mNext = line;
|
|
|
|
}
|
|
|
|
lastLine = line;
|
|
|
|
}
|
|
|
|
lastLine->mChildCount++;
|
|
|
|
pendingInlines++;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// Remember the previous frame
|
|
|
|
prevFrame = frame;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
if (0 != pendingInlines) {
|
|
|
|
// Set this to true in case we don't end up reflowing all of the
|
|
|
|
// frames on the line (because they end up being pushed).
|
|
|
|
lastLine->MarkDirty();
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PrepareInitialReflow(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
DrainOverflowLines();
|
|
|
|
return PrepareResizeReflow(aState);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PrepareFrameAppendedReflow(nsBlockReflowState& aState)
|
|
|
|
{
|
|
|
|
// Get the first of the newly appended frames
|
|
|
|
nsIFrame* firstAppendedFrame;
|
|
|
|
aState.reflowCommand->GetChildFrame(firstAppendedFrame);
|
|
|
|
|
|
|
|
// Add the new frames to the child list, and create new lines. Each
|
|
|
|
// impacted line will be marked dirty.
|
|
|
|
AppendNewFrames(aState.mPresContext, firstAppendedFrame);
|
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PrepareFrameInsertedReflow(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get the inserted frame
|
|
|
|
nsIFrame* newFrame;
|
|
|
|
aState.reflowCommand->GetChildFrame(newFrame);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get the previous sibling frame
|
|
|
|
nsIFrame* prevSibling;
|
|
|
|
aState.reflowCommand->GetPrevSiblingFrame(prevSibling);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Insert the frame. This marks the affected lines dirty
|
|
|
|
InsertNewFrame(aState.mPresContext, this, newFrame, prevSibling);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PrepareFrameRemovedReflow(nsBlockReflowState& aState)
|
|
|
|
{
|
|
|
|
if (nsnull == mLines) {
|
|
|
|
// Nothing to delete here
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get the deleted frame
|
|
|
|
nsIFrame* deletedFrame;
|
|
|
|
aState.reflowCommand->GetChildFrame(deletedFrame);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get the previous sibling frame
|
|
|
|
nsIFrame* prevSibling;
|
|
|
|
aState.reflowCommand->GetPrevSiblingFrame(prevSibling);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Remove the frame. This marks the affected lines dirty.
|
|
|
|
RemoveFrame(aState, this, deletedFrame, prevSibling);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-14 22:28:11 +03:00
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
nsresult
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::PrepareChildIncrementalReflow(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// If by chance we are inside a table, then give up and reflow
|
|
|
|
// everything because we don't cache max-element-size information in
|
|
|
|
// the lines.
|
|
|
|
if (aState.mComputeMaxElementSize) {
|
|
|
|
return PrepareResizeReflow(aState);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Determine the line being impacted
|
|
|
|
PRBool isFloater;
|
|
|
|
nsLineBox* line = FindLineFor(aState.mNextRCFrame, isFloater);
|
|
|
|
if (nsnull == line) {
|
|
|
|
// This can't happen, but just in case it does...
|
|
|
|
return PrepareResizeReflow(aState);
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// XXX: temporary: If the child frame is a floater then punt
|
|
|
|
if (isFloater) {
|
|
|
|
return PrepareResizeReflow(aState);
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX need code for run-in/compact
|
|
|
|
|
|
|
|
// Mark (at least) the affected line dirty.
|
|
|
|
line->MarkDirty();
|
|
|
|
if (aState.mNoWrap || line->IsBlock()) {
|
|
|
|
// If we aren't wrapping then we know for certain that any changes
|
|
|
|
// to a childs reflow can't affect the line that follows. This is
|
|
|
|
// also true if the line is a block line.
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// XXX: temporary: For now we are conservative and mark this line
|
|
|
|
// and any inline lines that follow it dirty.
|
|
|
|
line = line->mNext;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line->MarkDirty();
|
|
|
|
line = line->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PrepareStyleChangedReflow(nsBlockReflowState& aState)
|
1998-11-12 19:32:56 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX temporary
|
|
|
|
// Mark everything dirty
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
line->MarkDirty();
|
|
|
|
line = line->mNext;
|
1998-11-12 19:32:56 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
1998-11-12 19:32:56 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PrepareResizeReflow(nsBlockReflowState& aState)
|
1998-11-05 22:33:01 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Mark everything dirty
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
line->MarkDirty();
|
|
|
|
line = line->mNext;
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//----------------------------------------
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsLineBox*
|
|
|
|
nsBaseIBFrame::FindLineFor(nsIFrame* aFrame, PRBool& aIsFloaterResult)
|
|
|
|
{
|
|
|
|
aIsFloaterResult = PR_FALSE;
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (line->Contains(aFrame)) {
|
|
|
|
return line;
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
if (nsnull != line->mFloaters) {
|
|
|
|
nsVoidArray& a = *line->mFloaters;
|
|
|
|
PRInt32 i, n = a.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) a[i];
|
|
|
|
if (aFrame == ph->GetAnchoredItem()) {
|
|
|
|
aIsFloaterResult = PR_TRUE;
|
|
|
|
return line;
|
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
line = line->mNext;
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return line;
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::RecoverStateFrom(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Recover xmost
|
|
|
|
nscoord xmost = aLine->mBounds.XMost();
|
|
|
|
if (xmost > aState.mKidXMost) {
|
|
|
|
aState.mKidXMost = xmost;
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Recover the natural (un-collapsed margins) for the child
|
|
|
|
nsMargin childMargins(0, 0, 0, 0);
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
nsBlockReflowContext::ComputeMarginsFor(aState.mPresContext, frame,
|
|
|
|
spacing, aState, childMargins);
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Recompute running margin value (aState.mPrevBottomMargin). Also
|
|
|
|
// recover the aState.mCarriedOutTopMargin, when appropriate.
|
|
|
|
nscoord topMargin, bottomMargin;
|
|
|
|
nsBlockReflowContext::CollapseMargins(childMargins,
|
|
|
|
aLine->GetCarriedOutTopMargin(),
|
|
|
|
aLine->GetCarriedOutBottomMargin(),
|
|
|
|
aLine->GetHeight(),
|
|
|
|
aState.mPrevBottomMargin,
|
|
|
|
topMargin, bottomMargin);
|
|
|
|
aState.mPrevBottomMargin = bottomMargin;
|
|
|
|
if (!aState.ShouldApplyTopMargin()) {
|
|
|
|
aState.mCarriedOutTopMargin = topMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Advance Y to be below the line.
|
|
|
|
aState.mY = aLine->mBounds.YMost();
|
|
|
|
|
|
|
|
// XXX_fix_me: if the line has clear-before semantics then figure out
|
|
|
|
// if we need to do anything here or not!
|
|
|
|
|
|
|
|
// Apply any clear before/after semantics the line might have
|
|
|
|
if (!aLine->IsBlock() && (NS_STYLE_CLEAR_NONE != aLine->mBreakType)) {
|
|
|
|
// Apply clear
|
|
|
|
switch (aLine->mBreakType) {
|
|
|
|
case NS_STYLE_CLEAR_LEFT:
|
|
|
|
case NS_STYLE_CLEAR_RIGHT:
|
|
|
|
case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
|
|
|
|
// XXX_fix_me is this the right y value to use? or should we use
|
|
|
|
// the previous aState.mY?
|
|
|
|
aState.ClearFloaters(aState.mY, aLine->mBreakType);
|
|
|
|
break;
|
1998-11-12 19:32:56 +03:00
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
|
|
|
|
1998-09-24 00:10:40 +04:00
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Propogate reflow "damage" from the just reflowed line (aLine) to
|
|
|
|
* any subsequent lines that were affected. The only thing that causes
|
|
|
|
* damage is a change to the impact that floaters make.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsBaseIBFrame::PropogateReflowDamage(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscoord aDeltaY)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
if (aLine->mCombinedArea.YMost() > aLine->mBounds.YMost()) {
|
|
|
|
// The line has an object that extends outside of its bounding box.
|
|
|
|
nscoord impactY0 = aLine->mCombinedArea.y;
|
|
|
|
nscoord impactY1 = aLine->mCombinedArea.YMost();
|
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (aState.reason == eReflowReason_Incremental) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("impactY0=%d impactY1=%d deltaY=%d\n",
|
|
|
|
impactY0, impactY1, aDeltaY);
|
|
|
|
}
|
|
|
|
#endif
|
1998-09-26 04:37:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX Because we don't know what it is (it might be a floater; it
|
|
|
|
// might be something that is just relatively positioned) we
|
|
|
|
// *assume* that it's a floater and that lines that follow will
|
|
|
|
// need reflowing.
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Note: we cannot stop after the first non-intersecting line
|
|
|
|
// because lines might be overlapping because of negative margins.
|
|
|
|
nsLineBox* next = aLine->mNext;
|
|
|
|
while (nsnull != next) {
|
|
|
|
nscoord lineY0 = next->mBounds.y + aDeltaY;
|
|
|
|
nscoord lineY1 = lineY0 + next->mBounds.height;
|
|
|
|
if ((lineY0 < impactY1) && (impactY0 < lineY1)) {
|
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (aState.reason == eReflowReason_Incremental) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("line=%p setting dirty\n", next);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
next->MarkDirty();
|
|
|
|
}
|
|
|
|
next = next->mNext;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Reflow the dirty lines
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::ReflowDirtyLines(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
PRBool keepGoing = PR_TRUE;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (aState.reason == eReflowReason_Incremental) {
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aState.reflowCommand->GetType(type);
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": incrementally reflowing dirty lines: type=%s(%d)\n",
|
|
|
|
kReflowCommandType[type], type);
|
|
|
|
gNoiseIndent++;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
1998-11-14 22:28:11 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Reflow the lines that are already ours
|
|
|
|
aState.mPrevLine = nsnull;
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
nscoord deltaY = 0;
|
|
|
|
while (nsnull != line) {
|
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (aState.reason == eReflowReason_Incremental) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("line=%p mY=%d dirty=%s oldBounds=%d,%d,%d,%d deltaY=%d\n",
|
|
|
|
line, aState.mY, line->IsDirty() ? "yes" : "no",
|
|
|
|
line->mBounds, deltaY);
|
|
|
|
gNoiseIndent++;
|
1998-11-13 02:03:35 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
|
|
|
if (line->IsDirty()) {
|
|
|
|
// Compute the dirty lines "before" YMost, after factoring in
|
|
|
|
// the running deltaY value - the running value is implicit in
|
|
|
|
// aState.mY.
|
|
|
|
nscoord oldHeight = line->mBounds.height;
|
|
|
|
|
|
|
|
// Reflow the dirty line
|
|
|
|
rv = ReflowLine(aState, line, keepGoing);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
DidReflowLine(aState, line, keepGoing);
|
|
|
|
if (!keepGoing) {
|
1998-12-08 01:28:55 +03:00
|
|
|
if (0 == line->ChildCount()) {
|
|
|
|
DeleteLine(aState, line);
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
nscoord newHeight = line->mBounds.height;
|
|
|
|
deltaY += newHeight - oldHeight;
|
|
|
|
|
|
|
|
// If the next line is clean then check and see if reflowing the
|
|
|
|
// current line "damaged" the next line. Damage occurs when the
|
|
|
|
// current line contains floaters that intrude upon the
|
|
|
|
// subsequent lines.
|
|
|
|
nsLineBox* next = line->mNext;
|
|
|
|
if ((nsnull != next) && !next->IsDirty()) {
|
|
|
|
PropogateReflowDamage(aState, line, deltaY);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// XXX what if the slid line doesn't fit because we are in a
|
|
|
|
// vertically constrained situation?
|
|
|
|
if (0 != deltaY) {
|
|
|
|
// Move this line's frames by the current delta value
|
|
|
|
SlideFrames(aState.mPresContext, aState.mSpaceManager, line, deltaY);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Recover state as if we reflowed this line
|
|
|
|
RecoverStateFrom(aState, line);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (aState.reason == eReflowReason_Incremental) {
|
|
|
|
gNoiseIndent--;
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("line=%p mY=%d newBounds=%d,%d,%d,%d deltaY=%d\n",
|
|
|
|
line, aState.mY, line->mBounds, deltaY);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If this is an inline frame then its time to stop
|
|
|
|
aState.mPrevLine = line;
|
|
|
|
line = line->mNext;
|
|
|
|
if (aState.mLimitToOneLine) {
|
|
|
|
keepGoing = PR_FALSE;
|
|
|
|
if (nsnull != line) {
|
|
|
|
PushLines(aState);
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aState.mReflowStatus = IsComplete();
|
|
|
|
}
|
|
|
|
break;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aState.mLineLayout->NextLine();
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Pull data from a next-in-flow if we can
|
|
|
|
while (keepGoing && (nsnull != aState.mNextInFlow)) {
|
|
|
|
// Grab first line from our next-in-flow
|
|
|
|
line = aState.mNextInFlow->mLines;
|
|
|
|
if (nsnull == line) {
|
|
|
|
aState.mNextInFlow = (nsBaseIBFrame*) aState.mNextInFlow->mNextInFlow;
|
|
|
|
continue;
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX See if the line is not dirty; if it's not maybe we can
|
|
|
|
// avoid the pullup if it can't fit?
|
|
|
|
aState.mNextInFlow->mLines = line->mNext;
|
|
|
|
line->mNext = nsnull;
|
|
|
|
if (0 == line->ChildCount()) {
|
|
|
|
// The line is empty. Try the next one.
|
|
|
|
NS_ASSERTION(nsnull == line->mFirstChild, "bad empty line");
|
|
|
|
delete line;
|
|
|
|
continue;
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX move to a subroutine: run-in, overflow, pullframe and this do this
|
|
|
|
// Make the children in the line ours.
|
|
|
|
nsIFrame* frame = line->mFirstChild;
|
|
|
|
nsIFrame* lastFrame = nsnull;
|
|
|
|
PRInt32 n = line->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
nsIFrame* geometricParent;
|
|
|
|
nsIFrame* contentParent;
|
|
|
|
frame->GetGeometricParent(geometricParent);
|
|
|
|
frame->GetContentParent(contentParent);
|
|
|
|
if (contentParent == geometricParent) {
|
|
|
|
frame->SetContentParent(this);
|
|
|
|
}
|
|
|
|
frame->SetGeometricParent(this);
|
|
|
|
lastFrame = frame;
|
|
|
|
frame->GetNextSibling(frame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
lastFrame->SetNextSibling(nsnull);
|
1998-11-14 22:28:11 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Add line to our line list
|
|
|
|
if (nsnull == aState.mPrevLine) {
|
|
|
|
NS_ASSERTION(nsnull == mLines, "bad aState.mPrevLine");
|
|
|
|
mLines = line;
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
NS_ASSERTION(nsnull == aState.mPrevLine->mNext, "bad aState.mPrevLine");
|
|
|
|
aState.mPrevLine->mNext = line;
|
|
|
|
aState.mPrevChild->SetNextSibling(line->mFirstChild);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now reflow it and any lines that it makes during it's reflow
|
|
|
|
// (we have to loop here because reflowing the line may case a new
|
|
|
|
// line to be created; see SplitLine's callers for examples of
|
|
|
|
// when this happens).
|
|
|
|
while (nsnull != line) {
|
|
|
|
rv = ReflowLine(aState, line, keepGoing);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
DidReflowLine(aState, line, keepGoing);
|
|
|
|
if (!keepGoing) {
|
1998-12-08 01:28:55 +03:00
|
|
|
if (0 == line->ChildCount()) {
|
|
|
|
DeleteLine(aState, line);
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
break;
|
|
|
|
}
|
1998-11-14 22:28:11 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If this is an inline frame then its time to stop
|
|
|
|
aState.mPrevLine = line;
|
|
|
|
line = line->mNext;
|
|
|
|
if (aState.mLimitToOneLine) {
|
|
|
|
keepGoing = PR_FALSE;
|
|
|
|
if (nsnull != line) {
|
|
|
|
PushLines(aState);
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aState.mReflowStatus = IsComplete();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
aState.mLineLayout->NextLine();
|
|
|
|
}
|
|
|
|
}
|
1998-11-14 22:28:11 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// It's very important that an inline frame that has wrapped up a
|
|
|
|
// block frame not allow any other inline frames to follow it on the
|
|
|
|
// line that it is being reflowed within (our parent's
|
|
|
|
// linelayout). Therefore, make sure we return a line-break-after
|
|
|
|
// status.
|
|
|
|
if (BLOCK_IS_INLINE & mFlags) {
|
|
|
|
nsReflowStatus rs = aState.mReflowStatus;
|
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(rs) && NS_FRAME_IS_COMPLETE(rs)) {
|
|
|
|
if ((nsnull != mLines) && mLines->IsBlock()) {
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_AFTER(NS_FRAME_COMPLETE);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-11-14 22:28:11 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (aState.reason == eReflowReason_Incremental) {
|
|
|
|
gNoiseIndent--;
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": done reflowing dirty lines (status=%x, mLimitToOneLine=%d)\n",
|
|
|
|
aState.mReflowStatus, aState.mLimitToOneLine);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-08 01:28:55 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::DeleteLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 == aLine->ChildCount(), "can't delete !empty line");
|
|
|
|
if (0 == aLine->ChildCount()) {
|
|
|
|
if (nsnull == aState.mPrevLine) {
|
|
|
|
NS_ASSERTION(aLine == mLines, "huh");
|
|
|
|
mLines = nsnull;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(aState.mPrevLine->mNext == aLine, "bad prev-line");
|
|
|
|
aState.mPrevLine->mNext = aLine->mNext;
|
|
|
|
}
|
|
|
|
delete aLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX add in some state to nsBlockReflowState that indicates whether
|
|
|
|
// or not we *know* this fact or not...
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::IsComplete()
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult complete = NS_FRAME_COMPLETE;
|
|
|
|
nsBaseIBFrame* nextInFlow = (nsBaseIBFrame*) mNextInFlow;
|
|
|
|
while (nsnull != nextInFlow) {
|
|
|
|
if (((nsnull != nextInFlow->mLines) &&
|
|
|
|
(nsnull != nextInFlow->mLines->mFirstChild)) ||
|
|
|
|
((nsnull != nextInFlow->mOverflowLines) &&
|
|
|
|
(nsnull != nextInFlow->mOverflowLines->mFirstChild))) {
|
|
|
|
complete = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nextInFlow = (nsBaseIBFrame*) nextInFlow->mNextInFlow;
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return complete;
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::WillReflowLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine)
|
1998-11-14 22:28:11 +03:00
|
|
|
{
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Reflow a line. The line will either contain a single block frame
|
|
|
|
* or contain 1 or more inline frames. aLineReflowStatus indicates
|
|
|
|
* whether or not the caller should continue to reflow more lines.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::ReflowLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
PRBool& aKeepGoing)
|
1998-11-19 21:09:57 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::ReflowLine: line=%p", aLine));
|
1998-11-19 21:09:57 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = NS_OK;
|
1998-11-11 06:55:55 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If the line already has floaters on it from last time, remove
|
|
|
|
// them from the spacemanager now.
|
|
|
|
if (nsnull != aLine->mFloaters) {
|
|
|
|
if (eReflowReason_Resize != aState.reason) {
|
|
|
|
aLine->UnplaceFloaters(aState.mSpaceManager);
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aLine->mFloaters->Clear();
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If the line is empty then first pull a frame into it so that we
|
|
|
|
// know what kind of line it is (block or inline).
|
|
|
|
if (0 == aLine->ChildCount()) {
|
|
|
|
nsIFrame* frame;
|
|
|
|
rv = PullFrame(aState, aLine, frame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (nsnull == frame) {
|
1998-12-08 01:28:55 +03:00
|
|
|
#if 0
|
1998-12-05 19:02:08 +03:00
|
|
|
// If there is nothing left to pull then get rid of the empty
|
|
|
|
// line and return.
|
|
|
|
if (nsnull != aState.mPrevLine) {
|
|
|
|
aState.mPrevLine->mNext = nsnull;
|
|
|
|
}
|
|
|
|
delete aLine;
|
1998-12-08 01:28:55 +03:00
|
|
|
#endif
|
1998-12-05 19:02:08 +03:00
|
|
|
aKeepGoing = PR_FALSE;
|
|
|
|
return rv;
|
|
|
|
}
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Setup the line-layout for the new line. However, we only do this
|
|
|
|
// when we are reflowing multiple lines (if we aren't reflowing
|
|
|
|
// multiple lines it means that this is an inline frame that has to
|
|
|
|
// stop at the end of the line).
|
|
|
|
if (!aState.mLimitToOneLine) {
|
|
|
|
aState.mLineLayout->Reset();
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aState.mCurrentLine = aLine;
|
|
|
|
aLine->ClearDirty();
|
|
|
|
aLine->SetNeedDidReflow();
|
1998-11-11 06:55:55 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now that we know what kind of line we have, reflow it
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
// When reflowing a block frame we always get the available space
|
|
|
|
aState.GetAvailableSpace();
|
1998-11-11 06:55:55 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if ((nsnull != aState.lineLayout) &&
|
|
|
|
(0 != aState.lineLayout->GetPlacedFrames())) {
|
|
|
|
// Blocks are not allowed on the same line as anything else
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
aKeepGoing = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Notify observers that we are about to reflow the line
|
|
|
|
WillReflowLine(aState, aLine);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
rv = ReflowBlockFrame(aState, aLine, aKeepGoing);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-12-05 19:02:08 +03:00
|
|
|
// When this class is an inline frame and we are reflowing inline
|
|
|
|
// frames then there is no point in getting available space.
|
|
|
|
nscoord x, availWidth, availHeight;
|
|
|
|
if (0 == (BLOCK_IS_INLINE & mFlags)) {
|
|
|
|
aState.GetAvailableSpace();
|
|
|
|
|
|
|
|
// Setup initial coordinate system for reflowing the inline frames
|
|
|
|
// into.
|
1998-12-09 00:43:15 +03:00
|
|
|
x = aState.mAvailSpaceRect.x + aState.mBorderPadding.left;
|
|
|
|
availWidth = aState.mAvailSpaceRect.width;
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
if (aState.mUnconstrainedHeight) {
|
|
|
|
availHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* XXX get the height right! */
|
1998-12-09 00:43:15 +03:00
|
|
|
availHeight = aState.mAvailSpaceRect.height;
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-12-05 19:02:08 +03:00
|
|
|
x = aState.mBorderPadding.left;
|
|
|
|
availWidth = aState.mContentArea.width;
|
|
|
|
availHeight = aState.mContentArea.height;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aState.mInlineReflow->Init(x, aState.mY, availWidth, availHeight);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Notify observers that we are about to reflow the line
|
|
|
|
WillReflowLine(aState, aLine);
|
1998-09-25 20:10:10 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Reflow the frames that are already on the line first
|
|
|
|
PRBool keepLineGoing = PR_TRUE;
|
|
|
|
PRInt32 i;
|
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
for (i = 0; i < aLine->ChildCount(); i++) {
|
|
|
|
rv = ReflowInlineFrame(aState, aLine, frame,
|
|
|
|
keepLineGoing, aKeepGoing);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (!keepLineGoing) {
|
|
|
|
// It is possible that one or more of next lines are empty
|
|
|
|
// (because of DeleteNextInFlowsFor). If so, delete them now
|
|
|
|
// in case we are finished.
|
|
|
|
nsLineBox* nextLine = aLine->mNext;
|
|
|
|
while ((nsnull != nextLine) && (0 == nextLine->ChildCount())) {
|
|
|
|
// Discard empty lines immediately. Empty lines can happen
|
|
|
|
// here because of DeleteNextInFlowsFor not being able to
|
|
|
|
// delete lines.
|
|
|
|
aLine->mNext = nextLine->mNext;
|
|
|
|
NS_ASSERTION(nsnull == nextLine->mFirstChild, "bad empty line");
|
|
|
|
delete nextLine;
|
|
|
|
nextLine = aLine->mNext;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
break;
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Pull frames and reflow them until we can't
|
|
|
|
while (keepLineGoing) {
|
|
|
|
nsIFrame* frame;
|
|
|
|
rv = PullFrame(aState, aLine, frame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (nsnull == frame) {
|
1998-09-25 20:10:10 +04:00
|
|
|
break;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
rv = ReflowInlineFrame(aState, aLine, frame, keepLineGoing,
|
|
|
|
aKeepGoing);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If we are propogating out a break-before status then there is
|
|
|
|
// no point in placing the line.
|
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aState.mReflowStatus)) {
|
|
|
|
rv = PlaceLine(aState, aLine, aKeepGoing);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-11-14 22:28:11 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Pull frame from the next available location (one of our lines or
|
|
|
|
* one of our next-in-flows lines).
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PullFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame*& aFrameResult)
|
1998-11-14 22:28:11 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
PRBool stopPulling;
|
|
|
|
aFrameResult = nsnull;
|
|
|
|
|
|
|
|
// First check our remaining lines
|
|
|
|
while (nsnull != aLine->mNext) {
|
|
|
|
rv = PullFrame(aState, aLine, &aLine->mNext, PR_FALSE,
|
|
|
|
aFrameResult, stopPulling);
|
|
|
|
if (NS_FAILED(rv) || stopPulling) {
|
|
|
|
return rv;
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
|
|
|
}
|
1998-11-17 04:04:45 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Pull frames from the next-in-flow(s) until we can't
|
|
|
|
nsBaseIBFrame* nextInFlow = aState.mNextInFlow;
|
|
|
|
while (nsnull != nextInFlow) {
|
|
|
|
nsLineBox* line = nextInFlow->mLines;
|
|
|
|
if (nsnull == line) {
|
|
|
|
nextInFlow = (nsBaseIBFrame*) nextInFlow->mNextInFlow;
|
|
|
|
aState.mNextInFlow = nextInFlow;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rv = PullFrame(aState, aLine, &nextInFlow->mLines, PR_TRUE,
|
|
|
|
aFrameResult, stopPulling);
|
|
|
|
if (NS_FAILED(rv) || stopPulling) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-11-17 04:04:45 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return rv;
|
1998-11-14 22:28:11 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Try to pull a frame out a line pointed at by aFromList. If a frame
|
|
|
|
* is pulled then aPulled will be set to PR_TRUE. In addition, if
|
|
|
|
* aUpdateGeometricParent is set then the pulled frames geometric
|
|
|
|
* parent will be updated (e.g. when pulling from a next-in-flows line
|
|
|
|
* list).
|
|
|
|
*
|
|
|
|
* Note: pulling a frame from a line that is a place-holder frame
|
|
|
|
* doesn't automatically remove the corresponding floater from the
|
|
|
|
* line's floater array. This happens indirectly: either the line gets
|
|
|
|
* emptied (and destroyed) or the line gets reflowed (because we mark
|
|
|
|
* it dirty) and the code at the top of ReflowLine empties the
|
|
|
|
* array. So eventually, it will be removed, just not right away.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PullFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsLineBox** aFromList,
|
|
|
|
PRBool aUpdateGeometricParent,
|
|
|
|
nsIFrame*& aFrameResult,
|
|
|
|
PRBool& aStopPulling)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsLineBox* fromLine = *aFromList;
|
|
|
|
NS_ASSERTION(nsnull != fromLine, "bad line to pull from");
|
|
|
|
if (0 == fromLine->ChildCount()) {
|
|
|
|
// Discard empty lines immediately. Empty lines can happen here
|
|
|
|
// because of DeleteChildsNextInFlow not being able to delete
|
|
|
|
// lines. Don't stop pulling - there may be more frames around.
|
|
|
|
*aFromList = fromLine->mNext;
|
|
|
|
NS_ASSERTION(nsnull == fromLine->mFirstChild, "bad empty line");
|
|
|
|
delete fromLine;
|
|
|
|
aStopPulling = PR_FALSE;
|
|
|
|
aFrameResult = nsnull;
|
|
|
|
}
|
|
|
|
else if ((0 != aLine->ChildCount()) && fromLine->IsBlock()) {
|
|
|
|
// If our line is not empty and the child in aFromLine is a block
|
|
|
|
// then we cannot pull up the frame into this line. In this case
|
|
|
|
// we stop pulling.
|
|
|
|
aStopPulling = PR_TRUE;
|
|
|
|
aFrameResult = nsnull;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Take frame from fromLine
|
|
|
|
nsIFrame* frame = fromLine->mFirstChild;
|
|
|
|
if (0 == aLine->mChildCount++) {
|
|
|
|
aLine->mFirstChild = frame;
|
|
|
|
aLine->SetIsBlock(fromLine->IsBlock());
|
|
|
|
NS_ASSERTION(aLine->CheckIsBlock(), "bad line isBlock");
|
|
|
|
}
|
|
|
|
if (0 != --fromLine->mChildCount) {
|
|
|
|
// Mark line dirty now that we pulled a child
|
|
|
|
fromLine->MarkDirty();
|
|
|
|
frame->GetNextSibling(fromLine->mFirstChild);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Free up the fromLine now that it's empty
|
|
|
|
*aFromList = fromLine->mNext;
|
|
|
|
delete fromLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change geometric parents
|
|
|
|
if (aUpdateGeometricParent) {
|
|
|
|
nsIFrame* geometricParent;
|
|
|
|
nsIFrame* contentParent;
|
|
|
|
frame->GetGeometricParent(geometricParent);
|
|
|
|
frame->GetContentParent(contentParent);
|
|
|
|
if (contentParent == geometricParent) {
|
|
|
|
frame->SetContentParent(this);
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
frame->SetGeometricParent(this);
|
|
|
|
|
|
|
|
// The frame is being pulled from a next-in-flow; therefore we
|
|
|
|
// need to add it to our sibling list.
|
|
|
|
if (nsnull != aState.mPrevChild) {
|
|
|
|
aState.mPrevChild->SetNextSibling(frame);
|
|
|
|
}
|
|
|
|
frame->SetNextSibling(nsnull);
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLineLength(aLine);
|
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Stop pulling because we found a frame to pull
|
|
|
|
aStopPulling = PR_TRUE;
|
|
|
|
aFrameResult = frame;
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::DidReflowLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
PRBool aLineReflowStatus)
|
|
|
|
{
|
|
|
|
// If the line no longer needs a floater array, get rid of it and
|
|
|
|
// save some memory
|
|
|
|
nsVoidArray* array = aLine->mFloaters;
|
|
|
|
if (nsnull != array) {
|
|
|
|
if (0 == array->Count()) {
|
|
|
|
delete array;
|
|
|
|
aLine->mFloaters = nsnull;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
array->Compact();
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::SlideFrames(nsIPresContext& aPresContext,
|
|
|
|
nsISpaceManager* aSpaceManager,
|
|
|
|
nsLineBox* aLine, nscoord aDY)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-11-21 01:24:20 +03:00
|
|
|
#if 0
|
1998-12-05 19:02:08 +03:00
|
|
|
ListTag(stdout); printf(": SlideFrames: line=%p dy=%d\n", aDY);
|
1998-11-21 01:24:20 +03:00
|
|
|
#endif
|
1998-12-05 19:02:08 +03:00
|
|
|
// Adjust the Y coordinate of the frames in the line
|
|
|
|
nsIFrame* kid = aLine->mFirstChild;
|
|
|
|
PRInt32 n = aLine->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
nsRect r;
|
|
|
|
kid->GetRect(r);
|
|
|
|
r.y += aDY;
|
|
|
|
kid->SetRect(r);
|
1998-11-21 01:24:20 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If the child has any floaters that impact the space manager,
|
|
|
|
// slide them now
|
|
|
|
nsIHTMLReflow* ihr;
|
|
|
|
if (NS_OK == kid->QueryInterface(kIHTMLReflowIID, (void**)&ihr)) {
|
|
|
|
ihr->MoveInSpaceManager(aPresContext, aSpaceManager, 0, aDY);
|
1998-11-12 19:32:56 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
kid->GetNextSibling(kid);
|
1998-09-23 06:25:26 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Slide down our floaters too
|
|
|
|
nsVoidArray* floaters = aLine->mFloaters;
|
|
|
|
if (nsnull != floaters) {
|
|
|
|
PRInt32 i;
|
|
|
|
n = floaters->Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
|
|
|
|
kid = ph->GetAnchoredItem();
|
|
|
|
nsRect r;
|
|
|
|
kid->GetRect(r);
|
|
|
|
r.y += aDY;
|
|
|
|
kid->SetRect(r);
|
|
|
|
// XXX check and see if we should be calling OffsetRegion in the spacemanager!
|
|
|
|
#if 0
|
|
|
|
((nsFrame*)kid)->ListTag(stdout); printf(": moved=%d\n", aDY);
|
|
|
|
#endif
|
|
|
|
}
|
1998-09-23 06:25:26 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// Slide line box too
|
|
|
|
aLine->mBounds.y += aDY;
|
|
|
|
aLine->mCombinedArea.y += aDY;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::MoveInSpaceManager(nsIPresContext& aPresContext,
|
|
|
|
nsISpaceManager* aSpaceManager,
|
|
|
|
nscoord aDeltaX, nscoord aDeltaY)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
ListTag(stdout); printf(": MoveInSpaceManager: d=%d,%d\n", aDeltaX, aDeltaY);
|
|
|
|
#endif
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
PRInt32 i, n;
|
|
|
|
nsIFrame* kid;
|
|
|
|
|
|
|
|
// Move the floaters in the spacemanager
|
|
|
|
nsVoidArray* floaters = line->mFloaters;
|
|
|
|
if (nsnull != floaters) {
|
|
|
|
n = floaters->Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
|
|
|
|
kid = ph->GetAnchoredItem();
|
|
|
|
aSpaceManager->OffsetRegion(kid, aDeltaX, aDeltaY);
|
|
|
|
#if 0
|
|
|
|
((nsFrame*)kid)->ListTag(stdout); printf(": offset=%d,%d\n", aDeltaX, aDeltaY);
|
|
|
|
#endif
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tell kids about the move too
|
|
|
|
n = line->ChildCount();
|
|
|
|
kid = line->mFirstChild;
|
|
|
|
while (--n >= 0) {
|
|
|
|
nsIHTMLReflow* ihr;
|
|
|
|
if (NS_OK == kid->QueryInterface(kIHTMLReflowIID, (void**)&ihr)) {
|
|
|
|
ihr->MoveInSpaceManager(aPresContext, aSpaceManager, aDeltaX, aDeltaY);
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
kid->GetNextSibling(kid);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
line = line->mNext;
|
1998-09-23 06:25:26 +04:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseIBFrame*
|
|
|
|
nsBaseIBFrame::FindFollowingBlockFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsBaseIBFrame* followingBlockFrame = nsnull;
|
|
|
|
nsIFrame* frame = aFrame;
|
|
|
|
for (;;) {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
frame->GetNextSibling(nextFrame);
|
|
|
|
if (nsnull != nextFrame) {
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
nextFrame->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&) display);
|
|
|
|
if (NS_STYLE_DISPLAY_BLOCK == display->mDisplay) {
|
|
|
|
#ifdef NOISY_RUNIN
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": frame: ");
|
|
|
|
aFrame->ListTag(stdout);
|
|
|
|
printf(" followed by: ");
|
|
|
|
nextFrame->ListTag(stdout);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
followingBlockFrame = (nsBaseIBFrame*) nextFrame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_INLINE == display->mDisplay) {
|
|
|
|
// If it's a text-frame and it's just whitespace and we are
|
|
|
|
// in a normal whitespace situation THEN skip it and keep
|
|
|
|
// going...
|
|
|
|
// XXX WRITE ME!
|
|
|
|
}
|
|
|
|
frame = nextFrame;
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else
|
|
|
|
break;
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return followingBlockFrame;
|
|
|
|
}
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::WillReflowFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
aFrame->GetStyleContext(kidSC);
|
|
|
|
if (nsnull != kidSC) {
|
|
|
|
nsIStyleContext* kidParentSC;
|
|
|
|
kidParentSC = kidSC->GetParent();
|
|
|
|
if (nsnull != kidParentSC) {
|
|
|
|
if (kidParentSC != mStyleContext) {
|
|
|
|
// The frame has changed situations so re-resolve its style
|
|
|
|
// context in the new situation.
|
|
|
|
aFrame->ReResolveStyleContext(&aState.mPresContext, mStyleContext);
|
|
|
|
}
|
|
|
|
NS_RELEASE(kidParentSC);
|
|
|
|
}
|
|
|
|
NS_RELEASE(kidSC);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::DidReflowFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsReflowStatus aStatus)
|
|
|
|
{
|
|
|
|
}
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::ReflowBlockFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
PRBool& aKeepReflowGoing)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aKeepReflowGoing, "bad caller");
|
|
|
|
NS_PRECONDITION(0 == aState.mLineLayout->GetPlacedFrames(),
|
|
|
|
"non-empty line with a block");
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = NS_OK;
|
1998-11-18 01:28:51 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
|
|
|
|
// Prepare the inline reflow engine
|
|
|
|
nsBaseIBFrame* runInToFrame;
|
|
|
|
nsBaseIBFrame* compactWithFrame;
|
|
|
|
nscoord compactMarginWidth = 0;
|
|
|
|
PRBool isCompactFrame = PR_FALSE;
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
frame->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&) display);
|
|
|
|
switch (display->mDisplay) {
|
|
|
|
case NS_STYLE_DISPLAY_RUN_IN:
|
|
|
|
#ifdef NOISY_RUNIN
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": trying to see if ");
|
|
|
|
aFrame->ListTag(stdout);
|
|
|
|
printf(" is a run-in candidate\n");
|
|
|
|
#endif
|
|
|
|
runInToFrame = FindFollowingBlockFrame(frame);
|
|
|
|
if (nsnull != runInToFrame) {
|
|
|
|
// XXX run-in frame should be pushed to the next-in-flow too if the
|
|
|
|
// run-in-to frame is pushed.
|
|
|
|
nsRect r(0, aState.mY, 0, 0);
|
|
|
|
aLine->mBounds = r;
|
|
|
|
aLine->mCombinedArea = r;
|
|
|
|
aLine->mCarriedOutTopMargin = 0;
|
|
|
|
aLine->mCarriedOutBottomMargin = 0;
|
|
|
|
aLine->SetMarginFlags(0);
|
|
|
|
aLine->ClearOutsideChildren();
|
|
|
|
aLine->mBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
//XXX aFrame->WillReflow(aState.mPresContext);
|
|
|
|
frame->SetRect(r);
|
|
|
|
aState.mPrevChild = frame;
|
|
|
|
aState.mRunInToFrame = runInToFrame;
|
|
|
|
aState.mRunInFrame = (nsBlockFrame*) frame;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_DISPLAY_COMPACT:
|
|
|
|
compactWithFrame = FindFollowingBlockFrame(frame);
|
|
|
|
if (nsnull != compactWithFrame) {
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
nsMargin margin;
|
|
|
|
nsresult rv;
|
|
|
|
rv = compactWithFrame->GetStyleData(eStyleStruct_Spacing,
|
|
|
|
(const nsStyleStruct*&) spacing);
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != spacing)) {
|
|
|
|
nsHTMLReflowState::ComputeMarginFor(compactWithFrame, &aState,
|
|
|
|
margin);
|
|
|
|
compactMarginWidth = margin.left;
|
1998-11-06 05:09:21 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
isCompactFrame = PR_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1998-11-18 01:28:51 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockReflowContext brc(aState.mPresContext, *aState.mLineLayout, aState);
|
|
|
|
brc.SetCompactMarginWidth(compactMarginWidth);
|
|
|
|
|
|
|
|
// Clear floaters before the block if the clear style is not none
|
|
|
|
aLine->mBreakType = display->mBreakType;
|
|
|
|
if (NS_STYLE_CLEAR_NONE != display->mBreakType) {
|
|
|
|
switch (display->mBreakType) {
|
|
|
|
case NS_STYLE_CLEAR_LEFT:
|
|
|
|
case NS_STYLE_CLEAR_RIGHT:
|
|
|
|
case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
|
|
|
|
aState.ClearFloaters(aState.mY, display->mBreakType);
|
|
|
|
// XXX: ?If we just advanced Y then we need to factor that amount
|
|
|
|
// into the next margin calculation and reduce the amount of Y
|
|
|
|
// margin applied by the amount just moved.
|
|
|
|
break;
|
1998-11-06 05:09:21 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Set run-in frame if this is the run-in-to frame. That way the
|
|
|
|
// target block frame knows to pick up the children from the run-in
|
|
|
|
// frame.
|
|
|
|
if (frame == aState.mRunInToFrame) {
|
|
|
|
brc.SetRunInFrame(aState.mRunInFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute the available space for the block
|
|
|
|
nscoord availHeight = aState.mUnconstrainedHeight
|
|
|
|
? NS_UNCONSTRAINEDSIZE
|
|
|
|
: aState.mBottomEdge - aState.mY;
|
|
|
|
|
|
|
|
// Now setup the availSpace rect. If the block frame we are
|
|
|
|
// reflowing is one of "ours" (block, run-in, compact, list-item)
|
|
|
|
// then we get it an available space that is *NOT* affected by
|
|
|
|
// floaters. Otherwise we position the block outside of the
|
|
|
|
// floaters.
|
|
|
|
nscoord availX, availWidth;
|
1998-12-09 00:43:15 +03:00
|
|
|
nsSplittableType splitType;
|
1998-12-05 19:02:08 +03:00
|
|
|
switch (display->mDisplay) {
|
|
|
|
case NS_STYLE_DISPLAY_BLOCK:
|
|
|
|
case NS_STYLE_DISPLAY_RUN_IN:
|
|
|
|
case NS_STYLE_DISPLAY_COMPACT:
|
|
|
|
case NS_STYLE_DISPLAY_LIST_ITEM:
|
1998-12-09 00:43:15 +03:00
|
|
|
if (NS_SUCCEEDED(frame->IsSplittable(splitType)) &&
|
|
|
|
(NS_FRAME_SPLITTABLE_NON_RECTANGULAR == splitType)) {
|
|
|
|
availX = aState.mBorderPadding.left;
|
|
|
|
availWidth = aState.mUnconstrainedWidth
|
|
|
|
? NS_UNCONSTRAINEDSIZE
|
|
|
|
: aState.mContentArea.width;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Assume the frame is clueless about the space manager
|
|
|
|
// FALLTHROUGH
|
1998-11-18 01:28:51 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
default:
|
1998-12-09 00:43:15 +03:00
|
|
|
availX = aState.mAvailSpaceRect.x + aState.mBorderPadding.left;
|
|
|
|
availWidth = aState.mAvailSpaceRect.width;
|
1998-12-05 19:02:08 +03:00
|
|
|
break;
|
|
|
|
}
|
1998-11-18 01:28:51 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Reflow the block into the available space
|
|
|
|
nsRect availSpace(availX, aState.mY, availWidth, availHeight);
|
|
|
|
WillReflowFrame(aState, aLine, frame);
|
|
|
|
nsReflowStatus frameReflowStatus;
|
|
|
|
rv = brc.ReflowBlock(frame, availSpace, frameReflowStatus);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
DidReflowFrame(aState, aLine, frame, frameReflowStatus);
|
|
|
|
aState.mPrevChild = frame;
|
1998-11-18 01:28:51 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#if defined(REFLOW_STATUS_COVERAGE)
|
|
|
|
RecordReflowStatus(0 == (mFlags & BLOCK_IS_INLINE), PR_TRUE,
|
|
|
|
frameReflowStatus);
|
|
|
|
#endif
|
1998-11-18 01:28:51 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(frameReflowStatus)) {
|
|
|
|
// None of the child block fits.
|
|
|
|
PushLines(aState);
|
|
|
|
aKeepReflowGoing = PR_FALSE;
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
else {
|
1998-12-11 18:49:07 +03:00
|
|
|
// Note: line-break-after a block is a nop
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// Try to place the child block
|
|
|
|
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
|
|
|
|
PRBool applyTopMargin = aState.ShouldApplyTopMargin();
|
|
|
|
aKeepReflowGoing = brc.PlaceBlock(isAdjacentWithTop, applyTopMargin,
|
|
|
|
aState.mPrevBottomMargin,
|
|
|
|
aLine->mBounds, aLine->mCombinedArea);
|
|
|
|
if (aKeepReflowGoing) {
|
|
|
|
// Some of the child block fit
|
|
|
|
|
|
|
|
// Set carry out top margin value when margin is not being applied
|
|
|
|
if (!applyTopMargin) {
|
|
|
|
aState.mCarriedOutTopMargin = brc.GetCollapsedTopMargin();
|
|
|
|
}
|
1998-11-20 20:18:58 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Advance to new Y position
|
|
|
|
nscoord newY = aLine->mBounds.YMost();
|
|
|
|
if (isCompactFrame) {
|
|
|
|
// For compact frames, we don't adjust the Y coordinate at all IF
|
|
|
|
// the compact frame ended up fitting in the margin space
|
|
|
|
// allocated for it.
|
|
|
|
nsRect r;
|
|
|
|
frame->GetRect(r);
|
|
|
|
if (r.width <= compactMarginWidth) {
|
|
|
|
// XXX margins will be wrong
|
|
|
|
// XXX ltr/rtl for horizontal placement within the margin area
|
|
|
|
// XXX vertical alignment with the compactWith frame's *first line*
|
|
|
|
newY = aState.mY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aState.mY = newY;
|
|
|
|
aLine->mCarriedOutTopMargin = brc.GetCarriedOutTopMargin();
|
|
|
|
aLine->mCarriedOutBottomMargin = brc.GetCarriedOutBottomMargin();
|
|
|
|
|
|
|
|
// Continue the block frame now if it didn't completely fit in
|
|
|
|
// the available space.
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) {
|
|
|
|
PRBool madeContinuation;
|
|
|
|
rv = CreateContinuationFor(aState, aLine, frame, madeContinuation);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-11-20 20:18:58 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Push continuation to a new line, but only if we actually
|
|
|
|
// made one.
|
|
|
|
if (madeContinuation) {
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
nsLineBox* line = new nsLineBox(frame, 1, LINE_IS_BLOCK);
|
|
|
|
if (nsnull == line) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-10-17 00:22:39 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
line->mNext = aLine->mNext;
|
|
|
|
aLine->mNext = line;
|
1998-11-18 01:28:51 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Do not count the continuation child on the line it used
|
|
|
|
// to be on
|
|
|
|
aLine->mChildCount--;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// Advance to next line since some of the block fit. That way
|
|
|
|
// only the following lines will be pushed.
|
|
|
|
aState.mPrevLine = aLine;
|
|
|
|
PushLines(aState);
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
aKeepReflowGoing = PR_FALSE;
|
|
|
|
|
|
|
|
// The bottom margin for a block is only applied on the last
|
|
|
|
// flow block. Since we just continued the child block frame,
|
|
|
|
// we know that line->mFirstChild is not the last flow block
|
|
|
|
// therefore zero out the running margin value.
|
|
|
|
aState.mPrevBottomMargin = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aState.mPrevBottomMargin = brc.GetCollapsedBottomMargin();
|
1998-11-06 05:09:21 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Post-process the "line"
|
|
|
|
PostPlaceLine(aState, aLine, brc.GetMaxElementSize());
|
|
|
|
|
|
|
|
// Notify anyone who cares that the line has been placed
|
|
|
|
DidPlaceLine(aState, aLine, brc.GetCollapsedTopMargin(),
|
|
|
|
brc.GetCollapsedBottomMargin(), aKeepReflowGoing);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// None of the block fits. Determine the correct reflow status.
|
|
|
|
if (aLine == mLines) {
|
|
|
|
// If it's our very first line then we need to be pushed to
|
|
|
|
// our parents next-in-flow. Therefore, return break-before
|
|
|
|
// status for our reflow status.
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Push the line that didn't fit and any lines that follow it
|
|
|
|
// to our next-in-flow.
|
|
|
|
PushLines(aState);
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return rv;
|
|
|
|
}
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Reflow an inline frame. The reflow status is mapped from the frames
|
|
|
|
* reflow status to the lines reflow status (not to our reflow status).
|
|
|
|
* The line reflow status is simple: PR_TRUE means keep placing frames
|
|
|
|
* on the line; PR_FALSE means don't (the line is done). If the line
|
|
|
|
* has some sort of breaking affect then aLine->mBreakType will be set
|
|
|
|
* to something other than NS_STYLE_CLEAR_NONE.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::ReflowInlineFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRBool& aKeepLineGoing,
|
|
|
|
PRBool& aKeepReflowGoing)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aKeepLineGoing && aKeepReflowGoing, "bad caller");
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Send pre-reflow notification
|
|
|
|
WillReflowFrame(aState, aLine, aFrame);
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If it's currently ok to be reflowing in first-letter style then
|
|
|
|
// we must be about to reflow a frame that has first-letter style.
|
|
|
|
PRBool reflowingFirstLetter = aState.mLineLayout->GetFirstLetterStyleOK();
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Reflow the inline frame
|
|
|
|
nsReflowStatus frameReflowStatus;
|
|
|
|
nsresult rv = aState.mInlineReflow->ReflowFrame(aFrame, frameReflowStatus);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#if defined(REFLOW_STATUS_COVERAGE)
|
|
|
|
RecordReflowStatus(0 == (mFlags & BLOCK_IS_INLINE), PR_FALSE,
|
|
|
|
frameReflowStatus);
|
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Send post-reflow notification
|
|
|
|
DidReflowFrame(aState, aLine, aFrame, frameReflowStatus);
|
|
|
|
aState.mPrevChild = aFrame;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Process the child frames reflow status. There are 5 cases:
|
|
|
|
// complete, not-complete, break-before, break-after-complete,
|
|
|
|
// break-after-not-complete. There are two situations: we are a
|
|
|
|
// block or we are an inline. This makes a total of 10 cases
|
|
|
|
// (fortunately, there is some overlap).
|
|
|
|
aLine->mBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
if (NS_INLINE_IS_BREAK(frameReflowStatus)) {
|
|
|
|
// Always abort the line reflow (because a line break is the
|
|
|
|
// minimal amount of break we do).
|
|
|
|
aKeepLineGoing = PR_FALSE;
|
|
|
|
|
|
|
|
// XXX what should aLine->mBreakType be set to in all these cases?
|
|
|
|
PRUint8 breakType = NS_INLINE_GET_BREAK_TYPE(frameReflowStatus);
|
|
|
|
NS_ASSERTION(breakType != NS_STYLE_CLEAR_NONE, "bad break type");
|
|
|
|
NS_ASSERTION(NS_STYLE_CLEAR_PAGE != breakType, "no page breaks yet");
|
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(frameReflowStatus)) {
|
|
|
|
// Break-before cases.
|
|
|
|
if (aFrame == aLine->mFirstChild) {
|
|
|
|
// All break-before's that occur at the first child on a
|
|
|
|
// line stop the overall reflow.
|
|
|
|
aKeepReflowGoing = PR_FALSE;
|
|
|
|
if (mLines == aLine) {
|
|
|
|
// If it's our first child on our first line then propogate
|
|
|
|
// outward the break-before reflow status unmodified.
|
|
|
|
aState.mReflowStatus = frameReflowStatus;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Its not our first line; push the remaining lines to a
|
|
|
|
// next-in-flow
|
|
|
|
PushLines(aState);
|
|
|
|
|
|
|
|
// Adjust the reflow status to indicate a
|
|
|
|
// break-after-not-complete; because we need to be continued
|
|
|
|
// and we need to force a line break (or something stronger)
|
|
|
|
// upstream.
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE | NS_INLINE_BREAK |
|
|
|
|
NS_INLINE_BREAK_AFTER | NS_INLINE_MAKE_BREAK_TYPE(breakType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// It's not the first child on this line so go ahead and split
|
|
|
|
// the line. We will see the frame again on the next-line.
|
|
|
|
rv = SplitLine(aState, aLine, aFrame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (BLOCK_IS_INLINE & mFlags) {
|
|
|
|
// Push the line following this line to the next-in-flow
|
|
|
|
aState.mPrevLine = aLine;
|
|
|
|
PushLines(aState);
|
|
|
|
|
|
|
|
// Abort the inline reflow in addition to the line
|
|
|
|
// reflow. Adjust the reflow status to be a break-after
|
|
|
|
// type of break.
|
|
|
|
aKeepReflowGoing = PR_FALSE;
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE | NS_INLINE_BREAK |
|
|
|
|
NS_INLINE_BREAK_AFTER | NS_INLINE_MAKE_BREAK_TYPE(breakType);
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// Break-after cases
|
|
|
|
aLine->mBreakType = breakType;
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) {
|
|
|
|
// Create a continuation for the incomplete frame. Note that the
|
|
|
|
// frame may already have a continuation.
|
|
|
|
PRBool madeContinuation;
|
|
|
|
rv = CreateContinuationFor(aState, aLine, aFrame, madeContinuation);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Split line, but after the frame just reflowed
|
|
|
|
aFrame->GetNextSibling(aFrame);
|
|
|
|
rv = SplitLine(aState, aLine, aFrame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Terminate the overall reflow if this is an inline frame.
|
|
|
|
if (BLOCK_IS_INLINE & mFlags) {
|
|
|
|
// Push the line following this line to the next-in-flow
|
|
|
|
aState.mPrevLine = aLine;
|
|
|
|
PushLines(aState);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
aKeepReflowGoing = PR_FALSE;
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE | NS_INLINE_BREAK |
|
|
|
|
NS_INLINE_BREAK_AFTER | NS_INLINE_MAKE_BREAK_TYPE(breakType);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) {
|
|
|
|
// Frame is not-complete, no special breaking status
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Create a continuation for the incomplete frame. Note that the
|
|
|
|
// frame may already have a continuation.
|
|
|
|
PRBool madeContinuation;
|
|
|
|
rv = CreateContinuationFor(aState, aLine, aFrame, madeContinuation);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool needSplit = PR_FALSE;
|
|
|
|
if (reflowingFirstLetter) {
|
|
|
|
if (BLOCK_IS_INLINE & mFlags) {
|
|
|
|
// Force this inline frame to be continued so that it's style
|
|
|
|
// context can be repaired by the outermost block. Note that
|
|
|
|
// this works all the way up until we reach the containing
|
|
|
|
// block frame.
|
|
|
|
needSplit = PR_TRUE;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
1998-12-05 19:02:08 +03:00
|
|
|
needSplit = PR_TRUE;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (needSplit) {
|
|
|
|
// Split line after the current frame
|
|
|
|
aKeepLineGoing = PR_FALSE;
|
|
|
|
aFrame->GetNextSibling(aFrame);
|
|
|
|
rv = SplitLine(aState, aLine, aFrame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// Frame is complete. However, we might need to split anyway...
|
|
|
|
if (reflowingFirstLetter) {
|
|
|
|
if (BLOCK_IS_INLINE & mFlags) {
|
|
|
|
// Force this inline frame to be continued so that it's style
|
|
|
|
// context can be repaired by the outermost block. Note that
|
|
|
|
// this works all the way up until we reach the containing
|
|
|
|
// block frame.
|
|
|
|
aKeepLineGoing = PR_FALSE;
|
|
|
|
aFrame->GetNextSibling(aFrame);
|
|
|
|
rv = SplitLine(aState, aLine, aFrame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Create a continuation, if necessary, for aFrame. Place it on the
|
|
|
|
* same line that aFrame is on. Set aMadeNewFrame to PR_TRUE if a
|
|
|
|
* new frame is created.
|
|
|
|
*/
|
1998-09-15 04:19:49 +04:00
|
|
|
nsresult
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::CreateContinuationFor(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRBool& aMadeNewFrame)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
aMadeNewFrame = PR_FALSE;
|
|
|
|
nsresult rv;
|
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
rv = CreateNextInFlow(aState.mPresContext, this, aFrame, nextInFlow);
|
|
|
|
if (NS_FAILED(rv)) {
|
1998-09-15 04:19:49 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
if (nsnull != nextInFlow) {
|
|
|
|
aMadeNewFrame = PR_TRUE;
|
|
|
|
aLine->mChildCount++;
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLineLength(aLine);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::SplitLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame)
|
1998-10-03 01:50:53 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
PRInt32 pushCount = aLine->ChildCount() -
|
|
|
|
aState.mInlineReflow->GetCurrentFrameNum();
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::SplitLine: pushing %d frames",
|
|
|
|
pushCount));
|
|
|
|
if (0 != pushCount) {
|
|
|
|
NS_ASSERTION(aLine->ChildCount() > pushCount, "bad push");
|
|
|
|
NS_ASSERTION(nsnull != aFrame, "whoops");
|
|
|
|
nsLineBox* to = aLine->mNext;
|
|
|
|
if (nsnull != to) {
|
|
|
|
// Only push into the next line if it's empty; otherwise we can
|
|
|
|
// end up pushing a frame which is continued into the same frame
|
|
|
|
// as it's continuation. This causes all sorts of bad side
|
|
|
|
// effects so we don't allow it.
|
|
|
|
if (0 != to->ChildCount()) {
|
|
|
|
nsLineBox* insertedLine = new nsLineBox(aFrame, pushCount, 0);
|
|
|
|
if (nsnull == insertedLine) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aLine->mNext = insertedLine;
|
|
|
|
insertedLine->mNext = to;
|
|
|
|
to = insertedLine;
|
|
|
|
} else {
|
|
|
|
to->mFirstChild = aFrame;
|
|
|
|
to->mChildCount += pushCount;
|
|
|
|
to->MarkDirty();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
to = new nsLineBox(aFrame, pushCount, 0);
|
|
|
|
if (nsnull == to) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aLine->mNext = to;
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
to->SetIsBlock(aLine->IsBlock());
|
|
|
|
aLine->mChildCount -= pushCount;
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLineLength(aLine);
|
|
|
|
#endif
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Let inline reflow know that some frames are no longer part of
|
|
|
|
// its state.
|
|
|
|
if (!aLine->IsBlock()) {
|
|
|
|
aState.mInlineReflow->ChangeFrameCount(aLine->ChildCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool
|
|
|
|
nsBaseIBFrame::ShouldJustifyLine(nsBlockReflowState& aState, nsLineBox* aLine)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsLineBox* next = aLine->mNext;
|
|
|
|
while (nsnull != next) {
|
|
|
|
// There is another line
|
|
|
|
if (0 != next->ChildCount()) {
|
|
|
|
// If the next line is a block line then we must not justify
|
|
|
|
// this line because it means that this line is the last in a
|
|
|
|
// group of inline lines.
|
|
|
|
return !next->IsBlock();
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// The next line is empty, try the next one
|
|
|
|
next = next->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX Not sure about this part
|
|
|
|
// Try our next-in-flows lines to answer the question
|
|
|
|
nsBaseIBFrame* nextInFlow = (nsBaseIBFrame*) mNextInFlow;
|
|
|
|
while (nsnull != nextInFlow) {
|
|
|
|
nsLineBox* line = nextInFlow->mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (0 != line->ChildCount()) {
|
1998-12-11 18:49:07 +03:00
|
|
|
return !line->IsBlock();
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
line = line->mNext;
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
nextInFlow = (nsBaseIBFrame*) nextInFlow->mNextInFlow;
|
|
|
|
}
|
1998-11-11 06:55:55 +03:00
|
|
|
|
1998-12-11 18:49:07 +03:00
|
|
|
// This is the last line - so don't allow justification
|
|
|
|
return PR_FALSE;
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::PlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
PRBool& aKeepReflowGoing)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Align the children. This also determines the actual height and
|
|
|
|
// width of the line.
|
|
|
|
nsInlineReflow& ir = *aState.mInlineReflow;
|
|
|
|
ir.VerticalAlignFrames(aLine->mBounds, aState.mAscent, aState.mDescent);
|
|
|
|
|
|
|
|
// Only block frames horizontally align their children because
|
|
|
|
// inline frames "shrink-wrap" around their children (therefore
|
|
|
|
// there is no extra horizontal space).
|
|
|
|
if (0 == (BLOCK_IS_INLINE & mFlags)) {
|
|
|
|
PRBool allowJustify = PR_TRUE;
|
|
|
|
if (NS_STYLE_TEXT_ALIGN_JUSTIFY == aState.mStyleText->mTextAlign) {
|
|
|
|
allowJustify = ShouldJustifyLine(aState, aLine);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
ir.HorizontalAlignFrames(aLine->mBounds, allowJustify);
|
|
|
|
}
|
|
|
|
ir.RelativePositionFrames(aLine->mCombinedArea);
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Calculate the bottom margin for the line.
|
|
|
|
nscoord lineBottomMargin = 0;
|
|
|
|
if (0 == aLine->mBounds.height) {
|
|
|
|
nsIFrame* brFrame = aState.mLineLayout->GetBRFrame();
|
|
|
|
if (nsnull != brFrame) {
|
|
|
|
// If a line ends in a BR, and the line is empty of height, then
|
|
|
|
// we make sure that the line ends up with some height
|
|
|
|
// anyway. Note that the height looks like vertical margin so
|
|
|
|
// that it can compress with other block margins.
|
|
|
|
nsIStyleContext* brSC;
|
|
|
|
nsIPresContext& px = aState.mPresContext;
|
|
|
|
nsresult rv = brFrame->GetStyleContext(brSC);
|
|
|
|
if ((NS_OK == rv) && (nsnull != brSC)) {
|
|
|
|
const nsStyleFont* font = (const nsStyleFont*)
|
|
|
|
brSC->GetStyleData(eStyleStruct_Font);
|
|
|
|
nsIFontMetrics* fm = px.GetMetricsFor(font->mFont);
|
|
|
|
if (nsnull != fm) {
|
|
|
|
fm->GetHeight(lineBottomMargin);
|
|
|
|
NS_RELEASE(fm);
|
|
|
|
}
|
|
|
|
NS_RELEASE(brSC);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
aState.mRunInFromFrame = nsnull;
|
|
|
|
aState.mRunInToFrame = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the lines top and bottom margin values. The margin will
|
|
|
|
// come from an embedded block frame, not from inline
|
|
|
|
// frames. Because this is an "inline" line, the child margins are
|
|
|
|
// all effectively zero so we pass in nsMargin(0, 0, 0, 0).
|
|
|
|
nscoord topMargin, bottomMargin;
|
|
|
|
nsBlockReflowContext::CollapseMargins(nsMargin(0, 0, 0, 0),
|
|
|
|
ir.GetCarriedOutTopMargin(),
|
|
|
|
ir.GetCarriedOutBottomMargin(),
|
|
|
|
aLine->mBounds.height,
|
|
|
|
aState.mPrevBottomMargin,
|
|
|
|
topMargin, bottomMargin);
|
|
|
|
|
|
|
|
#if XXX
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": ");
|
|
|
|
((nsFrame*)(aLine->mFirstChild))->ListTag(stdout);
|
|
|
|
printf(" mY=%d carried=%d,%d top=%d bottom=%d prev=%d shouldApply=%s\n",
|
|
|
|
aState.mY, ir.GetCarriedOutTopMargin(), ir.GetCarriedOutBottomMargin(),
|
|
|
|
topMargin, bottomMargin, aState.mPrevBottomMargin,
|
|
|
|
aState.ShouldApplyTopMargin() ? "yes" : "no");
|
|
|
|
#endif
|
|
|
|
if (!aState.ShouldApplyTopMargin()) {
|
|
|
|
aState.mCarriedOutTopMargin = topMargin;
|
|
|
|
topMargin = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the line fit. If it doesn't we need to push it. Our first
|
|
|
|
// line will always fit.
|
|
|
|
nscoord newY = aLine->mBounds.YMost() + topMargin + lineBottomMargin;
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CHILD_REFLOW,
|
|
|
|
("nsBaseIBFrame::PlaceLine: newY=%d limit=%d lineHeight=%d",
|
|
|
|
newY, aState.mBottomEdge, aLine->mBounds.height));
|
|
|
|
if ((mLines != aLine) && (newY > aState.mBottomEdge)) {
|
|
|
|
// Push this line and all of it's children and anything else that
|
|
|
|
// follows to our next-in-flow
|
|
|
|
PushLines(aState);
|
|
|
|
|
|
|
|
// Stop reflow and whack the reflow status if reflow hasn't
|
|
|
|
// already been stopped.
|
|
|
|
if (aKeepReflowGoing) {
|
|
|
|
NS_ASSERTION(NS_FRAME_COMPLETE == aState.mReflowStatus,
|
|
|
|
"lost reflow status");
|
|
|
|
aState.mReflowStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
aKeepReflowGoing = PR_FALSE;
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return rv;
|
|
|
|
}
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
aLine->mCarriedOutTopMargin = ir.GetCarriedOutTopMargin();
|
|
|
|
aLine->mCarriedOutBottomMargin = ir.GetCarriedOutBottomMargin();
|
|
|
|
aState.mPrevBottomMargin = bottomMargin;
|
|
|
|
if (0 != topMargin) {
|
|
|
|
// Apply collapsed top-margin value
|
|
|
|
SlideFrames(aState.mPresContext, aState.mSpaceManager, aLine, topMargin);
|
|
|
|
}
|
|
|
|
aState.mY = newY;
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Any below current line floaters to place?
|
|
|
|
if (0 != aState.mPendingFloaters.Count()) {
|
|
|
|
aState.PlaceFloaters(&aState.mPendingFloaters, PR_FALSE);
|
|
|
|
aState.mPendingFloaters.Clear();
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Apply break-after clearing if necessary
|
|
|
|
PRUint8 breakType = aLine->mBreakType;
|
|
|
|
switch (breakType) {
|
|
|
|
case NS_STYLE_CLEAR_LEFT:
|
|
|
|
case NS_STYLE_CLEAR_RIGHT:
|
|
|
|
case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
|
|
|
|
aState.ClearFloaters(aState.mY, breakType);
|
|
|
|
break;
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PostPlaceLine(aState, aLine, ir.GetMaxElementSize());
|
|
|
|
|
|
|
|
// Notify anyone who cares that the line has been placed
|
|
|
|
DidPlaceLine(aState, aLine, topMargin, bottomMargin, aKeepReflowGoing);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::PostPlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
const nsSize& aMaxElementSize)
|
|
|
|
{
|
|
|
|
// Update max-element-size
|
|
|
|
if (aState.mComputeMaxElementSize) {
|
|
|
|
if (aMaxElementSize.width > aState.mMaxElementSize.width) {
|
|
|
|
aState.mMaxElementSize.width = aMaxElementSize.width;
|
|
|
|
}
|
|
|
|
if (aMaxElementSize.height > aState.mMaxElementSize.height) {
|
|
|
|
aState.mMaxElementSize.height = aMaxElementSize.height;
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute LINE_OUTSIDE_CHILDREN state for this line. The bit is set
|
|
|
|
// if any child frame has outside children.
|
|
|
|
aLine->ClearOutsideChildren();
|
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
PRInt32 n = aLine->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
nsFrameState state;
|
|
|
|
frame->GetFrameState(state);
|
|
|
|
if (NS_FRAME_OUTSIDE_CHILDREN & state) {
|
|
|
|
aLine->SetOutsideChildren();
|
1998-11-05 22:33:01 +03:00
|
|
|
break;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
frame->GetNextSibling(frame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Update xmost
|
|
|
|
nscoord xmost = aLine->mBounds.XMost();
|
|
|
|
if (xmost > aState.mKidXMost) {
|
|
|
|
aState.mKidXMost = xmost;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::DidPlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscoord aTopMargin, nscoord aBottomMargin,
|
|
|
|
PRBool aLineReflowStatus)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
static nsresult
|
|
|
|
FindFloatersIn(nsIFrame* aFrame, nsVoidArray*& aArray)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&) display);
|
|
|
|
if (NS_STYLE_FLOAT_NONE != display->mFloats) {
|
|
|
|
if (nsnull == aArray) {
|
|
|
|
aArray = new nsVoidArray();
|
|
|
|
if (nsnull == aArray) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aArray->AppendElement(aFrame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (NS_STYLE_DISPLAY_INLINE == display->mDisplay) {
|
|
|
|
nsIFrame* kid;
|
|
|
|
aFrame->FirstChild(nsnull, kid);
|
|
|
|
while (nsnull != kid) {
|
|
|
|
nsresult rv = FindFloatersIn(kid, aArray);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
kid->GetNextSibling(kid);
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::FindFloaters(nsLineBox* aLine)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsVoidArray* floaters = aLine->mFloaters;
|
|
|
|
if (nsnull != floaters) {
|
|
|
|
// Empty floater array before proceeding
|
|
|
|
floaters->Clear();
|
|
|
|
}
|
1998-09-18 21:18:37 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
PRInt32 n = aLine->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
FindFloatersIn(frame, floaters);
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
1998-09-18 21:18:37 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
aLine->mFloaters = floaters;
|
1998-09-18 21:18:37 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get rid of floater array if we don't need it
|
|
|
|
if (nsnull != floaters) {
|
|
|
|
if (0 == floaters->Count()) {
|
|
|
|
delete floaters;
|
|
|
|
aLine->mFloaters = nsnull;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::PushLines(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_ASSERTION(nsnull != aState.mPrevLine, "bad push");
|
1998-09-25 09:13:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsLineBox* lastLine = aState.mPrevLine;
|
|
|
|
nsLineBox* nextLine = lastLine->mNext;
|
1998-09-25 09:13:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
lastLine->mNext = nsnull;
|
|
|
|
mOverflowLines = nextLine;
|
1998-09-25 09:13:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Mark all the overflow lines dirty so that they get reflowed when
|
|
|
|
// they are pulled up by our next-in-flow.
|
|
|
|
while (nsnull != nextLine) {
|
|
|
|
nextLine->MarkDirty();
|
|
|
|
nextLine = nextLine->mNext;
|
1998-09-25 09:13:06 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Break frame sibling list
|
|
|
|
nsIFrame* lastFrame = lastLine->LastChild();
|
|
|
|
lastFrame->SetNextSibling(nsnull);
|
1998-09-25 09:13:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::PushLines: line=%p prevInFlow=%p nextInFlow=%p",
|
|
|
|
mOverflowLines, mPrevInFlow, mNextInFlow));
|
1998-09-25 09:13:06 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-12-05 19:02:08 +03:00
|
|
|
if (GetVerifyTreeEnable()) {
|
|
|
|
//XXX VerifyChildCount(mLines);
|
|
|
|
//XXX VerifyChildCount(mOverflowLines, PR_TRUE);
|
|
|
|
}
|
1998-09-25 09:13:06 +04:00
|
|
|
#endif
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-25 09:13:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool
|
|
|
|
nsBaseIBFrame::DrainOverflowLines()
|
|
|
|
{
|
|
|
|
PRBool drained = PR_FALSE;
|
1998-11-17 04:04:45 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// First grab the prev-in-flows overflow lines
|
|
|
|
nsBaseIBFrame* prevBlock = (nsBaseIBFrame*) mPrevInFlow;
|
|
|
|
if (nsnull != prevBlock) {
|
|
|
|
nsLineBox* line = prevBlock->mOverflowLines;
|
|
|
|
if (nsnull != line) {
|
|
|
|
drained = PR_TRUE;
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::DrainOverflowLines: line=%p prevInFlow=%p",
|
|
|
|
line, prevBlock));
|
|
|
|
prevBlock->mOverflowLines = nsnull;
|
1998-09-25 09:13:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Make all the frames on the mOverflowLines list mine
|
|
|
|
nsIFrame* lastFrame = nsnull;
|
|
|
|
nsIFrame* frame = line->mFirstChild;
|
|
|
|
while (nsnull != frame) {
|
|
|
|
nsIFrame* geometricParent;
|
|
|
|
nsIFrame* contentParent;
|
|
|
|
frame->GetGeometricParent(geometricParent);
|
|
|
|
frame->GetContentParent(contentParent);
|
|
|
|
if (contentParent == geometricParent) {
|
|
|
|
frame->SetContentParent(this);
|
|
|
|
}
|
|
|
|
frame->SetGeometricParent(this);
|
|
|
|
lastFrame = frame;
|
|
|
|
frame->GetNextSibling(frame);
|
1998-09-25 09:13:06 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Join the line lists
|
|
|
|
if (nsnull == mLines) {
|
|
|
|
mLines = line;
|
1998-09-25 09:13:06 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-12-05 19:02:08 +03:00
|
|
|
// Join the sibling lists together
|
|
|
|
lastFrame->SetNextSibling(mLines->mFirstChild);
|
1998-09-25 09:13:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Place overflow lines at the front of our line list
|
|
|
|
nsLineBox* lastLine = nsLineBox::LastLine(line);
|
|
|
|
lastLine->mNext = mLines;
|
|
|
|
mLines = line;
|
|
|
|
}
|
1998-09-25 09:13:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now grab our own overflow lines
|
|
|
|
if (nsnull != mOverflowLines) {
|
|
|
|
// This can happen when we reflow and not everything fits and then
|
|
|
|
// we are told to reflow again before a next-in-flow is created
|
|
|
|
// and reflows.
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::DrainOverflowLines: from me, line=%p",
|
|
|
|
mOverflowLines));
|
|
|
|
nsLineBox* lastLine = nsLineBox::LastLine(mLines);
|
|
|
|
if (nsnull == lastLine) {
|
|
|
|
mLines = mOverflowLines;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastLine->mNext = mOverflowLines;
|
|
|
|
nsIFrame* lastFrame = lastLine->LastChild();
|
|
|
|
lastFrame->SetNextSibling(mOverflowLines->mFirstChild);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Update our last-content-index now that we have a new last child
|
|
|
|
lastLine = nsLineBox::LastLine(mOverflowLines);
|
|
|
|
}
|
|
|
|
mOverflowLines = nsnull;
|
|
|
|
drained = PR_TRUE;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
if (GetVerifyTreeEnable()) {
|
|
|
|
//XXX VerifyChildCount(mLines, PR_TRUE);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-10-03 08:28:05 +04:00
|
|
|
#endif
|
1998-12-05 19:02:08 +03:00
|
|
|
return drained;
|
1998-09-25 20:10:10 +04:00
|
|
|
}
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
nsresult
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::InsertNewFrame(nsIPresContext& aPresContext,
|
|
|
|
nsBaseIBFrame* aParentFrame,
|
|
|
|
nsIFrame* aNewFrame,
|
|
|
|
nsIFrame* aPrevSibling)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
if (nsnull == mLines) {
|
|
|
|
NS_ASSERTION(nsnull == aPrevSibling, "prev-sibling and empty line list!");
|
|
|
|
return AppendNewFrames(aPresContext, aNewFrame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
const nsStyleDisplay* display;
|
|
|
|
aNewFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display);
|
|
|
|
const nsStylePosition* position;
|
|
|
|
aNewFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position);
|
|
|
|
PRUint16 newFrameIsBlock = nsLineLayout::TreatFrameAsBlock(display, position)
|
|
|
|
? LINE_IS_BLOCK : 0;
|
1998-10-10 08:33:06 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// See if we need to move the frame outside of the flow, and insert a
|
|
|
|
// placeholder frame in its place
|
|
|
|
nsIFrame* placeholder;
|
|
|
|
if (MoveFrameOutOfFlow(aPresContext, aNewFrame, display, position, placeholder)) {
|
|
|
|
// Add the placeholder frame to the flow
|
|
|
|
aNewFrame = placeholder;
|
|
|
|
newFrameIsBlock = PR_FALSE; // placeholder frame is always inline
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Wrap the frame in a view if necessary
|
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
aNewFrame->GetStyleContext(kidSC);
|
|
|
|
nsresult rv = CreateViewForFrame(aPresContext, aNewFrame, kidSC, PR_FALSE);
|
|
|
|
NS_RELEASE(kidSC);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Insert/append the frame into flows line list at the right spot
|
|
|
|
nsLineBox* newLine;
|
|
|
|
nsLineBox* line = aParentFrame->mLines;
|
|
|
|
if (nsnull == aPrevSibling) {
|
|
|
|
// Insert new frame into the sibling list
|
|
|
|
aNewFrame->SetNextSibling(line->mFirstChild);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (line->IsBlock() || newFrameIsBlock) {
|
|
|
|
// Create a new line
|
|
|
|
newLine = new nsLineBox(aNewFrame, 1, newFrameIsBlock);
|
|
|
|
if (nsnull == newLine) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
newLine->mNext = aParentFrame->mLines;
|
|
|
|
aParentFrame->mLines = newLine;
|
|
|
|
} else {
|
|
|
|
// Insert frame at the front of the line
|
|
|
|
line->mFirstChild = aNewFrame;
|
|
|
|
line->mChildCount++;
|
|
|
|
line->MarkDirty();
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Find line containing the previous sibling to the new frame
|
|
|
|
line = nsLineBox::FindLineContaining(line, aPrevSibling);
|
|
|
|
NS_ASSERTION(nsnull != line, "no line contains the previous sibling");
|
|
|
|
if (nsnull != line) {
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
// Create a new line just after line
|
|
|
|
newLine = new nsLineBox(aNewFrame, 1, newFrameIsBlock);
|
|
|
|
if (nsnull == newLine) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
newLine->mNext = line->mNext;
|
|
|
|
line->mNext = newLine;
|
|
|
|
}
|
|
|
|
else if (newFrameIsBlock) {
|
|
|
|
// Split line in two, if necessary. We can't allow a block to
|
|
|
|
// end up in an inline line.
|
|
|
|
if (line->IsLastChild(aPrevSibling)) {
|
|
|
|
// The new frame goes after prevSibling and prevSibling is
|
|
|
|
// the last frame on the line. Therefore we don't need to
|
|
|
|
// split the line, just create a new line.
|
|
|
|
newLine = new nsLineBox(aNewFrame, 1, newFrameIsBlock);
|
|
|
|
if (nsnull == newLine) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
newLine->mNext = line->mNext;
|
|
|
|
line->mNext = newLine;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// The new frame goes after prevSibling and prevSibling is
|
|
|
|
// somewhere in the line, but not at the end. Split the line
|
|
|
|
// just after prevSibling.
|
|
|
|
PRInt32 i, n = line->ChildCount();
|
|
|
|
nsIFrame* frame = line->mFirstChild;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
if (frame == aPrevSibling) {
|
|
|
|
nsIFrame* nextSibling;
|
|
|
|
aPrevSibling->GetNextSibling(nextSibling);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Create new line to hold the remaining frames
|
|
|
|
NS_ASSERTION(n - i - 1 > 0, "bad line count");
|
|
|
|
newLine = new nsLineBox(nextSibling, n - i - 1, 0);
|
|
|
|
if (nsnull == newLine) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
newLine->mNext = line->mNext;
|
|
|
|
line->mNext = newLine;
|
|
|
|
line->MarkDirty();
|
|
|
|
line->mChildCount = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now create a new line to hold the block
|
|
|
|
newLine = new nsLineBox(aNewFrame, 1, newFrameIsBlock);
|
|
|
|
if (nsnull == newLine) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
newLine->mNext = line->mNext;
|
|
|
|
line->mNext = newLine;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// Insert frame into the line.
|
|
|
|
//XXX NS_ASSERTION(line->GetLastContentIsComplete(), "bad line LCIC");
|
|
|
|
line->mChildCount++;
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// Insert new frame into the sibling list; note: this must be done
|
|
|
|
// after the above logic because the above logic depends on the
|
|
|
|
// sibling list being in the "before insertion" state.
|
|
|
|
nsIFrame* nextSibling;
|
|
|
|
aPrevSibling->GetNextSibling(nextSibling);
|
|
|
|
aNewFrame->SetNextSibling(nextSibling);
|
|
|
|
aPrevSibling->SetNextSibling(aNewFrame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX this code can't work...rewrite it!
|
|
|
|
nsresult
|
|
|
|
nsBaseIBFrame::RemoveFrame(nsBlockReflowState& aState,
|
|
|
|
nsBaseIBFrame* aParentFrame,
|
|
|
|
nsIFrame* aDeletedFrame,
|
|
|
|
nsIFrame* aPrevSibling)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Find the line that contains deletedFrame; we also find the pointer to
|
|
|
|
// the line.
|
|
|
|
nsBaseIBFrame* flow = this;
|
|
|
|
nsLineBox** linep = &flow->mLines;
|
|
|
|
nsLineBox* line = flow->mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (line->Contains(aDeletedFrame)) {
|
|
|
|
break;
|
1998-10-17 00:22:39 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
linep = &line->mNext;
|
|
|
|
line = line->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_ASSERTION(nsnull != line, "can't find deleted frame in lines");
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Remove frame and its continuations
|
|
|
|
while (nsnull != aDeletedFrame) {
|
|
|
|
while ((nsnull != line) && (nsnull != aDeletedFrame)) {
|
1998-09-15 04:19:49 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* parent;
|
|
|
|
aDeletedFrame->GetGeometricParent(parent);
|
|
|
|
NS_ASSERTION(flow == parent, "messed up delete code");
|
|
|
|
#endif
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CHILD_REFLOW,
|
|
|
|
("nsBaseIBFrame::ContentDeleted: deadFrame=%p", aDeletedFrame));
|
|
|
|
|
|
|
|
// See if the frame is a floater (actually, the floaters
|
|
|
|
// placeholder). If it is, then destroy the floated frame too.
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
nsresult rv = aDeletedFrame->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&)display);
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != display)) {
|
|
|
|
// XXX Sanitize "IsFloating" question *everywhere* (add a
|
|
|
|
// static method on nsFrame?)
|
|
|
|
if (NS_STYLE_FLOAT_NONE != display->mFloats) {
|
|
|
|
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) aDeletedFrame;
|
|
|
|
nsIFrame* floater = ph->GetAnchoredItem();
|
|
|
|
if (nsnull != floater) {
|
|
|
|
floater->DeleteFrame(aState.mPresContext);
|
|
|
|
if (nsnull != line->mFloaters) {
|
|
|
|
// Wipe out the floater array for this line. It will get
|
|
|
|
// recomputed during reflow anyway.
|
|
|
|
delete line->mFloaters;
|
|
|
|
line->mFloaters = nsnull;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-11-15 00:01:26 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Remove aDeletedFrame from the line
|
|
|
|
if (line->mFirstChild == aDeletedFrame) {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aDeletedFrame->GetNextSibling(nextFrame);
|
|
|
|
line->mFirstChild = nextFrame;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Take aDeletedFrame out of the sibling list
|
|
|
|
if (nsnull != aPrevSibling) {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aDeletedFrame->GetNextSibling(nextFrame);
|
|
|
|
aPrevSibling->SetNextSibling(nextFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy frame; capture its next-in-flow first in case we need
|
|
|
|
// to destroy that too.
|
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
aDeletedFrame->GetNextInFlow(nextInFlow);
|
|
|
|
if (nsnull != nextInFlow) {
|
|
|
|
aDeletedFrame->BreakFromNextFlow();
|
|
|
|
}
|
|
|
|
aDeletedFrame->DeleteFrame(aState.mPresContext);
|
|
|
|
aDeletedFrame = nextInFlow;
|
|
|
|
// XXX If next-in-flow is != next-sibling then we need to break
|
|
|
|
// out of this loop
|
|
|
|
|
|
|
|
// If line is empty, remove it now
|
|
|
|
nsLineBox* next = line->mNext;
|
|
|
|
if (0 == --line->mChildCount) {
|
|
|
|
*linep = next;
|
|
|
|
line->mNext = nsnull;
|
|
|
|
delete line;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
linep = &line->mNext;
|
|
|
|
}
|
|
|
|
line = next;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Advance to next flow block if the frame has more continuations
|
|
|
|
if (nsnull != aDeletedFrame) {
|
|
|
|
flow = (nsBaseIBFrame*) flow->mNextInFlow;
|
|
|
|
NS_ASSERTION(nsnull != flow, "whoops, continuation without a parent");
|
|
|
|
line = flow->mLines;
|
|
|
|
aPrevSibling = nsnull;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool
|
|
|
|
nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aChild)
|
1998-09-23 06:25:26 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_PRECONDITION(IsChild(aChild), "bad geometric parent");
|
1998-10-02 08:10:00 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
nsBaseIBFrame* parent;
|
|
|
|
|
|
|
|
aChild->GetNextInFlow(nextInFlow);
|
|
|
|
NS_PRECONDITION(nsnull != nextInFlow, "null next-in-flow");
|
|
|
|
nextInFlow->GetGeometricParent((nsIFrame*&)parent);
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If the next-in-flow has a next-in-flow then delete it, too (and
|
|
|
|
// delete it first).
|
|
|
|
nsIFrame* nextNextInFlow;
|
|
|
|
nextInFlow->GetNextInFlow(nextNextInFlow);
|
|
|
|
if (nsnull != nextNextInFlow) {
|
|
|
|
parent->DeleteChildsNextInFlow(aPresContext, nextInFlow);
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
PRInt32 childCount;
|
|
|
|
nsIFrame* firstChild;
|
|
|
|
nextInFlow->FirstChild(nsnull, firstChild);
|
|
|
|
childCount = LengthOf(firstChild);
|
|
|
|
NS_ASSERTION((0 == childCount) && (nsnull == firstChild),
|
|
|
|
"deleting !empty next-in-flow");
|
|
|
|
#endif
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Disconnect the next-in-flow from the flow list
|
|
|
|
nextInFlow->BreakFromPrevFlow();
|
|
|
|
|
|
|
|
// Remove nextInFlow from the parents line list. Also remove it from
|
|
|
|
// the sibling list.
|
|
|
|
if (RemoveChild(parent->mLines, nextInFlow)) {
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::DeleteNextInFlowsFor: frame=%p (from mLines)",
|
|
|
|
nextInFlow));
|
|
|
|
goto done;
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If we get here then we didn't find the child on the line list. If
|
|
|
|
// it's not there then it has to be on the overflow lines list.
|
|
|
|
if (nsnull != mOverflowLines) {
|
|
|
|
if (RemoveChild(parent->mOverflowLines, nextInFlow)) {
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::DeleteNextInFlowsFor: frame=%p (from overflow)",
|
|
|
|
nextInFlow));
|
|
|
|
goto done;
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_NOTREACHED("can't find next-in-flow in overflow list");
|
1998-10-06 04:38:56 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
done:;
|
|
|
|
// If the parent is us then we will finish reflowing and update the
|
|
|
|
// content offsets of our parents when we are a pseudo-frame; if the
|
|
|
|
// parent is not us then it's a next-in-flow which means it will get
|
|
|
|
// reflowed by our parent and fix its content offsets. So there.
|
1998-10-06 04:38:56 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Delete the next-in-flow frame and adjust its parents child count
|
|
|
|
nextInFlow->DeleteFrame(aPresContext);
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
aChild->GetNextInFlow(nextInFlow);
|
|
|
|
NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow");
|
|
|
|
#endif
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBaseIBFrame::RemoveChild(nsLineBox* aLines, nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
nsLineBox* line = aLines;
|
|
|
|
nsIFrame* prevChild = nsnull;
|
|
|
|
while (nsnull != line) {
|
|
|
|
nsIFrame* child = line->mFirstChild;
|
|
|
|
PRInt32 n = line->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
nsIFrame* nextChild;
|
|
|
|
child->GetNextSibling(nextChild);
|
|
|
|
if (child == aChild) {
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsBaseIBFrame::RemoveChild: line=%p frame=%p",
|
|
|
|
line, aChild));
|
|
|
|
// Continuations HAVE to be at the start of a line
|
|
|
|
NS_ASSERTION(child == line->mFirstChild, "bad continuation");
|
|
|
|
line->mFirstChild = nextChild;
|
|
|
|
if (0 == --line->mChildCount) {
|
|
|
|
line->mFirstChild = nsnull;
|
|
|
|
}
|
|
|
|
if (nsnull != prevChild) {
|
|
|
|
// When nextInFlow and it's continuation are in the same
|
|
|
|
// container then we remove the nextInFlow from the sibling
|
|
|
|
// list.
|
|
|
|
prevChild->SetNextSibling(nextChild);
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
prevChild = child;
|
|
|
|
child = nextChild;
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
line = line->mNext;
|
1998-10-06 04:38:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return PR_FALSE;
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// Floater support
|
|
|
|
|
1998-10-03 01:50:53 +04:00
|
|
|
void
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext,
|
|
|
|
nsBlockReflowState& aState,
|
|
|
|
nsIFrame* aFloaterFrame,
|
|
|
|
nsHTMLReflowState& aFloaterReflowState)
|
1998-10-03 01:50:53 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// If either dimension is constrained then get the border and
|
|
|
|
// padding values in advance.
|
|
|
|
nsMargin bp(0, 0, 0, 0);
|
|
|
|
if (aFloaterReflowState.HaveFixedContentWidth() ||
|
|
|
|
aFloaterReflowState.HaveFixedContentHeight()) {
|
|
|
|
nsHTMLReflowState::ComputeBorderPaddingFor(aFloaterFrame, &aState, bp);
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute the available width for the floater
|
|
|
|
nsSize& kidAvailSize = aFloaterReflowState.maxSize;
|
|
|
|
if (aFloaterReflowState.HaveFixedContentWidth()) {
|
|
|
|
// When the floater has a contrained width, give it just enough
|
|
|
|
// space for its styled width plus its borders and paddings.
|
|
|
|
kidAvailSize.width = aFloaterReflowState.minWidth + bp.left + bp.right;
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// If we are floating something and we don't know the width then
|
|
|
|
// find a maximum width for it to reflow into. Walk upwards until
|
|
|
|
// we find something with an unconstrained width.
|
|
|
|
const nsHTMLReflowState* rsp = &aState;
|
|
|
|
kidAvailSize.width = 0;
|
|
|
|
while (nsnull != rsp) {
|
|
|
|
if (eHTMLFrameConstraint_FixedContent == rsp->widthConstraint) {
|
|
|
|
kidAvailSize.width = rsp->minWidth;
|
|
|
|
break;
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else if (NS_UNCONSTRAINEDSIZE != rsp->widthConstraint) {
|
|
|
|
kidAvailSize.width = rsp->maxSize.width;
|
|
|
|
if (kidAvailSize.width > 0) {
|
|
|
|
break;
|
|
|
|
}
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX This cast is unfortunate!
|
|
|
|
rsp = (const nsHTMLReflowState*) rsp->parentReflowState;
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Compute the available height for the floater
|
|
|
|
if (aFloaterReflowState.HaveFixedContentHeight()) {
|
|
|
|
kidAvailSize.height = aFloaterReflowState.minHeight + bp.top + bp.bottom;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
kidAvailSize.height = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Resize reflow the anchored item into the available space
|
|
|
|
nsIHTMLReflow* floaterReflow;
|
|
|
|
if (NS_OK == aFloaterFrame->QueryInterface(kIHTMLReflowIID,
|
|
|
|
(void**)&floaterReflow)) {
|
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
nsReflowStatus status;
|
|
|
|
floaterReflow->WillReflow(aPresContext);
|
|
|
|
floaterReflow->Reflow(aPresContext, desiredSize, aFloaterReflowState,
|
|
|
|
status);
|
|
|
|
aFloaterFrame->SizeTo(desiredSize.width, desiredSize.height);
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockReflowState::InitFloater(nsPlaceholderFrame* aPlaceholder)
|
1998-09-23 06:25:26 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
|
1998-11-12 19:32:56 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
floater->SetGeometricParent(mBlock);
|
1998-10-10 02:58:25 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX the choice of constructors is confusing and non-obvious
|
|
|
|
nsSize kidAvailSize(0, 0);
|
|
|
|
nsHTMLReflowState reflowState(mPresContext, floater, *this,
|
|
|
|
kidAvailSize, eReflowReason_Initial);
|
|
|
|
mBlock->ReflowFloater(mPresContext, *this, floater, reflowState);
|
1998-11-12 19:32:56 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
AddFloater(aPlaceholder);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// This is called by the line layout's AddFloater method when a
|
|
|
|
// place-holder frame is reflowed in a line. If the floater is a
|
|
|
|
// left-most child (it's x coordinate is at the line's left margin)
|
|
|
|
// then the floater is place immediately, otherwise the floater
|
|
|
|
// placement is deferred until the line has been reflowed.
|
|
|
|
void
|
|
|
|
nsBlockReflowState::AddFloater(nsPlaceholderFrame* aPlaceholder)
|
|
|
|
{
|
|
|
|
// Update the current line's floater array
|
|
|
|
NS_ASSERTION(nsnull != mCurrentLine, "null ptr");
|
|
|
|
if (nsnull == mCurrentLine->mFloaters) {
|
|
|
|
mCurrentLine->mFloaters = new nsVoidArray();
|
1998-09-25 21:50:09 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
mCurrentLine->mFloaters->AppendElement(aPlaceholder);
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now place the floater immediately if possible. Otherwise stash it
|
|
|
|
// away in mPendingFloaters and place it later.
|
|
|
|
if (0 == mLineLayout->GetPlacedFrames()) {
|
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW,
|
|
|
|
("nsBlockReflowState::AddFloater: IsLeftMostChild, placeHolder=%p",
|
|
|
|
aPlaceholder));
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Flush out pending bottom margin before placing floater
|
|
|
|
if (0 != mPrevBottomMargin) {
|
|
|
|
mY += mPrevBottomMargin;
|
|
|
|
mPrevBottomMargin = 0;
|
1998-11-12 21:19:22 +03:00
|
|
|
}
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Because we are in the middle of reflowing a placeholder frame
|
|
|
|
// within a line (and possibly nested in an inline frame or two
|
|
|
|
// that's a child of our block) we need to restore the space
|
|
|
|
// manager's translation to the space that the block resides in
|
|
|
|
// before placing the floater.
|
|
|
|
PRBool isLeftFloater;
|
|
|
|
nscoord ox, oy;
|
|
|
|
mSpaceManager->GetTranslation(ox, oy);
|
|
|
|
nscoord dx = ox - mSpaceManagerX;
|
|
|
|
nscoord dy = oy - mSpaceManagerY;
|
|
|
|
mSpaceManager->Translate(-dx, -dy);
|
|
|
|
PlaceFloater(aPlaceholder, isLeftFloater);
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Pass on updated available space to the current inline reflow engine
|
|
|
|
GetAvailableSpace();
|
1998-12-09 00:43:15 +03:00
|
|
|
mLineLayout->UpdateInlines(mAvailSpaceRect.x + mBorderPadding.left,
|
1998-12-05 19:02:08 +03:00
|
|
|
mY,
|
1998-12-09 00:43:15 +03:00
|
|
|
mAvailSpaceRect.width,
|
|
|
|
mAvailSpaceRect.height,
|
1998-12-05 19:02:08 +03:00
|
|
|
isLeftFloater);
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Restore coordinate system
|
|
|
|
mSpaceManager->Translate(dx, dy);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// This floater will be placed after the line is done (it is a
|
|
|
|
// below current line floater).
|
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW,
|
|
|
|
("nsBlockReflowState::AddFloater: pending, placeHolder=%p",
|
|
|
|
aPlaceholder));
|
|
|
|
mPendingFloaters.AppendElement(aPlaceholder);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool
|
|
|
|
nsBlockReflowState::IsLeftMostChild(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
for (;;) {
|
|
|
|
nsIFrame* parent;
|
|
|
|
aFrame->GetGeometricParent(parent);
|
|
|
|
if (parent == mBlock) {
|
|
|
|
nsIFrame* child = mCurrentLine->mFirstChild;
|
|
|
|
PRInt32 n = mCurrentLine->ChildCount();
|
|
|
|
while ((nsnull != child) && (aFrame != child) && (--n >= 0)) {
|
|
|
|
nsSize size;
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Is the child zero-sized?
|
|
|
|
child->GetSize(size);
|
|
|
|
if (size.width > 0) {
|
|
|
|
// We found a non-zero sized child frame that precedes aFrame
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
child->GetNextSibling(child);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
break;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// See if there are any non-zero sized child frames that precede
|
|
|
|
// aFrame in the child list
|
|
|
|
nsIFrame* child;
|
|
|
|
parent->FirstChild(nsnull, child);
|
|
|
|
while ((nsnull != child) && (aFrame != child)) {
|
|
|
|
nsSize size;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Is the child zero-sized?
|
|
|
|
child->GetSize(size);
|
|
|
|
if (size.width > 0) {
|
|
|
|
// We found a non-zero sized child frame that precedes aFrame
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
child->GetNextSibling(child);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
// aFrame is the left-most non-zero sized frame in its geometric parent.
|
|
|
|
// Walk up one level and check that its parent is left-most as well
|
|
|
|
aFrame = parent;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,
|
|
|
|
PRBool& aIsLeftFloater)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX the choice of constructors is confusing and non-obvious
|
|
|
|
nsSize kidAvailSize(0, 0);
|
|
|
|
nsHTMLReflowState reflowState(mPresContext, floater, *this, kidAvailSize);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Reflow the floater if it's targetted for a reflow
|
|
|
|
if (nsnull != reflowCommand) {
|
|
|
|
if (floater == mNextRCFrame) {
|
|
|
|
reflowState.lineLayout = nsnull;
|
|
|
|
mBlock->ReflowFloater(mPresContext, *this, floater, reflowState);
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get the type of floater
|
|
|
|
const nsStyleDisplay* floaterDisplay;
|
|
|
|
const nsStyleSpacing* floaterSpacing;
|
|
|
|
floater->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&)floaterDisplay);
|
|
|
|
floater->GetStyleData(eStyleStruct_Spacing,
|
|
|
|
(const nsStyleStruct*&)floaterSpacing);
|
|
|
|
|
|
|
|
// See if the floater should clear any preceeding floaters...
|
|
|
|
if (NS_STYLE_CLEAR_NONE != floaterDisplay->mBreakType) {
|
|
|
|
ClearFloaters(mY, floaterDisplay->mBreakType);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Get the band of available space
|
|
|
|
GetAvailableSpace();
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get the floaters bounding box and margin information
|
|
|
|
nsRect region;
|
|
|
|
floater->GetRect(region);
|
|
|
|
nsMargin floaterMargin;
|
|
|
|
ComputeMarginFor(floater, this, floaterMargin);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Adjust the floater size by its margin. That's the area that will
|
|
|
|
// impact the space manager.
|
|
|
|
region.width += floaterMargin.left + floaterMargin.right;
|
|
|
|
region.height += floaterMargin.top + floaterMargin.bottom;
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Find a place to place the floater. The CSS2 spec doesn't want
|
|
|
|
// floaters overlapping each other or sticking out of the containing
|
|
|
|
// block (CSS2 spec section 9.5.1, see the rule list).
|
|
|
|
NS_ASSERTION((NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) ||
|
|
|
|
(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats),
|
|
|
|
"invalid float type");
|
|
|
|
|
|
|
|
// While there is not enough room for the floater, clear past
|
|
|
|
// other floaters until there is room (or the band is not impacted
|
|
|
|
// by a floater).
|
1998-12-09 00:43:15 +03:00
|
|
|
while ((mAvailSpaceRect.width < region.width) &&
|
|
|
|
(mAvailSpaceRect.width < mContentArea.width)) {
|
1998-12-05 19:02:08 +03:00
|
|
|
// The CSS2 spec says that floaters should be placed as high as
|
|
|
|
// possible. We accomodate this easily by noting that if the band
|
|
|
|
// is not the full width of the content area then it must have
|
|
|
|
// been impacted by a floater. And we know that the height of the
|
|
|
|
// band will be the height of the shortest floater, therefore we
|
|
|
|
// adjust mY by that distance and keep trying until we have enough
|
|
|
|
// space for this floater.
|
|
|
|
#ifdef NOISY_FLOATER_CLEARING
|
|
|
|
mBlock->ListTag(stdout);
|
|
|
|
printf(": clearing floater during floater placement: ");
|
|
|
|
printf("availWidth=%d regionWidth=%d,%d(w/o margins) contentWidth=%d\n",
|
1998-12-09 00:43:15 +03:00
|
|
|
mAvailSpaceRect.width, region.width,
|
1998-12-05 19:02:08 +03:00
|
|
|
region.width - floaterMargin.left - floaterMargin.right,
|
|
|
|
mContentArea.width);
|
|
|
|
#endif
|
1998-12-09 00:43:15 +03:00
|
|
|
mY += mAvailSpaceRect.height;
|
1998-12-05 19:02:08 +03:00
|
|
|
GetAvailableSpace();
|
|
|
|
}
|
1998-11-15 00:01:26 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Assign an x and y coordinate to the floater. Note that the x,y
|
|
|
|
// coordinates are computed <b>relative to the translation in the
|
|
|
|
// spacemanager</b> which means that the impacted region will be
|
|
|
|
// <b>inside</b> the border/padding area.
|
|
|
|
if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
|
|
|
|
aIsLeftFloater = PR_TRUE;
|
1998-12-09 00:43:15 +03:00
|
|
|
region.x = mAvailSpaceRect.x;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-12-05 19:02:08 +03:00
|
|
|
aIsLeftFloater = PR_FALSE;
|
1998-12-09 00:43:15 +03:00
|
|
|
region.x = mAvailSpaceRect.XMost() - region.width;
|
1998-12-08 06:57:12 +03:00
|
|
|
|
|
|
|
// In case the floater is too big, don't go past the left edge
|
1998-12-09 00:43:15 +03:00
|
|
|
if (region.x < mAvailSpaceRect.x) {
|
|
|
|
region.x = mAvailSpaceRect.x;
|
1998-12-08 06:57:12 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
region.y = mY - mBorderPadding.top;
|
|
|
|
if (region.y < 0) {
|
|
|
|
// CSS2 spec, 9.5.1 rule [4]: A floating box's outer top may not
|
|
|
|
// be higher than the top of its containing block.
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX It's not clear if it means the higher than the outer edge
|
|
|
|
// or the border edge or the inner edge?
|
|
|
|
region.y = 0;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Place the floater in the space manager
|
|
|
|
mSpaceManager->AddRectRegion(floater, region);
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Set the origin of the floater frame, in frame coordinates. These
|
|
|
|
// coordinates are <b>not</b> relative to the spacemanager
|
|
|
|
// translation, therefore we have to factor in our border/padding.
|
|
|
|
floater->MoveTo(mBorderPadding.left + floaterMargin.left + region.x,
|
|
|
|
mBorderPadding.top + floaterMargin.top + region.y);
|
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (reason == eReflowReason_Incremental) {
|
|
|
|
nsRect r;
|
|
|
|
floater->GetRect(r);
|
|
|
|
nsFrame::IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("placed floater: ");
|
|
|
|
((nsFrame*)floater)->ListTag(stdout);
|
|
|
|
printf(" %d,%d,%d,%d\n", r.x, r.y, r.width, r.height);
|
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
#endif
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Place below-current-line floaters.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsBlockReflowState::PlaceFloaters(nsVoidArray* aFloaters, PRBool aAllOfThem)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFloaters->Count() > 0, "no floaters");
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRInt32 numFloaters = aFloaters->Count();
|
|
|
|
for (PRInt32 i = 0; i < numFloaters; i++) {
|
|
|
|
nsPlaceholderFrame* placeholderFrame = (nsPlaceholderFrame*)
|
|
|
|
aFloaters->ElementAt(i);
|
|
|
|
if (!aAllOfThem && IsLeftMostChild(placeholderFrame)) {
|
|
|
|
// Left-most children are placed during the line's reflow
|
|
|
|
continue;
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool isLeftFloater;
|
|
|
|
PlaceFloater(placeholderFrame, isLeftFloater);
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Update available spcae now that the floaters have been placed
|
|
|
|
GetAvailableSpace();
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockReflowState::ClearFloaters(nscoord aY, PRUint8 aBreakType)
|
1998-10-27 19:51:02 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (reason == eReflowReason_Incremental) {
|
|
|
|
nsFrame::IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("clear floaters: in: mY=%d aY=%d(%d)\n",
|
|
|
|
mY, aY, aY - mBorderPadding.top);
|
|
|
|
}
|
|
|
|
#endif
|
1998-10-27 19:51:02 +03:00
|
|
|
|
1998-12-09 00:43:15 +03:00
|
|
|
nscoord newY = mCurrentBand.ClearFloaters(aY - mBorderPadding.top,
|
|
|
|
aBreakType);
|
|
|
|
mY = newY;
|
1998-12-05 19:02:08 +03:00
|
|
|
GetAvailableSpace();
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
#ifdef NOISY_INCREMENTAL_REFLOW
|
|
|
|
if (reason == eReflowReason_Incremental) {
|
|
|
|
nsFrame::IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("clear floaters: out: mY=%d(%d)\n",
|
|
|
|
mY, mY - mBorderPadding.top);
|
1998-10-27 19:51:02 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
|
|
|
}
|
1998-10-27 19:51:02 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Painting, event handling
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRIntn
|
|
|
|
nsBaseIBFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
1998-09-30 02:32:56 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
1998-11-11 06:55:55 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return skip;
|
|
|
|
}
|
1998-09-30 02:32:56 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Only paint the border and background if we're visible
|
|
|
|
if (disp->mVisible) {
|
|
|
|
PRIntn skipSides = GetSkipSides();
|
|
|
|
const nsStyleColor* color = (const nsStyleColor*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Paint background and border
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *color, 0, 0);
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *spacing, skipSides);
|
1998-10-31 01:10:10 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If overflow is hidden then set the clip rect so that children
|
|
|
|
// don't leak out of us
|
|
|
|
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
|
|
|
PRBool clipState;
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
|
|
|
|
nsClipCombine_kIntersect, clipState);
|
1998-10-03 01:50:53 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Child elements have the opportunity to override the visibility
|
|
|
|
// property and display even if the parent is hidden
|
|
|
|
PaintFloaters(aPresContext, aRenderingContext, aDirtyRect);
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
|
|
|
PRBool clipState;
|
|
|
|
aRenderingContext.PopState(clipState);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::PaintFloaters(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
|
|
|
{
|
|
|
|
for (nsLineBox* line = mLines; nsnull != line; line = line->mNext) {
|
|
|
|
nsVoidArray* floaters = line->mFloaters;
|
|
|
|
if (nsnull == floaters) {
|
|
|
|
continue;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
PRInt32 i, n = floaters->Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
|
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
ph->GetAnchoredItem());
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBaseIBFrame::PaintChildren(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
|
|
|
{
|
|
|
|
for (nsLineBox* line = mLines; nsnull != line; line = line->mNext) {
|
|
|
|
// If the line has outside children or if the line intersects the
|
|
|
|
// dirty rect then paint the children in the line.
|
|
|
|
if (line->OutsideChildren() ||
|
|
|
|
!((line->mBounds.YMost() <= aDirtyRect.y) ||
|
|
|
|
(line->mBounds.y >= aDirtyRect.YMost()))) {
|
|
|
|
nsIFrame* kid = line->mFirstChild;
|
|
|
|
PRInt32 n = line->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid);
|
|
|
|
kid->GetNextSibling(kid);
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
nsresult rv = GetFrameForPointUsing(aPoint, nsnull, aFrame);
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Debugging
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
static PRBool
|
|
|
|
InLineList(nsLineBox* aLines, nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
while (nsnull != aLines) {
|
|
|
|
nsIFrame* frame = aLines->mFirstChild;
|
|
|
|
PRInt32 n = aLines->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
if (frame == aFrame) {
|
|
|
|
return PR_TRUE;
|
1998-11-05 22:33:01 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
frame->GetNextSibling(frame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aLines = aLines->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return PR_FALSE;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
static PRBool
|
|
|
|
InSiblingList(nsLineBox* aLine, nsIFrame* aFrame)
|
1998-11-12 21:19:22 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
if (nsnull != aLine) {
|
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
while (nsnull != frame) {
|
|
|
|
if (frame == aFrame) {
|
|
|
|
return PR_TRUE;
|
1998-11-12 21:19:22 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
frame->GetNextSibling(frame);
|
1998-11-12 21:19:22 +03:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return PR_FALSE;
|
1998-11-12 21:19:22 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool
|
|
|
|
nsBaseIBFrame::IsChild(nsIFrame* aFrame)
|
1998-11-12 21:19:22 +03:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* parent;
|
|
|
|
aFrame->GetGeometricParent(parent);
|
|
|
|
if (parent != (nsIFrame*)this) {
|
|
|
|
return PR_FALSE;
|
1998-11-12 21:19:22 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
if (InLineList(mLines, aFrame) && InSiblingList(mLines, aFrame)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
if (InLineList(mOverflowLines, aFrame) &&
|
|
|
|
InSiblingList(mOverflowLines, aFrame)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
1998-11-12 21:19:22 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
1998-11-12 21:19:22 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseIBFrame::VerifyTree() const
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX rewrite this
|
1998-09-15 04:19:49 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//----------------------------------------------------------------------
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
NS_NewBlockFrame(nsIFrame*& aNewFrame, PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
nsBlockFrame* it = new nsBlockFrame;
|
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
it->SetFlags(aFlags);
|
|
|
|
aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrame::nsBlockFrame()
|
|
|
|
{
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrame::~nsBlockFrame()
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IF_RELEASE(mFirstLineStyle);
|
|
|
|
NS_IF_RELEASE(mFirstLetterStyle);
|
|
|
|
nsTextRun::DeleteTextRuns(mTextRuns);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::DeleteFrame(nsIPresContext& aPresContext)
|
|
|
|
{
|
|
|
|
// When we have a bullet frame and it's not in our child list then
|
|
|
|
// we need to delete it ourselves (this is the common case for
|
|
|
|
// list-item's that have outside bullets).
|
|
|
|
if ((nsnull != mBullet) &&
|
|
|
|
((nsnull == mLines) || (mBullet != mLines->mFirstChild))) {
|
|
|
|
mBullet->DeleteFrame(aPresContext);
|
|
|
|
mBullet = nsnull;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
DeleteFrameList(aPresContext, &mFloaters);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return nsBlockFrameSuper::DeleteFrame(aPresContext);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
if (aIID.Equals(kBlockFrameCID)) {
|
|
|
|
nsBlockFrame* tmp = this;
|
|
|
|
*aInstancePtr = (void*) tmp;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsBlockFrameSuper::QueryInterface(aIID, aInstancePtr);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
|
|
|
|
nsIStyleContext* aParentContext)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIStyleContext* oldContext = mStyleContext;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// NOTE: using nsFrame's ReResolveStyleContext method to avoid
|
|
|
|
// useless version in base classes.
|
|
|
|
nsresult rv = nsFrame::ReResolveStyleContext(aPresContext, aParentContext);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (oldContext != mStyleContext) {
|
|
|
|
// Re-resolve the :first-line pseudo style context
|
|
|
|
if (nsnull == mPrevInFlow) {
|
|
|
|
nsIStyleContext* newFirstLineStyle =
|
|
|
|
aPresContext->ProbePseudoStyleContextFor(mContent,
|
|
|
|
nsHTMLAtoms::firstLinePseudo,
|
|
|
|
mStyleContext);
|
|
|
|
if (newFirstLineStyle != mFirstLineStyle) {
|
|
|
|
NS_IF_RELEASE(mFirstLineStyle);
|
|
|
|
mFirstLineStyle = newFirstLineStyle;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_IF_RELEASE(newFirstLineStyle);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Re-resolve the :first-letter pseudo style context
|
|
|
|
nsIStyleContext* newFirstLetterStyle =
|
|
|
|
aPresContext->ProbePseudoStyleContextFor(mContent,
|
|
|
|
nsHTMLAtoms::firstLetterPseudo,
|
|
|
|
(nsnull != mFirstLineStyle
|
|
|
|
? mFirstLineStyle
|
|
|
|
: mStyleContext));
|
|
|
|
if (newFirstLetterStyle != mFirstLetterStyle) {
|
|
|
|
NS_IF_RELEASE(mFirstLetterStyle);
|
|
|
|
mFirstLetterStyle = newFirstLetterStyle;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IF_RELEASE(newFirstLetterStyle);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Update the child frames on each line
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
nsIFrame* child = line->mFirstChild;
|
|
|
|
PRInt32 n = line->mChildCount;
|
|
|
|
while ((--n >= 0) && NS_SUCCEEDED(rv)) {
|
|
|
|
if (line == mLines) {
|
|
|
|
rv = child->ReResolveStyleContext(aPresContext,
|
|
|
|
(nsnull != mFirstLineStyle
|
|
|
|
? mFirstLineStyle
|
|
|
|
: mStyleContext));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = child->ReResolveStyleContext(aPresContext, mStyleContext);
|
|
|
|
}
|
|
|
|
child->GetNextSibling(child);
|
|
|
|
}
|
|
|
|
line = line->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != mOverflowLines)) {
|
|
|
|
rv = ReResolveLineList(aPresContext, mOverflowLines, mStyleContext);
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != mPrevInFlow)) {
|
|
|
|
nsLineBox* lines = ((nsBlockFrame*)mPrevInFlow)->mOverflowLines;
|
|
|
|
if (nsnull != lines) {
|
|
|
|
rv = ReResolveLineList(aPresContext, lines, mStyleContext);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = nsBlockFrameSuper::SetInitialChildList(aPresContext,
|
|
|
|
aListName,
|
|
|
|
aChildList);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
1998-11-21 01:24:20 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Create list bullet if this is a list-item. Note that this is done
|
|
|
|
// here so that RenumberLists will work (it needs the bullets to
|
|
|
|
// store the bullet numbers).
|
|
|
|
const nsStyleDisplay* styleDisplay;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
|
|
|
|
if ((nsnull == mPrevInFlow) &&
|
|
|
|
(NS_STYLE_DISPLAY_LIST_ITEM == styleDisplay->mDisplay) &&
|
|
|
|
(nsnull == mBullet)) {
|
|
|
|
// Resolve style for the bullet frame
|
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
kidSC = aPresContext.ResolvePseudoStyleContextFor(mContent,
|
|
|
|
nsHTMLAtoms::bulletPseudo, mStyleContext);
|
1998-09-29 08:47:59 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Create bullet frame
|
|
|
|
mBullet = new nsBulletFrame;
|
|
|
|
if (nsnull == mBullet) {
|
|
|
|
NS_RELEASE(kidSC);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
mBullet->Init(aPresContext, mContent, this, kidSC);
|
|
|
|
NS_RELEASE(kidSC);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// If the list bullet frame should be positioned inside then add
|
|
|
|
// it to the flow now.
|
|
|
|
const nsStyleList* styleList;
|
|
|
|
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList);
|
|
|
|
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) {
|
|
|
|
InsertNewFrame(aPresContext, this, mBullet, nsnull);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Lookup up the two pseudo style contexts
|
|
|
|
if (nsnull == mPrevInFlow) {
|
|
|
|
mFirstLineStyle = aPresContext.
|
|
|
|
ProbePseudoStyleContextFor(mContent, nsHTMLAtoms::firstLinePseudo,
|
|
|
|
mStyleContext);
|
|
|
|
mFirstLetterStyle = aPresContext.
|
|
|
|
ProbePseudoStyleContextFor(mContent, nsHTMLAtoms::firstLetterPseudo,
|
|
|
|
(nsnull != mFirstLineStyle
|
|
|
|
? mFirstLineStyle
|
|
|
|
: mStyleContext));
|
|
|
|
#ifdef NOISY_FIRST_LETTER
|
|
|
|
if (nsnull != mFirstLetterStyle) {
|
|
|
|
printf("block(%d)@%p: first-letter style found\n",
|
|
|
|
ContentIndexInContainer(this), this);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
static void
|
|
|
|
ListTextRuns(FILE* out, PRInt32 aIndent, nsTextRun* aRuns)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
while (nsnull != aRuns) {
|
|
|
|
aRuns->List(out, aIndent);
|
|
|
|
aRuns = aRuns->GetNext();
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsBlockFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
|
|
|
{
|
|
|
|
PRInt32 i;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// if a filter is present, only output this frame if the filter says
|
|
|
|
// we should
|
|
|
|
nsAutoString tagString;
|
|
|
|
if (nsnull != mContent) {
|
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (tag != nsnull) {
|
|
|
|
tag->ToString(tagString);
|
|
|
|
NS_RELEASE(tag);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool outputMe = (nsnull == aFilter) || aFilter->OutputTag(&tagString);
|
|
|
|
if (outputMe) {
|
|
|
|
// Indent
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the tag
|
|
|
|
ListTag(out);
|
|
|
|
nsIView* view;
|
|
|
|
GetView(view);
|
|
|
|
if (nsnull != view) {
|
|
|
|
fprintf(out, " [view=%p]", view);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the flow linkage
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
fprintf(out, " prev-in-flow=%p", mPrevInFlow);
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
fprintf(out, " next-in-flow=%p", mNextInFlow);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the rect and state
|
|
|
|
out << mRect;
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
fputs("<\n", out);
|
|
|
|
aIndent++;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output bullet first
|
|
|
|
if (nsnull != mBullet) {
|
|
|
|
if (outputMe) {
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fprintf(out, "bullet <\n");
|
|
|
|
}
|
|
|
|
mBullet->List(out, aIndent+1, aFilter);
|
|
|
|
if (outputMe) {
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fputs(">\n", out);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the lines
|
|
|
|
if (nsnull != mLines) {
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
line->List(out, aIndent, aFilter, outputMe);
|
|
|
|
line = line->mNext;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output floaters next
|
|
|
|
if (nsnull != mFloaters) {
|
|
|
|
if (outputMe) {
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fprintf(out, "all-floaters <\n");
|
|
|
|
}
|
|
|
|
nsIFrame* floater = mFloaters;
|
|
|
|
while (nsnull != floater) {
|
|
|
|
floater->List(out, aIndent+1, aFilter);
|
|
|
|
floater->GetNextSibling(floater);
|
|
|
|
}
|
|
|
|
if (outputMe) {
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Output the text-runs
|
|
|
|
if (outputMe) {
|
|
|
|
if (nsnull != mTextRuns) {
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fputs("text-runs <\n", out);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
ListTextRuns(out, aIndent + 1, mTextRuns);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fputs(">\n", out);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
aIndent--;
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fputs(">\n", out);
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-11-17 04:04:45 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::GetFrameName(nsString& aResult) const
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
return MakeFrameName("Block", aResult);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrame* cf = new nsBlockFrame;
|
|
|
|
if (nsnull == cf) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
cf->Init(aPresContext, mContent, aParent, aStyleContext);
|
|
|
|
cf->SetFlags(mFlags);
|
|
|
|
cf->AppendToFlow(this);
|
|
|
|
aContinuingFrame = cf;
|
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
if (nsnull == aListName) {
|
|
|
|
aFirstChild = (nsnull != mLines) ? mLines->mFirstChild : nsnull;
|
|
|
|
return NS_OK;
|
1998-10-16 03:27:12 +04:00
|
|
|
}
|
1998-12-09 08:30:17 +03:00
|
|
|
else if (aListName == nsLayoutAtoms::floaterList) {
|
1998-12-05 19:02:08 +03:00
|
|
|
aFirstChild = mFloaters;
|
|
|
|
return NS_OK;
|
1998-10-16 03:27:12 +04:00
|
|
|
}
|
1998-12-09 08:30:17 +03:00
|
|
|
else if (aListName == nsLayoutAtoms::bulletList) {
|
1998-12-05 19:02:08 +03:00
|
|
|
aFirstChild = mBullet;
|
|
|
|
return NS_OK;
|
1998-10-17 00:22:39 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aFirstChild = nsnull;
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::GetAdditionalChildListName(PRInt32 aIndex,
|
|
|
|
nsIAtom*& aListName) const
|
|
|
|
{
|
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
1998-10-17 00:22:39 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIAtom* atom = nsnull;
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_BLOCK_FRAME_FLOATER_LIST_INDEX:
|
1998-12-09 08:30:17 +03:00
|
|
|
atom = nsLayoutAtoms::floaterList;
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_ADDREF(atom);
|
|
|
|
break;
|
|
|
|
case NS_BLOCK_FRAME_BULLET_LIST_INDEX:
|
1998-12-09 08:30:17 +03:00
|
|
|
atom = nsLayoutAtoms::bulletList;
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_ADDREF(atom);
|
|
|
|
break;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
aListName = atom;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::IsPercentageBase(PRBool& aBase) const
|
|
|
|
{
|
|
|
|
aBase = PR_TRUE;
|
|
|
|
return NS_OK;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = nsBlockFrameSuper::Reflow(aPresContext, aDesiredSize,
|
|
|
|
aReflowState, aStatus);
|
1998-12-09 00:43:15 +03:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
|
|
|
printf("look ma, an incomplete block!\n");
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
BuildFloaterList();
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrame::RenumberLists(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Setup initial list ordinal value
|
|
|
|
PRInt32 ordinal = 1;
|
|
|
|
nsIHTMLContent* hc;
|
|
|
|
if (mContent && (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc))) {
|
|
|
|
nsHTMLValue value;
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
|
|
|
hc->GetAttribute(nsHTMLAtoms::start, value)) {
|
|
|
|
if (eHTMLUnit_Integer == value.GetUnit()) {
|
|
|
|
ordinal = value.GetIntValue();
|
|
|
|
if (ordinal <= 0) {
|
|
|
|
ordinal = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
}
|
|
|
|
aState.mNextListOrdinal = ordinal;
|
1998-10-10 02:58:25 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Get to first-in-flow
|
|
|
|
nsBlockFrame* block = this;
|
|
|
|
while (nsnull != block->mPrevInFlow) {
|
|
|
|
block = (nsBlockFrame*) block->mPrevInFlow;
|
|
|
|
}
|
1998-10-17 00:22:39 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// For each flow-block...
|
|
|
|
while (nsnull != block) {
|
|
|
|
// For each frame in the flow-block...
|
|
|
|
nsIFrame* frame = block->mLines ? block->mLines->mFirstChild : nsnull;
|
|
|
|
while (nsnull != frame) {
|
|
|
|
// If the frame is a list-item and the frame implements our
|
|
|
|
// block frame API then get it's bullet and set the list item
|
|
|
|
// ordinal.
|
1998-09-15 04:19:49 +04:00
|
|
|
const nsStyleDisplay* display;
|
1998-12-05 19:02:08 +03:00
|
|
|
frame->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&) display);
|
|
|
|
if (NS_STYLE_DISPLAY_LIST_ITEM == display->mDisplay) {
|
|
|
|
// Make certain that the frame isa block-frame in case
|
|
|
|
// something foriegn has crept in.
|
|
|
|
nsBlockFrame* listItem;
|
|
|
|
if (NS_OK == frame->QueryInterface(kBlockFrameCID,
|
|
|
|
(void**) &listItem)) {
|
|
|
|
if (nsnull != listItem->mBullet) {
|
|
|
|
aState.mNextListOrdinal =
|
|
|
|
listItem->mBullet->SetListItemOrdinal(aState.mNextListOrdinal);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
frame->GetNextSibling(frame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
block = (nsBlockFrame*) block->mNextInFlow;
|
|
|
|
}
|
|
|
|
}
|
1998-10-17 00:22:39 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool
|
|
|
|
nsBlockFrame::ShouldPlaceBullet(nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
PRBool ok = PR_FALSE;
|
|
|
|
const nsStyleList* list;
|
|
|
|
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&)list);
|
|
|
|
if (NS_STYLE_LIST_STYLE_POSITION_OUTSIDE == list->mListStylePosition) {
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (line->mBounds.height > 0) {
|
|
|
|
if (aLine == line) {
|
|
|
|
ok = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aLine == line) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line = line->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
return ok;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockFrame::DidPlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscoord aTopMargin, nscoord aBottomMargin,
|
|
|
|
PRBool aLineReflowStatus)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Place the outside list bullet, if we have one
|
|
|
|
if ((nsnull == mPrevInFlow) && (nsnull != mBullet) &&
|
|
|
|
ShouldPlaceBullet(aLine)) {
|
|
|
|
nscoord ascent = aState.mAscent;
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
ascent = 0;
|
|
|
|
|
|
|
|
// For bullets that are placed next to a child block, there will
|
|
|
|
// be no correct ascent value. Therefore, make one up...
|
|
|
|
const nsStyleFont* font;
|
|
|
|
nsresult rv;
|
|
|
|
rv = aLine->mFirstChild->GetStyleData(eStyleStruct_Font,
|
|
|
|
(const nsStyleStruct*&) font);
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != font)) {
|
|
|
|
nsIRenderingContext& rc = *aState.rendContext;
|
|
|
|
rc.SetFont(font->mFont);
|
|
|
|
nsIFontMetrics* fm;
|
|
|
|
rv = rc.GetFontMetrics(fm);
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != fm)) {
|
|
|
|
fm->GetMaxAscent(ascent);
|
|
|
|
NS_RELEASE(fm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PlaceBullet(aState, ascent, aTopMargin);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockFrame::PlaceBullet(nsBlockReflowState& aState,
|
|
|
|
nscoord aMaxAscent,
|
|
|
|
nscoord aTopMargin)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Reflow the bullet now
|
|
|
|
nsSize availSize;
|
|
|
|
availSize.width = NS_UNCONSTRAINEDSIZE;
|
|
|
|
availSize.height = NS_UNCONSTRAINEDSIZE;
|
|
|
|
nsHTMLReflowState reflowState(aState.mPresContext, mBullet, aState,
|
|
|
|
availSize, aState.mLineLayout);
|
|
|
|
nsHTMLReflowMetrics metrics(nsnull);
|
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
nsresult rv = mBullet->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsReflowStatus status;
|
|
|
|
htmlReflow->WillReflow(aState.mPresContext);
|
|
|
|
htmlReflow->Reflow(aState.mPresContext, metrics, reflowState, status);
|
|
|
|
htmlReflow->DidReflow(aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
|
|
|
}
|
1998-11-19 06:52:29 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Place the bullet now; use its right margin to distance it
|
|
|
|
// from the rest of the frames in the line
|
|
|
|
nsMargin margin;
|
|
|
|
nsHTMLReflowState::ComputeMarginFor(mBullet, &aState, margin);
|
|
|
|
nscoord x = aState.mBorderPadding.left - margin.right - metrics.width;
|
|
|
|
// XXX This calculation may be wrong, especially if
|
|
|
|
// vertical-alignment occurs on the line!
|
|
|
|
nscoord y = aState.mBorderPadding.top + aMaxAscent -
|
|
|
|
metrics.ascent + aTopMargin;
|
|
|
|
mBullet->SetRect(nsRect(x, y, metrics.width, metrics.height));
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockFrame::BuildFloaterList()
|
|
|
|
{
|
|
|
|
nsIFrame* head = nsnull;
|
|
|
|
nsIFrame* current = nsnull;
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (nsnull != line->mFloaters) {
|
|
|
|
nsVoidArray& array = *line->mFloaters;
|
|
|
|
PRInt32 i, n = array.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) array[i];
|
|
|
|
nsIFrame* floater = ph->GetAnchoredItem();
|
|
|
|
if (nsnull == head) {
|
|
|
|
current = head = floater;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
current->SetNextSibling(floater);
|
|
|
|
current = floater;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line = line->mNext;
|
1998-11-19 06:52:29 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Terminate end of floater list just in case a floater was removed
|
|
|
|
if (nsnull != current) {
|
|
|
|
current->SetNextSibling(nsnull);
|
1998-11-19 06:52:29 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
mFloaters = head;
|
|
|
|
}
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX keep the text-run data in the first-in-flow of the block
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::FindTextRuns(nsBlockReflowState& aState)
|
|
|
|
{
|
|
|
|
// Destroy old run information first
|
|
|
|
nsTextRun::DeleteTextRuns(mTextRuns);
|
|
|
|
mTextRuns = nsnull;
|
|
|
|
aState.mLineLayout->ResetTextRuns();
|
1998-10-31 01:10:10 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Ask each child that implements nsIInlineReflow to find its text runs
|
|
|
|
nsLineLayout& ll = *aState.mLineLayout;
|
|
|
|
nsLineBox* line = mLines;
|
|
|
|
while (nsnull != line) {
|
|
|
|
if (!line->IsBlock()) {
|
|
|
|
nsIFrame* frame = line->mFirstChild;
|
|
|
|
PRInt32 n = line->ChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
nsIHTMLReflow* hr;
|
|
|
|
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&hr)) {
|
|
|
|
nsresult rv = hr->FindTextRuns(ll);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// A frame that doesn't implement nsIHTMLReflow isn't text
|
|
|
|
// therefore it will end an open text run.
|
|
|
|
ll.EndTextRun();
|
|
|
|
}
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// A frame that doesn't implement nsIInlineReflow isn't text
|
|
|
|
// therefore it will end an open text run.
|
|
|
|
ll.EndTextRun();
|
|
|
|
}
|
|
|
|
line = line->mNext;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
ll.EndTextRun();
|
|
|
|
|
|
|
|
// Now take the text-runs away from the line layout engine.
|
|
|
|
mTextRuns = ll.TakeTextRuns();
|
1998-09-15 04:19:49 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX create a list-item subclass too!
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
void
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrameSuper::ComputeFinalSize(aState, aMetrics);
|
|
|
|
if (nsnull != mBullet) {
|
|
|
|
nsRect r;
|
|
|
|
mBullet->GetRect(r);
|
|
|
|
nscoord x0 = aMetrics.mCombinedArea.x;
|
|
|
|
nscoord y0 = aMetrics.mCombinedArea.y;
|
|
|
|
nscoord x1 = x0 + aMetrics.mCombinedArea.width;
|
|
|
|
nscoord y1 = y0 + aMetrics.mCombinedArea.height;
|
|
|
|
if (r.x < x0) x0 = r.x;
|
|
|
|
if (r.XMost() > x1) x1 = r.XMost();
|
|
|
|
if (r.y < y0) y0 = r.y;
|
|
|
|
if (r.YMost() > y1) y1 = r.YMost();
|
|
|
|
aMetrics.mCombinedArea.x = x0;
|
|
|
|
aMetrics.mCombinedArea.y = y0;
|
|
|
|
aMetrics.mCombinedArea.width = x1 - x0;
|
|
|
|
aMetrics.mCombinedArea.height = y1 - y0;
|
|
|
|
|
|
|
|
// If the combined area of our children exceeds our bounding box
|
|
|
|
// then set the NS_FRAME_OUTSIDE_CHILDREN flag, otherwise clear it.
|
|
|
|
if ((aMetrics.mCombinedArea.x < 0) ||
|
|
|
|
(aMetrics.mCombinedArea.y < 0) ||
|
|
|
|
(aMetrics.mCombinedArea.XMost() > aMetrics.width) ||
|
|
|
|
(aMetrics.mCombinedArea.YMost() > aMetrics.height)) {
|
|
|
|
mState |= NS_FRAME_OUTSIDE_CHILDREN;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-11 18:49:07 +03:00
|
|
|
#if 0
|
|
|
|
if (nsnull != aMetrics.maxElementSize) {
|
|
|
|
ListTag(stdout); printf(": maxElementSize=%d,%d\n",
|
|
|
|
*aMetrics.maxElementSize);
|
|
|
|
if (aMetrics.maxElementSize->width > 15000) {
|
|
|
|
printf("YIKES!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-09-23 06:25:26 +04:00
|
|
|
void
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrame::TakeRunInFrames(nsBlockFrame* aRunInFrame)
|
1998-09-23 06:25:26 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Simply steal the run-in-frame's line list and make it our
|
|
|
|
// own. XXX Very similar to the logic in DrainOverflowLines...
|
|
|
|
nsLineBox* line = aRunInFrame->mLines;
|
1998-10-06 04:38:56 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Make all the frames on the mOverflowLines list mine
|
|
|
|
nsIFrame* lastFrame = nsnull;
|
|
|
|
nsIFrame* frame = line->mFirstChild;
|
|
|
|
while (nsnull != frame) {
|
|
|
|
nsIFrame* geometricParent;
|
|
|
|
nsIFrame* contentParent;
|
|
|
|
frame->GetGeometricParent(geometricParent);
|
|
|
|
frame->GetContentParent(contentParent);
|
|
|
|
if (contentParent == geometricParent) {
|
|
|
|
frame->SetContentParent(this);
|
1998-09-23 06:25:26 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
frame->SetGeometricParent(this);
|
|
|
|
lastFrame = frame;
|
|
|
|
frame->GetNextSibling(frame);
|
1998-09-23 06:25:26 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Join the line lists
|
|
|
|
if (nsnull == mLines) {
|
|
|
|
mLines = line;
|
1998-11-19 21:09:57 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// Join the sibling lists together
|
|
|
|
lastFrame->SetNextSibling(mLines->mFirstChild);
|
|
|
|
|
|
|
|
// Place overflow lines at the front of our line list
|
|
|
|
nsLineBox* lastLine = nsLineBox::LastLine(line);
|
|
|
|
lastLine->mNext = mLines;
|
|
|
|
mLines = line;
|
1998-11-19 21:09:57 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
aRunInFrame->mLines = nsnull;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::PrepareInitialReflow(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
if ((nsnull == mPrevInFlow) && (nsnull != aState.mRunInFrame)) {
|
|
|
|
#ifdef NOISY_RUNIN
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": run-in from: ");
|
|
|
|
aReflowState.mRunInFrame->ListTag(stdout);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
// Take frames away from the run-in frame
|
|
|
|
TakeRunInFrames(aState.mRunInFrame);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
nsresult rv = nsBlockFrameSuper::PrepareInitialReflow(aState);
|
|
|
|
FindTextRuns(aState);
|
|
|
|
RenumberLists(aState);
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::PrepareFrameAppendedReflow(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = nsBlockFrameSuper::PrepareFrameAppendedReflow(aState);
|
|
|
|
RenumberLists(aState);
|
|
|
|
rv = FindTextRuns(aState);
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::PrepareFrameInsertedReflow(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = nsBlockFrameSuper::PrepareFrameInsertedReflow(aState);
|
|
|
|
RenumberLists(aState);
|
|
|
|
rv = FindTextRuns(aState);
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::PrepareFrameRemovedReflow(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = nsBlockFrameSuper::PrepareFrameRemovedReflow(aState);
|
|
|
|
RenumberLists(aState);
|
|
|
|
rv = FindTextRuns(aState);
|
|
|
|
return rv;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Inform line layout of where the text runs are
|
|
|
|
aState.mLineLayout->SetReflowTextRuns(mTextRuns);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Let base class do the work...
|
|
|
|
return nsBlockFrameSuper::ReflowDirtyLines(aState);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockFrame::WillReflowLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
// Setup the first-letter-style-ok flag
|
|
|
|
nsLineLayout& lineLayout = *aState.mLineLayout;
|
|
|
|
if (mFirstLetterStyle && (0 == lineLayout.GetLineNumber())) {
|
|
|
|
lineLayout.SetFirstLetterStyleOK(PR_TRUE);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
lineLayout.SetFirstLetterStyleOK(PR_FALSE);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockFrame::WillReflowFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
PRBool repairStyleContext = PR_TRUE;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// When reflowing a frame that is on the first-line, check and see
|
|
|
|
// if a special style context should be placed in the context chain.
|
|
|
|
if ((nsnull == mPrevInFlow) &&
|
|
|
|
(0 == aState.mLineLayout->GetLineNumber())) {
|
|
|
|
if (nsnull != mFirstLineStyle) {
|
|
|
|
// Update the child frames style to inherit from the first-line
|
|
|
|
// style.
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX add code to check first and only do it if it needs doing!
|
|
|
|
#ifdef REALLY_NOISY_FIRST_LINE
|
|
|
|
DumpStyleGeneaology(aFrame, "");
|
|
|
|
#endif
|
|
|
|
#ifdef NOISY_FIRST_LINE
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": ");
|
|
|
|
((nsFrame*)aFrame)->ListTag(stdout);
|
|
|
|
printf(" adding in first-line style\n");
|
|
|
|
#endif
|
|
|
|
aFrame->ReResolveStyleContext(&aState.mPresContext, mFirstLineStyle);
|
|
|
|
repairStyleContext = PR_FALSE;
|
|
|
|
#ifdef REALLY_NOISY_FIRST_LINE
|
|
|
|
DumpStyleGeneaology(aFrame, " ");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if ((nsnull != mFirstLetterStyle) &&
|
|
|
|
aState.mLineLayout->GetFirstLetterStyleOK()) {
|
|
|
|
aFrame->ReResolveStyleContext(&aState.mPresContext, mFirstLetterStyle);
|
|
|
|
repairStyleContext = PR_FALSE;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
if (repairStyleContext) {
|
|
|
|
// Update style context when appropriate
|
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
aFrame->GetStyleContext(kidSC);
|
|
|
|
if (nsnull != kidSC) {
|
|
|
|
nsIStyleContext* kidParentSC;
|
|
|
|
kidParentSC = kidSC->GetParent();
|
|
|
|
if (nsnull != kidParentSC) {
|
|
|
|
if (kidParentSC != mStyleContext) {
|
|
|
|
aFrame->ReResolveStyleContext(&aState.mPresContext, mStyleContext);
|
|
|
|
}
|
|
|
|
NS_RELEASE(kidParentSC);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_RELEASE(kidSC);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult rv = nsBlockFrameSuper::GetFrameForPoint(aPoint, aFrame);
|
|
|
|
if (NS_OK == rv) {
|
1998-09-15 04:19:49 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
if (nsnull != mBullet) {
|
1998-12-09 08:30:17 +03:00
|
|
|
rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::bulletList, aFrame);
|
1998-12-05 19:02:08 +03:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nsnull != mFloaters) {
|
1998-12-09 08:30:17 +03:00
|
|
|
rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::floaterList, aFrame);
|
1998-12-05 19:02:08 +03:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*aFrame = this;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
|
|
|
{
|
|
|
|
if (nsnull != mBullet) {
|
|
|
|
// Paint outside bullets manually
|
|
|
|
const nsStyleList* list = (const nsStyleList*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_List);
|
|
|
|
if (NS_STYLE_LIST_STYLE_POSITION_OUTSIDE == list->mListStylePosition) {
|
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect, mBullet);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockFrameSuper::PaintChildren(aPresContext,
|
|
|
|
aRenderingContext,
|
|
|
|
aDirtyRect);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|