Skip to content

Commit d449cb7

Browse files
committed
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. Differential Revision: https://phabricator.services.mozilla.com/D197260
1 parent 89c0784 commit d449cb7

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

dom/base/nsDOMWindowUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,6 +3106,8 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
31063106
return NS_OK;
31073107
}
31083108

3109+
bounds -= CSSPoint::FromAppUnits(rootScrollFrame->GetScrollPosition());
3110+
31093111
bool waitForRefresh = false;
31103112
for (nsIScrollableFrame* scrollAncestor :
31113113
CollectScrollableAncestors(element->GetPrimaryFrame())) {

gfx/layers/apz/src/APZCTreeManager.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3363,10 +3363,14 @@ CSSRect APZCTreeManager::ConvertRectInApzcToRoot(AsyncPanZoomController* aApzc,
33633363
const CSSRect& aRect) const {
33643364
MOZ_ASSERT(aApzc->IsRootForLayersId());
33653365
RefPtr<AsyncPanZoomController> rootContentApzc = FindZoomableApzc(aApzc);
3366-
if (!rootContentApzc || rootContentApzc == aApzc) {
3366+
if (!rootContentApzc) {
33673367
return aRect;
33683368
}
33693369

3370+
if (rootContentApzc == aApzc) {
3371+
return aRect + rootContentApzc->GetLayoutScrollOffset();
3372+
}
3373+
33703374
return GetOopifToRootContentTransform(aApzc).TransformBounds(aRect);
33713375
}
33723376

gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_iframe-2.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
}
8787

8888
waitUntilApzStable()
89+
.then(async () => test("helper_zoomToFocusedInput_iframe_subframe.html?margin-top=200vh"))
8990
// A test case where the layout scroll offset isn't zero.
9091
.then(async () => moveIframe())
9192
.then(async () => test("helper_zoomToFocusedInput_iframe_subframe.html"))

widget/nsIWidget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,11 @@ class nsIWidget : public nsISupports {
20322032
virtual TextEventDispatcherListener*
20332033
GetNativeTextEventDispatcherListener() = 0;
20342034

2035+
/**
2036+
* Trigger an animation to zoom to the given |aRect|.
2037+
* |aRect| should be relative to the layout viewport of the widget's root
2038+
* document
2039+
*/
20352040
virtual void ZoomToRect(const uint32_t& aPresShellId,
20362041
const ScrollableLayerGuid::ViewID& aViewId,
20372042
const CSSRect& aRect, const uint32_t& aFlags) = 0;

0 commit comments

Comments
 (0)