From 516dd41c49565521bf0511bcc9c886076d4f40c8 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Wed, 3 Jan 2024 19:12:22 +0000 Subject: [PATCH] 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 --- devtools/client/inspector/markup/test/head.js | 1 + layout/base/PresShell.cpp | 7 +++++++ ...cus-large-element-in-overflow-hidden-container.html.ini | 2 -- ...s-visible-element-in-overflow-hidden-container.html.ini | 2 -- 4 files changed, 8 insertions(+), 4 deletions(-) delete mode 100644 testing/web-platform/meta/focus/focus-large-element-in-overflow-hidden-container.html.ini delete mode 100644 testing/web-platform/meta/focus/focus-visible-element-in-overflow-hidden-container.html.ini diff --git a/devtools/client/inspector/markup/test/head.js b/devtools/client/inspector/markup/test/head.js index fb2153d5dc80..ddd04516082a 100644 --- a/devtools/client/inspector/markup/test/head.js +++ b/devtools/client/inspector/markup/test/head.js @@ -478,6 +478,7 @@ async function simulateNodeDrag( typeof selector === "string" ? await getContainerForSelector(selector, inspector) : selector; + container.elt.scrollIntoView(true); const rect = container.tagLine.getBoundingClientRect(); const scrollX = inspector.markup.doc.documentElement.scrollLeft; const scrollY = inspector.markup.doc.documentElement.scrollTop; diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 18c7d7c422e5..a39c0b88ff3a 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -3326,6 +3326,13 @@ static bool ComputeNeedToScroll(WhenToScroll aWhenToScroll, nscoord aLineSize, // The caller wants the frame as visible as possible return true; 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. return aRectMax - aLineSize <= aViewMin || aRectMin + aLineSize >= aViewMax; diff --git a/testing/web-platform/meta/focus/focus-large-element-in-overflow-hidden-container.html.ini b/testing/web-platform/meta/focus/focus-large-element-in-overflow-hidden-container.html.ini deleted file mode 100644 index 703dfe13847c..000000000000 --- a/testing/web-platform/meta/focus/focus-large-element-in-overflow-hidden-container.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[focus-large-element-in-overflow-hidden-container.html] - expected: FAIL diff --git a/testing/web-platform/meta/focus/focus-visible-element-in-overflow-hidden-container.html.ini b/testing/web-platform/meta/focus/focus-visible-element-in-overflow-hidden-container.html.ini deleted file mode 100644 index e3e234c8f16f..000000000000 --- a/testing/web-platform/meta/focus/focus-visible-element-in-overflow-hidden-container.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[focus-visible-element-in-overflow-hidden-container.html] - expected: FAIL