gecko-dev/layout/generic/nsLineLayout.h

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

1998-06-18 20:25:41 +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.
*/
1998-09-15 04:19:49 +04:00
#ifndef nsLineLayout_h___
#define nsLineLayout_h___
1998-06-18 20:25:41 +04:00
1998-06-19 03:16:00 +04:00
#include "nsIFrame.h"
1998-06-18 20:25:41 +04:00
#include "nsVoidArray.h"
#include "nsTextReflow.h"
1998-06-18 20:25:41 +04:00
class nsBlockReflowState;
class nsInlineReflow;
1998-08-05 01:17:56 +04:00
class nsPlaceholderFrame;
1998-07-22 22:38:57 +04:00
struct nsStyleDisplay;
struct nsStylePosition;
struct nsStyleSpacing;
1998-07-22 22:38:57 +04:00
// XXX rename to nsLineReflow
1998-06-18 20:25:41 +04:00
//----------------------------------------------------------------------
1998-09-15 04:19:49 +04:00
class nsLineLayout {
1998-06-18 20:25:41 +04:00
public:
nsLineLayout(nsIPresContext& aPresContext,
1998-09-15 04:19:49 +04:00
nsISpaceManager* aSpaceManager);
~nsLineLayout();
1998-06-18 20:25:41 +04:00
void Init(nsBlockReflowState* aReflowState) {/* XXX ctor arg really */
1998-08-05 01:17:56 +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);
// Reset the text-run information in preparation for a FindTextRuns
void ResetTextRuns();
1998-06-18 20:25:41 +04:00
// Add another piece of text to a text-run during FindTextRuns.
1998-06-18 20:25:41 +04:00
// 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();
1998-06-18 20:25:41 +04:00
1998-09-15 04:19:49 +04:00
// This returns the first nsTextRun found during a
// FindTextRuns. The internal text-run state is reset.
1998-09-15 04:19:49 +04:00
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-06-18 20:25:41 +04:00
PRInt32 GetColumn() {
return mColumn;
}
void SetColumn(PRInt32 aNewColumn) {
mColumn = aNewColumn;
}
1998-06-25 20:33:10 +04:00
void NextLine() {
mLineNumber++;
}
1998-10-17 05:06:17 +04:00
PRInt32 GetLineNumber() const {
return mLineNumber;
}
1998-06-25 20:33:10 +04:00
1998-07-22 22:38:57 +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-06-18 20:25:41 +04:00
nsISpaceManager* mSpaceManager;
1998-09-15 04:19:49 +04:00
nsBlockReflowState* mBlockReflowState;
1998-06-18 20:25:41 +04:00
PRBool mListPositionOutside;
PRInt32 mLineNumber;
PRInt32 mColumn;
void SetUnderstandsWhiteSpace(PRBool aSetting) {
mUnderstandsWhiteSpace = aSetting;
}
1998-06-18 20:25:41 +04:00
PRBool GetUnderstandsWhiteSpace() const {
return mUnderstandsWhiteSpace;
}
1998-06-25 20:33:10 +04:00
void SetEndsInWhiteSpace(PRBool aState) {
mEndsInWhiteSpace = aState;
1998-06-25 20:33:10 +04:00
}
PRBool GetEndsInWhiteSpace() const {
return mEndsInWhiteSpace;
}
1998-11-05 22:30:31 +03:00
PRBool GetFirstLetterStyleOK() const {
return mFirstLetterStyleOK;
}
void SetFirstLetterStyleOK(PRBool aSetting) {
mFirstLetterStyleOK = aSetting;
}
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;
// These slots are used during FindTextRuns
1998-09-15 04:19:49 +04:00
nsTextRun* mTextRuns;
nsTextRun** mTextRunP;
nsTextRun* mNewTextRun;
// These slots are used during InlineReflow
1998-09-15 04:19:49 +04:00
nsTextRun* mReflowTextRuns;
nsTextRun* mTextRun;
1998-06-18 20:25:41 +04:00
};
1998-09-15 04:19:49 +04:00
#endif /* nsLineLayout_h___ */