gecko-dev/layout/generic/nsLineLayout.h

249 строки
6.6 KiB
C
Исходник Обычный вид История

1998-05-01 03:32:32 +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 "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsLineLayout_h___
#define nsLineLayout_h___
#include "nsIFrame.h"
#include "nsCoord.h"
#include "nsSize.h"
#include "nsVoidArray.h"
1998-05-01 03:32:32 +04:00
class nsIPresContext;
1998-05-02 04:40:25 +04:00
class nsISpaceManager;
1998-05-01 03:32:32 +04:00
class nsBlockFrame;
struct nsBlockReflowState;
1998-06-09 21:47:20 +04:00
struct nsLineLayout;
/* d76e29b0-ff56-11d1-89e7-006008911b81 */
#define NS_IINLINE_FRAME_IID \
{0xd76e29b0, 0xff56, 0x11d1, {0x89, 0xe7, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81}}
/**
* Interface to "inline frames". Inline frames are those that are aware
* of html line layout.
*
* Note that this interface does not expose AddRef/Release (like all frame
* interfaces)
*/
class nsIInlineFrame : private nsISupports {
public:
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) = 0;
NS_IMETHOD ReflowInline(nsLineLayout& aLineLayout,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus) = 0;
};
//----------------------------------------------------------------------
1998-05-01 03:32:32 +04:00
/**
* Persistent per-line data
*/
struct nsLineData {
nsLineData();
~nsLineData();
nsIFrame* GetLastChild();
1998-05-02 04:40:25 +04:00
nsresult Verify(PRBool aFinalCheck = PR_TRUE) const;
1998-05-01 03:32:32 +04:00
void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
void UnlinkLine();
PRIntn GetLineNumber() const;
nsLineData* mNextLine;
nsLineData* mPrevLine;
nsIFrame* mFirstChild;
PRInt32 mChildCount;
PRInt32 mFirstContentOffset;
PRInt32 mLastContentOffset;
nsRect mBounds;
PRPackedBool mLastContentIsComplete;
1998-05-02 04:40:25 +04:00
PRPackedBool mIsBlock;
nsVoidArray* mFloaters; // placeholder frames for below current line floaters
1998-05-01 03:32:32 +04:00
};
//----------------------------------------------------------------------
/**
* Transient state used during line reflow.
*/
// State used during line layout that may need to be rewound because
// of an inconvenient word break.
struct nsLineLayoutState {
// The next x coordinate to place the child frame
1998-05-01 03:32:32 +04:00
nscoord mX;
// This is true if the next frame to reflow should skip over leading
// whitespace.
PRBool mSkipLeadingWhiteSpace;
// The column number when pre-formatting (for tab spacing)
PRInt32 mColumn;
// The child frame being considered for reflow
nsIFrame* mKidFrame;
// The previous child frame just reflowed
nsIFrame* mPrevKidFrame;
// The child frame's content index-in-parent
PRInt32 mKidIndex;
// The child frame number within this line
PRInt32 mKidFrameNum;
// Current line values values
1998-05-01 03:32:32 +04:00
nsSize mMaxElementSize;
nscoord mMaxAscent;
nscoord mMaxDescent;
};
struct nsLineLayout {
1998-05-02 04:40:25 +04:00
nsLineLayout(nsBlockReflowState& aState);
1998-05-01 03:32:32 +04:00
~nsLineLayout();
1998-05-02 04:40:25 +04:00
nsresult Initialize(nsBlockReflowState& aState, nsLineData* aLine);
void SetReflowSpace(nsRect& aAvailableSpaceRect);
1998-05-01 03:32:32 +04:00
nsresult ReflowLine();
1998-06-09 08:51:44 +04:00
nsresult IncrementalReflowFromChild(nsIReflowCommand* aReflowCommand,
nsIFrame* aChildFrame);
void AtSpace();
void AtWordStart(nsIFrame* aFrame, nscoord aX);
PRBool SkipLeadingWhiteSpace() {
return mState.mSkipLeadingWhiteSpace;
}
void SetSkipLeadingWhiteSpace(PRBool aSkip) {
mState.mSkipLeadingWhiteSpace = aSkip;
}
PRIntn GetColumn() {
return mState.mColumn;
}
void SetColumn(PRIntn aNewColumn) {
mState.mColumn = aNewColumn;
}
// A value set by line-layout cognizant frames. Frames that are not
// aware of line layout leave the value unchanged and can thus be
// detected by the line-layout algorithm.
PRInt32 mReflowResult;
1998-05-01 03:32:32 +04:00
// The presentation context
nsIPresContext* mPresContext;
// The block behind the line
nsBlockFrame* mBlock;
1998-05-13 03:49:40 +04:00
nsBlockReflowState& mBlockReflowState;
1998-05-02 04:40:25 +04:00
nsISpaceManager* mSpaceManager;
1998-05-01 03:32:32 +04:00
nsIContent* mBlockContent;
1998-06-05 21:53:28 +04:00
PRBool mNoWrap;
1998-05-01 03:32:32 +04:00
// The line we are reflowing
nsLineData* mLine;
nsIFrame* mKidPrevInFlow;
// Whenever the line layout creates a frame this slot is incremented
PRIntn mNewFrames;
PRIntn mFramesReflowed;
PRIntn mOldChildCount;
1998-05-01 03:32:32 +04:00
nsLineLayoutState mState;
nsLineLayoutState mSavedState;
// The current breakable point in the line. If a line-break is
// requested then this is where the line will break at.
nsIFrame* mBreakFrame;
nscoord mBreakX;
1998-05-30 21:46:11 +04:00
PRUint8 mPendingBreak;
1998-05-01 03:32:32 +04:00
// XXX ick
1998-05-02 04:40:25 +04:00
// This is set by the block code when it updates the available
// reflow area when a floater is placed.
PRBool mReflowDataChanged;
PRPackedBool mMustReflowMappedChildren;
1998-05-01 03:32:32 +04:00
PRPackedBool mUnconstrainedWidth;
PRPackedBool mUnconstrainedHeight;
1998-05-13 03:49:40 +04:00
PRPackedBool mMarginApplied;
1998-05-01 03:32:32 +04:00
nscoord mY;
nscoord mLineHeight;
1998-05-02 04:40:25 +04:00
nscoord mMaxWidth;
nscoord mMaxHeight;
1998-05-01 03:32:32 +04:00
nsSize* mMaxElementSizePointer;
nscoord mLeftEdge;
nscoord mRightEdge;
1998-05-01 03:32:32 +04:00
nscoord* mAscents;
nscoord mAscentBuf[20];
nscoord mMaxAscents;
protected:
nsresult SetAscent(nscoord aAscent);
1998-05-01 03:32:32 +04:00
nsresult ReflowMappedChild();
1998-06-09 08:51:44 +04:00
nsresult ReflowChild(nsIReflowCommand* aReflowCommand, PRBool aNewChild);
1998-05-01 03:32:32 +04:00
nsresult PlaceChild(nsRect& kidRect,
const nsReflowMetrics& kidMetrics,
const nsSize* kidMaxElementSize,
const nsMargin& kidMargin,
nsReflowStatus kidReflowStatus);
1998-05-01 03:32:32 +04:00
nsresult ReflowMapped();
nsresult SplitLine(PRInt32 aChildReflowStatus);
1998-05-01 03:32:32 +04:00
nsresult PushChildren();
nsresult CreateNextInFlow(nsIFrame* aFrame);
nsresult PullUpChildren();
nsresult CreateFrameFor(nsIContent* aKid);
nsresult ReflowUnmapped();
void AlignChildren();
1998-05-01 03:32:32 +04:00
PRBool CanBreak();
1998-05-01 03:32:32 +04:00
};
// Value's for nsLineLayout.mReflowResult
1998-05-02 04:40:25 +04:00
#define NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE 0
#define NS_LINE_LAYOUT_REFLOW_RESULT_AWARE 1
#define NS_LINE_LAYOUT_REFLOW_RESULT_BREAK_AFTER 2
1998-05-01 03:32:32 +04:00
// Return value's from nsLineLayout reflow methods
#define NS_LINE_LAYOUT_COMPLETE 0
#define NS_LINE_LAYOUT_NOT_COMPLETE 1
#define NS_LINE_LAYOUT_BREAK_BEFORE 2
#define NS_LINE_LAYOUT_BREAK_AFTER 3
#endif /* nsLineLayout_h___ */