Fix placement of positioned elements with auto "top". Bug 44508, patch
by Mats Palmgren (mats.palmgren@bredband.net), r=dbaron, sr=bzbarsky. git-svn-id: svn://10.0.0.236/trunk@127417 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -2884,6 +2884,9 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
||||
// 2) if position is 'absolute' or 'fixed' then display must be 'block and float must be 'none'
|
||||
// XXX - see note for fixup 1) above...
|
||||
if (display->IsAbsolutelyPositioned() && display->mDisplay != NS_STYLE_DISPLAY_NONE) {
|
||||
// Backup original display value for calculation of a hypothetical box (CSS2 10.6.4/10.6.5)
|
||||
// See nsHTMLReflowState::CalculateHypotheticalBox
|
||||
display->mOriginalDisplay = display->mDisplay;
|
||||
EnsureBlockDisplay(display->mDisplay);
|
||||
display->mFloats = NS_STYLE_FLOAT_NONE;
|
||||
}
|
||||
|
||||
@@ -710,6 +710,7 @@ struct nsStyleDisplay : public nsStyleStruct {
|
||||
PRInt32 CalcDifference(const nsStyleDisplay& aOther) const;
|
||||
|
||||
PRUint8 mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
|
||||
PRUint8 mOriginalDisplay; // [reset] saved mDisplay for position:absolute/fixed
|
||||
PRUint8 mAppearance; // [reset]
|
||||
nsString mBinding; // [reset] absolute url string
|
||||
PRUint8 mPosition; // [reset] see nsStyleConsts.h
|
||||
|
||||
@@ -1023,6 +1023,7 @@ nsStyleDisplay::nsStyleDisplay()
|
||||
{
|
||||
mAppearance = 0;
|
||||
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
||||
mOriginalDisplay = NS_STYLE_DISPLAY_NONE;
|
||||
mPosition = NS_STYLE_POSITION_NORMAL;
|
||||
mFloats = NS_STYLE_FLOAT_NONE;
|
||||
mBreakType = NS_STYLE_CLEAR_NONE;
|
||||
@@ -1037,6 +1038,7 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
||||
{
|
||||
mAppearance = aSource.mAppearance;
|
||||
mDisplay = aSource.mDisplay;
|
||||
mOriginalDisplay = aSource.mOriginalDisplay;
|
||||
mBinding = aSource.mBinding;
|
||||
mPosition = aSource.mPosition;
|
||||
mFloats = aSource.mFloats;
|
||||
|
||||
@@ -781,6 +781,9 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
|
||||
nsIFrame* aAbsoluteContainingBlockFrame,
|
||||
nsHypotheticalBox& aHypotheticalBox)
|
||||
{
|
||||
NS_ASSERTION(mStyleDisplay->mOriginalDisplay != NS_STYLE_DISPLAY_NONE,
|
||||
"mOriginalDisplay has not been properly initialized");
|
||||
|
||||
// If it's a replaced element and it has a 'auto' value for 'width', see if we
|
||||
// can get the intrinsic size. This will allow us to exactly determine both the
|
||||
// left and right edges
|
||||
@@ -796,7 +799,7 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
|
||||
// element had been in the flow
|
||||
nscoord boxWidth;
|
||||
PRBool knowBoxWidth = PR_FALSE;
|
||||
if ((NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mDisplay) &&
|
||||
if ((NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mOriginalDisplay) &&
|
||||
!NS_FRAME_IS_REPLACED(mFrameType)) {
|
||||
// For non-replaced inline-level elements the 'width' property doesn't apply,
|
||||
// so we don't know what the width would have been without reflowing it
|
||||
@@ -841,7 +844,7 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
|
||||
|
||||
// How we determine the hypothetical box depends on whether the element
|
||||
// would have been inline-level or block-level
|
||||
if (NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mDisplay) {
|
||||
if (NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mOriginalDisplay) {
|
||||
nsPoint placeholderOffset;
|
||||
|
||||
// Get the placeholder x-offset and y-offset in the coordinate
|
||||
|
||||
@@ -781,6 +781,9 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
|
||||
nsIFrame* aAbsoluteContainingBlockFrame,
|
||||
nsHypotheticalBox& aHypotheticalBox)
|
||||
{
|
||||
NS_ASSERTION(mStyleDisplay->mOriginalDisplay != NS_STYLE_DISPLAY_NONE,
|
||||
"mOriginalDisplay has not been properly initialized");
|
||||
|
||||
// If it's a replaced element and it has a 'auto' value for 'width', see if we
|
||||
// can get the intrinsic size. This will allow us to exactly determine both the
|
||||
// left and right edges
|
||||
@@ -796,7 +799,7 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
|
||||
// element had been in the flow
|
||||
nscoord boxWidth;
|
||||
PRBool knowBoxWidth = PR_FALSE;
|
||||
if ((NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mDisplay) &&
|
||||
if ((NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mOriginalDisplay) &&
|
||||
!NS_FRAME_IS_REPLACED(mFrameType)) {
|
||||
// For non-replaced inline-level elements the 'width' property doesn't apply,
|
||||
// so we don't know what the width would have been without reflowing it
|
||||
@@ -841,7 +844,7 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
|
||||
|
||||
// How we determine the hypothetical box depends on whether the element
|
||||
// would have been inline-level or block-level
|
||||
if (NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mDisplay) {
|
||||
if (NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mOriginalDisplay) {
|
||||
nsPoint placeholderOffset;
|
||||
|
||||
// Get the placeholder x-offset and y-offset in the coordinate
|
||||
|
||||
@@ -2884,6 +2884,9 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
||||
// 2) if position is 'absolute' or 'fixed' then display must be 'block and float must be 'none'
|
||||
// XXX - see note for fixup 1) above...
|
||||
if (display->IsAbsolutelyPositioned() && display->mDisplay != NS_STYLE_DISPLAY_NONE) {
|
||||
// Backup original display value for calculation of a hypothetical box (CSS2 10.6.4/10.6.5)
|
||||
// See nsHTMLReflowState::CalculateHypotheticalBox
|
||||
display->mOriginalDisplay = display->mDisplay;
|
||||
EnsureBlockDisplay(display->mDisplay);
|
||||
display->mFloats = NS_STYLE_FLOAT_NONE;
|
||||
}
|
||||
|
||||
@@ -1023,6 +1023,7 @@ nsStyleDisplay::nsStyleDisplay()
|
||||
{
|
||||
mAppearance = 0;
|
||||
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
||||
mOriginalDisplay = NS_STYLE_DISPLAY_NONE;
|
||||
mPosition = NS_STYLE_POSITION_NORMAL;
|
||||
mFloats = NS_STYLE_FLOAT_NONE;
|
||||
mBreakType = NS_STYLE_CLEAR_NONE;
|
||||
@@ -1037,6 +1038,7 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
||||
{
|
||||
mAppearance = aSource.mAppearance;
|
||||
mDisplay = aSource.mDisplay;
|
||||
mOriginalDisplay = aSource.mOriginalDisplay;
|
||||
mBinding = aSource.mBinding;
|
||||
mPosition = aSource.mPosition;
|
||||
mFloats = aSource.mFloats;
|
||||
|
||||
@@ -710,6 +710,7 @@ struct nsStyleDisplay : public nsStyleStruct {
|
||||
PRInt32 CalcDifference(const nsStyleDisplay& aOther) const;
|
||||
|
||||
PRUint8 mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
|
||||
PRUint8 mOriginalDisplay; // [reset] saved mDisplay for position:absolute/fixed
|
||||
PRUint8 mAppearance; // [reset]
|
||||
nsString mBinding; // [reset] absolute url string
|
||||
PRUint8 mPosition; // [reset] see nsStyleConsts.h
|
||||
|
||||
Reference in New Issue
Block a user