mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 06:45:42 +00:00
When all three of 'left', 'width', and 'right' of an absolutely-positioned elemnt are 'auto', use the direction of the static-position containing block (rather than the actual containing block) to decide whether to set 'left' or 'right' to the static position. bug=403328 r+sr=dbaron b1.9=mtschrep
This commit is contained in:
parent
b5e568eb95
commit
569b5e7d24
@ -1124,14 +1124,12 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
||||
mComputedOffsets.right);
|
||||
}
|
||||
|
||||
PRUint8 direction = cbrs ? cbrs->mStyleVisibility->mDirection : NS_STYLE_DIRECTION_LTR;
|
||||
|
||||
// Use the horizontal component of the hypothetical box in the cases
|
||||
// where it's needed.
|
||||
if (leftIsAuto && rightIsAuto) {
|
||||
// Use the 'direction' to dictate whether 'left' or 'right' is
|
||||
// treated like 'static-position'
|
||||
if (NS_STYLE_DIRECTION_LTR == direction) {
|
||||
// Use the direction of the original ("static-position") containing block
|
||||
// to dictate whether 'left' or 'right' is treated like 'static-position'.
|
||||
if (NS_STYLE_DIRECTION_LTR == cbFrame->GetStyleVisibility()->mDirection) {
|
||||
if (hypotheticalBox.mLeftIsExact) {
|
||||
mComputedOffsets.left = hypotheticalBox.mLeft;
|
||||
leftIsAuto = PR_FALSE;
|
||||
@ -1259,15 +1257,16 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
||||
|
||||
if (availMarginSpace < 0 ||
|
||||
(!marginLeftIsAuto && !marginRightIsAuto)) {
|
||||
// We're over-constrained so use 'direction' to dictate which
|
||||
// value to ignore. (And note that the spec says to ignore 'left'
|
||||
// or 'right' rather than 'margin-left' or 'margin-right'.)
|
||||
if (NS_STYLE_DIRECTION_LTR == direction) {
|
||||
// Ignore the specified value for 'right'.
|
||||
mComputedOffsets.right += availMarginSpace;
|
||||
} else {
|
||||
// We're over-constrained so use the direction of the containing block
|
||||
// to dictate which value to ignore. (And note that the spec says to ignore
|
||||
// 'left' or 'right' rather than 'margin-left' or 'margin-right'.)
|
||||
if (cbrs &&
|
||||
NS_STYLE_DIRECTION_RTL == cbrs->mStyleVisibility->mDirection) {
|
||||
// Ignore the specified value for 'left'.
|
||||
mComputedOffsets.left += availMarginSpace;
|
||||
} else {
|
||||
// Ignore the specified value for 'right'.
|
||||
mComputedOffsets.right += availMarginSpace;
|
||||
}
|
||||
} else if (marginLeftIsAuto) {
|
||||
if (marginRightIsAuto) {
|
||||
|
45
layout/reftests/bugs/403328-1-ref.html
Normal file
45
layout/reftests/bugs/403328-1-ref.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
<title>Testcase for bug 403328</title>
|
||||
<style>
|
||||
body {
|
||||
margin-left:40px;
|
||||
}
|
||||
div.cb {
|
||||
background-color: lime;
|
||||
width: 80px;
|
||||
}
|
||||
div.spcb {
|
||||
background-color: blue;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
width: 40px;
|
||||
}
|
||||
div.abs {
|
||||
background-color: red;
|
||||
height: 40px;
|
||||
}
|
||||
div.extrawide {
|
||||
width: 100px;
|
||||
}
|
||||
div.narrow {
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head><body>
|
||||
|
||||
<div class="cb">
|
||||
<div class="spcb">
|
||||
<div class="abs narrow" style="margin-left:auto;"></div>
|
||||
<div class="abs narrow"></div>
|
||||
<div class="abs extrawide" style="margin-left:-20px;"></div>
|
||||
<div class="abs extrawide" style="margin-left:-40px;"></div>
|
||||
<div class="abs narrow" style="margin-left:-20px;"></div>
|
||||
<div class="abs narrow" style="margin-left:auto; margin-right:-20px;"></div>
|
||||
<div class="abs narrow" style="margin-left:auto;"></div>
|
||||
<div class="abs narrow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body></html>
|
115
layout/reftests/bugs/403328-1.html
Normal file
115
layout/reftests/bugs/403328-1.html
Normal file
@ -0,0 +1,115 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
<title>Testcase for bug 403328</title>
|
||||
<style>
|
||||
body {
|
||||
margin-left:40px;
|
||||
}
|
||||
div.cb {
|
||||
background-color: lime;
|
||||
position: relative;
|
||||
width: 80px;
|
||||
}
|
||||
div.spcb {
|
||||
background-color: blue;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
}
|
||||
div.abs {
|
||||
background-color: red;
|
||||
position: absolute;
|
||||
height: 20px;
|
||||
}
|
||||
div.auto-margins {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
div.zero-margins {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
div.extrawide {
|
||||
width: 100px;
|
||||
}
|
||||
div.narrow {
|
||||
width: 20px;
|
||||
}
|
||||
div.leftright {
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head><body>
|
||||
|
||||
<div dir="ltr" class="cb">
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="ltr" class="abs"><div class="narrow"></div></div>
|
||||
</div>
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="rtl" class="abs"><div class="narrow"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div dir="rtl" class="cb">
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="ltr" class="abs"><div class="narrow"></div></div>
|
||||
</div>
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="rtl" class="abs"><div class="narrow"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div dir="ltr" class="cb">
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="ltr" class="abs leftright extrawide auto-margins"></div>
|
||||
</div>
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="rtl" class="abs leftright extrawide auto-margins"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div dir="rtl" class="cb">
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="ltr" class="abs leftright extrawide auto-margins"></div>
|
||||
</div>
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="rtl" class="abs leftright extrawide auto-margins"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div dir="ltr" class="cb">
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="ltr" class="abs leftright narrow zero-margins"></div>
|
||||
</div>
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="rtl" class="abs leftright narrow zero-margins"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div dir="rtl" class="cb">
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="ltr" class="abs leftright narrow zero-margins"></div>
|
||||
</div>
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="rtl" class="abs leftright narrow zero-margins"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div dir="ltr" class="cb">
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="ltr" class="abs narrow"></div>
|
||||
</div>
|
||||
<div dir="rtl" class="spcb">
|
||||
<div dir="rtl" class="abs narrow"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div dir="rtl" class="cb">
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="ltr" class="abs narrow"></div>
|
||||
</div>
|
||||
<div dir="ltr" class="spcb">
|
||||
<div dir="rtl" class="abs narrow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body></html>
|
@ -649,6 +649,7 @@ random == 403134-1.html 403134-1-ref.html # bug 405377
|
||||
== 403249-1b.html 403249-1-ref.html
|
||||
== 403249-2a.html 403249-2-ref.html
|
||||
== 403249-2b.html 403249-2-ref.html
|
||||
== 403328-1.html 403328-1-ref.html
|
||||
== 403426-1.html 403426-1-ref.html
|
||||
== 403455-1.html 403455-1-ref.html
|
||||
== 403505-1.xml 403505-1-ref.xul
|
||||
|
Loading…
Reference in New Issue
Block a user