pjs/layout/generic/nsLineLayout.h

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

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"
#include "nsTextReflow.h"
1998-09-15 04:19:49 +04:00
class nsBlockReflowState;
class nsInlineReflow;
1998-09-15 04:19:49 +04:00
class nsPlaceholderFrame;
struct nsStyleDisplay;
struct nsStylePosition;
struct nsStyleSpacing;
1998-09-15 04:19:49 +04:00
// XXX rename to nsLineReflow
1998-09-15 04:19:49 +04:00
//----------------------------------------------------------------------
class nsLineLayout {
public:
nsLineLayout(nsIPresContext& aPresContext,
1998-09-15 04:19:49 +04:00
nsISpaceManager* aSpaceManager);
~nsLineLayout();
void Init(nsBlockReflowState* aReflowState) {/* XXX ctor arg really */
1998-09-15 04:19:49 +04:00
mBlockReflowState = aReflowState;
}
// Prepare this line-layout for the reflow of a new line
void Reset() {
mTotalPlacedFrames = 0;
mColumn = 0;
mEndsInWhiteSpace = PR_TRUE;
mUnderstandsWhiteSpace = PR_FALSE;
mBRFrame = nsnull;
mPlacedFrames.Clear();
1998-10-10 08:35:01 +04:00
ForgetWordFrames();
mFirstLetterStyleOK = PR_FALSE;
mPass2VAlignCount = 0;
}
// Record the prescence of a frame that needs pass2 vertical-align
// handling.
void RecordPass2VAlignFrame() {
mPass2VAlignCount++;
}
PRBool NeedPass2VAlign() const {
return 0 != mPass2VAlignCount;
}
// 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;
}
void SetBRFrame(nsIFrame* aFrame) {
mBRFrame = aFrame;
}
nsIFrame* GetBRFrame() const {
return mBRFrame;
}
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);
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);
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);
nsIPresContext& mPresContext;
1998-09-15 04:19:49 +04:00
nsISpaceManager* mSpaceManager;
nsBlockReflowState* mBlockReflowState;
PRBool mListPositionOutside;
PRInt32 mLineNumber;
PRInt32 mColumn;
void SetUnderstandsWhiteSpace(PRBool aSetting) {
mUnderstandsWhiteSpace = aSetting;
}
1998-09-15 04:19:49 +04:00
PRBool GetUnderstandsWhiteSpace() const {
return mUnderstandsWhiteSpace;
}
1998-09-15 04:19:49 +04:00
void SetEndsInWhiteSpace(PRBool aState) {
mEndsInWhiteSpace = aState;
1998-09-15 04:19:49 +04: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:
nsIFrame* mBRFrame;
PRBool mEndsInWhiteSpace;
PRBool mUnderstandsWhiteSpace;
1998-11-05 22:30:31 +03:00
PRBool mFirstLetterStyleOK;
PRInt32 mPass2VAlignCount;
PRInt32 mTotalPlacedFrames;
nsVoidArray mPlacedFrames;
1998-10-10 08:35:01 +04:00
nsVoidArray mWordFrames;
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___ */