diff --git a/mozilla/layout/base/public/nsHTMLReflowMetrics.h b/mozilla/layout/base/public/nsHTMLReflowMetrics.h
index 026b59242a0..4f50ae414f7 100644
--- a/mozilla/layout/base/public/nsHTMLReflowMetrics.h
+++ b/mozilla/layout/base/public/nsHTMLReflowMetrics.h
@@ -96,6 +96,14 @@ struct nsCollapsingMargin {
mMostNeg = aCoord;
}
+ void Include(const nsCollapsingMargin& aOther)
+ {
+ if (aOther.mMostPos > mMostPos)
+ mMostPos = aOther.mMostPos;
+ if (aOther.mMostNeg < mMostNeg)
+ mMostNeg = aOther.mMostNeg;
+ }
+
void Zero()
{
mMostPos = 0;
diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp
index 624ef25ee48..8e176380944 100644
--- a/mozilla/layout/generic/nsBlockFrame.cpp
+++ b/mozilla/layout/generic/nsBlockFrame.cpp
@@ -757,8 +757,8 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
containingBlockHeight,
handled);
- // If the incremental reflow command was handled by the absolute positioning
- // code, then we're all done
+ // If the incremental reflow command was handled by the absolute
+ // positioning code, then we're all done.
if (handled) {
// Just return our current size as our desired size.
aMetrics.width = mRect.width;
@@ -1370,14 +1370,8 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
// because we can't shrink any smaller.
maxHeight = aMetrics.height;
- // Don't carry out a bottom margin when our height is fixed
- // unless the bottom of the last line adjoins the bottom of our
- // content area.
- if (!aState.GetFlag(BRS_ISBOTTOMMARGINROOT)) {
- if (aState.mY + aState.mPrevBottomMargin.get() != aMetrics.height) {
- aState.mPrevBottomMargin.Zero();
- }
- }
+ // Don't carry out a bottom margin when our height is fixed.
+ aState.mPrevBottomMargin.Zero();
}
else {
nscoord autoHeight = aState.mY;
@@ -3344,8 +3338,9 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
nsCollapsingMargin collapsedBottomMargin;
nsRect combinedArea(0,0,0,0);
- *aKeepReflowGoing = brc.PlaceBlock(blockHtmlRS, isAdjacentWithTop, computedOffsets,
- collapsedBottomMargin, aLine->mBounds, combinedArea);
+ *aKeepReflowGoing = brc.PlaceBlock(blockHtmlRS, isAdjacentWithTop,
+ computedOffsets, collapsedBottomMargin,
+ aLine->mBounds, combinedArea);
aLine->SetCarriedOutBottomMargin(collapsedBottomMargin);
if (aState.GetFlag(BRS_SHRINKWRAPWIDTH)) {
diff --git a/mozilla/layout/generic/nsBlockReflowContext.cpp b/mozilla/layout/generic/nsBlockReflowContext.cpp
index ab967910483..201abfac560 100644
--- a/mozilla/layout/generic/nsBlockReflowContext.cpp
+++ b/mozilla/layout/generic/nsBlockReflowContext.cpp
@@ -409,7 +409,7 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
aFrameRS.availableHeight -= aPrevBottomMargin.get();
}
}
- mTopMargin = aPrevBottomMargin.get();
+ mTopMargin = aPrevBottomMargin;
// Compute x/y coordinate where reflow will begin. Use the rules
// from 10.3.3 to determine what to apply. At this point in the
@@ -419,7 +419,7 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
mStyleMargin = aFrameRS.mStyleMargin;
mStylePadding = aFrameRS.mStylePadding;
nscoord x;
- nscoord y = mSpace.y + mTopMargin;
+ nscoord y = mSpace.y + mTopMargin.get();
// If it's a right floated element, then calculate the x-offset
// differently
@@ -687,13 +687,12 @@ nsBlockReflowContext::PlaceBlock(const nsHTMLReflowState& aReflowState,
y = mSpace.y;
- // Empty blocks do not have anything special done to them and they
- // always fit. Note: don't force the width to 0
- nsRect r(x, y, mMetrics.width, 0);
-
// Now place the frame and complete the reflow process
nsContainerFrame::FinishReflowChild(mFrame, mPresContext, &aReflowState, mMetrics, x, y, 0);
- aInFlowBounds = r;
+
+ // Empty blocks do not have anything special done to them and they
+ // always fit. Note: don't force the width to 0
+ aInFlowBounds = nsRect(x, y, mMetrics.width, 0);
// Retain combined area information in case we contain a floater
// and nothing else.
@@ -773,7 +772,7 @@ nsBlockReflowContext::PlaceBlock(const nsHTMLReflowState& aReflowState,
// auto top/bottom margins are always zero)
// XXXldb Should it?
- m->height += mTopMargin + mBottomMargin;
+ m->height += mTopMargin.get() + mBottomMargin;
#endif
}
}
diff --git a/mozilla/layout/generic/nsBlockReflowContext.h b/mozilla/layout/generic/nsBlockReflowContext.h
index 838f6305463..d31128a651a 100644
--- a/mozilla/layout/generic/nsBlockReflowContext.h
+++ b/mozilla/layout/generic/nsBlockReflowContext.h
@@ -82,7 +82,7 @@ public:
}
nscoord GetTopMargin() const {
- return mTopMargin;
+ return mTopMargin.get();
}
const nsMargin& GetMargin() const {
@@ -128,7 +128,7 @@ protected:
nsMargin mMargin;
nscoord mX, mY;
nsHTMLReflowMetrics mMetrics;
- nscoord mTopMargin;
+ nsCollapsingMargin mTopMargin;
nsSize mMaxElementSize;
PRPackedBool mIsTable;
PRPackedBool mComputeMaximumWidth;
diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp
index 1c4ae0200a6..84dcf843c4b 100644
--- a/mozilla/layout/generic/nsBlockReflowState.cpp
+++ b/mozilla/layout/generic/nsBlockReflowState.cpp
@@ -448,11 +448,10 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine)
mPrevBottomMargin.Zero();
nsBlockFrame *block = mBlock;
- const nsStyleText* styleText = NS_STATIC_CAST(const nsStyleText*,
- block->mStyleContext->GetStyleData(eStyleStruct_Text));
- PRBool isPre =
- ((NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) ||
- (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace));
+ const nsStyleText* styleText;
+ ::GetStyleData(block, &styleText);
+ PRBool isPre = NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace ||
+ NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace;
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
diff --git a/mozilla/layout/generic/nsHTMLReflowMetrics.h b/mozilla/layout/generic/nsHTMLReflowMetrics.h
index 026b59242a0..4f50ae414f7 100644
--- a/mozilla/layout/generic/nsHTMLReflowMetrics.h
+++ b/mozilla/layout/generic/nsHTMLReflowMetrics.h
@@ -96,6 +96,14 @@ struct nsCollapsingMargin {
mMostNeg = aCoord;
}
+ void Include(const nsCollapsingMargin& aOther)
+ {
+ if (aOther.mMostPos > mMostPos)
+ mMostPos = aOther.mMostPos;
+ if (aOther.mMostNeg < mMostNeg)
+ mMostNeg = aOther.mMostNeg;
+ }
+
void Zero()
{
mMostPos = 0;
diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp
index 624ef25ee48..8e176380944 100644
--- a/mozilla/layout/html/base/src/nsBlockFrame.cpp
+++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp
@@ -757,8 +757,8 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
containingBlockHeight,
handled);
- // If the incremental reflow command was handled by the absolute positioning
- // code, then we're all done
+ // If the incremental reflow command was handled by the absolute
+ // positioning code, then we're all done.
if (handled) {
// Just return our current size as our desired size.
aMetrics.width = mRect.width;
@@ -1370,14 +1370,8 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
// because we can't shrink any smaller.
maxHeight = aMetrics.height;
- // Don't carry out a bottom margin when our height is fixed
- // unless the bottom of the last line adjoins the bottom of our
- // content area.
- if (!aState.GetFlag(BRS_ISBOTTOMMARGINROOT)) {
- if (aState.mY + aState.mPrevBottomMargin.get() != aMetrics.height) {
- aState.mPrevBottomMargin.Zero();
- }
- }
+ // Don't carry out a bottom margin when our height is fixed.
+ aState.mPrevBottomMargin.Zero();
}
else {
nscoord autoHeight = aState.mY;
@@ -3344,8 +3338,9 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
nsCollapsingMargin collapsedBottomMargin;
nsRect combinedArea(0,0,0,0);
- *aKeepReflowGoing = brc.PlaceBlock(blockHtmlRS, isAdjacentWithTop, computedOffsets,
- collapsedBottomMargin, aLine->mBounds, combinedArea);
+ *aKeepReflowGoing = brc.PlaceBlock(blockHtmlRS, isAdjacentWithTop,
+ computedOffsets, collapsedBottomMargin,
+ aLine->mBounds, combinedArea);
aLine->SetCarriedOutBottomMargin(collapsedBottomMargin);
if (aState.GetFlag(BRS_SHRINKWRAPWIDTH)) {
diff --git a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp
index ab967910483..201abfac560 100644
--- a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp
+++ b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp
@@ -409,7 +409,7 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
aFrameRS.availableHeight -= aPrevBottomMargin.get();
}
}
- mTopMargin = aPrevBottomMargin.get();
+ mTopMargin = aPrevBottomMargin;
// Compute x/y coordinate where reflow will begin. Use the rules
// from 10.3.3 to determine what to apply. At this point in the
@@ -419,7 +419,7 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
mStyleMargin = aFrameRS.mStyleMargin;
mStylePadding = aFrameRS.mStylePadding;
nscoord x;
- nscoord y = mSpace.y + mTopMargin;
+ nscoord y = mSpace.y + mTopMargin.get();
// If it's a right floated element, then calculate the x-offset
// differently
@@ -687,13 +687,12 @@ nsBlockReflowContext::PlaceBlock(const nsHTMLReflowState& aReflowState,
y = mSpace.y;
- // Empty blocks do not have anything special done to them and they
- // always fit. Note: don't force the width to 0
- nsRect r(x, y, mMetrics.width, 0);
-
// Now place the frame and complete the reflow process
nsContainerFrame::FinishReflowChild(mFrame, mPresContext, &aReflowState, mMetrics, x, y, 0);
- aInFlowBounds = r;
+
+ // Empty blocks do not have anything special done to them and they
+ // always fit. Note: don't force the width to 0
+ aInFlowBounds = nsRect(x, y, mMetrics.width, 0);
// Retain combined area information in case we contain a floater
// and nothing else.
@@ -773,7 +772,7 @@ nsBlockReflowContext::PlaceBlock(const nsHTMLReflowState& aReflowState,
// auto top/bottom margins are always zero)
// XXXldb Should it?
- m->height += mTopMargin + mBottomMargin;
+ m->height += mTopMargin.get() + mBottomMargin;
#endif
}
}
diff --git a/mozilla/layout/html/base/src/nsBlockReflowContext.h b/mozilla/layout/html/base/src/nsBlockReflowContext.h
index 838f6305463..d31128a651a 100644
--- a/mozilla/layout/html/base/src/nsBlockReflowContext.h
+++ b/mozilla/layout/html/base/src/nsBlockReflowContext.h
@@ -82,7 +82,7 @@ public:
}
nscoord GetTopMargin() const {
- return mTopMargin;
+ return mTopMargin.get();
}
const nsMargin& GetMargin() const {
@@ -128,7 +128,7 @@ protected:
nsMargin mMargin;
nscoord mX, mY;
nsHTMLReflowMetrics mMetrics;
- nscoord mTopMargin;
+ nsCollapsingMargin mTopMargin;
nsSize mMaxElementSize;
PRPackedBool mIsTable;
PRPackedBool mComputeMaximumWidth;
diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp
index 1c4ae0200a6..84dcf843c4b 100644
--- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp
+++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp
@@ -448,11 +448,10 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine)
mPrevBottomMargin.Zero();
nsBlockFrame *block = mBlock;
- const nsStyleText* styleText = NS_STATIC_CAST(const nsStyleText*,
- block->mStyleContext->GetStyleData(eStyleStruct_Text));
- PRBool isPre =
- ((NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) ||
- (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace));
+ const nsStyleText* styleText;
+ ::GetStyleData(block, &styleText);
+ PRBool isPre = NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace ||
+ NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace;
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);