Backed out 5 changesets (bug 1649440) for causing reftest failures in zoom-to-focus-input-oopif.html CLOSED TREE

Backed out changeset 4cca72b5cd90 (bug 1649440)
Backed out changeset a4ee97519b88 (bug 1649440)
Backed out changeset 4c44cb1968ae (bug 1649440)
Backed out changeset 9f29d5bbcaa7 (bug 1649440)
Backed out changeset 677d0763ba27 (bug 1649440)
This commit is contained in:
Cristian Tuns 2023-08-28 23:01:46 -04:00
parent bed9848763
commit fccd8c0ac9
16 changed files with 43 additions and 277 deletions

View File

@ -3097,7 +3097,7 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
layers::TouchActionHelper::GetAllowedTouchBehaviorForFrame(
element->GetPrimaryFrame());
uint32_t flags = layers::DISABLE_ZOOM_OUT | layers::ZOOM_TO_FOCUSED_INPUT;
uint32_t flags = layers::DISABLE_ZOOM_OUT;
if (!Preferences::GetBool("formhelper.autozoom") ||
Preferences::GetBool("formhelper.autozoom.force-disable.test-only",
/* aFallback = */ false) ||
@ -3140,6 +3140,8 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
return NS_OK;
}
bounds.Inflate(15.0f, 0.0f);
bool waitForRefresh = false;
for (nsIScrollableFrame* scrollAncestor :
CollectScrollableAncestors(element->GetPrimaryFrame())) {

View File

@ -37,7 +37,6 @@ enum ZoomToRectBehavior : uint32_t {
DISABLE_ZOOM_OUT = 1 << 0,
PAN_INTO_VIEW_ONLY = 1 << 1,
ONLY_ZOOM_TO_DEFAULT_SCALE = 1 << 2,
ZOOM_TO_FOCUSED_INPUT = 1 << 3,
};
enum class BrowserGestureResponse : bool;

View File

@ -2411,26 +2411,6 @@ void APZCTreeManager::ZoomToRect(const ScrollableLayerGuid& aGuid,
APZThreadUtils::AssertOnControllerThread();
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
if (aFlags & ZOOM_TO_FOCUSED_INPUT) {
// In the case of ZoomToFocusInput the targetRect is in the in-process root
// content coordinates. We need to convert it to the top level content
// coordiates.
if (apzc) {
CSSRect transformedRect =
ConvertRectInApzcToRoot(apzc, aZoomTarget.targetRect);
transformedRect.Inflate(15.0f, 0.0f);
// Note that ZoomToFocusedInput doesn't use the other fields of
// ZoomTarget.
ZoomTarget zoomTarget{transformedRect};
apzc = FindZoomableApzc(apzc);
if (apzc) {
apzc->ZoomToRect(zoomTarget, aFlags);
}
}
return;
}
if (apzc) {
apzc->ZoomToRect(aZoomTarget, aFlags);
}
@ -3194,43 +3174,43 @@ ScreenToParentLayerMatrix4x4 APZCTreeManager::GetScreenToApzcTransform(
* See the long comment above GetScreenToApzcTransform() for a detailed
* explanation of this function.
*/
ParentLayerToParentLayerMatrix4x4 APZCTreeManager::GetApzcToApzcTransform(
const AsyncPanZoomController* aStartApzc,
const AsyncPanZoomController* aStopApzc,
ParentLayerToScreenMatrix4x4 APZCTreeManager::GetApzcToGeckoTransform(
const AsyncPanZoomController* aApzc,
const AsyncTransformComponents& aComponents) const {
Matrix4x4 result;
RecursiveMutexAutoLock lock(mTreeLock);
// The comments below assume there is a chain of layers L..R with L and P
// having APZC instances as explained in the comment above, and |aStopApzc| is
// nullptr. This function is called with aStartApzc at L, and the loop below
// performs one iteration, where parent is at P. The comments explain what
// values are stored in the variables at these two levels. All the comments
// use standard matrix notation where the leftmost matrix in a multiplication
// is applied first.
// having APZC instances as explained in the comment above. This function is
// called with aApzc at L, and the loop below performs one iteration, where
// parent is at P. The comments explain what values are stored in the
// variables at these two levels. All the comments use standard matrix
// notation where the leftmost matrix in a multiplication is applied first.
// asyncUntransform is LA.Inverse()
Matrix4x4 asyncUntransform = aStartApzc
Matrix4x4 asyncUntransform = aApzc
->GetAsyncTransformForInputTransformation(
aComponents, aStartApzc->GetLayersId())
aComponents, aApzc->GetLayersId())
.Inverse()
.ToUnknownMatrix();
// result is initialized to LA.Inverse() * LD * MC * NC * OC * PC
// aTransformToGeckoOut is initialized to LA.Inverse() * LD * MC * NC * OC *
// PC
result = asyncUntransform *
aStartApzc->GetTransformToLastDispatchedPaint(
aComponents, aStartApzc->GetLayersId()) *
aStartApzc->GetAncestorTransform();
aApzc->GetTransformToLastDispatchedPaint(aComponents,
aApzc->GetLayersId()) *
aApzc->GetAncestorTransform();
for (AsyncPanZoomController* parent = aStartApzc->GetParent();
parent && parent != aStopApzc; parent = parent->GetParent()) {
// result is LA.Inverse() * LD * MC * NC * OC * PC * PD * QC * RC
for (AsyncPanZoomController* parent = aApzc->GetParent(); parent;
parent = parent->GetParent()) {
// aTransformToGeckoOut is LA.Inverse() * LD * MC * NC * OC * PC * PD * QC *
// RC
//
// Note: Do not pass the async transform components for the current target
// to the parent.
result = result *
parent->GetTransformToLastDispatchedPaint(
LayoutAndVisual, aStartApzc->GetLayersId()) *
parent->GetTransformToLastDispatchedPaint(LayoutAndVisual,
aApzc->GetLayersId()) *
parent->GetAncestorTransform();
// The above value for result when parent == P matches the required output
@ -3238,15 +3218,7 @@ ParentLayerToParentLayerMatrix4x4 APZCTreeManager::GetApzcToApzcTransform(
// terms are guaranteed to be identity transforms.
}
return ViewAs<ParentLayerToParentLayerMatrix4x4>(result);
}
ParentLayerToScreenMatrix4x4 APZCTreeManager::GetApzcToGeckoTransform(
const AsyncPanZoomController* aApzc,
const AsyncTransformComponents& aComponents) const {
return ViewAs<ParentLayerToScreenMatrix4x4>(
GetApzcToApzcTransform(aApzc, nullptr, aComponents),
PixelCastJustification::ScreenIsParentLayerForRoot);
return ViewAs<ParentLayerToScreenMatrix4x4>(result);
}
ParentLayerToScreenMatrix4x4 APZCTreeManager::GetApzcToGeckoTransformForHit(
@ -3260,49 +3232,6 @@ ParentLayerToScreenMatrix4x4 APZCTreeManager::GetApzcToGeckoTransformForHit(
return GetApzcToGeckoTransform(aHitResult.mTargetApzc, components);
}
ParentLayerToParentLayerMatrix4x4
APZCTreeManager::GetOopifApzcToRootContentApzcTransform(
AsyncPanZoomController* aApzc) const {
ParentLayerToParentLayerMatrix4x4 result;
MOZ_ASSERT(aApzc->IsRootForLayersId());
RefPtr<AsyncPanZoomController> rootContentApzc = FindZoomableApzc(aApzc);
MOZ_ASSERT(aApzc->GetLayersId() != rootContentApzc->GetLayersId(),
"aApzc must be out-of-process of the rootContentApzc");
if (!rootContentApzc || rootContentApzc == aApzc ||
rootContentApzc->GetLayersId() == aApzc->GetLayersId()) {
return result;
}
return GetApzcToApzcTransform(aApzc, rootContentApzc,
AsyncTransformComponent::eLayout) *
// We need to multiply by the root content APZC's
// GetPaintedResolutionTransform() here; See
// https://phabricator.services.mozilla.com/D184440?vs=755900&id=757585#6173584
// for the details.
ViewAs<AsyncTransformComponentMatrix>(
rootContentApzc->GetPaintedResolutionTransform());
}
CSSRect APZCTreeManager::ConvertRectInApzcToRoot(AsyncPanZoomController* aApzc,
const CSSRect& aRect) const {
MOZ_ASSERT(aApzc->IsRootForLayersId());
RefPtr<AsyncPanZoomController> rootContentApzc = FindZoomableApzc(aApzc);
if (!rootContentApzc || rootContentApzc == aApzc) {
return aRect;
}
ParentLayerRect rectInParent = aRect * aApzc->GetZoom();
ParentLayerRect rectInRoot =
GetOopifApzcToRootContentApzcTransform(aApzc).TransformBounds(
rectInParent);
if (rootContentApzc->GetZoom() != CSSToParentLayerScale(0)) {
return rectInRoot / rootContentApzc->GetZoom();
}
return rectInRoot / CSSToParentLayerScale(1);
}
ScreenPoint APZCTreeManager::GetCurrentMousePosition() const {
auto pos = mCurrentMousePosition.Lock();
return pos.ref();

View File

@ -565,37 +565,6 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
ParentLayerToScreenMatrix4x4 GetApzcToGeckoTransform(
const AsyncPanZoomController* aApzc,
const AsyncTransformComponents& aComponents) const;
/*
* A common utility function used for GetApzcToGeckoTransform and
* GetOopifApzcToRootContentApzcTransform.
*
* NOTE: The matrix returned by this function can NOT be used to convert
* metrics in |aStartApzc| to |aStopApzc|. If you want the conversion matrix,
* you will have to use either GetApzcToGeckoTransform or
* GetOopifApzcToRootContentApzcTransform.
*/
ParentLayerToParentLayerMatrix4x4 GetApzcToApzcTransform(
const AsyncPanZoomController* aStartApzc,
const AsyncPanZoomController* aStopApzc,
const AsyncTransformComponents& aComponents) const;
/*
* Returns the transform matrix from |aApzc| to the root content APZC of
* |aApzc|.
* |aApzc| must be the root APZC of an out-of-process iframe.
*/
ParentLayerToParentLayerMatrix4x4 GetOopifApzcToRootContentApzcTransform(
AsyncPanZoomController* aApzc) const;
/**
* Convert the given |aRect| in the document coordinates of |aApzc| to the top
* level document coordinates.
* |aApzc| must be an in-process root APZC.
*/
CSSRect ConvertRectInApzcToRoot(AsyncPanZoomController* aApzc,
const CSSRect& aRect) const;
ScreenPoint GetCurrentMousePosition() const;
void SetCurrentMousePosition(const ScreenPoint& aNewPos);

View File

@ -1274,11 +1274,6 @@ class AsyncPanZoomController {
return mScrollMetadata.GetMetrics().GetScrollableRect();
}
CSSToParentLayerScale GetZoom() const {
RecursiveMutexAutoLock lock(mRecursiveMutex);
return Metrics().GetZoom();
}
// Returns the delta for the given InputData.
ParentLayerPoint GetDeltaForEvent(const InputData& aEvent) const;

View File

@ -2,9 +2,6 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="helper_subframe_style.css"/>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script src="apz_test_utils.js"></script>
</head>
<body>
<div style="height: 8000px;">ABC</div>

View File

@ -9,92 +9,55 @@
</head>
<body>
<div style="height: 8000px;">ABC</div>
<iframe style="height: 30em;"></iframe>
<iframe style="height: 30em;" src="helper_iframe_textarea.html"></iframe>
</div>
<!-- Leave additional room below the element so it can be scrolled to the center -->
<div style="height: 1000px;">ABC</div>
<script type="application/javascript">
async function test() {
let isCrossOrigin = (location.search == "?cross-origin");
let iframeURL =
SimpleTest.getTestFileURL("helper_iframe_textarea.html")
if (isCrossOrigin) {
iframeURL.replace(window.location.origin, "https://example.com/");
}
let utils = SpecialPowers.getDOMWindowUtils(window);
let iframe = document.querySelector("iframe");
const iframeLoadPromise = promiseOneEvent(iframe, "load", null);
iframe.src = iframeURL;
await iframeLoadPromise;
let textarea = iframe.contentDocument.querySelector("textarea");
for (let i = 0; i < 20; i++) {
textarea.value += "foo\n";
}
await SpecialPowers.spawn(iframe, [], async () => {
await content.wrappedJSObject.waitUntilApzStable();
});
let win = iframe.contentWindow;
iframe.focus();
textarea.focus();
await SpecialPowers.spawn(iframe, [], async () => {
let textarea = content.document.querySelector("textarea");
for (let i = 0; i < 20; i++) {
textarea.value += "foo\n";
}
textarea.focus();
});
await SpecialPowers.spawn(iframe, [], async () => {
await content.wrappedJSObject.waitToClearOutAnyPotentialScrolls(content.window);
});
await SpecialPowers.spawn(iframe, [], async () => {
let textarea = content.document.querySelector("textarea");
textarea.setSelectionRange(0, 0);
});
await waitToClearOutAnyPotentialScrolls(win);
textarea.setSelectionRange(0, 0);
window.scrollTo(0, 0);
await SpecialPowers.spawn(iframe, [], async () => {
await content.wrappedJSObject.waitToClearOutAnyPotentialScrolls(content.window);
});
await waitToClearOutAnyPotentialScrolls(win);
is(0, window.scrollY, "scroll position is reset");
let transformEndPromise = promiseTransformEnd();
await SpecialPowers.spawn(iframe, [], async () => {
SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
});
utils.zoomToFocusedInput();
await promiseApzFlushedRepaints();
ok(window.scrollY > 0, "scroll position isn't top");
let iframeWindowScrollY = await SpecialPowers.spawn(iframe, [], () => {
return content.window.scrollY;
});
ok(iframeWindowScrollY > 0, "scroll position into iframe isn't top");
ok(iframe.contentWindow.scrollY > 0, "scroll position into iframe isn't top");
let prevPosY = window.scrollY;
await transformEndPromise;
await promiseApzFlushedRepaints();
window.scrollTo(0, 0);
await SpecialPowers.spawn(iframe, [], async () => {
await content.wrappedJSObject.waitToClearOutAnyPotentialScrolls(content.window);
});
await waitToClearOutAnyPotentialScrolls(win);
is(0, window.scrollY, "scroll position is reset");
SpecialPowers.spawn(iframe, [], async () => {
let textarea = content.document.querySelector("textarea");
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
});
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
transformEndPromise = promiseTransformEnd();
await SpecialPowers.spawn(iframe, [], async () => {
SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
});
utils.zoomToFocusedInput();
await transformEndPromise;
await promiseApzFlushedRepaints();
ok(window.scrollY > 0, "scroll position isn't top");
iframeWindowScrollY = await SpecialPowers.spawn(iframe, [], () => {
return content.window.scrollY;
});
ok(iframeWindowScrollY > 0, "scroll position into iframe isn't top");
ok(iframe.contentWindow.scrollY > 0, "scroll position into iframe isn't top");
ok(prevPosY < window.scrollY,
"scroll position is different from first line of textarea");
}

View File

@ -13,7 +13,6 @@ var subtests = [
{"file": "helper_zoomToFocusedInput_scroll.html"},
{"file": "helper_zoomToFocusedInput_multiline.html"},
{"file": "helper_zoomToFocusedInput_iframe.html"},
{"file": "helper_zoomToFocusedInput_iframe.html?cross-origin"},
{"file": "helper_zoomToFocusedInput_fixed_bug1673511.html"},
{"file": "helper_zoomToFocusedInput_nozoom_bug1738696.html"},
];

View File

@ -48,5 +48,3 @@ pref(apz.allow_zooming,true) == iframe-zoomed.html iframe-zoomed-ref.html
pref(apz.allow_zooming,true) == scaled-iframe-zoomed.html scaled-iframe-zoomed-ref.html
== root-scrollbars-1.html root-scrollbars-1-ref.html
skip-if(Android) pref(dom.meta-viewport.enabled,true) pref(apz.allow_zooming,true) pref(formhelper.autozoom,true) HTTP == zoom-to-focus-input-oopif.html zoom-to-focus-input-oopif-ref.html

View File

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html class="reftest-wait">
<meta name="viewport" content="width=device-width">
<style>
iframe {
position: absolute;
width: 1600px;
height: 2000px;
top: 200px;
left: 100px;
}
</style>
<iframe src="zoom-to-focus-input-subframe.html"></iframe>
<script>
document.addEventListener('MozReftestInvalidate', async () => {
const transformEndPromise = new Promise(resolve => {
SpecialPowers.Services.obs.addObserver(function observer() {
SpecialPowers.Services.obs.removeObserver(observer, "APZ:TransformEnd");
resolve();
}, "APZ:TransformEnd");
});
const iframe = document.querySelector("iframe");
const input = iframe.contentDocument.querySelector("input");
input.focus();
SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
await transformEndPromise;
document.documentElement.classList.remove('reftest-wait');
});
</script>
</html>

View File

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html class="reftest-wait">
<meta name="viewport" content="width=device-width">
<style>
iframe {
position: absolute;
width: 1600px;
height: 2000px;
top: 200px;
left: 100px;
}
</style>
<iframe src="http://example.org/zoom-to-focus-input-subframe.html"></iframe>
<script>
document.addEventListener('MozReftestInvalidate', async () => {
const transformEndPromise = new Promise(resolve => {
SpecialPowers.Services.obs.addObserver(function observer() {
SpecialPowers.Services.obs.removeObserver(observer, "APZ:TransformEnd");
resolve();
}, "APZ:TransformEnd");
});
const iframe = document.querySelector("iframe");
await SpecialPowers.spawn(iframe, [], () => {
const input = content.document.querySelector("input");
input.focus();
SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
});
await transformEndPromise;
document.documentElement.classList.remove('reftest-wait');
});
</script>
</html>

View File

@ -1,12 +0,0 @@
<!DOCTYPE html>
<style>
input {
position: absolute;
top: 100px;
left: 300px;
}
input:focus {
background-color: green;
}
</style>
<input type="text" id="input" size="10"/>

View File

@ -154,12 +154,7 @@ 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);
this.sendToAllChildren(aEvent, aData);
break;
case "GeckoView:ScrollBy":
// Unclear if that actually works with oop iframes?

View File

@ -12,4 +12,5 @@ TESTING_JS_MODULES += [
"ContentEventListenerChild.sys.mjs",
"ContentEventListenerParent.sys.mjs",
"ContentTask.sys.mjs",
"ContentTaskUtils.sys.mjs",
]

View File

@ -21,7 +21,6 @@ FINAL_TARGET_FILES.content += [
]
modules = [
"content/ContentTaskUtils.sys.mjs",
"content/MockColorPicker.sys.mjs",
"content/MockFilePicker.sys.mjs",
"content/MockPermissionPrompt.sys.mjs",