1998-06-18 16:25:41 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-10-25 01:08:40 +00:00
|
|
|
* vim:cindent:ts=2:et:sw=2:
|
1998-06-18 16:25:41 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (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/
|
1998-06-18 16:25:41 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* 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.
|
1998-06-18 16:25:41 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 03:40:37 +00:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-04-17 14:40:46 +00:00
|
|
|
* Steve Clark <buster@netscape.com>
|
|
|
|
* Robert O'Callahan <roc+moz@cs.cmu.edu>
|
2000-05-02 23:07:11 +00:00
|
|
|
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
|
|
|
* described herein are Copyright (c) International Business Machines Corporation, 2000.
|
|
|
|
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
|
|
|
|
*
|
|
|
|
* Date Modified by Description of modification
|
|
|
|
* 04/20/2000 IBM Corp. OS/2 VisualAge build.
|
1998-06-18 16:25:41 +00:00
|
|
|
*/
|
1998-09-15 00:19:49 +00:00
|
|
|
#ifndef nsLineLayout_h___
|
|
|
|
#define nsLineLayout_h___
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
#include "nsFrame.h"
|
2002-03-19 21:57:45 +00:00
|
|
|
#include "nsDeque.h"
|
2000-02-15 04:26:44 +00:00
|
|
|
#include "nsLineBox.h"
|
2001-05-01 04:22:57 +00:00
|
|
|
#include "nsBlockReflowState.h"
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2001-10-26 05:06:07 +00:00
|
|
|
class nsSpaceManager;
|
1998-08-04 21:17:56 +00:00
|
|
|
class nsPlaceholderFrame;
|
1999-03-18 21:03:25 +00:00
|
|
|
struct nsStyleText;
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2002-08-14 13:00:16 +00:00
|
|
|
#define NS_LINELAYOUT_NUM_FRAMES 5
|
|
|
|
#define NS_LINELAYOUT_NUM_SPANS 5
|
|
|
|
|
1998-09-15 00:19:49 +00:00
|
|
|
class nsLineLayout {
|
1998-06-18 16:25:41 +00:00
|
|
|
public:
|
1999-11-24 06:03:41 +00:00
|
|
|
nsLineLayout(nsIPresContext* aPresContext,
|
2001-10-26 05:06:07 +00:00
|
|
|
nsSpaceManager* aSpaceManager,
|
1999-03-18 21:03:25 +00:00
|
|
|
const nsHTMLReflowState* aOuterReflowState,
|
|
|
|
PRBool aComputeMaxElementSize);
|
1998-09-15 00:19:49 +00:00
|
|
|
~nsLineLayout();
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1999-08-27 21:49:12 +00:00
|
|
|
void Init(nsBlockReflowState* aState, nscoord aMinLineHeight,
|
|
|
|
PRInt32 aLineNumber) {
|
1999-03-18 21:03:25 +00:00
|
|
|
mBlockRS = aState;
|
1999-08-27 21:49:12 +00:00
|
|
|
mMinLineHeight = aMinLineHeight;
|
|
|
|
mLineNumber = aLineNumber;
|
1998-08-04 21:17:56 +00:00
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
PRInt32 GetColumn() {
|
|
|
|
return mColumn;
|
1999-02-18 03:28:00 +00:00
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void SetColumn(PRInt32 aNewColumn) {
|
|
|
|
mColumn = aNewColumn;
|
1998-09-23 02:31:00 +00:00
|
|
|
}
|
1999-03-18 21:03:25 +00:00
|
|
|
|
|
|
|
PRInt32 GetLineNumber() const {
|
|
|
|
return mLineNumber;
|
1998-09-23 02:31:00 +00:00
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void BeginLineReflow(nscoord aX, nscoord aY,
|
|
|
|
nscoord aWidth, nscoord aHeight,
|
1999-03-21 01:14:05 +00:00
|
|
|
PRBool aImpactedByFloaters,
|
1999-03-18 21:03:25 +00:00
|
|
|
PRBool aIsTopOfPage);
|
1998-10-27 16:52:10 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void EndLineReflow();
|
1998-09-29 22:32:04 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void UpdateBand(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
1999-10-29 14:33:26 +00:00
|
|
|
PRBool aPlacedLeftFloater,
|
|
|
|
nsIFrame* aFloaterFrame);
|
1998-09-29 22:32:04 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
nsresult BeginSpan(nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState* aSpanReflowState,
|
|
|
|
nscoord aLeftEdge,
|
|
|
|
nscoord aRightEdge);
|
1998-10-09 22:58:25 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void EndSpan(nsIFrame* aFrame, nsSize& aSizeResult,
|
1999-09-09 21:04:37 +00:00
|
|
|
nsSize* aMaxElementSize);
|
1999-09-03 03:47:49 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
PRInt32 GetCurrentSpanCount() const;
|
1998-10-09 22:58:25 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void SplitLineTo(PRInt32 aNewCount);
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
PRBool IsZeroHeight();
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2000-01-03 04:32:13 +00:00
|
|
|
// Reflows the frame and returns the reflow status. aPushedFrame is PR_TRUE
|
|
|
|
// if the frame is pushed to the next line because it doesn't fit
|
1999-03-18 21:03:25 +00:00
|
|
|
nsresult ReflowFrame(nsIFrame* aFrame,
|
1999-10-29 14:33:26 +00:00
|
|
|
nsReflowStatus& aReflowStatus,
|
2000-01-03 04:32:13 +00:00
|
|
|
nsHTMLReflowMetrics* aMetrics,
|
|
|
|
PRBool& aPushedFrame);
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
nsresult AddBulletFrame(nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowMetrics& aMetrics);
|
1998-10-20 00:22:48 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void RemoveBulletFrame(nsIFrame* aFrame) {
|
|
|
|
PushFrame(aFrame);
|
1998-10-10 04:35:01 +00:00
|
|
|
}
|
|
|
|
|
2001-07-04 02:00:05 +00:00
|
|
|
void VerticalAlignLine(nsLineBox* aLineBox,
|
|
|
|
nsSize& aMaxElementSizeResult,
|
|
|
|
nscoord& aLineBoxAscent);
|
1998-10-10 04:35:01 +00:00
|
|
|
|
1999-10-12 23:27:32 +00:00
|
|
|
PRBool TrimTrailingWhiteSpace();
|
1998-10-10 04:35:01 +00:00
|
|
|
|
2000-01-03 04:32:13 +00:00
|
|
|
PRBool HorizontalAlignFrames(nsRect& aLineBounds,
|
|
|
|
PRBool aAllowJustify,
|
|
|
|
PRBool aShrinkWrapWidth);
|
1998-10-10 04:35:01 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void RelativePositionFrames(nsRect& aCombinedArea);
|
1998-10-10 04:35:01 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
//----------------------------------------
|
1998-10-10 04:35:01 +00:00
|
|
|
|
2000-04-17 14:40:46 +00:00
|
|
|
// Supporting methods and data for flags
|
|
|
|
protected:
|
|
|
|
#define LL_ENDSINWHITESPACE 0x00000001
|
|
|
|
#define LL_UNDERSTANDSNWHITESPACE 0x00000002
|
|
|
|
#define LL_TEXTSTARTSWITHNBSP 0x00000004
|
|
|
|
#define LL_FIRSTLETTERSTYLEOK 0x00000008
|
|
|
|
#define LL_ISTOPOFPAGE 0x00000010
|
|
|
|
#define LL_UPDATEDBAND 0x00000020
|
|
|
|
#define LL_IMPACTEDBYFLOATERS 0x00000040
|
|
|
|
#define LL_LASTFLOATERWASLETTERFRAME 0x00000080
|
|
|
|
#define LL_CANPLACEFLOATER 0x00000100
|
2002-06-25 21:16:17 +00:00
|
|
|
#define LL_LINEENDSINBR 0x00000200
|
2000-04-17 14:40:46 +00:00
|
|
|
#define LL_LASTFLAG LL_LINEENDSINBR
|
|
|
|
|
|
|
|
PRUint16 mFlags;
|
|
|
|
|
|
|
|
void SetFlag(PRUint32 aFlag, PRBool aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=LL_LASTFLAG, "bad flag");
|
|
|
|
NS_ASSERTION(aValue==PR_FALSE || aValue==PR_TRUE, "bad value");
|
|
|
|
if (aValue) { // set flag
|
|
|
|
mFlags |= aFlag;
|
|
|
|
}
|
|
|
|
else { // unset flag
|
|
|
|
mFlags &= ~aFlag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool GetFlag(PRUint32 aFlag) const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=LL_LASTFLAG, "bad flag");
|
|
|
|
PRBool result = (mFlags & aFlag);
|
|
|
|
if (result) return PR_TRUE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
// Support methods for white-space compression and word-wrapping
|
|
|
|
// during line reflow
|
|
|
|
|
|
|
|
void SetEndsInWhiteSpace(PRBool aState) {
|
2000-04-17 14:40:46 +00:00
|
|
|
SetFlag(LL_ENDSINWHITESPACE, aState);
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
PRBool GetEndsInWhiteSpace() const {
|
2000-04-17 14:40:46 +00:00
|
|
|
return GetFlag(LL_ENDSINWHITESPACE);
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void SetUnderstandsWhiteSpace(PRBool aSetting) {
|
2000-04-17 14:40:46 +00:00
|
|
|
SetFlag(LL_UNDERSTANDSNWHITESPACE, aSetting);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTextJustificationWeights(PRInt32 aNumSpaces, PRInt32 aNumLetters) {
|
|
|
|
mTextJustificationNumSpaces = aNumSpaces;
|
|
|
|
mTextJustificationNumLetters = aNumLetters;
|
1998-06-25 16:33:10 +00:00
|
|
|
}
|
1999-03-18 21:03:25 +00:00
|
|
|
|
2000-04-17 14:40:46 +00:00
|
|
|
|
1999-11-02 15:44:57 +00:00
|
|
|
void SetTextStartsWithNBSP(PRBool aYes) {
|
2000-04-17 14:40:46 +00:00
|
|
|
SetFlag(LL_TEXTSTARTSWITHNBSP, aYes);
|
1999-11-02 15:44:57 +00:00
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void RecordWordFrame(nsIFrame* aWordFrame) {
|
2002-03-19 21:57:45 +00:00
|
|
|
mWordFrames.Push(aWordFrame);
|
1998-10-17 01:06:17 +00:00
|
|
|
}
|
1998-06-25 16:33:10 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
PRBool InWord() const {
|
2002-03-19 21:57:45 +00:00
|
|
|
return 0 != mWordFrames.GetSize();
|
1999-03-18 21:03:25 +00:00
|
|
|
}
|
1998-07-22 18:38:57 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void ForgetWordFrame(nsIFrame* aFrame);
|
1999-02-01 17:32:33 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
void ForgetWordFrames() {
|
2002-03-19 21:57:45 +00:00
|
|
|
mWordFrames.Empty();
|
1999-03-18 21:03:25 +00:00
|
|
|
}
|
1998-10-10 04:35:01 +00:00
|
|
|
|
2000-07-27 05:16:08 +00:00
|
|
|
nsIFrame* FindNextText(nsIPresContext* aPresContext, nsIFrame* aFrame);
|
1998-11-10 18:04:19 +00:00
|
|
|
|
1999-03-24 15:41:17 +00:00
|
|
|
PRBool CanPlaceFloaterNow() const;
|
1998-10-10 04:35:01 +00:00
|
|
|
|
1999-03-24 15:41:17 +00:00
|
|
|
PRBool LineIsEmpty() const;
|
|
|
|
|
|
|
|
PRBool LineIsBreakable() const;
|
1999-03-21 01:14:05 +00:00
|
|
|
|
2000-04-17 14:40:46 +00:00
|
|
|
PRBool GetLineEndsInBR() const
|
|
|
|
{
|
|
|
|
return GetFlag(LL_LINEENDSINBR);
|
|
|
|
}
|
1999-10-29 14:33:26 +00:00
|
|
|
|
2000-04-17 14:40:46 +00:00
|
|
|
void SetLineEndsInBR(PRBool aOn)
|
|
|
|
{
|
|
|
|
SetFlag(LL_LINEENDSINBR, aOn);
|
|
|
|
}
|
1999-10-29 14:33:26 +00:00
|
|
|
|
2002-08-11 18:00:07 +00:00
|
|
|
PRBool InStrictMode() const
|
2002-06-25 21:16:17 +00:00
|
|
|
{
|
|
|
|
return mCompatMode != eCompatibility_NavQuirks;
|
|
|
|
}
|
|
|
|
|
2002-08-11 18:00:07 +00:00
|
|
|
nsCompatibility GetCompatMode() const
|
|
|
|
{
|
|
|
|
return mCompatMode;
|
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
//----------------------------------------
|
|
|
|
// Inform the line-layout about the presence of a floating frame
|
|
|
|
// XXX get rid of this: use get-frame-type?
|
2002-05-28 22:50:43 +00:00
|
|
|
void InitFloater(nsPlaceholderFrame* aFrame, nsReflowStatus& aReflowStatus) {
|
|
|
|
mBlockRS->InitFloater(*this, aFrame, aReflowStatus);
|
2001-05-01 04:22:57 +00:00
|
|
|
}
|
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
void AddFloater(nsPlaceholderFrame* aFrame, nsReflowStatus& aReflowStatus) {
|
|
|
|
mBlockRS->AddFloater(*this, aFrame, PR_FALSE, aReflowStatus);
|
2001-05-01 04:22:57 +00:00
|
|
|
}
|
1998-06-25 16:33:10 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
//----------------------------------------
|
1998-06-27 22:56:09 +00:00
|
|
|
|
1998-11-05 19:30:31 +00:00
|
|
|
PRBool GetFirstLetterStyleOK() const {
|
2000-04-17 14:40:46 +00:00
|
|
|
return GetFlag(LL_FIRSTLETTERSTYLEOK);
|
1998-11-05 19:30:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetFirstLetterStyleOK(PRBool aSetting) {
|
2000-04-17 14:40:46 +00:00
|
|
|
SetFlag(LL_FIRSTLETTERSTYLEOK, aSetting);
|
1998-11-05 19:30:31 +00:00
|
|
|
}
|
|
|
|
|
1999-03-26 00:41:36 +00:00
|
|
|
void SetFirstLetterFrame(nsIFrame* aFrame) {
|
|
|
|
mFirstLetterFrame = aFrame;
|
|
|
|
}
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
static PRBool TreatFrameAsBlock(nsIFrame* aFrame);
|
|
|
|
|
2000-09-11 20:46:44 +00:00
|
|
|
static PRBool IsPercentageUnitSides(const nsStyleSides* aSides);
|
|
|
|
|
|
|
|
static PRBool IsPercentageAwareReplacedElement(nsIPresContext *aPresContext,
|
|
|
|
nsIFrame *aFrame);
|
|
|
|
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
nsIPresContext* mPresContext;
|
1999-03-18 21:03:25 +00:00
|
|
|
|
1998-06-27 22:56:09 +00:00
|
|
|
protected:
|
1999-03-18 21:03:25 +00:00
|
|
|
// This state is constant for a given block frame doing line layout
|
2001-10-26 05:06:07 +00:00
|
|
|
nsSpaceManager* mSpaceManager;
|
2001-10-25 01:08:40 +00:00
|
|
|
const nsStyleText* mStyleText; // for the block
|
1999-03-18 21:03:25 +00:00
|
|
|
const nsHTMLReflowState* mBlockReflowState;
|
|
|
|
nsBlockReflowState* mBlockRS;/* XXX hack! */
|
2002-06-25 21:16:17 +00:00
|
|
|
nsCompatibility mCompatMode;
|
1999-03-18 21:03:25 +00:00
|
|
|
nscoord mMinLineHeight;
|
2000-01-04 02:59:35 +00:00
|
|
|
PRPackedBool mComputeMaxElementSize;
|
1999-03-18 21:03:25 +00:00
|
|
|
PRUint8 mTextAlign;
|
|
|
|
|
2002-05-14 12:55:55 +00:00
|
|
|
// The amount of text indent that we applied to this line, needed for
|
|
|
|
// max-element-size calculation.
|
|
|
|
nscoord mTextIndent;
|
|
|
|
|
1999-03-22 20:45:09 +00:00
|
|
|
// This state varies during the reflow of a line but is line
|
|
|
|
// "global" state not span "local" state.
|
1999-03-26 00:41:36 +00:00
|
|
|
nsIFrame* mFirstLetterFrame;
|
1999-03-18 21:03:25 +00:00
|
|
|
PRInt32 mLineNumber;
|
|
|
|
PRInt32 mColumn;
|
2000-04-17 14:40:46 +00:00
|
|
|
PRInt32 mTextJustificationNumSpaces;
|
|
|
|
PRInt32 mTextJustificationNumLetters;
|
|
|
|
|
2000-02-15 04:26:44 +00:00
|
|
|
nsLineBox* mLineBox;
|
2000-04-17 14:40:46 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
PRUint8 mPlacedFloaters;
|
1998-09-23 02:31:00 +00:00
|
|
|
PRInt32 mTotalPlacedFrames;
|
2002-03-19 21:57:45 +00:00
|
|
|
nsDeque mWordFrames;
|
1998-10-10 04:35:01 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
nscoord mTopEdge;
|
|
|
|
nscoord mBottomEdge;
|
|
|
|
nscoord mMaxTopBoxHeight;
|
|
|
|
nscoord mMaxBottomBoxHeight;
|
|
|
|
|
1999-10-12 23:27:32 +00:00
|
|
|
// Final computed line-height value after VerticalAlignFrames for
|
|
|
|
// the block has been called.
|
|
|
|
nscoord mFinalLineHeight;
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
// Per-frame data recorded by the line-layout reflow logic. This
|
|
|
|
// state is the state needed to post-process the line after reflow
|
|
|
|
// has completed (vertical alignment, horizontal alignment,
|
|
|
|
// justification and relative positioning).
|
1999-03-31 04:21:53 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
struct PerSpanData;
|
1999-04-12 20:12:15 +00:00
|
|
|
struct PerFrameData;
|
|
|
|
friend struct PerSpanData;
|
|
|
|
friend struct PerFrameData;
|
1999-03-18 21:03:25 +00:00
|
|
|
struct PerFrameData {
|
|
|
|
// link to next/prev frame in same span
|
|
|
|
PerFrameData* mNext;
|
|
|
|
PerFrameData* mPrev;
|
|
|
|
|
|
|
|
// pointer to child span data if this is an inline container frame
|
|
|
|
PerSpanData* mSpan;
|
|
|
|
|
|
|
|
// The frame and its type
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
nsCSSFrameType mFrameType;
|
|
|
|
|
|
|
|
// From metrics
|
|
|
|
nscoord mAscent, mDescent;
|
|
|
|
nsRect mBounds;
|
|
|
|
nsSize mMaxElementSize;
|
|
|
|
nsRect mCombinedArea;
|
|
|
|
|
|
|
|
// From reflow-state
|
|
|
|
nsMargin mMargin;
|
|
|
|
nsMargin mBorderPadding;
|
|
|
|
nsMargin mOffsets;
|
|
|
|
|
|
|
|
// Other state we use
|
|
|
|
PRUint8 mVerticalAlign;
|
2000-04-17 14:40:46 +00:00
|
|
|
|
|
|
|
// state for text justification
|
|
|
|
PRInt32 mJustificationNumSpaces;
|
|
|
|
PRInt32 mJustificationNumLetters;
|
|
|
|
|
|
|
|
|
|
|
|
// PerFrameData flags
|
|
|
|
#define PFD_RELATIVEPOS 0x00000001
|
|
|
|
#define PFD_ISTEXTFRAME 0x00000002
|
|
|
|
#define PFD_ISNONEMPTYTEXTFRAME 0x00000004
|
|
|
|
#define PFD_ISNONWHITESPACETEXTFRAME 0x00000008
|
|
|
|
#define PFD_ISLETTERFRAME 0x00000010
|
|
|
|
#define PFD_ISSTICKY 0x00000020
|
|
|
|
#define PFD_ISBULLET 0x00000040
|
|
|
|
#define PFD_LASTFLAG PFD_ISBULLET
|
|
|
|
|
|
|
|
PRPackedBool mFlags;
|
|
|
|
|
|
|
|
void SetFlag(PRUint32 aFlag, PRBool aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=PFD_LASTFLAG, "bad flag");
|
|
|
|
NS_ASSERTION(aValue==PR_FALSE || aValue==PR_TRUE, "bad value");
|
|
|
|
if (aValue) { // set flag
|
|
|
|
mFlags |= aFlag;
|
|
|
|
}
|
|
|
|
else { // unset flag
|
|
|
|
mFlags &= ~aFlag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool GetFlag(PRUint32 aFlag) const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=PFD_LASTFLAG, "bad flag");
|
|
|
|
PRBool result = (mFlags & aFlag);
|
|
|
|
if (result) return PR_TRUE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-09-21 00:14:22 +00:00
|
|
|
|
|
|
|
PerFrameData* Last() {
|
|
|
|
PerFrameData* pfd = this;
|
|
|
|
while (pfd->mNext) {
|
|
|
|
pfd = pfd->mNext;
|
|
|
|
}
|
|
|
|
return pfd;
|
|
|
|
}
|
1999-03-18 21:03:25 +00:00
|
|
|
};
|
2002-08-14 13:00:16 +00:00
|
|
|
PerFrameData mFrameDataBuf[NS_LINELAYOUT_NUM_FRAMES];
|
|
|
|
PerFrameData* mFrameFreeList;
|
|
|
|
PRInt32 mInitialFramesFreed;
|
1999-03-18 21:03:25 +00:00
|
|
|
|
2002-01-25 15:07:38 +00:00
|
|
|
#if defined(AIX_XLC_364) || defined(XP_OS2_VACPP)
|
1999-03-31 04:21:53 +00:00
|
|
|
public:
|
1999-04-12 20:12:15 +00:00
|
|
|
#endif
|
1999-03-18 21:03:25 +00:00
|
|
|
struct PerSpanData {
|
2002-08-14 13:00:16 +00:00
|
|
|
union {
|
|
|
|
PerSpanData* mParent;
|
|
|
|
PerSpanData* mNextFreeSpan;
|
|
|
|
};
|
1999-03-18 21:03:25 +00:00
|
|
|
PerFrameData* mFrame;
|
|
|
|
PerFrameData* mFirstFrame;
|
|
|
|
PerFrameData* mLastFrame;
|
|
|
|
|
|
|
|
const nsHTMLReflowState* mReflowState;
|
2000-01-04 02:59:35 +00:00
|
|
|
PRPackedBool mNoWrap;
|
1999-03-22 20:45:09 +00:00
|
|
|
PRUint8 mDirection;
|
2000-01-04 02:59:35 +00:00
|
|
|
PRPackedBool mChangedFrameDirection;
|
|
|
|
PRPackedBool mZeroEffectiveSpanBox;
|
|
|
|
PRPackedBool mContainsFloater;
|
1999-03-22 20:45:09 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
nscoord mLeftEdge;
|
|
|
|
nscoord mX;
|
|
|
|
nscoord mRightEdge;
|
|
|
|
|
|
|
|
nscoord mTopLeading, mBottomLeading;
|
|
|
|
nscoord mLogicalHeight;
|
|
|
|
nscoord mMinY, mMaxY;
|
|
|
|
|
|
|
|
void AppendFrame(PerFrameData* pfd) {
|
|
|
|
if (nsnull == mLastFrame) {
|
|
|
|
mFirstFrame = pfd;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mLastFrame->mNext = pfd;
|
|
|
|
pfd->mPrev = mLastFrame;
|
|
|
|
}
|
|
|
|
mLastFrame = pfd;
|
|
|
|
}
|
|
|
|
};
|
2002-01-25 15:07:38 +00:00
|
|
|
#if defined(AIX_XLC_364) || defined(XP_OS2_VACPP)
|
1999-03-31 04:21:53 +00:00
|
|
|
protected:
|
1999-04-12 20:12:15 +00:00
|
|
|
#endif
|
2002-08-14 13:00:16 +00:00
|
|
|
PerSpanData mSpanDataBuf[NS_LINELAYOUT_NUM_SPANS];
|
|
|
|
PerSpanData* mSpanFreeList;
|
|
|
|
PRInt32 mInitialSpansFreed;
|
1999-03-18 21:03:25 +00:00
|
|
|
PerSpanData* mRootSpan;
|
|
|
|
PerSpanData* mCurrentSpan;
|
|
|
|
PRInt32 mSpanDepth;
|
2002-08-14 13:00:16 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRInt32 mSpansAllocated, mSpansFreed;
|
|
|
|
PRInt32 mFramesAllocated, mFramesFreed;
|
|
|
|
#endif
|
1999-03-18 21:03:25 +00:00
|
|
|
|
|
|
|
nsresult NewPerFrameData(PerFrameData** aResult);
|
|
|
|
|
|
|
|
nsresult NewPerSpanData(PerSpanData** aResult);
|
|
|
|
|
2002-08-14 13:00:16 +00:00
|
|
|
void FreeSpan(PerSpanData* psd);
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
PRBool InBlockContext() const {
|
|
|
|
return mSpanDepth == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushFrame(nsIFrame* aFrame);
|
|
|
|
|
2002-01-30 23:28:56 +00:00
|
|
|
void ApplyStartMargin(PerFrameData* pfd,
|
|
|
|
nsHTMLReflowState& aReflowState);
|
1999-03-18 21:03:25 +00:00
|
|
|
|
|
|
|
PRBool CanPlaceFrame(PerFrameData* pfd,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-22 20:45:09 +00:00
|
|
|
PRBool aNotSafeToBreak,
|
1999-03-18 21:03:25 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
|
|
|
void PlaceFrame(PerFrameData* pfd,
|
|
|
|
nsHTMLReflowMetrics& aMetrics);
|
|
|
|
|
|
|
|
void UpdateFrames();
|
|
|
|
|
|
|
|
void VerticalAlignFrames(PerSpanData* psd);
|
|
|
|
|
|
|
|
void PlaceTopBottomFrames(PerSpanData* psd,
|
|
|
|
nscoord aDistanceFromTop,
|
|
|
|
nscoord aLineHeight);
|
|
|
|
|
|
|
|
void RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea);
|
|
|
|
|
1999-09-21 00:14:22 +00:00
|
|
|
PRBool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaWidth);
|
|
|
|
|
2000-04-17 14:40:46 +00:00
|
|
|
|
|
|
|
void ComputeJustificationWeights(PerSpanData* psd, PRInt32* numSpaces, PRInt32* numLetters);
|
|
|
|
|
|
|
|
struct FrameJustificationState {
|
|
|
|
PRInt32 mTotalNumSpaces;
|
|
|
|
PRInt32 mTotalNumLetters;
|
|
|
|
nscoord mTotalWidthForSpaces;
|
|
|
|
nscoord mTotalWidthForLetters;
|
|
|
|
PRInt32 mNumSpacesProcessed;
|
|
|
|
PRInt32 mNumLettersProcessed;
|
|
|
|
nscoord mWidthForSpacesProcessed;
|
|
|
|
nscoord mWidthForLettersProcessed;
|
|
|
|
};
|
|
|
|
nscoord ApplyFrameJustification(PerSpanData* aPSD, FrameJustificationState* aState);
|
|
|
|
|
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void DumpPerSpanData(PerSpanData* psd, PRInt32 aIndent);
|
|
|
|
#endif
|
1998-06-18 16:25:41 +00:00
|
|
|
};
|
|
|
|
|
1998-09-15 00:19:49 +00:00
|
|
|
#endif /* nsLineLayout_h___ */
|