Bug 1791069 - Clamp scrollable element's first/last baseline position to border box. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D161068
This commit is contained in:
David Shin 2022-11-09 16:25:46 +00:00
Родитель e7ac53264e
Коммит 247d54c98b
10 изменённых файлов: 46 добавлений и 99 удалений

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

@ -5859,11 +5859,8 @@ bool nsLayoutUtils::GetFirstLinePosition(WritingMode aWM,
}
// For first-line baselines, we have to consider scroll frames.
if (fType == LayoutFrameType::Scroll) {
nsIScrollableFrame* sFrame = do_QueryFrame(const_cast<nsIFrame*>(aFrame));
if (!sFrame) {
MOZ_ASSERT_UNREACHABLE("not scroll frame");
}
if (nsIScrollableFrame* sFrame =
do_QueryFrame(const_cast<nsIFrame*>(aFrame))) {
LinePosition kidPosition;
if (GetFirstLinePosition(aWM, sFrame->GetScrolledFrame(), &kidPosition)) {
// Consider only the border (Padding is ignored, since
@ -5871,6 +5868,10 @@ bool nsLayoutUtils::GetFirstLinePosition(WritingMode aWM,
// contributes to the kid's position, not the scrolling, so we get the
// initial position.
*aResult = kidPosition + aFrame->GetLogicalUsedBorder(aWM).BStart(aWM);
// Don't want to move the line's block positioning, but the baseline
// needs to be clamped (See bug 1791069).
aResult->mBaseline = std::clamp(aResult->mBaseline, 0,
aFrame->GetLogicalSize(aWM).BSize(aWM));
return true;
}
return false;
@ -5940,9 +5941,9 @@ bool nsLayoutUtils::GetLastLineBaseline(WritingMode aWM, const nsIFrame* aFrame,
// Go from scrolled frame to scrollable frame position.
*aResult += aFrame->GetLogicalUsedBorder(aWM).BStart(aWM);
const auto maxBaseline = aFrame->GetLogicalSize(aWM).BSize(aWM);
// If out of range, let the caller decide on how to syhthesize the
// baseline.
return *aResult <= maxBaseline && *aResult >= 0;
// Clamp the last baseline to border (See bug 1791069).
*aResult = std::clamp(*aResult, 0, maxBaseline);
return true;
}
// No baseline.
return false;
@ -5960,7 +5961,8 @@ bool nsLayoutUtils::GetLastLineBaseline(WritingMode aWM, const nsIFrame* aFrame,
*aResult = kidBaseline +
kid->GetLogicalNormalPosition(aWM, containerSize).B(aWM);
return true;
} else if (kid->IsScrollFrame()) {
}
if (kid->IsScrollFrame()) {
// Defer to nsIFrame::GetLogicalBaseline (which synthesizes a baseline
// from the margin-box).
kidBaseline = kid->GetLogicalBaseline(aWM);

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

@ -1341,8 +1341,11 @@ nscoord nsHTMLScrollFrame::GetLogicalBaseline(WritingMode aWritingMode) const {
// because the scrolled frame handles our padding.)
LogicalMargin border = GetLogicalUsedBorder(aWritingMode);
return border.BStart(aWritingMode) +
mHelper.mScrolledFrame->GetLogicalBaseline(aWritingMode);
// Clamp the baseline to the border rect. See bug 1791069.
return std::clamp(
border.BStart(aWritingMode) +
mHelper.mScrolledFrame->GetLogicalBaseline(aWritingMode),
0, GetLogicalSize().BSize(aWritingMode));
}
void nsHTMLScrollFrame::AdjustForPerspective(nsRect& aScrollableOverflow) {

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

@ -4,11 +4,23 @@
[.target > * 3]
expected: FAIL
[.target > * 4]
expected: FAIL
[.target > * 15]
expected: FAIL
[.target > * 16]
expected: FAIL
[.target > * 19]
expected: FAIL
[.target > * 20]
expected: FAIL
[.target > * 23]
expected: FAIL
[.target > * 24]
expected: FAIL

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

@ -1,14 +0,0 @@
[flex-align-baseline-overflow-001.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[.target > * 6]
expected: FAIL
[.target > * 7]
expected: FAIL
[.target > * 8]
expected: FAIL
[.target > * 9]
expected: FAIL

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

@ -1,14 +0,0 @@
[flex-align-baseline-overflow-002.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[.target > * 5]
expected: FAIL
[.target > * 7]
expected: FAIL
[.target > * 10]
expected: FAIL
[.target > * 11]
expected: FAIL

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

@ -1,17 +0,0 @@
[flex-align-baseline-overflow-003.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[.target > * 6]
expected: FAIL
[.target > * 7]
expected: FAIL
[.target > * 8]
expected: FAIL
[.target > * 9]
expected: FAIL
[.target > * 11]
expected: FAIL

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

@ -4,6 +4,9 @@
[.target > * 3]
expected: FAIL
[.target > * 4]
expected: FAIL
[.target > * 13]
expected: FAIL
@ -13,6 +16,11 @@
[.target > * 15]
expected: FAIL
[.target > * 16]
expected:
if (os == "android"): [OK, TIMEOUT]
FAIL
[.target > * 17]
expected: FAIL
@ -22,6 +30,11 @@
[.target > * 19]
expected: FAIL
[.target > * 20]
expected:
if (os == "android"): [OK, TIMEOUT]
FAIL
[.target > * 21]
expected: FAIL
@ -30,3 +43,8 @@
[.target > * 23]
expected: FAIL
[.target > * 24]
expected:
if (os == "android"): [OK, TIMEOUT]
FAIL

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

@ -1,17 +0,0 @@
[grid-align-baseline-overflow-001.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[.target > * 6]
expected: FAIL
[.target > * 7]
expected: FAIL
[.target > * 8]
expected: FAIL
[.target > * 9]
expected: FAIL
[.target > * 11]
expected: FAIL

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

@ -1,12 +0,0 @@
[grid-align-baseline-overflow-002.html]
[.target > * 3]
expected: [FAIL, PASS]
[.target > * 5]
expected: FAIL
[.target > * 7]
expected: FAIL
[.target > * 10]
expected: FAIL

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

@ -1,14 +0,0 @@
[grid-align-baseline-overflow-003.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[.target > * 6]
expected: FAIL
[.target > * 7]
expected: FAIL
[.target > * 8]
expected: FAIL
[.target > * 9]
expected: FAIL