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.
|
|
|
|
*/
|
|
|
|
#ifndef nsLineLayout_h___
|
|
|
|
#define nsLineLayout_h___
|
|
|
|
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsVoidArray.h"
|
1998-10-20 04:22:48 +04:00
|
|
|
#include "nsTextReflow.h"
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:05:52 +03:00
|
|
|
class nsBlockReflowState;
|
1998-10-10 02:58:25 +04:00
|
|
|
class nsInlineReflow;
|
1998-09-15 04:19:49 +04:00
|
|
|
class nsPlaceholderFrame;
|
|
|
|
struct nsStyleDisplay;
|
|
|
|
struct nsStylePosition;
|
1998-09-23 06:31:00 +04:00
|
|
|
struct nsStyleSpacing;
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-10-20 04:22:48 +04:00
|
|
|
// XXX rename to nsLineReflow
|
1998-09-15 04:19:49 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsLineLayout {
|
|
|
|
public:
|
1998-09-23 06:31:00 +04:00
|
|
|
nsLineLayout(nsIPresContext& aPresContext,
|
1998-09-15 04:19:49 +04:00
|
|
|
nsISpaceManager* aSpaceManager);
|
|
|
|
~nsLineLayout();
|
|
|
|
|
1998-09-23 06:31:00 +04:00
|
|
|
void Init(nsBlockReflowState* aReflowState) {/* XXX ctor arg really */
|
1998-09-15 04:19:49 +04:00
|
|
|
mBlockReflowState = aReflowState;
|
|
|
|
}
|
|
|
|
|
1998-09-23 06:31:00 +04:00
|
|
|
// Prepare this line-layout for the reflow of a new line
|
|
|
|
void Reset() {
|
|
|
|
mTotalPlacedFrames = 0;
|
|
|
|
mColumn = 0;
|
1998-11-01 01:48:56 +03:00
|
|
|
mEndsInWhiteSpace = PR_TRUE;
|
|
|
|
mUnderstandsWhiteSpace = PR_FALSE;
|
1998-09-30 02:32:04 +04:00
|
|
|
mBRFrame = nsnull;
|
1998-09-23 06:31:00 +04:00
|
|
|
mPlacedFrames.Clear();
|
1998-10-10 08:35:01 +04:00
|
|
|
ForgetWordFrames();
|
1998-12-05 19:05:52 +03:00
|
|
|
mFirstLetterStyleOK = PR_FALSE;
|
1999-02-18 06:28:00 +03:00
|
|
|
mPass2VAlignCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Record the prescence of a frame that needs pass2 vertical-align
|
|
|
|
// handling.
|
|
|
|
void RecordPass2VAlignFrame() {
|
|
|
|
mPass2VAlignCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool NeedPass2VAlign() const {
|
|
|
|
return 0 != mPass2VAlignCount;
|
1998-09-23 06:31:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add to the placed-frame count
|
|
|
|
void AddPlacedFrame(nsIFrame* aFrame) {
|
|
|
|
mTotalPlacedFrames++;
|
|
|
|
mPlacedFrames.AppendElement(aFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the placed-frame count
|
|
|
|
PRInt32 GetPlacedFrames() const {
|
|
|
|
return mTotalPlacedFrames;
|
|
|
|
}
|
|
|
|
|
1998-10-27 19:52:10 +03:00
|
|
|
const nsVoidArray& PlacedFrames() const {
|
|
|
|
return mPlacedFrames;
|
|
|
|
}
|
|
|
|
|
1998-09-30 02:32:04 +04:00
|
|
|
void SetBRFrame(nsIFrame* aFrame) {
|
|
|
|
mBRFrame = aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* GetBRFrame() const {
|
|
|
|
return mBRFrame;
|
|
|
|
}
|
|
|
|
|
1998-10-10 02:58:25 +04:00
|
|
|
void PushInline(nsInlineReflow* aInlineReflow) {
|
|
|
|
mInlineStack.AppendElement(aInlineReflow);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PopInline() {
|
|
|
|
PRInt32 n = mInlineStack.Count();
|
|
|
|
if (n > 0) {
|
|
|
|
mInlineStack.RemoveElementAt(n - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateInlines(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
|
|
|
PRBool aPlacedLeftFloater);
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
// Reset the text-run information in preparation for a FindTextRuns
|
|
|
|
void ResetTextRuns();
|
|
|
|
|
|
|
|
// Add another piece of text to a text-run during FindTextRuns.
|
|
|
|
// Note: continuation frames must NOT add themselves; just the
|
|
|
|
// first-in-flow
|
|
|
|
nsresult AddText(nsIFrame* aTextFrame);
|
|
|
|
|
|
|
|
// Close out a text-run during FindTextRuns.
|
|
|
|
void EndTextRun();
|
|
|
|
|
|
|
|
// This returns the first nsTextRun found during a
|
|
|
|
// FindTextRuns. The internal text-run state is reset.
|
|
|
|
nsTextRun* TakeTextRuns();
|
|
|
|
|
1998-10-10 08:35:01 +04:00
|
|
|
void SetReflowTextRuns(nsTextRun* aTextRuns) {
|
|
|
|
mReflowTextRuns = aTextRuns;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* FindNextText(nsIFrame* aFrame);
|
|
|
|
|
1998-10-20 04:22:48 +04:00
|
|
|
nsTextRun* FindTextRunFor(nsIFrame* aFrame);
|
|
|
|
|
1998-10-10 08:35:01 +04:00
|
|
|
void RecordWordFrame(nsIFrame* aWordFrame) {
|
|
|
|
mWordFrames.AppendElement(aWordFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForgetWordFrames() {
|
|
|
|
mWordFrames.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool IsNextWordFrame(nsIFrame* aFrame);
|
|
|
|
|
1998-10-20 04:22:48 +04:00
|
|
|
PRBool InWord() {
|
1998-10-10 08:35:01 +04:00
|
|
|
return 0 != mWordFrames.Count();
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool IsLastWordFrame(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
void ForgetWordFrame(nsIFrame* aFrame);
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
PRInt32 GetColumn() {
|
|
|
|
return mColumn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetColumn(PRInt32 aNewColumn) {
|
|
|
|
mColumn = aNewColumn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NextLine() {
|
|
|
|
mLineNumber++;
|
|
|
|
}
|
1998-10-17 05:06:17 +04:00
|
|
|
|
|
|
|
PRInt32 GetLineNumber() const {
|
|
|
|
return mLineNumber;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
|
|
|
static PRBool TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
|
|
|
|
const nsStylePosition* aPosition);
|
|
|
|
|
1999-02-01 20:32:33 +03:00
|
|
|
static PRBool TreatFrameAsBlock(nsIFrame* aFrame);
|
|
|
|
|
1998-10-10 08:35:01 +04:00
|
|
|
// --------------------------------------------------
|
|
|
|
|
1998-11-10 21:04:19 +03:00
|
|
|
void InitFloater(nsPlaceholderFrame* aFrame);
|
|
|
|
|
1998-10-10 08:35:01 +04:00
|
|
|
void AddFloater(nsPlaceholderFrame* aFrame);
|
|
|
|
|
1998-09-23 06:31:00 +04:00
|
|
|
nsIPresContext& mPresContext;
|
1998-09-15 04:19:49 +04:00
|
|
|
nsISpaceManager* mSpaceManager;
|
|
|
|
nsBlockReflowState* mBlockReflowState;
|
|
|
|
|
|
|
|
PRBool mListPositionOutside;
|
|
|
|
PRInt32 mLineNumber;
|
|
|
|
PRInt32 mColumn;
|
1998-11-01 01:48:56 +03:00
|
|
|
|
|
|
|
void SetUnderstandsWhiteSpace(PRBool aSetting) {
|
|
|
|
mUnderstandsWhiteSpace = aSetting;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-11-01 01:48:56 +03:00
|
|
|
PRBool GetUnderstandsWhiteSpace() const {
|
|
|
|
return mUnderstandsWhiteSpace;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-11-01 01:48:56 +03:00
|
|
|
void SetEndsInWhiteSpace(PRBool aState) {
|
|
|
|
mEndsInWhiteSpace = aState;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-11-01 01:48:56 +03:00
|
|
|
PRBool GetEndsInWhiteSpace() const {
|
|
|
|
return mEndsInWhiteSpace;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-11-05 22:30:31 +03:00
|
|
|
PRBool GetFirstLetterStyleOK() const {
|
|
|
|
return mFirstLetterStyleOK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetFirstLetterStyleOK(PRBool aSetting) {
|
|
|
|
mFirstLetterStyleOK = aSetting;
|
|
|
|
}
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
protected:
|
1998-09-30 02:32:04 +04:00
|
|
|
nsIFrame* mBRFrame;
|
|
|
|
|
1998-11-01 01:48:56 +03:00
|
|
|
PRBool mEndsInWhiteSpace;
|
|
|
|
PRBool mUnderstandsWhiteSpace;
|
1998-11-05 22:30:31 +03:00
|
|
|
PRBool mFirstLetterStyleOK;
|
1999-02-18 06:28:00 +03:00
|
|
|
PRInt32 mPass2VAlignCount;
|
1998-11-01 01:48:56 +03:00
|
|
|
|
1998-09-23 06:31:00 +04:00
|
|
|
PRInt32 mTotalPlacedFrames;
|
|
|
|
nsVoidArray mPlacedFrames;
|
|
|
|
|
1998-10-10 08:35:01 +04:00
|
|
|
nsVoidArray mWordFrames;
|
|
|
|
|
1998-10-10 02:58:25 +04:00
|
|
|
nsVoidArray mInlineStack;
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
// These slots are used during FindTextRuns
|
|
|
|
nsTextRun* mTextRuns;
|
|
|
|
nsTextRun** mTextRunP;
|
|
|
|
nsTextRun* mNewTextRun;
|
|
|
|
|
|
|
|
// These slots are used during InlineReflow
|
|
|
|
nsTextRun* mReflowTextRuns;
|
|
|
|
nsTextRun* mTextRun;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsLineLayout_h___ */
|