Bug 1866939 - Offset the in-process root frame scroll position layout in nsDOMWindowUtils::ZoomToFocusedInput(). r=botond

And complement it in APZCTreeManager::ConvertRectInApzcToRoot in the case of
the given APZC is the root content one.

Depends on D197259

Differential Revision: https://phabricator.services.mozilla.com/D197260
This commit is contained in:
Hiroyuki Ikezoe 2024-01-18 06:54:50 +00:00
Родитель 231270112d
Коммит 19eafbddec
4 изменённых файлов: 20 добавлений и 2 удалений

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

@ -3106,6 +3106,8 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
return NS_OK;
}
bounds -= CSSPoint::FromAppUnits(rootScrollFrame->GetScrollPosition());
bool waitForRefresh = false;
for (nsIScrollableFrame* scrollAncestor :
CollectScrollableAncestors(element->GetPrimaryFrame())) {

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

@ -3363,10 +3363,14 @@ CSSRect APZCTreeManager::ConvertRectInApzcToRoot(AsyncPanZoomController* aApzc,
const CSSRect& aRect) const {
MOZ_ASSERT(aApzc->IsRootForLayersId());
RefPtr<AsyncPanZoomController> rootContentApzc = FindZoomableApzc(aApzc);
if (!rootContentApzc || rootContentApzc == aApzc) {
if (!rootContentApzc) {
return aRect;
}
if (rootContentApzc == aApzc) {
return aRect + rootContentApzc->GetLayoutScrollOffset();
}
return GetOopifToRootContentTransform(aApzc).TransformBounds(aRect);
}

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

@ -36,13 +36,14 @@ async function setupIframe(aURL) {
});
}
let initial_resolution;
async function test(aTestFile) {
let iframeURL = SimpleTest.getTestFileURL(aTestFile);
// Load the test document in the same origin.
await setupIframe(iframeURL);
let initial_resolution = await getResolution();
initial_resolution = await getResolution();
ok(initial_resolution > 0,
"The initial_resolution is " + initial_resolution + ", which is some sane value");
@ -88,6 +89,12 @@ async function moveIframe() {
}
waitUntilApzStable()
.then(async () => test("helper_zoomToFocusedInput_iframe_subframe.html?margin-top=200vh"))
.then(async () => {
// Reset the scale to the initial value.
SpecialPowers.DOMWindowUtils.setResolutionAndScaleTo(initial_resolution);
await promiseApzFlushedRepaints();
})
// A test case where the layout scroll offset isn't zero.
.then(async () => moveIframe())
.then(async () => test("helper_zoomToFocusedInput_iframe_subframe.html"))

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

@ -2032,6 +2032,11 @@ class nsIWidget : public nsISupports {
virtual TextEventDispatcherListener*
GetNativeTextEventDispatcherListener() = 0;
/**
* Trigger an animation to zoom to the given |aRect|.
* |aRect| should be relative to the layout viewport of the widget's root
* document
*/
virtual void ZoomToRect(const uint32_t& aPresShellId,
const ScrollableLayerGuid::ViewID& aViewId,
const CSSRect& aRect, const uint32_t& aFlags) = 0;