1998-09-15 04:19:49 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-10-25 05:08:40 +04:00
|
|
|
* vim:cindent:ts=2:et:sw=2:
|
1998-09-15 04:19:49 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-09-15 04:19:49 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
|
|
|
*
|
|
|
|
* 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-09-15 04:19:49 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* Contributor(s):
|
2000-04-17 18:40:46 +04:00
|
|
|
* Steve Clark <buster@netscape.com>
|
2004-04-18 18:30:37 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK *****
|
2000-05-03 03:07:11 +04: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-09-15 04:19:49 +04:00
|
|
|
*/
|
|
|
|
#ifndef nsLineLayout_h___
|
|
|
|
#define nsLineLayout_h___
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
#include "nsFrame.h"
|
2002-03-20 00:57:45 +03:00
|
|
|
#include "nsDeque.h"
|
2000-02-15 07:26:44 +03:00
|
|
|
#include "nsLineBox.h"
|
2001-05-01 08:22:57 +04:00
|
|
|
#include "nsBlockReflowState.h"
|
2004-07-15 21:50:34 +04:00
|
|
|
#include "plarena.h"
|
1998-09-15 04:19:49 +04:00
|
|
|
|
2001-10-26 09:06:07 +04:00
|
|
|
class nsSpaceManager;
|
1998-09-15 04:19:49 +04:00
|
|
|
class nsPlaceholderFrame;
|
1999-03-19 00:03:25 +03:00
|
|
|
struct nsStyleText;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
|
|
|
class nsLineLayout {
|
|
|
|
public:
|
2004-08-01 03:15:21 +04:00
|
|
|
nsLineLayout(nsPresContext* aPresContext,
|
2001-10-26 09:06:07 +04:00
|
|
|
nsSpaceManager* aSpaceManager,
|
1999-03-19 00:03:25 +03:00
|
|
|
const nsHTMLReflowState* aOuterReflowState,
|
2003-01-09 17:26:32 +03:00
|
|
|
PRBool aComputeMaxElementWidth);
|
1998-09-15 04:19:49 +04:00
|
|
|
~nsLineLayout();
|
|
|
|
|
2004-07-15 21:50:34 +04:00
|
|
|
class ArenaDeque : public nsDeque
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ArenaDeque() : nsDeque(nsnull) {}
|
|
|
|
void *operator new(size_t, PLArenaPool &pool);
|
|
|
|
void operator delete(void *) {} // Dont do anything. Its Arena memory
|
|
|
|
};
|
|
|
|
|
1999-08-28 01:49:12 +04:00
|
|
|
void Init(nsBlockReflowState* aState, nscoord aMinLineHeight,
|
|
|
|
PRInt32 aLineNumber) {
|
1999-03-19 00:03:25 +03:00
|
|
|
mBlockRS = aState;
|
1999-08-28 01:49:12 +04:00
|
|
|
mMinLineHeight = aMinLineHeight;
|
|
|
|
mLineNumber = aLineNumber;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
PRInt32 GetColumn() {
|
|
|
|
return mColumn;
|
1999-02-18 06:28:00 +03:00
|
|
|
}
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void SetColumn(PRInt32 aNewColumn) {
|
|
|
|
mColumn = aNewColumn;
|
1998-09-23 06:31:00 +04:00
|
|
|
}
|
1999-03-19 00:03:25 +03:00
|
|
|
|
|
|
|
PRInt32 GetLineNumber() const {
|
|
|
|
return mLineNumber;
|
1998-09-23 06:31:00 +04:00
|
|
|
}
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void BeginLineReflow(nscoord aX, nscoord aY,
|
|
|
|
nscoord aWidth, nscoord aHeight,
|
2003-10-14 01:51:02 +04:00
|
|
|
PRBool aImpactedByFloats,
|
1999-03-19 00:03:25 +03:00
|
|
|
PRBool aIsTopOfPage);
|
1998-10-27 19:52:10 +03:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void EndLineReflow();
|
1998-09-30 02:32:04 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void UpdateBand(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
2003-10-14 01:51:02 +04:00
|
|
|
PRBool aPlacedLeftFloat,
|
|
|
|
nsIFrame* aFloatFrame);
|
1998-09-30 02:32:04 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
nsresult BeginSpan(nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState* aSpanReflowState,
|
|
|
|
nscoord aLeftEdge,
|
|
|
|
nscoord aRightEdge);
|
1998-10-10 02:58:25 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void EndSpan(nsIFrame* aFrame, nsSize& aSizeResult,
|
2003-01-09 17:26:32 +03:00
|
|
|
nscoord* aMaxElementWidth);
|
1999-09-03 07:47:49 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
PRInt32 GetCurrentSpanCount() const;
|
1998-10-10 02:58:25 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void SplitLineTo(PRInt32 aNewCount);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
PRBool IsZeroHeight();
|
1998-09-15 04:19:49 +04:00
|
|
|
|
2000-01-03 07:32:13 +03: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-19 00:03:25 +03:00
|
|
|
nsresult ReflowFrame(nsIFrame* aFrame,
|
1999-10-29 18:33:26 +04:00
|
|
|
nsReflowStatus& aReflowStatus,
|
2000-01-03 07:32:13 +03:00
|
|
|
nsHTMLReflowMetrics* aMetrics,
|
|
|
|
PRBool& aPushedFrame);
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
nsresult AddBulletFrame(nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowMetrics& aMetrics);
|
1998-10-20 04:22:48 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void RemoveBulletFrame(nsIFrame* aFrame) {
|
|
|
|
PushFrame(aFrame);
|
1998-10-10 08:35:01 +04:00
|
|
|
}
|
|
|
|
|
2001-07-04 06:00:05 +04:00
|
|
|
void VerticalAlignLine(nsLineBox* aLineBox,
|
2003-01-09 17:26:32 +03:00
|
|
|
nscoord* aMaxElementWidthResult);
|
1998-10-10 08:35:01 +04:00
|
|
|
|
1999-10-13 03:27:32 +04:00
|
|
|
PRBool TrimTrailingWhiteSpace();
|
1998-10-10 08:35:01 +04:00
|
|
|
|
2000-01-03 07:32:13 +03:00
|
|
|
PRBool HorizontalAlignFrames(nsRect& aLineBounds,
|
|
|
|
PRBool aAllowJustify,
|
|
|
|
PRBool aShrinkWrapWidth);
|
1998-10-10 08:35:01 +04:00
|
|
|
|
2003-07-23 04:14:16 +04:00
|
|
|
/**
|
|
|
|
* Handle all the relative positioning in the line, compute the
|
|
|
|
* combined area (== overflow area) for the line, and handle view
|
|
|
|
* sizing/positioning and the setting of NS_FRAME_OUTSIDE_CHILDREN.
|
|
|
|
*/
|
1999-03-19 00:03:25 +03:00
|
|
|
void RelativePositionFrames(nsRect& aCombinedArea);
|
1998-10-10 08:35:01 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
//----------------------------------------
|
1998-10-10 08:35:01 +04:00
|
|
|
|
2000-04-17 18:40:46 +04:00
|
|
|
// Supporting methods and data for flags
|
|
|
|
protected:
|
|
|
|
#define LL_ENDSINWHITESPACE 0x00000001
|
|
|
|
#define LL_UNDERSTANDSNWHITESPACE 0x00000002
|
|
|
|
#define LL_FIRSTLETTERSTYLEOK 0x00000008
|
|
|
|
#define LL_ISTOPOFPAGE 0x00000010
|
|
|
|
#define LL_UPDATEDBAND 0x00000020
|
2003-10-14 01:51:02 +04:00
|
|
|
#define LL_IMPACTEDBYFLOATS 0x00000040
|
|
|
|
#define LL_LASTFLOATWASLETTERFRAME 0x00000080
|
|
|
|
#define LL_CANPLACEFLOAT 0x00000100
|
2002-06-26 01:16:17 +04:00
|
|
|
#define LL_LINEENDSINBR 0x00000200
|
2000-04-17 18:40:46 +04: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-19 00:03:25 +03:00
|
|
|
// Support methods for white-space compression and word-wrapping
|
|
|
|
// during line reflow
|
|
|
|
|
|
|
|
void SetEndsInWhiteSpace(PRBool aState) {
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(LL_ENDSINWHITESPACE, aState);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
PRBool GetEndsInWhiteSpace() const {
|
2000-04-17 18:40:46 +04:00
|
|
|
return GetFlag(LL_ENDSINWHITESPACE);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void SetUnderstandsWhiteSpace(PRBool aSetting) {
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(LL_UNDERSTANDSNWHITESPACE, aSetting);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTextJustificationWeights(PRInt32 aNumSpaces, PRInt32 aNumLetters) {
|
|
|
|
mTextJustificationNumSpaces = aNumSpaces;
|
|
|
|
mTextJustificationNumLetters = aNumLetters;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1999-03-19 00:03:25 +03:00
|
|
|
|
|
|
|
void RecordWordFrame(nsIFrame* aWordFrame) {
|
2004-07-15 21:50:34 +04:00
|
|
|
if(mWordFrames || AllocateDeque())
|
|
|
|
mWordFrames->Push(aWordFrame);
|
1998-10-17 05:06:17 +04:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
PRBool InWord() const {
|
2004-07-15 21:50:34 +04:00
|
|
|
return mWordFrames && 0 != mWordFrames->GetSize();
|
1999-03-19 00:03:25 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void ForgetWordFrame(nsIFrame* aFrame);
|
1999-02-01 20:32:33 +03:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
void ForgetWordFrames() {
|
2004-07-15 21:50:34 +04:00
|
|
|
if(mWordFrames) {
|
|
|
|
mWordFrames->Empty();
|
|
|
|
}
|
1999-03-19 00:03:25 +03:00
|
|
|
}
|
1998-10-10 08:35:01 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsIFrame* FindNextText(nsPresContext* aPresContext, nsIFrame* aFrame);
|
1998-11-10 21:04:19 +03:00
|
|
|
|
2003-10-14 01:51:02 +04:00
|
|
|
PRBool CanPlaceFloatNow() const;
|
1998-10-10 08:35:01 +04:00
|
|
|
|
1999-03-24 18:41:17 +03:00
|
|
|
PRBool LineIsBreakable() const;
|
1999-03-21 04:14:05 +03:00
|
|
|
|
2000-04-17 18:40:46 +04:00
|
|
|
PRBool GetLineEndsInBR() const
|
|
|
|
{
|
|
|
|
return GetFlag(LL_LINEENDSINBR);
|
|
|
|
}
|
1999-10-29 18:33:26 +04:00
|
|
|
|
2000-04-17 18:40:46 +04:00
|
|
|
void SetLineEndsInBR(PRBool aOn)
|
|
|
|
{
|
|
|
|
SetFlag(LL_LINEENDSINBR, aOn);
|
|
|
|
}
|
1999-10-29 18:33:26 +04:00
|
|
|
|
2002-08-11 22:00:07 +04:00
|
|
|
PRBool InStrictMode() const
|
2002-06-26 01:16:17 +04:00
|
|
|
{
|
|
|
|
return mCompatMode != eCompatibility_NavQuirks;
|
|
|
|
}
|
|
|
|
|
2002-08-11 22:00:07 +04:00
|
|
|
nsCompatibility GetCompatMode() const
|
|
|
|
{
|
|
|
|
return mCompatMode;
|
|
|
|
}
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
//----------------------------------------
|
|
|
|
// Inform the line-layout about the presence of a floating frame
|
|
|
|
// XXX get rid of this: use get-frame-type?
|
2005-03-23 06:35:08 +03:00
|
|
|
PRBool InitFloat(nsPlaceholderFrame* aFrame, nsReflowStatus& aReflowStatus) {
|
|
|
|
return mBlockRS->InitFloat(*this, aFrame, aReflowStatus);
|
2001-05-01 08:22:57 +04:00
|
|
|
}
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
PRBool AddFloat(nsPlaceholderFrame* aFrame, nsReflowStatus& aReflowStatus) {
|
|
|
|
return mBlockRS->AddFloat(*this, aFrame, PR_FALSE, aReflowStatus);
|
2001-05-01 08:22:57 +04:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
//----------------------------------------
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-11-05 22:30:31 +03:00
|
|
|
PRBool GetFirstLetterStyleOK() const {
|
2000-04-17 18:40:46 +04:00
|
|
|
return GetFlag(LL_FIRSTLETTERSTYLEOK);
|
1998-11-05 22:30:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetFirstLetterStyleOK(PRBool aSetting) {
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(LL_FIRSTLETTERSTYLEOK, aSetting);
|
1998-11-05 22:30:31 +03:00
|
|
|
}
|
|
|
|
|
1999-03-26 03:41:36 +03:00
|
|
|
void SetFirstLetterFrame(nsIFrame* aFrame) {
|
|
|
|
mFirstLetterFrame = aFrame;
|
|
|
|
}
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
static PRBool TreatFrameAsBlock(nsIFrame* aFrame);
|
|
|
|
|
2000-09-12 00:46:44 +04:00
|
|
|
static PRBool IsPercentageUnitSides(const nsStyleSides* aSides);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
static PRBool IsPercentageAwareReplacedElement(nsPresContext *aPresContext,
|
2000-09-12 00:46:44 +04:00
|
|
|
nsIFrame *aFrame);
|
|
|
|
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
//----------------------------------------
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* mPresContext;
|
1999-03-19 00:03:25 +03:00
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
protected:
|
1999-03-19 00:03:25 +03:00
|
|
|
// This state is constant for a given block frame doing line layout
|
2001-10-26 09:06:07 +04:00
|
|
|
nsSpaceManager* mSpaceManager;
|
2001-10-25 05:08:40 +04:00
|
|
|
const nsStyleText* mStyleText; // for the block
|
1999-03-19 00:03:25 +03:00
|
|
|
const nsHTMLReflowState* mBlockReflowState;
|
2002-09-25 02:13:20 +04:00
|
|
|
|
|
|
|
// XXX remove this when landing bug 154892 (splitting absolute positioned frames)
|
|
|
|
friend class nsInlineFrame;
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
nsBlockReflowState* mBlockRS;/* XXX hack! */
|
2002-06-26 01:16:17 +04:00
|
|
|
nsCompatibility mCompatMode;
|
1999-03-19 00:03:25 +03:00
|
|
|
nscoord mMinLineHeight;
|
2003-01-09 17:26:32 +03:00
|
|
|
PRPackedBool mComputeMaxElementWidth;
|
1999-03-19 00:03:25 +03:00
|
|
|
PRUint8 mTextAlign;
|
|
|
|
|
2003-10-14 01:51:02 +04:00
|
|
|
PRUint8 mPlacedFloats;
|
2002-11-06 05:03:43 +03:00
|
|
|
|
2002-05-14 16:55:55 +04:00
|
|
|
// The amount of text indent that we applied to this line, needed for
|
|
|
|
// max-element-size calculation.
|
|
|
|
nscoord mTextIndent;
|
|
|
|
|
1999-03-22 23:45:09 +03:00
|
|
|
// This state varies during the reflow of a line but is line
|
|
|
|
// "global" state not span "local" state.
|
1999-03-26 03:41:36 +03:00
|
|
|
nsIFrame* mFirstLetterFrame;
|
1999-03-19 00:03:25 +03:00
|
|
|
PRInt32 mLineNumber;
|
|
|
|
PRInt32 mColumn;
|
2000-04-17 18:40:46 +04:00
|
|
|
PRInt32 mTextJustificationNumSpaces;
|
|
|
|
PRInt32 mTextJustificationNumLetters;
|
|
|
|
|
2000-02-15 07:26:44 +03:00
|
|
|
nsLineBox* mLineBox;
|
2000-04-17 18:40:46 +04:00
|
|
|
|
1998-09-23 06:31:00 +04:00
|
|
|
PRInt32 mTotalPlacedFrames;
|
2004-07-15 21:50:34 +04:00
|
|
|
ArenaDeque *mWordFrames;
|
|
|
|
PRBool AllocateDeque();
|
1998-10-10 08:35:01 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
nscoord mTopEdge;
|
|
|
|
nscoord mMaxTopBoxHeight;
|
|
|
|
nscoord mMaxBottomBoxHeight;
|
|
|
|
|
1999-10-13 03:27:32 +04:00
|
|
|
// Final computed line-height value after VerticalAlignFrames for
|
|
|
|
// the block has been called.
|
|
|
|
nscoord mFinalLineHeight;
|
|
|
|
|
1999-03-19 00:03:25 +03: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 08:21:53 +04:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
struct PerSpanData;
|
1999-04-13 00:12:15 +04:00
|
|
|
struct PerFrameData;
|
|
|
|
friend struct PerSpanData;
|
|
|
|
friend struct PerFrameData;
|
1999-03-19 00:03:25 +03: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;
|
2003-01-09 17:26:32 +03:00
|
|
|
nscoord mMaxElementWidth;
|
1999-03-19 00:03:25 +03:00
|
|
|
nsRect mCombinedArea;
|
|
|
|
|
|
|
|
// From reflow-state
|
|
|
|
nsMargin mMargin;
|
|
|
|
nsMargin mBorderPadding;
|
|
|
|
nsMargin mOffsets;
|
|
|
|
|
2000-04-17 18:40:46 +04:00
|
|
|
// state for text justification
|
|
|
|
PRInt32 mJustificationNumSpaces;
|
|
|
|
PRInt32 mJustificationNumLetters;
|
2002-11-06 05:03:43 +03:00
|
|
|
|
|
|
|
// Other state we use
|
|
|
|
PRUint8 mVerticalAlign;
|
2000-04-17 18:40:46 +04:00
|
|
|
|
|
|
|
// 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
|
2004-03-02 04:23:13 +03:00
|
|
|
#define PFD_ISPLACEHOLDERFRAME 0x00000080
|
|
|
|
#define PFD_LASTFLAG PFD_ISPLACEHOLDERFRAME
|
2000-04-17 18:40:46 +04:00
|
|
|
|
2004-03-02 04:23:13 +03:00
|
|
|
PRPackedBool mFlags;
|
2000-04-17 18:40:46 +04:00
|
|
|
|
|
|
|
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 04:14:22 +04:00
|
|
|
|
|
|
|
PerFrameData* Last() {
|
|
|
|
PerFrameData* pfd = this;
|
|
|
|
while (pfd->mNext) {
|
|
|
|
pfd = pfd->mNext;
|
|
|
|
}
|
|
|
|
return pfd;
|
|
|
|
}
|
1999-03-19 00:03:25 +03:00
|
|
|
};
|
2002-08-14 17:00:16 +04:00
|
|
|
PerFrameData* mFrameFreeList;
|
1999-03-19 00:03:25 +03:00
|
|
|
|
|
|
|
struct PerSpanData {
|
2002-08-14 17:00:16 +04:00
|
|
|
union {
|
|
|
|
PerSpanData* mParent;
|
|
|
|
PerSpanData* mNextFreeSpan;
|
|
|
|
};
|
1999-03-19 00:03:25 +03:00
|
|
|
PerFrameData* mFrame;
|
|
|
|
PerFrameData* mFirstFrame;
|
|
|
|
PerFrameData* mLastFrame;
|
|
|
|
|
|
|
|
const nsHTMLReflowState* mReflowState;
|
2000-01-04 05:59:35 +03:00
|
|
|
PRPackedBool mNoWrap;
|
1999-03-22 23:45:09 +03:00
|
|
|
PRUint8 mDirection;
|
2000-01-04 05:59:35 +03:00
|
|
|
PRPackedBool mChangedFrameDirection;
|
|
|
|
PRPackedBool mZeroEffectiveSpanBox;
|
2003-10-14 01:51:02 +04:00
|
|
|
PRPackedBool mContainsFloat;
|
1999-03-22 23:45:09 +03:00
|
|
|
|
1999-03-19 00:03:25 +03: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-08-14 17:00:16 +04:00
|
|
|
PerSpanData* mSpanFreeList;
|
1999-03-19 00:03:25 +03:00
|
|
|
PerSpanData* mRootSpan;
|
|
|
|
PerSpanData* mCurrentSpan;
|
|
|
|
PRInt32 mSpanDepth;
|
2002-08-14 17:00:16 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRInt32 mSpansAllocated, mSpansFreed;
|
|
|
|
PRInt32 mFramesAllocated, mFramesFreed;
|
|
|
|
#endif
|
2004-07-15 21:50:34 +04:00
|
|
|
PLArenaPool mArena; // Per span and per frame data
|
1999-03-19 00:03:25 +03:00
|
|
|
|
|
|
|
nsresult NewPerFrameData(PerFrameData** aResult);
|
|
|
|
|
|
|
|
nsresult NewPerSpanData(PerSpanData** aResult);
|
|
|
|
|
2002-08-14 17:00:16 +04:00
|
|
|
void FreeSpan(PerSpanData* psd);
|
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
PRBool InBlockContext() const {
|
|
|
|
return mSpanDepth == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushFrame(nsIFrame* aFrame);
|
|
|
|
|
2002-01-31 02:28:56 +03:00
|
|
|
void ApplyStartMargin(PerFrameData* pfd,
|
|
|
|
nsHTMLReflowState& aReflowState);
|
1999-03-19 00:03:25 +03:00
|
|
|
|
|
|
|
PRBool CanPlaceFrame(PerFrameData* pfd,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-22 23:45:09 +03:00
|
|
|
PRBool aNotSafeToBreak,
|
1999-03-19 00:03:25 +03: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 04:14:22 +04:00
|
|
|
PRBool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaWidth);
|
|
|
|
|
2000-04-17 18:40:46 +04: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-19 00:03:25 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
void DumpPerSpanData(PerSpanData* psd, PRInt32 aIndent);
|
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsLineLayout_h___ */
|