From 3678a3f43059225b3fa804298c19bca8abde8899 Mon Sep 17 00:00:00 2001 From: Alexandru Marc Date: Thu, 16 Jan 2025 07:56:47 +0200 Subject: [PATCH] Backed out 5 changesets (bug 1941175) for causing reftest failures @ details-display-inline.html CLOSED TREE Backed out changeset e908e40ae014 (bug 1941175) Backed out changeset f0ddddc22390 (bug 1941175) Backed out changeset 7e16ac152467 (bug 1941175) Backed out changeset e5ff999da3c5 (bug 1941175) Backed out changeset 1509d43843a0 (bug 1941175) --- dom/base/nsDOMWindowUtils.cpp | 15 ++- dom/interfaces/base/nsIDOMWindowUtils.idl | 11 +- .../apz/test/mochitest/apz_test_utils.js | 7 +- gfx/layers/apz/test/mochitest/browser.toml | 6 - .../browser_test_paint_skip_in_popup.js | 119 ------------------ .../mochitest/helper_paint_skip_in_popup.html | 33 ----- layout/generic/ScrollContainerFrame.cpp | 2 +- widget/PuppetWidget.cpp | 4 - widget/PuppetWidget.h | 1 - widget/nsBaseWidget.cpp | 5 - widget/nsBaseWidget.h | 1 - widget/nsIWidget.h | 5 - 12 files changed, 15 insertions(+), 194 deletions(-) delete mode 100644 gfx/layers/apz/test/mochitest/browser_test_paint_skip_in_popup.js delete mode 100644 gfx/layers/apz/test/mochitest/helper_paint_skip_in_popup.html diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index e0f43131cafb..92f3b5cc0ccd 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -4176,9 +4176,8 @@ nsDOMWindowUtils::GetContentAPZTestData( NS_IMETHODIMP nsDOMWindowUtils::GetCompositorAPZTestData( - Element* aElement, JSContext* aContext, - JS::MutableHandle aOutCompositorTestData) { - if (nsIWidget* widget = GetWidgetForElement(aElement)) { + JSContext* aContext, JS::MutableHandle aOutCompositorTestData) { + if (nsIWidget* widget = GetWidget()) { WindowRenderer* renderer = widget->GetWindowRenderer(); if (!renderer) { return NS_OK; @@ -4817,12 +4816,16 @@ nsDOMWindowUtils::IsCoepCredentialless(bool* aResult) { } NS_IMETHODIMP -nsDOMWindowUtils::GetLayersId(Element* aElement, uint64_t* aOutLayersId) { - nsIWidget* widget = GetWidgetForElement(aElement); +nsDOMWindowUtils::GetLayersId(uint64_t* aOutLayersId) { + nsIWidget* widget = GetWidget(); if (!widget) { return NS_ERROR_FAILURE; } - *aOutLayersId = (uint64_t)widget->GetLayersId(); + BrowserChild* child = widget->GetOwningBrowserChild(); + if (!child) { + return NS_ERROR_FAILURE; + } + *aOutLayersId = (uint64_t)child->GetLayersId(); return NS_OK; } diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index a5e8ad6aef38..8ddde6e5de31 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -2007,12 +2007,7 @@ interface nsIDOMWindowUtils : nsISupports { * The return values are of type APZTestData (see APZTestData.webidl). */ [implicit_jscontext] jsval getContentAPZTestData(); - - /* - * |aElement| is an optional argument for popup window where APZ is enabled. - * |aElement| would be a popup element for popup - */ - [implicit_jscontext] jsval getCompositorAPZTestData([optional] in Element aElement); + [implicit_jscontext] jsval getCompositorAPZTestData(); /** * Posts an RestyleHint::RESTYLE_SELF restyle event for the given element. @@ -2314,9 +2309,7 @@ interface nsIDOMWindowUtils : nsISupports { void syncFlushCompositor(); - // |aElement| is an optional argument for popup window where APZ is enabled. - // |aElement| would be a popup element for popup. - unsigned long long getLayersId([optional] in Element aElement); + unsigned long long getLayersId(); // Returns true if we are effectively throttling frame requests. readonly attribute boolean effectivelyThrottlesFrameRequests; diff --git a/gfx/layers/apz/test/mochitest/apz_test_utils.js b/gfx/layers/apz/test/mochitest/apz_test_utils.js index 208b2ef322e8..39c6e21aa9b3 100644 --- a/gfx/layers/apz/test/mochitest/apz_test_utils.js +++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js @@ -1215,12 +1215,11 @@ async function cancelScrollAnimation(aElement, aWindow = window) { await aWindow.promiseApzFlushedRepaints(); } -function collectSampledScrollOffsets(aElement, aPopupElement = null) { - let data = - SpecialPowers.DOMWindowUtils.getCompositorAPZTestData(aPopupElement); +function collectSampledScrollOffsets(aElement) { + let data = SpecialPowers.DOMWindowUtils.getCompositorAPZTestData(); let sampledResults = data.sampledResults; - const layersId = SpecialPowers.DOMWindowUtils.getLayersId(aPopupElement); + const layersId = SpecialPowers.DOMWindowUtils.getLayersId(); const scrollId = SpecialPowers.DOMWindowUtils.getViewId(aElement); return sampledResults.filter( diff --git a/gfx/layers/apz/test/mochitest/browser.toml b/gfx/layers/apz/test/mochitest/browser.toml index 9b13b7862305..106246f94fe3 100644 --- a/gfx/layers/apz/test/mochitest/browser.toml +++ b/gfx/layers/apz/test/mochitest/browser.toml @@ -54,12 +54,6 @@ skip-if = [ ["browser_test_mousemove_optimization.js"] skip-if = ["display == 'wayland' && os_version == '22.04'"] # Bug 1857059 -["browser_test_paint_skip_in_popup.js"] -support-files = ["helper_paint_skip_in_popup.html"] -skip-if = [ - "os == 'mac'", # On Mac popup windows having no remote content doesn't have the compositor -] - ["browser_test_popup_menu_in_parent_process.js"] support-files = [ "helper_popup_menu_in_parent_process-1.html", diff --git a/gfx/layers/apz/test/mochitest/browser_test_paint_skip_in_popup.js b/gfx/layers/apz/test/mochitest/browser_test_paint_skip_in_popup.js deleted file mode 100644 index 2eb6a6dafbf5..000000000000 --- a/gfx/layers/apz/test/mochitest/browser_test_paint_skip_in_popup.js +++ /dev/null @@ -1,119 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -Services.scriptloader.loadSubScript( - "chrome://mochikit/content/tests/SimpleTest/paint_listener.js", - this -); - -Services.scriptloader.loadSubScript( - new URL("apz_test_utils.js", gTestPath).href, - this -); - -/* import-globals-from helper_browser_test_utils.js */ -// For openSelectPopup. -Services.scriptloader.loadSubScript( - new URL("helper_browser_test_utils.js", gTestPath).href, - this -); - -// Cleanup for paint_listener.js. -add_task(() => { - registerCleanupFunction(() => { - delete window.waitForAllPaintsFlushed; - delete window.waitForAllPaints; - delete window.promiseAllPaintsDone; - }); -}); - -// Setup preferences. -add_task(async () => { - await SpecialPowers.pushPrefEnv({ - set: [ - ["apz.popups.enabled", true], - ["apz.popups_without_remote.enabled", true], - ["apz.test.logging_enabled", true], - ["layout.scroll.disable-pixel-alignment", true], - ], - }); -}); - -add_task(async () => { - function httpURL(filename) { - let chromeURL = getRootDirectory(gTestPath) + filename; - return chromeURL.replace( - "chrome://mochitests/content/", - "http://mochi.test:8888/" - ); - } - const url = httpURL("helper_paint_skip_in_popup.html"); - const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); - - await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { - await content.wrappedJSObject.promiseApzFlushedRepaints(); - await content.wrappedJSObject.waitUntilApzStable(); - }); - - // Focus to the select element. This stuff is necessary for `openSelectPopup()` - // since the function is triggered on the focused element. - await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { - const select = content.document.querySelector("select"); - const focusPromise = new Promise(resolve => { - select.addEventListener("focus", resolve, { once: true }); - }); - select.focus(); - await focusPromise; - }); - - // Open the select popup. - const selectPopup = await openSelectPopup(); - - const arrowscrollbox = selectPopup.shadowRoot.querySelector("arrowscrollbox"); - ok(arrowscrollbox, "There's inside the popup"); - - const scrollbox = arrowscrollbox.shadowRoot.querySelector("scrollbox"); - ok(scrollbox, "There's inside the popup"); - - // Scroll down as much as possible to get the max scroll offset. - scrollbox.scrollTo(0, 100000); - const scrollMax = scrollbox.scrollTop; - ok(scrollMax, "The max scroll offset should not be zero"); - - // Restore the scroll offset. - // Note that this restoring needs to be done in the same paint where the above scrollTo happened so that - // APZ will never sample the max scroll offset at this moment. - scrollbox.scrollTo(0, 0); - await promiseApzFlushedRepaints(selectPopup); - - // Now scroll to a position which is close to the bottom. - scrollbox.scrollBy(0, scrollMax - 10); - await promiseApzFlushedRepaints(selectPopup); - - // Try to scroll to the bottom with a `scrollBy` call, even if paint-skip - // is enabled, this scroll operation should be reflected to APZ. - scrollbox.scrollBy(0, 10); - - // Wait a bit to make sure that APZ has sampled the new scroll offset. - await promiseApzFlushedRepaints(selectPopup); - await promiseApzFlushedRepaints(selectPopup); - - is( - scrollbox.scrollTop, - scrollMax, - `The scroll offset: ${scrollbox.scrollTop} on the main-thread should be ${scrollMax}` - ); - - const sampledData = collectSampledScrollOffsets(scrollbox, selectPopup); - ok(sampledData.length, "There should be at least one collected offsets"); - ok( - sampledData.some( - data => SpecialPowers.wrap(data).scrollOffsetY == scrollMax - ), - `There should be ${scrollMax} in [${sampledData.map(data => SpecialPowers.wrap(data).scrollOffsetY)}]` - ); - - BrowserTestUtils.removeTab(tab); -}); diff --git a/gfx/layers/apz/test/mochitest/helper_paint_skip_in_popup.html b/gfx/layers/apz/test/mochitest/helper_paint_skip_in_popup.html deleted file mode 100644 index b057c1e3ebe2..000000000000 --- a/gfx/layers/apz/test/mochitest/helper_paint_skip_in_popup.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - Dropdown with 1000 Random Items - - -

Dropdown with 1000 Random Elements

- - - - - - diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp index f3c54681a03a..132504f526ba 100644 --- a/layout/generic/ScrollContainerFrame.cpp +++ b/layout/generic/ScrollContainerFrame.cpp @@ -3160,7 +3160,7 @@ void ScrollContainerFrame::ScrollToImpl( schedulePaint = false; PAINT_SKIP_LOG("Skipping due to APZ scroll\n"); } else if (mScrollableByAPZ) { - nsIWidget* widget = GetNearestWidget(); + nsIWidget* widget = presContext->GetNearestWidget(); WindowRenderer* renderer = widget ? widget->GetWindowRenderer() : nullptr; if (renderer) { diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 4b2fcd682d83..059cdbb03be8 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -1125,9 +1125,5 @@ nsresult PuppetWidget::GetSystemFont(nsCString& aFontName) { return NS_OK; } -LayersId PuppetWidget::GetLayersId() const { - return mBrowserChild ? mBrowserChild->GetLayersId() : LayersId{0}; -} - } // namespace widget } // namespace mozilla diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index f732d2093177..24f093b6341f 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -196,7 +196,6 @@ class PuppetWidget final : public nsBaseWidget, void PaintNowIfNeeded(); BrowserChild* GetOwningBrowserChild() override { return mBrowserChild; } - LayersId GetLayersId() const override; void UpdateBackingScaleCache(float aDpi, int32_t aRounding, double aScale) { mDPI = aDpi; diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 446f3264418d..c7ec10d07fc0 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -2494,11 +2494,6 @@ bool nsBaseWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput) { return true; } -LayersId nsBaseWidget::GetLayersId() const { - return mCompositorSession ? mCompositorSession->RootLayerTreeId() - : LayersId{0}; -} - const IMENotificationRequests& nsIWidget::IMENotificationRequestsRef() { TextEventDispatcher* dispatcher = GetTextEventDispatcher(); return dispatcher->IMENotificationRequestsRef(); diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 6cb2dfe87af0..44708fe667e4 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -200,7 +200,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { nsresult MakeFullScreen(bool aFullScreen) override; void InfallibleMakeFullScreen(bool aFullScreen); - LayersId GetLayersId() const override; WindowRenderer* GetWindowRenderer() override; bool HasWindowRenderer() const final { return !!mWindowRenderer; } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 3ce36547c060..daebadcb136a 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1887,11 +1887,6 @@ class nsIWidget : public nsISupports { */ virtual BrowserChild* GetOwningBrowserChild() { return nullptr; } - /* - * Returns the layersId for this widget. - */ - virtual LayersId GetLayersId() const = 0; - /** * If this isn't directly compositing to its window surface, * return the compositor which is doing that on our behalf.