diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index a0ae178fbced..7246d3056678 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -2534,6 +2534,8 @@ static nsGenericHTMLElement::EnumTable kCompatTableHAlignTable[] = { { "char", NS_STYLE_TEXT_ALIGN_CHAR }, { "justify",NS_STYLE_TEXT_ALIGN_JUSTIFY }, { "abscenter", NS_STYLE_TEXT_ALIGN_CENTER }, + { "absmiddle", NS_STYLE_TEXT_ALIGN_CENTER }, + { "middle", NS_STYLE_TEXT_ALIGN_CENTER }, { 0 } }; diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 6c7a332ca9c9..b9754ccfea07 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -1502,12 +1502,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { - /* - ListTag(stdout); - printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n", - aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight, - aReflowState.mComputedWidth, aReflowState.mComputedHeight); -*/ DO_GLOBAL_REFLOW_COUNT("nsBlockFrame", aReflowState.reason); #ifdef DEBUG @@ -2570,14 +2564,24 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) nsLineBox* line = mLines; if (tryAndSkipLines) { - // The line's bounds are relative to the border edge of the frame nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left; if (NS_SHRINKWRAPWIDTH == aState.mReflowState.mComputedWidth) { - newAvailWidth += aState.mReflowState.mComputedMaxWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedMaxWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } else { - newAvailWidth += aState.mReflowState.mComputedWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != newAvailWidth, "bad math, newAvailWidth is infinite"); #ifdef DEBUG if (gNoisyReflow) { @@ -4450,13 +4454,14 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState, if (NS_FAILED(rv)) { return rv; } - +#if 0 // Mark next line dirty in case SplitLine didn't end up // pushing any frames. nsLineBox* next = aLine->mNext; if ((nsnull != next) && !next->IsBlock()) { next->MarkDirty(); } +#endif } } else if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) { diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index 6c7a332ca9c9..b9754ccfea07 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -1502,12 +1502,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { - /* - ListTag(stdout); - printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n", - aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight, - aReflowState.mComputedWidth, aReflowState.mComputedHeight); -*/ DO_GLOBAL_REFLOW_COUNT("nsBlockFrame", aReflowState.reason); #ifdef DEBUG @@ -2570,14 +2564,24 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) nsLineBox* line = mLines; if (tryAndSkipLines) { - // The line's bounds are relative to the border edge of the frame nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left; if (NS_SHRINKWRAPWIDTH == aState.mReflowState.mComputedWidth) { - newAvailWidth += aState.mReflowState.mComputedMaxWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedMaxWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } else { - newAvailWidth += aState.mReflowState.mComputedWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != newAvailWidth, "bad math, newAvailWidth is infinite"); #ifdef DEBUG if (gNoisyReflow) { @@ -4450,13 +4454,14 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState, if (NS_FAILED(rv)) { return rv; } - +#if 0 // Mark next line dirty in case SplitLine didn't end up // pushing any frames. nsLineBox* next = aLine->mNext; if ((nsnull != next) && !next->IsBlock()) { next->MarkDirty(); } +#endif } } else if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) { diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 6c7a332ca9c9..b9754ccfea07 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -1502,12 +1502,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { - /* - ListTag(stdout); - printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n", - aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight, - aReflowState.mComputedWidth, aReflowState.mComputedHeight); -*/ DO_GLOBAL_REFLOW_COUNT("nsBlockFrame", aReflowState.reason); #ifdef DEBUG @@ -2570,14 +2564,24 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) nsLineBox* line = mLines; if (tryAndSkipLines) { - // The line's bounds are relative to the border edge of the frame nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left; if (NS_SHRINKWRAPWIDTH == aState.mReflowState.mComputedWidth) { - newAvailWidth += aState.mReflowState.mComputedMaxWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedMaxWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } else { - newAvailWidth += aState.mReflowState.mComputedWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != newAvailWidth, "bad math, newAvailWidth is infinite"); #ifdef DEBUG if (gNoisyReflow) { @@ -4450,13 +4454,14 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState, if (NS_FAILED(rv)) { return rv; } - +#if 0 // Mark next line dirty in case SplitLine didn't end up // pushing any frames. nsLineBox* next = aLine->mNext; if ((nsnull != next) && !next->IsBlock()) { next->MarkDirty(); } +#endif } } else if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) { diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index d0b575b04b39..1b1b5fd711f9 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -1441,18 +1441,13 @@ nsHTMLReflowState::ComputeContainingBlockRectangle(nsIPresContext* aPre if (NS_UNCONSTRAINEDSIZE == availableWidth) { aContainingBlockWidth = NS_UNCONSTRAINEDSIZE; } - // a table in quirks mode gets a containing block based on the viewport (less - // body margins, border, padding) if the table is a child of the body. + // an element in quirks mode gets a containing block based on the viewport (less + // body margins, border, padding) if the element is a child of the body. if (NS_AUTOHEIGHT == aContainingBlockHeight) { - nsCOMPtr fType; - frame->GetFrameType(getter_AddRefs(fType)); - if (nsLayoutAtoms::tableFrame == fType.get() || - nsLayoutAtoms::htmlFrameOuterFrame == fType.get()) { - nsCompatibility mode; - aPresContext->GetCompatibilityMode(&mode); - if (eCompatibility_NavQuirks == mode) { - aContainingBlockHeight = CalcQuirkContainingBlockHeight(*aContainingBlockRS); - } + nsCompatibility mode; + aPresContext->GetCompatibilityMode(&mode); + if (eCompatibility_NavQuirks == mode) { + aContainingBlockHeight = CalcQuirkContainingBlockHeight(*aContainingBlockRS); } } } @@ -1551,8 +1546,34 @@ nsHTMLReflowState::InitConstraints(nsIPresContext* aPresContext, // that depends on the content height if (eStyleUnit_Percent == heightUnit) { if (NS_AUTOHEIGHT == aContainingBlockHeight) { - // Interpret the height like 'auto' - heightUnit = eStyleUnit_Auto; + // this if clause enables %-height on replaced inline frames, + // such as images. See bug 54119. The else clause "heightUnit = eStyleUnit_Auto;" + // used to be called exclusively. + if (NS_FRAME_REPLACED(NS_CSS_FRAME_TYPE_INLINE) == mFrameType) { + // Get the containing block reflow state + const nsHTMLReflowState* cbrs = + GetContainingBlockReflowState(parentReflowState); + NS_ASSERTION(nsnull != cbrs, "no containing block"); + nsCompatibility mode; + aPresContext->GetCompatibilityMode(&mode); + // in quirks mode, get the cb height using the special quirk method + if (eCompatibility_NavQuirks == mode) { + aContainingBlockHeight = CalcQuirkContainingBlockHeight(*cbrs); + } + // in standard mode, use the cb height. if it's "auto", as will be the case + // by default in BODY, use auto height as per CSS2 spec. + else + { + if (NS_AUTOHEIGHT != cbrs->mComputedHeight) + aContainingBlockHeight = cbrs->mComputedHeight; + else + heightUnit = eStyleUnit_Auto; + } + } + else { + // default to interpreting the height like 'auto' + heightUnit = eStyleUnit_Auto; + } } } @@ -1849,6 +1870,7 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext, // Use 'min-width' as the value for 'width' mComputedWidth = mComputedMinWidth; } + } } } else { diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 6c7a332ca9c9..b9754ccfea07 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -1502,12 +1502,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { - /* - ListTag(stdout); - printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n", - aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight, - aReflowState.mComputedWidth, aReflowState.mComputedHeight); -*/ DO_GLOBAL_REFLOW_COUNT("nsBlockFrame", aReflowState.reason); #ifdef DEBUG @@ -2570,14 +2564,24 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) nsLineBox* line = mLines; if (tryAndSkipLines) { - // The line's bounds are relative to the border edge of the frame nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left; if (NS_SHRINKWRAPWIDTH == aState.mReflowState.mComputedWidth) { - newAvailWidth += aState.mReflowState.mComputedMaxWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedMaxWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } else { - newAvailWidth += aState.mReflowState.mComputedWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != newAvailWidth, "bad math, newAvailWidth is infinite"); #ifdef DEBUG if (gNoisyReflow) { @@ -4450,13 +4454,14 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState, if (NS_FAILED(rv)) { return rv; } - +#if 0 // Mark next line dirty in case SplitLine didn't end up // pushing any frames. nsLineBox* next = aLine->mNext; if ((nsnull != next) && !next->IsBlock()) { next->MarkDirty(); } +#endif } } else if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) { diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index 6c7a332ca9c9..b9754ccfea07 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -1502,12 +1502,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { - /* - ListTag(stdout); - printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n", - aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight, - aReflowState.mComputedWidth, aReflowState.mComputedHeight); -*/ DO_GLOBAL_REFLOW_COUNT("nsBlockFrame", aReflowState.reason); #ifdef DEBUG @@ -2570,14 +2564,24 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) nsLineBox* line = mLines; if (tryAndSkipLines) { - // The line's bounds are relative to the border edge of the frame nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left; if (NS_SHRINKWRAPWIDTH == aState.mReflowState.mComputedWidth) { - newAvailWidth += aState.mReflowState.mComputedMaxWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedMaxWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } else { - newAvailWidth += aState.mReflowState.mComputedWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != newAvailWidth, "bad math, newAvailWidth is infinite"); #ifdef DEBUG if (gNoisyReflow) { @@ -4450,13 +4454,14 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState, if (NS_FAILED(rv)) { return rv; } - +#if 0 // Mark next line dirty in case SplitLine didn't end up // pushing any frames. nsLineBox* next = aLine->mNext; if ((nsnull != next) && !next->IsBlock()) { next->MarkDirty(); } +#endif } } else if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) { diff --git a/layout/html/base/src/nsBlockReflowState.h b/layout/html/base/src/nsBlockReflowState.h index 6c7a332ca9c9..b9754ccfea07 100644 --- a/layout/html/base/src/nsBlockReflowState.h +++ b/layout/html/base/src/nsBlockReflowState.h @@ -1502,12 +1502,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { - /* - ListTag(stdout); - printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n", - aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight, - aReflowState.mComputedWidth, aReflowState.mComputedHeight); -*/ DO_GLOBAL_REFLOW_COUNT("nsBlockFrame", aReflowState.reason); #ifdef DEBUG @@ -2570,14 +2564,24 @@ nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) nsLineBox* line = mLines; if (tryAndSkipLines) { - // The line's bounds are relative to the border edge of the frame nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left; if (NS_SHRINKWRAPWIDTH == aState.mReflowState.mComputedWidth) { - newAvailWidth += aState.mReflowState.mComputedMaxWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedMaxWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } else { - newAvailWidth += aState.mReflowState.mComputedWidth; + if (NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedMaxWidth) { + newAvailWidth += aState.mReflowState.mComputedWidth; + } + else { + newAvailWidth += aState.mReflowState.availableWidth; + } } + NS_ASSERTION(NS_UNCONSTRAINEDSIZE != newAvailWidth, "bad math, newAvailWidth is infinite"); #ifdef DEBUG if (gNoisyReflow) { @@ -4450,13 +4454,14 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState, if (NS_FAILED(rv)) { return rv; } - +#if 0 // Mark next line dirty in case SplitLine didn't end up // pushing any frames. nsLineBox* next = aLine->mNext; if ((nsnull != next) && !next->IsBlock()) { next->MarkDirty(); } +#endif } } else if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) { diff --git a/layout/html/base/src/nsHTMLReflowState.cpp b/layout/html/base/src/nsHTMLReflowState.cpp index d0b575b04b39..1b1b5fd711f9 100644 --- a/layout/html/base/src/nsHTMLReflowState.cpp +++ b/layout/html/base/src/nsHTMLReflowState.cpp @@ -1441,18 +1441,13 @@ nsHTMLReflowState::ComputeContainingBlockRectangle(nsIPresContext* aPre if (NS_UNCONSTRAINEDSIZE == availableWidth) { aContainingBlockWidth = NS_UNCONSTRAINEDSIZE; } - // a table in quirks mode gets a containing block based on the viewport (less - // body margins, border, padding) if the table is a child of the body. + // an element in quirks mode gets a containing block based on the viewport (less + // body margins, border, padding) if the element is a child of the body. if (NS_AUTOHEIGHT == aContainingBlockHeight) { - nsCOMPtr fType; - frame->GetFrameType(getter_AddRefs(fType)); - if (nsLayoutAtoms::tableFrame == fType.get() || - nsLayoutAtoms::htmlFrameOuterFrame == fType.get()) { - nsCompatibility mode; - aPresContext->GetCompatibilityMode(&mode); - if (eCompatibility_NavQuirks == mode) { - aContainingBlockHeight = CalcQuirkContainingBlockHeight(*aContainingBlockRS); - } + nsCompatibility mode; + aPresContext->GetCompatibilityMode(&mode); + if (eCompatibility_NavQuirks == mode) { + aContainingBlockHeight = CalcQuirkContainingBlockHeight(*aContainingBlockRS); } } } @@ -1551,8 +1546,34 @@ nsHTMLReflowState::InitConstraints(nsIPresContext* aPresContext, // that depends on the content height if (eStyleUnit_Percent == heightUnit) { if (NS_AUTOHEIGHT == aContainingBlockHeight) { - // Interpret the height like 'auto' - heightUnit = eStyleUnit_Auto; + // this if clause enables %-height on replaced inline frames, + // such as images. See bug 54119. The else clause "heightUnit = eStyleUnit_Auto;" + // used to be called exclusively. + if (NS_FRAME_REPLACED(NS_CSS_FRAME_TYPE_INLINE) == mFrameType) { + // Get the containing block reflow state + const nsHTMLReflowState* cbrs = + GetContainingBlockReflowState(parentReflowState); + NS_ASSERTION(nsnull != cbrs, "no containing block"); + nsCompatibility mode; + aPresContext->GetCompatibilityMode(&mode); + // in quirks mode, get the cb height using the special quirk method + if (eCompatibility_NavQuirks == mode) { + aContainingBlockHeight = CalcQuirkContainingBlockHeight(*cbrs); + } + // in standard mode, use the cb height. if it's "auto", as will be the case + // by default in BODY, use auto height as per CSS2 spec. + else + { + if (NS_AUTOHEIGHT != cbrs->mComputedHeight) + aContainingBlockHeight = cbrs->mComputedHeight; + else + heightUnit = eStyleUnit_Auto; + } + } + else { + // default to interpreting the height like 'auto' + heightUnit = eStyleUnit_Auto; + } } } @@ -1849,6 +1870,7 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext, // Use 'min-width' as the value for 'width' mComputedWidth = mComputedMinWidth; } + } } } else { diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index a0ae178fbced..7246d3056678 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -2534,6 +2534,8 @@ static nsGenericHTMLElement::EnumTable kCompatTableHAlignTable[] = { { "char", NS_STYLE_TEXT_ALIGN_CHAR }, { "justify",NS_STYLE_TEXT_ALIGN_JUSTIFY }, { "abscenter", NS_STYLE_TEXT_ALIGN_CENTER }, + { "absmiddle", NS_STYLE_TEXT_ALIGN_CENTER }, + { "middle", NS_STYLE_TEXT_ALIGN_CENTER }, { 0 } };