From b9461281f6d71b30cc8e3e2a04361de0810fb9b5 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 4 Apr 2024 23:54:06 +0000 Subject: [PATCH] Bug 1888861 - Wait for resize events in the parent process document for ZoomToFocusInput. r=geckoview-reviewers,m_kato Differential Revision: https://phabricator.services.mozilla.com/D206203 --- .../android/actors/GeckoViewContentChild.sys.mjs | 31 +------------- .../modules/geckoview/GeckoViewContent.sys.mjs | 48 ++++++++++++++++++---- .../interactive-content.html.ini | 2 +- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/mobile/android/actors/GeckoViewContentChild.sys.mjs b/mobile/android/actors/GeckoViewContentChild.sys.mjs index 97691c97fdb3..f961aba42d59 100644 --- a/mobile/android/actors/GeckoViewContentChild.sys.mjs +++ b/mobile/android/actors/GeckoViewContentChild.sys.mjs @@ -154,36 +154,7 @@ export class GeckoViewContentChild extends GeckoViewActorChild { }, "apz-repaints-flushed"); }; - const { force } = message.data; - - let gotResize = false; - const onResize = function () { - gotResize = true; - if (dwu.isMozAfterPaintPending) { - contentWindow.windowRoot.addEventListener( - "MozAfterPaint", - () => zoomToFocusedInput(), - { capture: true, once: true } - ); - } else { - zoomToFocusedInput(); - } - }; - - contentWindow.addEventListener("resize", onResize, { capture: true }); - - // When the keyboard is displayed, we can get one resize event, - // multiple resize events, or none at all. Try to handle all these - // cases by allowing resizing within a set interval, and still zoom to - // input if there is no resize event at the end of the interval. - contentWindow.setTimeout(() => { - contentWindow.removeEventListener("resize", onResize, { - capture: true, - }); - if (!gotResize && force) { - onResize(); - } - }, 500); + zoomToFocusedInput(); break; } case "RestoreSessionState": { diff --git a/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs b/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs index 240aea0cbe59..35ffb76d90be 100644 --- a/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs @@ -193,14 +193,48 @@ export class GeckoViewContent extends GeckoViewModule { } break; } - case "GeckoView:ZoomToInput": - // For ZoomToInput we just need to send the message to the current focused one. - const actor = - Services.focus.focusedContentBrowsingContext.currentWindowGlobal.getActor( - "GeckoViewContent" - ); - actor.sendAsyncMessage(aEvent, aData); + case "GeckoView:ZoomToInput": { + const sendZoomToFocusedInputMessage = function () { + // For ZoomToInput we just need to send the message to the current focused one. + const actor = + Services.focus.focusedContentBrowsingContext.currentWindowGlobal.getActor( + "GeckoViewContent" + ); + + actor.sendAsyncMessage(aEvent, aData); + }; + + const { force } = aData; + let gotResize = false; + const onResize = function () { + gotResize = true; + if (this.window.windowUtils.isMozAfterPaintPending) { + this.window.addEventListener( + "MozAfterPaint", + () => sendZoomToFocusedInputMessage(), + { capture: true, once: true } + ); + } else { + sendZoomToFocusedInputMessage(); + } + }; + + this.window.addEventListener("resize", onResize, { capture: true }); + + // When the keyboard is displayed, we can get one resize event, + // multiple resize events, or none at all. Try to handle all these + // cases by allowing resizing within a set interval, and still zoom to + // input if there is no resize event at the end of the interval. + this.window.setTimeout(() => { + this.window.removeEventListener("resize", onResize, { + capture: true, + }); + if (!gotResize && force) { + onResize(); + } + }, 500); break; + } case "GeckoView:ScrollBy": // Unclear if that actually works with oop iframes? this.sendToAllChildren(aEvent, aData); diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-summary-element/interactive-content.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-summary-element/interactive-content.html.ini index 6c1cbb561ee6..c38bdcdda2b2 100644 --- a/testing/web-platform/meta/html/semantics/interactive-elements/the-summary-element/interactive-content.html.ini +++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-summary-element/interactive-content.html.ini @@ -1,3 +1,4 @@ +prefs: [apz.zoom-to-focused-input.enabled:false] [interactive-content.html] expected: if (os == "mac") and not debug: TIMEOUT @@ -23,7 +24,6 @@ expected: if (os == "mac") and not debug: [NOTRUN, PASS] if (os == "linux") and not debug: NOTRUN - if os == "android": FAIL [Clicking an doesn't open
] expected: -- 2.11.4.GIT