Bug 1525133: Explicitly skip orthogonal-flow children when determining last-baseline of a block from its children. r=mats

Without the check that I'm adding in this patch, we'd violate the
"parallel writing mode" expectation of some baseline accessors
that we use in the now-guarded code. And we'd produce bogus layout
as a result.

The added assertions are just for good measure. The included testcase
causes us to fail both assertions, in a build that's missing the fix.

Differential Revision: https://phabricator.services.mozilla.com/D18715

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daniel Holbert 2019-02-05 19:45:46 +00:00
Родитель d026b0f026
Коммит 3cee4428b6
5 изменённых файлов: 88 добавлений и 1 удалений

Просмотреть файл

@ -487,7 +487,8 @@ bool nsBlockFrame::GetNaturalBaselineBOffset(
if (line->IsBlock()) {
nscoord offset;
nsIFrame* kid = line->mFirstChild;
if (kid->GetVerticalAlignBaseline(aWM, &offset)) {
if (!aWM.IsOrthogonalTo(kid->GetWritingMode()) &&
kid->GetVerticalAlignBaseline(aWM, &offset)) {
// Ignore relative positioning for baseline calculations.
const nsSize& sz = line->mContainerSize;
offset += kid->GetLogicalNormalPosition(aWM, sz).B(aWM);

Просмотреть файл

@ -122,6 +122,9 @@ class nsBlockFrame : public nsContainerFrame {
nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const override;
bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
nscoord* aBaseline) const override {
NS_ASSERTION(!aWM.IsOrthogonalTo(GetWritingMode()),
"You should only call this on frames with a WM that's "
"parallel to aWM");
nscoord lastBaseline;
if (GetNaturalBaselineBOffset(aWM, BaselineSharingGroup::eLast,
&lastBaseline)) {

Просмотреть файл

@ -814,6 +814,9 @@ class nsHTMLScrollFrame : public nsContainerFrame,
bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
nscoord* aBaseline) const override {
NS_ASSERTION(!aWM.IsOrthogonalTo(GetWritingMode()),
"You should only call this on frames with a WM that's "
"parallel to aWM");
*aBaseline = GetLogicalBaseline(aWM);
return true;
}

Просмотреть файл

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
CSS Test: orthogonal-flow child should be skipped over when determining parent's last-baseline
</title>
<link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-align/#baseline-export">
<link rel="match" href="reference/baseline-with-orthogonal-flow-001-ref.html">
<!-- The inline-blocks in this example are using last-baseline alignment, and
css-align-3 sec 9.1 says they should take their last-baseline position:
"from the ...(last) in-flow block-level child in the block container
that contributes a set of ... (last) baselines".
The orthogonal-flow doesn't contribute a first/last baseline set (not
for its parent's writing-mode at least), so it should not affect the
baseline determination.
-->
<style>
.ib {
display: inline-block;
}
.vert {
writing-mode: vertical-rl;
color: transparent;
}
.overflow {
overflow: hidden;
}
</style>
</head>
<body>
Test passes if the visible characters below are baseline-aligned.
<br><br>
aaa
<div class="ib">
bbb
<!-- This shouldn't influence the baseline of our inline block: -->
<div class="vert">vvv</div>
</div>
<div class="ib">
ccc
<!-- This shouldn't influence the baseline of our inline block: -->
<div class="vert overflow">ooo</div>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
CSS Reference Case
</title>
<style>
.ib {
display: inline-block;
}
</style>
</head>
<body>
Test passes if the visible characters below are baseline-aligned.
<br><br>
aaa
<div class="ib">
bbb
</div>
<div class="ib">
ccc
</div>
</body>
</html>