Bug 774794 - Make the aLineList param for MarkLineDirty mandatory; make nsBlockInFlowLineIterator have a valid mLineList for its mLine. r=roc

This commit is contained in:
Mats Palmgren 2012-07-20 14:27:03 -04:00
parent a2a1ad85bd
commit b7f6677771
2 changed files with 33 additions and 39 deletions

View File

@ -1538,7 +1538,7 @@ nsBlockFrame::UpdateOverflow()
return nsBlockFrameSuper::UpdateOverflow();
}
nsresult
void
nsBlockFrame::MarkLineDirty(line_iterator aLine, const nsLineList* aLineList)
{
// Mark aLine dirty
@ -1555,8 +1555,7 @@ nsBlockFrame::MarkLineDirty(line_iterator aLine, const nsLineList* aLineList)
// Mark previous line dirty if it's an inline line so that it can
// maybe pullup something from the line just affected.
// XXX We don't need to do this if aPrevLine ends in a break-after...
if (aLine != (aLineList ? aLineList : &mLines)->front() &&
aLine->IsInline() &&
if (aLine != aLineList->front() && aLine->IsInline() &&
aLine.prev()->IsInline()) {
aLine.prev()->MarkDirty();
aLine.prev()->SetInvalidateTextRuns(true);
@ -1569,8 +1568,6 @@ nsBlockFrame::MarkLineDirty(line_iterator aLine, const nsLineList* aLineList)
}
#endif
}
return NS_OK;
}
/**
@ -5174,7 +5171,7 @@ nsBlockFrame::TryAllLines(nsLineList::iterator* aIterator,
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
line_iterator aLine)
: mFrame(aFrame), mLine(aLine), mInOverflowLines(nsnull)
: mFrame(aFrame), mLine(aLine), mLineList(&aFrame->mLines)
{
// This will assert if aLine isn't in mLines of aFrame:
DebugOnly<bool> check = aLine == mFrame->begin_lines();
@ -5182,16 +5179,15 @@ nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
line_iterator aLine, bool aInOverflow)
: mFrame(aFrame), mLine(aLine), mInOverflowLines(nsnull)
: mFrame(aFrame), mLine(aLine),
mLineList(aInOverflow ? &aFrame->GetOverflowLines()->mLines
: &aFrame->mLines)
{
if (aInOverflow) {
mInOverflowLines = &aFrame->GetOverflowLines()->mLines;
}
}
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
bool* aFoundValidLine)
: mFrame(aFrame), mInOverflowLines(nsnull)
: mFrame(aFrame), mLineList(&aFrame->mLines)
{
mLine = aFrame->begin_lines();
*aFoundValidLine = FindValidLine();
@ -5222,7 +5218,7 @@ FindChildContaining(nsBlockFrame* aFrame, nsIFrame* aFindFrame)
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
nsIFrame* aFindFrame, bool* aFoundValidLine)
: mFrame(aFrame), mInOverflowLines(nsnull)
: mFrame(aFrame), mLineList(&aFrame->mLines)
{
*aFoundValidLine = false;
@ -5293,7 +5289,7 @@ nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
nsBlockFrame::line_iterator
nsBlockInFlowLineIterator::End()
{
return mInOverflowLines ? mInOverflowLines->end() : mFrame->end_lines();
return mLineList->end();
}
bool
@ -5313,17 +5309,17 @@ nsBlockInFlowLineIterator::Next()
bool
nsBlockInFlowLineIterator::Prev()
{
line_iterator begin = mInOverflowLines ? mInOverflowLines->begin() : mFrame->begin_lines();
line_iterator begin = mLineList->begin();
if (mLine != begin) {
--mLine;
return true;
}
bool currentlyInOverflowLines = mInOverflowLines != nsnull;
bool currentlyInOverflowLines = GetInOverflow();
while (true) {
if (currentlyInOverflowLines) {
mInOverflowLines = nsnull;
mLine = mFrame->end_lines();
if (mLine != mFrame->begin_lines()) {
mLineList = &mFrame->mLines;
mLine = mLineList->end();
if (mLine != mLineList->begin()) {
--mLine;
return true;
}
@ -5332,10 +5328,10 @@ nsBlockInFlowLineIterator::Prev()
if (!mFrame)
return false;
nsBlockFrame::FrameLines* overflowLines = mFrame->GetOverflowLines();
mInOverflowLines = overflowLines ? &overflowLines->mLines : nsnull;
if (mInOverflowLines) {
mLine = mInOverflowLines->end();
NS_ASSERTION(mLine != mInOverflowLines->begin(), "empty overflow line list?");
if (overflowLines) {
mLineList = &overflowLines->mLines;
mLine = mLineList->end();
NS_ASSERTION(mLine != mLineList->begin(), "empty overflow line list?");
--mLine;
return true;
}
@ -5347,25 +5343,25 @@ nsBlockInFlowLineIterator::Prev()
bool
nsBlockInFlowLineIterator::FindValidLine()
{
line_iterator end = mInOverflowLines ? mInOverflowLines->end() : mFrame->end_lines();
line_iterator end = mLineList->end();
if (mLine != end)
return true;
bool currentlyInOverflowLines = mInOverflowLines != nsnull;
bool currentlyInOverflowLines = GetInOverflow();
while (true) {
if (currentlyInOverflowLines) {
mFrame = static_cast<nsBlockFrame*>(mFrame->GetNextInFlow());
if (!mFrame)
return false;
mInOverflowLines = nsnull;
mLine = mFrame->begin_lines();
if (mLine != mFrame->end_lines())
mLineList = &mFrame->mLines;
mLine = mLineList->begin();
if (mLine != mLineList->end())
return true;
} else {
nsBlockFrame::FrameLines* overflowLines = mFrame->GetOverflowLines();
mInOverflowLines = overflowLines ? &overflowLines->mLines : nsnull;
if (mInOverflowLines) {
mLine = mInOverflowLines->begin();
NS_ASSERTION(mLine != mInOverflowLines->end(), "empty overflow line list?");
if (overflowLines) {
mLineList = &overflowLines->mLines;
mLine = mLineList->begin();
NS_ASSERTION(mLine != mLineList->end(), "empty overflow line list?");
return true;
}
}
@ -6476,7 +6472,7 @@ nsBlockFrame::ChildIsDirty(nsIFrame* aChild)
}
if (bulletLine != end_lines()) {
MarkLineDirty(bulletLine);
MarkLineDirty(bulletLine, &mLines);
}
// otherwise we have an empty line list, and ReflowDirtyLines
// will handle reflowing the bullet.

View File

@ -542,11 +542,9 @@ protected:
* on those lines because the text in the lines might have changed due to
* addition/removal of frames.
* @param aLine the line to mark dirty
* @param aLineList the line list containing that line, null means the line
* is in 'mLines' of this frame.
* @param aLineList the line list containing that line
*/
nsresult MarkLineDirty(line_iterator aLine,
const nsLineList* aLineList = nsnull);
void MarkLineDirty(line_iterator aLine, const nsLineList* aLineList);
// XXX where to go
bool IsLastLine(nsBlockReflowState& aState,
@ -870,13 +868,13 @@ public:
line_iterator GetLine() { return mLine; }
bool IsLastLineInList();
nsBlockFrame* GetContainer() { return mFrame; }
bool GetInOverflow() { return mInOverflowLines != nsnull; }
bool GetInOverflow() { return mLineList != &mFrame->mLines; }
/**
* Returns the current line list we're iterating, null means
* we're iterating |mLines| of the container.
*/
nsLineList* GetLineList() { return mInOverflowLines; }
nsLineList* GetLineList() { return mLineList; }
/**
* Returns the end-iterator of whatever line list we're in.
@ -901,7 +899,7 @@ private:
nsBlockFrame* mFrame;
line_iterator mLine;
nsLineList* mInOverflowLines;
nsLineList* mLineList; // the line list mLine is in
/**
* Moves iterator to next valid line reachable from the current block.