Bug 1858984 - Fix ComputeNeedToScroll with large line sizes. r=emilio,devtools-reviewers,ochameau

When the line scroll amount is larger than that of the rectangle to
scroll into view, do not use the line size to determine if we should
scroll.

Depends on D192869

Differential Revision: https://phabricator.services.mozilla.com/D192870
This commit is contained in:
Dan Robertson
2024-01-03 19:12:22 +00:00
parent 3365e64177
commit 516dd41c49
4 changed files with 8 additions and 4 deletions

View File

@@ -478,6 +478,7 @@ async function simulateNodeDrag(
typeof selector === "string" typeof selector === "string"
? await getContainerForSelector(selector, inspector) ? await getContainerForSelector(selector, inspector)
: selector; : selector;
container.elt.scrollIntoView(true);
const rect = container.tagLine.getBoundingClientRect(); const rect = container.tagLine.getBoundingClientRect();
const scrollX = inspector.markup.doc.documentElement.scrollLeft; const scrollX = inspector.markup.doc.documentElement.scrollLeft;
const scrollY = inspector.markup.doc.documentElement.scrollTop; const scrollY = inspector.markup.doc.documentElement.scrollTop;

View File

@@ -3326,6 +3326,13 @@ static bool ComputeNeedToScroll(WhenToScroll aWhenToScroll, nscoord aLineSize,
// The caller wants the frame as visible as possible // The caller wants the frame as visible as possible
return true; return true;
case WhenToScroll::IfNotVisible: case WhenToScroll::IfNotVisible:
if (aLineSize > (aRectMax - aRectMin)) {
// If the line size is greater than the size of the rect
// to scroll into view, do not use the line size to determine
// if we need to scroll.
aLineSize = 0;
}
// Scroll only if no part of the frame is visible in this view. // Scroll only if no part of the frame is visible in this view.
return aRectMax - aLineSize <= aViewMin || return aRectMax - aLineSize <= aViewMin ||
aRectMin + aLineSize >= aViewMax; aRectMin + aLineSize >= aViewMax;

View File

@@ -1,2 +0,0 @@
[focus-large-element-in-overflow-hidden-container.html]
expected: FAIL

View File

@@ -1,2 +0,0 @@
[focus-visible-element-in-overflow-hidden-container.html]
expected: FAIL