Bug 599882. Make baselines not depend on relative positioning of kids. r=dbaron

This commit is contained in:
Boris Zbarsky 2012-10-17 17:01:55 -04:00
parent dd82a0d964
commit 0eba625d0e
8 changed files with 100 additions and 5 deletions

View File

@ -3418,7 +3418,8 @@ nsLayoutUtils::GetFirstLinePosition(const nsIFrame* aFrame,
nsIFrame* kid = aFrame->GetFirstPrincipalChild();
// kid might be a legend frame here, but that's ok.
if (GetFirstLinePosition(kid, &kidPosition)) {
*aResult = kidPosition + kid->GetPosition().y;
*aResult = kidPosition + (kid->GetPosition().y -
kid->GetRelativeOffset().y);
return true;
}
return false;
@ -3435,7 +3436,8 @@ nsLayoutUtils::GetFirstLinePosition(const nsIFrame* aFrame,
nsIFrame *kid = line->mFirstChild;
LinePosition kidPosition;
if (GetFirstLinePosition(kid, &kidPosition)) {
*aResult = kidPosition + kid->GetPosition().y;
*aResult = kidPosition + (kid->GetPosition().y -
kid->GetRelativeOffset().y);
return true;
}
} else {
@ -3468,12 +3470,14 @@ nsLayoutUtils::GetLastLineBaseline(const nsIFrame* aFrame, nscoord* aResult)
nsIFrame *kid = line->mFirstChild;
nscoord kidBaseline;
if (GetLastLineBaseline(kid, &kidBaseline)) {
*aResult = kidBaseline + kid->GetPosition().y;
// Ignore relative positioning for baseline calculations
*aResult = kidBaseline + kid->GetPosition().y -
kid->GetRelativeOffset().y;
return true;
} else if (kid->GetType() == nsGkAtoms::scrollFrame) {
// Use the bottom of the scroll frame.
// XXX CSS2.1 really doesn't say what to do here.
*aResult = kid->GetRect().YMost();
*aResult = kid->GetRect().YMost() - kid->GetRelativeOffset().y;
return true;
}
} else {

View File

@ -1082,7 +1082,7 @@ public:
}
};
static bool GetFirstLinePosition(const nsIFrame* aFrame,
LinePosition* aResult);
LinePosition* aResult);
/**

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.positioned {
display:block;
}
.container {
display:inline-block;
}
</style>
</head>
<body>
<span style="vertical-align: baseline">Baseline aligned</span>
<span class="container"><span class="positioned">&nbsp;</span></span>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.positioned {
display:block;
position: relative;
top:200px;
}
.container {
display:inline-block;
}
</style>
</head>
<body>
<span style="vertical-align: baseline">Baseline aligned</span>
<span class="container"><span class="positioned">&nbsp;</span></span>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.positioned {
display:block;
position: relative;
top:200px;
}
.container {
display:inline-table;
}
</style>
</head>
<body>
<span style="vertical-align: baseline">Baseline aligned</span>
<span class="container"><span class="positioned">&nbsp;</span></span>
</body>
</html>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<body>
<ul>
<li>
<div class="positioned">&nbsp;</div>
</ul>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.positioned {
position: relative;
top:200px;
}
</style>
</head>
<body>
<ul>
<li>
<div class="positioned">&nbsp;</div>
</li>
</ul>
</body>
</html>

View File

@ -1589,6 +1589,9 @@ skip-if(!browserIsRemote) == 593243-2.html 593243-2-ref.html # bug 593168
random-if(winWidget) needs-focus == 598726-1.html 598726-1-ref.html # Fails on Windows, bug 782196
== 599113-1.html 599113-1-ref.html
fails-if(!haveTestPlugin) == 599476.html 599476-ref.html
== 599882-1a.html 599882-1-ref.html
== 599882-1b.html 599882-1-ref.html
== 599882-2.html 599882-2-ref.html
== 600045-1.html 600045-1-ref.html
== 600803-1.html 600803-1-ref.html
== 603423-1.html 603423-1-ref.html