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
|
|
|
#include "nsLineLayout.h"
|
1998-06-18 20:25:41 +04:00
|
|
|
#include "nsCSSLayout.h"
|
1998-07-22 22:38:57 +04:00
|
|
|
#include "nsStyleConsts.h"
|
1998-06-18 20:25:41 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
|
|
|
|
void
|
1998-09-15 04:19:49 +04:00
|
|
|
nsTextRun::List(FILE* out, PRInt32 aIndent)
|
1998-06-18 20:25:41 +04:00
|
|
|
{
|
|
|
|
PRInt32 i;
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
PRInt32 n = mArray.Count();
|
1998-07-01 00:14:33 +04:00
|
|
|
fprintf(out, "%p: count=%d <", this, n);
|
1998-06-18 20:25:41 +04:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIFrame* text = (nsIFrame*) mArray.ElementAt(i);
|
1998-07-01 00:14:33 +04:00
|
|
|
text->ListTag(out);
|
|
|
|
printf(" ");
|
1998-06-18 20:25:41 +04:00
|
|
|
}
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
nsLineLayout::nsLineLayout(nsIPresContext* aPresContext,
|
1998-06-18 20:25:41 +04:00
|
|
|
nsISpaceManager* aSpaceManager)
|
|
|
|
{
|
|
|
|
mPresContext = aPresContext;
|
|
|
|
mSpaceManager = aSpaceManager;
|
|
|
|
mListPositionOutside = PR_FALSE;
|
|
|
|
mLineNumber = 0;
|
|
|
|
mLeftEdge = 0;
|
|
|
|
mColumn = 0;
|
1998-06-25 20:33:10 +04:00
|
|
|
mSkipLeadingWS = PR_TRUE;
|
1998-06-28 02:56:09 +04:00
|
|
|
|
|
|
|
mTextRuns = nsnull;
|
|
|
|
ResetTextRuns();
|
1998-06-18 20:25:41 +04:00
|
|
|
}
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
nsLineLayout::~nsLineLayout()
|
1998-06-18 20:25:41 +04:00
|
|
|
{
|
1998-09-15 04:19:49 +04:00
|
|
|
nsTextRun::DeleteTextRuns(mTextRuns);
|
1998-06-28 02:56:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-09-15 04:19:49 +04:00
|
|
|
nsLineLayout::ResetTextRuns()
|
1998-06-28 02:56:09 +04:00
|
|
|
{
|
1998-09-15 04:19:49 +04:00
|
|
|
nsTextRun::DeleteTextRuns(mTextRuns);
|
1998-06-28 02:56:09 +04:00
|
|
|
mTextRuns = nsnull;
|
|
|
|
mTextRunP = &mTextRuns;
|
|
|
|
mNewTextRun = nsnull;
|
|
|
|
}
|
|
|
|
|
1998-09-15 04:19:49 +04:00
|
|
|
nsTextRun*
|
|
|
|
nsLineLayout::TakeTextRuns()
|
1998-06-28 02:56:09 +04:00
|
|
|
{
|
1998-09-15 04:19:49 +04:00
|
|
|
nsTextRun* result = mTextRuns;
|
1998-06-28 02:56:09 +04:00
|
|
|
mTextRuns = nsnull;
|
|
|
|
ResetTextRuns();
|
|
|
|
return result;
|
1998-06-18 20:25:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-09-15 04:19:49 +04:00
|
|
|
nsLineLayout::EndTextRun()
|
1998-06-18 20:25:41 +04:00
|
|
|
{
|
1998-06-28 02:56:09 +04:00
|
|
|
mNewTextRun = nsnull;
|
1998-06-18 20:25:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1998-09-15 04:19:49 +04:00
|
|
|
nsLineLayout::AddText(nsIFrame* aTextFrame)
|
1998-06-18 20:25:41 +04:00
|
|
|
{
|
1998-06-28 02:56:09 +04:00
|
|
|
if (nsnull == mNewTextRun) {
|
1998-09-15 04:19:49 +04:00
|
|
|
mNewTextRun = new nsTextRun();
|
1998-06-28 02:56:09 +04:00
|
|
|
if (nsnull == mNewTextRun) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*mTextRunP = mNewTextRun;
|
|
|
|
mTextRunP = &mNewTextRun->mNext;
|
1998-06-18 20:25:41 +04:00
|
|
|
}
|
1998-06-28 02:56:09 +04:00
|
|
|
mNewTextRun->mArray.AppendElement(aTextFrame);
|
1998-06-18 20:25:41 +04:00
|
|
|
return NS_OK;/* XXX */
|
|
|
|
}
|
1998-07-22 22:38:57 +04:00
|
|
|
|
|
|
|
// XXX move this somewhere else!!!
|
|
|
|
PRBool
|
1998-09-15 04:19:49 +04:00
|
|
|
nsLineLayout::TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
|
1998-07-22 22:38:57 +04:00
|
|
|
const nsStylePosition* aPosition)
|
|
|
|
{
|
|
|
|
if (NS_STYLE_POSITION_ABSOLUTE == aPosition->mPosition) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
if (NS_STYLE_FLOAT_NONE != aDisplay->mFloats) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
switch (aDisplay->mDisplay) {
|
|
|
|
case NS_STYLE_DISPLAY_BLOCK:
|
|
|
|
case NS_STYLE_DISPLAY_LIST_ITEM:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE:
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|