Update the content offset for existing non-fluid continuations when creating a next-in-flow. b=406380 r+sr=roc a=blocking1.9

git-svn-id: svn://10.0.0.236/trunk@242359 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mats.palmgren%bredband.net 2008-01-04 17:09:36 +00:00
parent 04d4502450
commit c0b7fb8c80
3 changed files with 35 additions and 9 deletions

View File

@ -53,6 +53,7 @@ load 398181-1.html
load 398181-2.html
load 400232-1.html
load 404204-1.html
load 406380.html
load 407009-1.xhtml
load 408749-1.xhtml
load 408883-1.html

View File

@ -60,6 +60,8 @@ class PropertyProvider;
class nsTextFrame : public nsFrame {
public:
friend class nsContinuingTextFrame;
nsTextFrame(nsStyleContext* aContext) : nsFrame(aContext)
{
NS_ASSERTION(mContentOffset == 0, "Bogus content offset");
@ -284,7 +286,11 @@ public:
#endif
PRInt32 GetContentOffset() const { return mContentOffset; }
PRInt32 GetContentLength() const { return GetContentEnd() - mContentOffset; }
PRInt32 GetContentLength() const
{
NS_ASSERTION(GetContentEnd() - mContentOffset >= 0, "negative length");
return GetContentEnd() - mContentOffset;
}
PRInt32 GetContentEnd() const;
// This returns the length the frame thinks it *should* have after it was
// last reflowed (0 if it hasn't been reflowed yet). This should be used only

View File

@ -1078,6 +1078,7 @@ void BuildTextRunsScanner::FlushFrames(PRBool aFlushLineBreaks, PRBool aSuppress
void BuildTextRunsScanner::AccumulateRunInfo(nsTextFrame* aFrame)
{
NS_ASSERTION(mMaxTextLength <= mMaxTextLength + aFrame->GetContentLength(), "integer overflow");
mMaxTextLength += aFrame->GetContentLength();
mDoubleByteText |= aFrame->GetContent()->GetText()->Is2b();
mLastFrame = aFrame;
@ -3159,7 +3160,10 @@ nsContinuingTextFrame::Init(nsIContent* aContent,
// NOTE: bypassing nsTextFrame::Init!!!
nsresult rv = nsFrame::Init(aContent, aParent, aPrevInFlow);
nsIFrame* nextContinuation = aPrevInFlow->GetNextContinuation();
#ifdef IBMBIDI
nsTextFrame* nextContinuation =
static_cast<nsTextFrame*>(aPrevInFlow->GetNextContinuation());
#endif // IBMBIDI
// Hook the frame into the flow
SetPrevInFlow(aPrevInFlow);
aPrevInFlow->SetNextInFlow(this);
@ -3176,9 +3180,6 @@ nsContinuingTextFrame::Init(nsIContent* aContent,
}
#ifdef IBMBIDI
if (aPrevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) {
PRInt32 start, end;
aPrevInFlow->GetOffsets(start, mContentOffset);
nsPropertyTable *propTable = PresContext()->PropertyTable();
propTable->SetProperty(this, nsGkAtoms::embeddingLevel,
propTable->GetProperty(aPrevInFlow, nsGkAtoms::embeddingLevel),
@ -3192,7 +3193,20 @@ nsContinuingTextFrame::Init(nsIContent* aContent,
if (nextContinuation) {
SetNextContinuation(nextContinuation);
nextContinuation->SetPrevContinuation(this);
nextContinuation->GetOffsets(start, end);
// Adjust next-continuations' content offset as needed.
while (nextContinuation &&
nextContinuation->GetContentOffset() < mContentOffset) {
NS_ASSERTION(
propTable->GetProperty(this, nsGkAtoms::embeddingLevel) ==
propTable->GetProperty(nextContinuation, nsGkAtoms::embeddingLevel) &&
propTable->GetProperty(this, nsGkAtoms::baseLevel) ==
propTable->GetProperty(nextContinuation, nsGkAtoms::baseLevel) &&
propTable->GetProperty(this, nsGkAtoms::charType) ==
propTable->GetProperty(nextContinuation, nsGkAtoms::charType),
"stealing text from different type of BIDI continuation");
nextContinuation->mContentOffset = mContentOffset;
nextContinuation = static_cast<nsTextFrame*>(nextContinuation->GetNextContinuation());
}
}
mState |= NS_FRAME_IS_BIDI;
} // prev frame is bidi
@ -5178,6 +5192,13 @@ nsTextFrame::SetLength(PRInt32 aLength)
}
f = static_cast<nsTextFrame*>(f->GetNextInFlow());
}
#ifdef DEBUG
f = static_cast<nsTextFrame*>(this->GetFirstContinuation());
while (f) {
f->GetContentLength(); // Assert if negative length
f = static_cast<nsTextFrame*>(f->GetNextContinuation());
}
#endif
}
NS_IMETHODIMP
@ -6024,10 +6045,8 @@ nsTextFrame::AdjustOffsetsForBidi(PRInt32 aStart, PRInt32 aEnd)
aEnd = PR_MAX(aEnd, prevOffset);
prev->ClearTextRun();
}
if (mContentOffset != aStart) {
mContentOffset = aStart;
}
mContentOffset = aStart;
SetLength(aEnd - aStart);
}