1998-06-18 16:25:41 +00: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-09-15 00:19:49 +00:00
|
|
|
#ifndef nsLineLayout_h___
|
|
|
|
#define nsLineLayout_h___
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1998-06-18 23:16:00 +00:00
|
|
|
#include "nsIFrame.h"
|
1998-06-18 16:25:41 +00:00
|
|
|
#include "nsVoidArray.h"
|
|
|
|
|
1998-09-15 00:19:49 +00:00
|
|
|
struct nsBlockReflowState;
|
1998-08-04 21:17:56 +00:00
|
|
|
class nsPlaceholderFrame;
|
1998-07-22 18:38:57 +00:00
|
|
|
struct nsStyleDisplay;
|
|
|
|
struct nsStylePosition;
|
1998-09-23 02:31:00 +00:00
|
|
|
struct nsStyleSpacing;
|
1998-07-22 18:38:57 +00:00
|
|
|
|
1998-06-18 16:25:41 +00:00
|
|
|
// This structure represents a run of text. In mText are the
|
|
|
|
// nsIFrame's that are considered text frames.
|
1998-09-15 00:19:49 +00:00
|
|
|
struct nsTextRun {
|
|
|
|
nsTextRun() {
|
1998-06-18 16:25:41 +00:00
|
|
|
mNext = nsnull;
|
|
|
|
}
|
|
|
|
|
1998-09-15 00:19:49 +00:00
|
|
|
static void DeleteTextRuns(nsTextRun* aRun) {
|
1998-06-27 22:56:09 +00:00
|
|
|
while (nsnull != aRun) {
|
1998-09-15 00:19:49 +00:00
|
|
|
nsTextRun* next = aRun->mNext;
|
1998-06-27 22:56:09 +00:00
|
|
|
delete aRun;
|
|
|
|
aRun = next;
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void List(FILE* out, PRInt32 aIndent);
|
|
|
|
|
|
|
|
nsVoidArray mArray;
|
1998-09-15 00:19:49 +00:00
|
|
|
nsTextRun* mNext;
|
1998-06-27 22:56:09 +00:00
|
|
|
|
|
|
|
protected:
|
1998-09-15 00:19:49 +00:00
|
|
|
~nsTextRun() {
|
1998-06-27 22:56:09 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-09-15 00:19:49 +00:00
|
|
|
class nsLineLayout {
|
1998-06-18 16:25:41 +00:00
|
|
|
public:
|
1998-09-23 02:31:00 +00:00
|
|
|
nsLineLayout(nsIPresContext& aPresContext,
|
1998-09-15 00:19:49 +00:00
|
|
|
nsISpaceManager* aSpaceManager);
|
|
|
|
~nsLineLayout();
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1998-09-23 02:31:00 +00:00
|
|
|
void Init(nsBlockReflowState* aReflowState) {/* XXX ctor arg really */
|
1998-08-04 21:17:56 +00:00
|
|
|
mBlockReflowState = aReflowState;
|
|
|
|
}
|
|
|
|
|
1998-09-23 02:31:00 +00:00
|
|
|
// Prepare this line-layout for the reflow of a new line
|
|
|
|
void Reset() {
|
|
|
|
mTotalPlacedFrames = 0;
|
|
|
|
mColumn = 0;
|
|
|
|
mSkipLeadingWS = PR_TRUE;
|
1998-09-29 22:32:04 +00:00
|
|
|
mBRFrame = nsnull;
|
1998-09-23 02:31:00 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
mPlacedFrames.Clear();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add to the placed-frame count
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
void AddPlacedFrame(nsIFrame* aFrame) {
|
|
|
|
mTotalPlacedFrames++;
|
|
|
|
mPlacedFrames.AppendElement(aFrame);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void AddPlacedFrame() {
|
|
|
|
mTotalPlacedFrames++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Get the placed-frame count
|
|
|
|
PRInt32 GetPlacedFrames() const {
|
|
|
|
return mTotalPlacedFrames;
|
|
|
|
}
|
|
|
|
|
1998-09-29 22:32:04 +00:00
|
|
|
void SetBRFrame(nsIFrame* aFrame) {
|
|
|
|
mBRFrame = aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* GetBRFrame() const {
|
|
|
|
return mBRFrame;
|
|
|
|
}
|
|
|
|
|
1998-09-23 02:31:00 +00:00
|
|
|
// --------------------------------------------------
|
|
|
|
|
1998-06-27 22:56:09 +00:00
|
|
|
// Reset the text-run information in preparation for a FindTextRuns
|
|
|
|
void ResetTextRuns();
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1998-06-27 22:56:09 +00:00
|
|
|
// Add another piece of text to a text-run during FindTextRuns.
|
1998-06-18 16:25:41 +00:00
|
|
|
// Note: continuation frames must NOT add themselves; just the
|
|
|
|
// first-in-flow
|
|
|
|
nsresult AddText(nsIFrame* aTextFrame);
|
|
|
|
|
1998-06-27 22:56:09 +00:00
|
|
|
// Close out a text-run during FindTextRuns.
|
|
|
|
void EndTextRun();
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1998-09-15 00:19:49 +00:00
|
|
|
// This returns the first nsTextRun found during a
|
1998-06-27 22:56:09 +00:00
|
|
|
// FindTextRuns. The internal text-run state is reset.
|
1998-09-15 00:19:49 +00:00
|
|
|
nsTextRun* TakeTextRuns();
|
1998-06-27 22:56:09 +00:00
|
|
|
|
1998-06-18 16:25:41 +00:00
|
|
|
PRInt32 GetColumn() {
|
|
|
|
return mColumn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetColumn(PRInt32 aNewColumn) {
|
|
|
|
mColumn = aNewColumn;
|
|
|
|
}
|
|
|
|
|
1998-06-25 16:33:10 +00:00
|
|
|
void NextLine() {
|
|
|
|
mLineNumber++;
|
|
|
|
}
|
|
|
|
|
1998-08-04 21:17:56 +00:00
|
|
|
void AddFloater(nsPlaceholderFrame* aFrame);
|
1998-07-18 21:45:40 +00:00
|
|
|
|
1998-07-22 18:38:57 +00:00
|
|
|
static PRBool TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
|
|
|
|
const nsStylePosition* aPosition);
|
|
|
|
|
1998-09-23 02:31:00 +00:00
|
|
|
nsIPresContext& mPresContext;
|
1998-06-18 16:25:41 +00:00
|
|
|
nsISpaceManager* mSpaceManager;
|
1998-09-15 00:19:49 +00:00
|
|
|
nsBlockReflowState* mBlockReflowState;
|
1998-06-18 16:25:41 +00:00
|
|
|
|
|
|
|
PRBool mListPositionOutside;
|
|
|
|
PRInt32 mLineNumber;
|
1998-09-23 02:31:00 +00:00
|
|
|
// nscoord mLeftEdge;
|
1998-06-18 16:25:41 +00:00
|
|
|
PRInt32 mColumn;
|
|
|
|
|
1998-06-25 16:33:10 +00:00
|
|
|
//XXX temporary?
|
|
|
|
|
|
|
|
void SetSkipLeadingWhiteSpace(PRBool aNewSetting) {
|
|
|
|
mSkipLeadingWS = aNewSetting;
|
|
|
|
}
|
|
|
|
PRBool GetSkipLeadingWhiteSpace() { return mSkipLeadingWS; }
|
|
|
|
|
|
|
|
PRBool mSkipLeadingWS;
|
1998-06-27 22:56:09 +00:00
|
|
|
|
|
|
|
protected:
|
1998-09-29 22:32:04 +00:00
|
|
|
nsIFrame* mBRFrame;
|
|
|
|
|
1998-09-23 02:31:00 +00:00
|
|
|
PRInt32 mTotalPlacedFrames;
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsVoidArray mPlacedFrames;
|
|
|
|
#endif
|
|
|
|
|
1998-06-27 22:56:09 +00:00
|
|
|
// These slots are used during FindTextRuns
|
1998-09-15 00:19:49 +00:00
|
|
|
nsTextRun* mTextRuns;
|
|
|
|
nsTextRun** mTextRunP;
|
|
|
|
nsTextRun* mNewTextRun;
|
1998-06-27 22:56:09 +00:00
|
|
|
|
|
|
|
// These slots are used during InlineReflow
|
1998-09-15 00:19:49 +00:00
|
|
|
nsTextRun* mReflowTextRuns;
|
|
|
|
nsTextRun* mTextRun;
|
1998-06-18 16:25:41 +00:00
|
|
|
};
|
|
|
|
|
1998-09-15 00:19:49 +00:00
|
|
|
#endif /* nsLineLayout_h___ */
|