Make nsLineBox track two separate overflow areas. (Bug 542595, patch 6) r=roc a2.0=blocking2.0:beta8

This commit is contained in:
L. David Baron 2010-10-06 21:25:45 -07:00
Родитель d9a8d2b5bd
Коммит 8503895e5a
2 изменённых файлов: 47 добавлений и 27 удалений

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

@ -206,9 +206,15 @@ nsLineBox::List(FILE* out, PRInt32 aIndent) const
fprintf(out, "{%d,%d,%d,%d} ",
mBounds.x, mBounds.y, mBounds.width, mBounds.height);
if (mData) {
fprintf(out, "ca={%d,%d,%d,%d} ",
mData->mCombinedArea.x, mData->mCombinedArea.y,
mData->mCombinedArea.width, mData->mCombinedArea.height);
fprintf(out, "vis-overflow={%d,%d,%d,%d} scr-overflow={%d,%d,%d,%d} ",
mData->mOverflowAreas.VisualOverflow().x,
mData->mOverflowAreas.VisualOverflow().y,
mData->mOverflowAreas.VisualOverflow().width,
mData->mOverflowAreas.VisualOverflow().height,
mData->mOverflowAreas.ScrollableOverflow().x,
mData->mOverflowAreas.ScrollableOverflow().y,
mData->mOverflowAreas.ScrollableOverflow().width,
mData->mOverflowAreas.ScrollableOverflow().height);
}
fprintf(out, "<\n");
@ -419,7 +425,7 @@ nsLineBox::SetCarriedOutBottomMargin(nsCollapsingMargin aValue)
void
nsLineBox::MaybeFreeData()
{
if (mData && (mData->mCombinedArea == mBounds)) {
if (mData && mData->mOverflowAreas == nsOverflowAreas(mBounds, mBounds)) {
if (IsInline()) {
if (mInlineData->mFloats.IsEmpty()) {
delete mInlineData;
@ -489,29 +495,31 @@ nsLineBox::RemoveFloat(nsIFrame* aFrame)
}
void
nsLineBox::SetCombinedArea(const nsRect& aCombinedArea)
{
NS_ASSERTION(aCombinedArea.width >= 0, "illegal width for combined area");
NS_ASSERTION(aCombinedArea.height >= 0, "illegal height for combined area");
if (aCombinedArea != mBounds) {
if (mData) {
mData->mCombinedArea = aCombinedArea;
}
else {
nsLineBox::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas)
{
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
NS_ASSERTION(aOverflowAreas.Overflow(otype).width >= 0,
"illegal width for combined area");
NS_ASSERTION(aOverflowAreas.Overflow(otype).height >= 0,
"illegal height for combined area");
}
// REVIEW: should this use IsExactEqual?
if (aOverflowAreas.VisualOverflow() != mBounds ||
aOverflowAreas.ScrollableOverflow() != mBounds) {
if (!mData) {
if (IsInline()) {
mInlineData = new ExtraInlineData(aCombinedArea);
mInlineData = new ExtraInlineData(mBounds);
}
else {
mBlockData = new ExtraBlockData(aCombinedArea);
mBlockData = new ExtraBlockData(mBounds);
}
}
mData->mOverflowAreas = aOverflowAreas;
}
else {
if (mData) {
// Store away new value so that MaybeFreeData compares against
// the right value.
mData->mCombinedArea = aCombinedArea;
}
else if (mData) {
// Store away new value so that MaybeFreeData compares against
// the right value.
mData->mOverflowAreas = aOverflowAreas;
MaybeFreeData();
}
}

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

@ -410,15 +410,27 @@ public:
// overflow area of its parent block. The combined area should be
// used for painting-related things, but should never be used for
// layout (except for handling of 'overflow').
void SetCombinedArea(const nsRect& aCombinedArea);
nsRect GetCombinedArea() {
return mData ? mData->mCombinedArea : mBounds;
void SetOverflowAreas(const nsOverflowAreas& aOverflowAreas);
nsRect GetOverflowArea(nsOverflowType aType) {
return mData ? mData->mOverflowAreas.Overflow(aType) : mBounds;
}
nsOverflowAreas GetOverflowAreas() {
if (mData) {
return mData->mOverflowAreas;
}
return nsOverflowAreas(mBounds, mBounds);
}
nsRect GetVisualOverflowArea()
{ return GetOverflowArea(eVisualOverflow); }
nsRect GetScrollableOverflowArea()
{ return GetOverflowArea(eScrollableOverflow); }
void SlideBy(nscoord aDY) {
mBounds.y += aDY;
if (mData) {
mData->mCombinedArea.y += aDY;
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
mData->mOverflowAreas.Overflow(otype).y += aDY;
}
}
}
@ -517,9 +529,9 @@ public:
};
struct ExtraData {
ExtraData(const nsRect& aBounds) : mCombinedArea(aBounds) {
ExtraData(const nsRect& aBounds) : mOverflowAreas(aBounds, aBounds) {
}
nsRect mCombinedArea;
nsOverflowAreas mOverflowAreas;
};
struct ExtraBlockData : public ExtraData {