Remaining nsBlockFrame changes for split overflow areas. (Bug 542595, patch 14) r=roc a2.0=blocking2.0:beta8

This commit is contained in:
L. David Baron
2010-10-06 21:25:45 -07:00
parent 41ccd4a16d
commit b716e5fc39

View File

@@ -961,9 +961,10 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
if (needFloatManager) if (needFloatManager)
autoFloatManager.CreateFloatManager(aPresContext); autoFloatManager.CreateFloatManager(aPresContext);
// OK, some lines may be reflowed. Blow away any saved line cursor because // OK, some lines may be reflowed. Blow away any saved line cursor
// we may invalidate the nondecreasing combinedArea.y/yMost invariant, // because we may invalidate the nondecreasing
// and we may even delete the line with the line cursor. // overflowArea.VisualOverflow().y/yMost invariant, and we may even
// delete the line with the line cursor.
ClearLineCursor(); ClearLineCursor();
if (IsFrameTreeTooDeep(aReflowState, aMetrics)) { if (IsFrameTreeTooDeep(aReflowState, aMetrics)) {
@@ -1193,12 +1194,17 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
aStatus, NS_FRAME_IS_COMPLETE(aStatus) ? "" : "not ", aStatus, NS_FRAME_IS_COMPLETE(aStatus) ? "" : "not ",
aMetrics.width, aMetrics.height, aMetrics.width, aMetrics.height,
aMetrics.mCarriedOutBottomMargin.get()); aMetrics.mCarriedOutBottomMargin.get());
if (HasOverflowRect()) { if (HasOverflowAreas()) {
printf(" combinedArea={%d,%d,%d,%d}", printf(" overflow-vis={%d,%d,%d,%d}",
aMetrics.mOverflowArea.x, aMetrics.VisualOverflow().x,
aMetrics.mOverflowArea.y, aMetrics.VisualOverflow().y,
aMetrics.mOverflowArea.width, aMetrics.VisualOverflow().width,
aMetrics.mOverflowArea.height); aMetrics.VisualOverflow().height);
printf(" overflow-scr={%d,%d,%d,%d}",
aMetrics.ScrollableOverflow().x,
aMetrics.ScrollableOverflow().y,
aMetrics.ScrollableOverflow().width,
aMetrics.ScrollableOverflow().height);
} }
printf("\n"); printf("\n");
} }
@@ -1659,8 +1665,11 @@ nsBlockFrame::PropagateFloatDamage(nsBlockReflowState& aState,
// with aLine's floats // with aLine's floats
nscoord lineYA = aLine->mBounds.y + aDeltaY; nscoord lineYA = aLine->mBounds.y + aDeltaY;
nscoord lineYB = lineYA + aLine->mBounds.height; nscoord lineYB = lineYA + aLine->mBounds.height;
nscoord lineYCombinedA = aLine->GetCombinedArea().y + aDeltaY; // Scrollable overflow should be sufficient for things that affect
nscoord lineYCombinedB = lineYCombinedA + aLine->GetCombinedArea().height; // layout.
nsRect overflow = aLine->GetOverflowArea(eScrollableOverflow);
nscoord lineYCombinedA = overflow.y + aDeltaY;
nscoord lineYCombinedB = lineYCombinedA + overflow.height;
if (floatManager->IntersectsDamage(lineYA, lineYB) || if (floatManager->IntersectsDamage(lineYA, lineYB) ||
floatManager->IntersectsDamage(lineYCombinedA, lineYCombinedB)) { floatManager->IntersectsDamage(lineYCombinedA, lineYCombinedB)) {
aLine->MarkDirty(); aLine->MarkDirty();
@@ -1732,14 +1741,16 @@ static void DumpLine(const nsBlockReflowState& aState, nsLineBox* aLine,
nscoord aDeltaY, PRInt32 aDeltaIndent) { nscoord aDeltaY, PRInt32 aDeltaIndent) {
#ifdef DEBUG #ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) { if (nsBlockFrame::gNoisyReflow) {
nsRect lca(aLine->GetCombinedArea()); nsRect ovis(aLine->GetVisualOverflowArea());
nsRect oscr(aLine->GetScrollableOverflowArea());
nsBlockFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent + aDeltaIndent); nsBlockFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent + aDeltaIndent);
printf("line=%p mY=%d dirty=%s oldBounds={%d,%d,%d,%d} oldCombinedArea={%d,%d,%d,%d} deltaY=%d mPrevBottomMargin=%d childCount=%d\n", printf("line=%p mY=%d dirty=%s oldBounds={%d,%d,%d,%d} oldoverflow-vis={%d,%d,%d,%d} oldoverflow-scr={%d,%d,%d,%d} deltaY=%d mPrevBottomMargin=%d childCount=%d\n",
static_cast<void*>(aLine), aState.mY, static_cast<void*>(aLine), aState.mY,
aLine->IsDirty() ? "yes" : "no", aLine->IsDirty() ? "yes" : "no",
aLine->mBounds.x, aLine->mBounds.y, aLine->mBounds.x, aLine->mBounds.y,
aLine->mBounds.width, aLine->mBounds.height, aLine->mBounds.width, aLine->mBounds.height,
lca.x, lca.y, lca.width, lca.height, ovis.x, ovis.y, ovis.width, ovis.height,
oscr.x, oscr.y, oscr.width, oscr.height,
aDeltaY, aState.mPrevBottomMargin.get(), aLine->GetChildCount()); aDeltaY, aState.mPrevBottomMargin.get(), aLine->GetChildCount());
} }
#endif #endif
@@ -2448,7 +2459,7 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
// Now that we know what kind of line we have, reflow it // Now that we know what kind of line we have, reflow it
if (aLine->IsBlock()) { if (aLine->IsBlock()) {
nsRect oldBounds = aLine->mFirstChild->GetRect(); nsRect oldBounds = aLine->mFirstChild->GetRect();
nsRect oldCombinedArea(aLine->GetCombinedArea()); nsRect oldVisOverflow(aLine->GetVisualOverflowArea());
rv = ReflowBlockFrame(aState, aLine, aKeepReflowGoing); rv = ReflowBlockFrame(aState, aLine, aKeepReflowGoing);
nsRect newBounds = aLine->mFirstChild->GetRect(); nsRect newBounds = aLine->mFirstChild->GetRect();
@@ -2461,13 +2472,13 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
// overflowArea and bounds. This should be considered a temporary hack // overflowArea and bounds. This should be considered a temporary hack
// until we decide how it's really supposed to work. // until we decide how it's really supposed to work.
// Note that we have a similar hack in nsTableFrame::InvalidateFrame. // Note that we have a similar hack in nsTableFrame::InvalidateFrame.
nsRect lineCombinedArea(aLine->GetCombinedArea()); nsRect visOverflow(aLine->GetVisualOverflowArea());
if (oldCombinedArea.TopLeft() != lineCombinedArea.TopLeft() || if (oldVisOverflow.TopLeft() != visOverflow.TopLeft() ||
oldBounds.TopLeft() != newBounds.TopLeft()) { oldBounds.TopLeft() != newBounds.TopLeft()) {
// The block has moved, and so to be safe we need to repaint // The block has moved, and so to be safe we need to repaint
// XXX We need to improve on this... // XXX We need to improve on this...
nsRect dirtyRect; nsRect dirtyRect;
dirtyRect.UnionRect(oldCombinedArea, lineCombinedArea); dirtyRect.UnionRect(oldVisOverflow, visOverflow);
#ifdef NOISY_BLOCK_INVALIDATE #ifdef NOISY_BLOCK_INVALIDATE
printf("%p invalidate 6 (%d, %d, %d, %d)\n", printf("%p invalidate 6 (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height); this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
@@ -2479,7 +2490,7 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
nsRect boundsHStrip, boundsVStrip; nsRect boundsHStrip, boundsVStrip;
nsLayoutUtils::GetRectDifferenceStrips(oldBounds, newBounds, nsLayoutUtils::GetRectDifferenceStrips(oldBounds, newBounds,
&boundsHStrip, &boundsVStrip); &boundsHStrip, &boundsVStrip);
nsLayoutUtils::GetRectDifferenceStrips(oldCombinedArea, lineCombinedArea, nsLayoutUtils::GetRectDifferenceStrips(oldVisOverflow, visOverflow,
&combinedAreaHStrip, &combinedAreaHStrip,
&combinedAreaVStrip); &combinedAreaVStrip);
@@ -2502,7 +2513,7 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
} }
} }
else { else {
nsRect oldCombinedArea(aLine->GetCombinedArea()); nsRect oldVisOverflow(aLine->GetVisualOverflowArea());
aLine->SetLineWrapped(PR_FALSE); aLine->SetLineWrapped(PR_FALSE);
rv = ReflowInlineFrames(aState, aLine, aKeepReflowGoing); rv = ReflowInlineFrames(aState, aLine, aKeepReflowGoing);
@@ -2510,7 +2521,7 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
// We don't really know what changed in the line, so use the union // We don't really know what changed in the line, so use the union
// of the old and new combined areas // of the old and new combined areas
nsRect dirtyRect; nsRect dirtyRect;
dirtyRect.UnionRect(oldCombinedArea, aLine->GetCombinedArea()); dirtyRect.UnionRect(oldVisOverflow, aLine->GetVisualOverflowArea());
#ifdef NOISY_BLOCK_INVALIDATE #ifdef NOISY_BLOCK_INVALIDATE
printf("%p invalidate (%d, %d, %d, %d)\n", printf("%p invalidate (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height); this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
@@ -2640,7 +2651,7 @@ nsBlockFrame::PullFrameFrom(nsBlockReflowState& aState,
if (aFromLine.next() != fromLineList->end()) if (aFromLine.next() != fromLineList->end())
aFromLine.next()->MarkPreviousMarginDirty(); aFromLine.next()->MarkPreviousMarginDirty();
Invalidate(fromLine->GetCombinedArea()); Invalidate(fromLine->GetVisualOverflowArea());
fromLineList->erase(aFromLine); fromLineList->erase(aFromLine);
// aFromLine is now invalid // aFromLine is now invalid
aState.FreeLineBox(fromLine); aState.FreeLineBox(fromLine);
@@ -2679,10 +2690,10 @@ nsBlockFrame::SlideLine(nsBlockReflowState& aState,
{ {
NS_PRECONDITION(aDY != 0, "why slide a line nowhere?"); NS_PRECONDITION(aDY != 0, "why slide a line nowhere?");
Invalidate(aLine->GetCombinedArea()); Invalidate(aLine->GetVisualOverflowArea());
// Adjust line state // Adjust line state
aLine->SlideBy(aDY); aLine->SlideBy(aDY);
Invalidate(aLine->GetCombinedArea()); Invalidate(aLine->GetVisualOverflowArea());
// Adjust the frames in the line // Adjust the frames in the line
nsIFrame* kid = aLine->mFirstChild; nsIFrame* kid = aLine->mFirstChild;
@@ -5392,13 +5403,13 @@ nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, PRUint32 aFlags)
// XXX We need to do this if we're removing a frame as a result of // XXX We need to do this if we're removing a frame as a result of
// a call to RemoveFrame(), but we may not need to do this in all // a call to RemoveFrame(), but we may not need to do this in all
// cases... // cases...
nsRect lineCombinedArea(cur->GetCombinedArea()); nsRect visOverflow(cur->GetVisualOverflowArea());
#ifdef NOISY_BLOCK_INVALIDATE #ifdef NOISY_BLOCK_INVALIDATE
printf("%p invalidate 10 (%d, %d, %d, %d)\n", printf("%p invalidate 10 (%d, %d, %d, %d)\n",
this, lineCombinedArea.x, lineCombinedArea.y, this, visOverflow.x, visOverflow.y,
lineCombinedArea.width, lineCombinedArea.height); visOverflow.width, visOverflow.height);
#endif #endif
Invalidate(lineCombinedArea); Invalidate(visOverflow);
} else { } else {
nsLineList* lineList = RemoveOverflowLines(); nsLineList* lineList = RemoveOverflowLines();
line = lineList->erase(line); line = lineList->erase(line);
@@ -5771,7 +5782,7 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
if (aFloat->HasView()) { if (aFloat->HasView()) {
nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, aFloat, nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, aFloat,
aFloat->GetView(), aFloat->GetView(),
&metrics.mOverflowArea, metrics.VisualOverflow(),
NS_FRAME_NO_MOVE_VIEW); NS_FRAME_NO_MOVE_VIEW);
} }
// Pass floatRS so the frame hierarchy can be used (redoFloatRS has the same hierarchy) // Pass floatRS so the frame hierarchy can be used (redoFloatRS has the same hierarchy)
@@ -6035,7 +6046,7 @@ nsBlockFrame::AdjustForTextIndent(const nsLineBox* aLine,
static void DebugOutputDrawLine(PRInt32 aDepth, nsLineBox* aLine, PRBool aDrawn) { static void DebugOutputDrawLine(PRInt32 aDepth, nsLineBox* aLine, PRBool aDrawn) {
if (nsBlockFrame::gNoisyDamageRepair) { if (nsBlockFrame::gNoisyDamageRepair) {
nsFrame::IndentBy(stdout, aDepth+1); nsFrame::IndentBy(stdout, aDepth+1);
nsRect lineArea = aLine->GetCombinedArea(); nsRect lineArea = aLine->GetVisualOverflowArea();
printf("%s line=%p bounds=%d,%d,%d,%d ca=%d,%d,%d,%d\n", printf("%s line=%p bounds=%d,%d,%d,%d ca=%d,%d,%d,%d\n",
aDrawn ? "draw" : "skip", aDrawn ? "draw" : "skip",
static_cast<void*>(aLine), static_cast<void*>(aLine),
@@ -6149,7 +6160,7 @@ nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
for (line_iterator line = mLines.begin(cursor); for (line_iterator line = mLines.begin(cursor);
line != line_end; line != line_end;
++line) { ++line) {
nsRect lineArea = line->GetCombinedArea(); nsRect lineArea = line->GetVisualOverflowArea();
if (!lineArea.IsEmpty()) { if (!lineArea.IsEmpty()) {
// Because we have a cursor, the combinedArea.ys are non-decreasing. // Because we have a cursor, the combinedArea.ys are non-decreasing.
// Once we've passed aDirtyRect.YMost(), we can never see it again. // Once we've passed aDirtyRect.YMost(), we can never see it again.
@@ -6170,7 +6181,7 @@ nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
for (line_iterator line = begin_lines(); for (line_iterator line = begin_lines();
line != line_end; line != line_end;
++line) { ++line) {
nsRect lineArea = line->GetCombinedArea(); nsRect lineArea = line->GetVisualOverflowArea();
rv = DisplayLine(aBuilder, lineArea, aDirtyRect, line, depth, drawnLines, rv = DisplayLine(aBuilder, lineArea, aDirtyRect, line, depth, drawnLines,
aLists, this); aLists, this);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@@ -6312,17 +6323,17 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y)
nsLineBox* property = static_cast<nsLineBox*> nsLineBox* property = static_cast<nsLineBox*>
(props.Get(LineCursorProperty())); (props.Get(LineCursorProperty()));
line_iterator cursor = mLines.begin(property); line_iterator cursor = mLines.begin(property);
nsRect cursorArea = cursor->GetCombinedArea(); nsRect cursorArea = cursor->GetVisualOverflowArea();
while ((cursorArea.IsEmpty() || cursorArea.YMost() > y) while ((cursorArea.IsEmpty() || cursorArea.YMost() > y)
&& cursor != mLines.front()) { && cursor != mLines.front()) {
cursor = cursor.prev(); cursor = cursor.prev();
cursorArea = cursor->GetCombinedArea(); cursorArea = cursor->GetVisualOverflowArea();
} }
while ((cursorArea.IsEmpty() || cursorArea.YMost() <= y) while ((cursorArea.IsEmpty() || cursorArea.YMost() <= y)
&& cursor != mLines.back()) { && cursor != mLines.back()) {
cursor = cursor.next(); cursor = cursor.next();
cursorArea = cursor->GetCombinedArea(); cursorArea = cursor->GetVisualOverflowArea();
} }
if (cursor.get() != property) { if (cursor.get() != property) {