Compute nsBlockFrame::ComputeCombinedArea to split overflow areas. (Bug 542595, patch 10) r=roc a2.0=blocking2.0:beta8

This commit is contained in:
L. David Baron 2010-10-06 21:25:45 -07:00
Родитель 3ab4906eba
Коммит 8c6cf1d539
2 изменённых файлов: 30 добавлений и 22 удалений

Просмотреть файл

@ -1101,7 +1101,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
// Compute our final size // Compute our final size
nscoord bottomEdgeOfChildren; nscoord bottomEdgeOfChildren;
ComputeFinalSize(aReflowState, state, aMetrics, &bottomEdgeOfChildren); ComputeFinalSize(aReflowState, state, aMetrics, &bottomEdgeOfChildren);
ComputeCombinedArea(aReflowState, aMetrics, bottomEdgeOfChildren); ComputeOverflowAreas(aReflowState, aMetrics, bottomEdgeOfChildren);
// Factor overflow container child bounds into the overflow area // Factor overflow container child bounds into the overflow area
aMetrics.mOverflowAreas.UnionWith(ocBounds); aMetrics.mOverflowAreas.UnionWith(ocBounds);
// Factor pushed float child bounds into the overflow area // Factor pushed float child bounds into the overflow area
@ -1429,14 +1429,15 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
} }
void void
nsBlockFrame::ComputeCombinedArea(const nsHTMLReflowState& aReflowState, nsBlockFrame::ComputeOverflowAreas(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aMetrics, nsHTMLReflowMetrics& aMetrics,
nscoord aBottomEdgeOfChildren) nscoord aBottomEdgeOfChildren)
{ {
// Compute the combined area of our children // Compute the overflow areas of our children
// XXX_perf: This can be done incrementally. It is currently one of // XXX_perf: This can be done incrementally. It is currently one of
// the things that makes incremental reflow O(N^2). // the things that makes incremental reflow O(N^2).
nsRect area(0, 0, aMetrics.width, aMetrics.height); nsRect bounds(0, 0, aMetrics.width, aMetrics.height);
nsOverflowAreas areas(bounds, bounds);
if (NS_STYLE_OVERFLOW_CLIP != aReflowState.mStyleDisplay->mOverflowX) { if (NS_STYLE_OVERFLOW_CLIP != aReflowState.mStyleDisplay->mOverflowX) {
PRBool inQuirks = (PresContext()->CompatibilityMode() == eCompatibility_NavQuirks); PRBool inQuirks = (PresContext()->CompatibilityMode() == eCompatibility_NavQuirks);
@ -1446,21 +1447,21 @@ nsBlockFrame::ComputeCombinedArea(const nsHTMLReflowState& aReflowState,
// Text-shadow overflows // Text-shadow overflows
if (!inQuirks && line->IsInline()) { if (!inQuirks && line->IsInline()) {
nsRect shadowRect = nsLayoutUtils::GetTextShadowRectsUnion(line->GetCombinedArea(), nsRect shadowRect = nsLayoutUtils::GetTextShadowRectsUnion(
this); line->GetVisualOverflowArea(), this);
area.UnionRect(area, shadowRect); areas.VisualOverflow().UnionRect(areas.VisualOverflow(), shadowRect);
} }
area.UnionRect(area, line->GetCombinedArea()); areas.UnionWith(line->GetOverflowAreas());
} }
// Factor the bullet in; normally the bullet will be factored into // Factor the bullet in; normally the bullet will be factored into
// the line-box's combined area. However, if the line is a block // the line-box's overflow areas. However, if the line is a block
// line then it won't; if there are no lines, it won't. So just // line then it won't; if there are no lines, it won't. So just
// factor it in anyway (it can't hurt if it was already done). // factor it in anyway (it can't hurt if it was already done).
// XXXldb Can we just fix GetCombinedArea instead? // XXXldb Can we just fix GetOverflowArea instead?
if (mBullet) { if (mBullet) {
area.UnionRect(area, mBullet->GetRect()); areas.UnionAllWith(mBullet->GetRect());
} }
// Factor in the bottom edge of the children. Child frames // Factor in the bottom edge of the children. Child frames
@ -1475,14 +1476,20 @@ nsBlockFrame::ComputeCombinedArea(const nsHTMLReflowState& aReflowState,
// to the bottom edge of the children // to the bottom edge of the children
bottomEdgeOfContents += aReflowState.mComputedPadding.bottom; bottomEdgeOfContents += aReflowState.mComputedPadding.bottom;
} }
area.height = NS_MAX(area.YMost(), bottomEdgeOfContents) - area.y; // REVIEW: For now, we do this for both visual and scrollable area,
// although when we make scrollable overflow area not be a subset of
// visual, we can change this.
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
nsRect& o = areas.Overflow(otype);
o.height = NS_MAX(o.YMost(), bottomEdgeOfContents) - o.y;
}
} }
#ifdef NOISY_COMBINED_AREA #ifdef NOISY_COMBINED_AREA
ListTag(stdout); ListTag(stdout);
printf(": ca=%d,%d,%d,%d\n", area.x, area.y, area.width, area.height); printf(": ca=%d,%d,%d,%d\n", area.x, area.y, area.width, area.height);
#endif #endif
aMetrics.mOverflowArea = area; aMetrics.mOverflowAreas = areas;
} }
nsresult nsresult

Просмотреть файл

@ -215,10 +215,11 @@ public:
// line cursor methods to speed up searching for the line(s) // line cursor methods to speed up searching for the line(s)
// containing a point. The basic idea is that we set the cursor // containing a point. The basic idea is that we set the cursor
// property if the lines' combinedArea.ys and combinedArea.yMosts // property if the lines' overflowArea.VisualOverflow().ys and
// are non-decreasing (considering only non-empty combinedAreas; // overflowArea.VisualOverflow().yMosts are non-decreasing
// empty combinedAreas never participate in event handling or // (considering only non-empty overflowArea.VisualOverflow()s; empty
// painting), and the block has sufficient number of lines. The // overflowArea.VisualOverflow()s never participate in event handling
// or painting), and the block has sufficient number of lines. The
// cursor property points to a "recently used" line. If we get a // cursor property points to a "recently used" line. If we get a
// series of requests that work on lines // series of requests that work on lines
// "near" the cursor, then we can find those nearby lines quickly by // "near" the cursor, then we can find those nearby lines quickly by
@ -396,7 +397,7 @@ protected:
nsHTMLReflowMetrics& aMetrics, nsHTMLReflowMetrics& aMetrics,
nscoord* aBottomEdgeOfChildren); nscoord* aBottomEdgeOfChildren);
void ComputeCombinedArea(const nsHTMLReflowState& aReflowState, void ComputeOverflowAreas(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aMetrics, nsHTMLReflowMetrics& aMetrics,
nscoord aBottomEdgeOfChildren); nscoord aBottomEdgeOfChildren);