From bccf559d4b579599fc65b9346cd65a4c35e25171 Mon Sep 17 00:00:00 2001 From: criss Date: Wed, 25 Aug 2021 04:08:24 +0300 Subject: [PATCH] Backed out changeset 8868fe82dafd (bug 1708403) for causing failures on test_drawSnapshot_fixed.html. CLOSED TREE --- .../extensions/screenshots/background/takeshot.js | 1 - devtools/server/actors/utils/capture-screenshot.js | 3 +-- dom/canvas/test/test_drawSnapshot_fixed.html | 2 +- dom/chrome-webidl/WindowGlobalActors.webidl | 7 +------ dom/ipc/WindowGlobalParent.cpp | 4 +--- dom/ipc/WindowGlobalParent.h | 2 +- .../systemservices/video_engine/tab_capturer.cc | 2 +- gfx/ipc/CrossProcessPaint.cpp | 4 +--- gfx/ipc/CrossProcessPaint.h | 1 - .../components/extensions/parent/ext-tabs-base.js | 14 +------------- .../extensions/schemas/extension_types.json | 5 ----- 11 files changed, 8 insertions(+), 37 deletions(-) diff --git a/browser/extensions/screenshots/background/takeshot.js b/browser/extensions/screenshots/background/takeshot.js index 6ee93b2cdfff..fc21807e27a8 100644 --- a/browser/extensions/screenshots/background/takeshot.js +++ b/browser/extensions/screenshots/background/takeshot.js @@ -40,7 +40,6 @@ this.takeshot = (function() { height: pos.height, }; options.rect = rectangle; - options.resetScrollPosition = true; // To avoid creating extremely large images (which causes // performance problems), we set the devicePixelRatio to 1. diff --git a/devtools/server/actors/utils/capture-screenshot.js b/devtools/server/actors/utils/capture-screenshot.js index 02b134c3c923..a58b534b0885 100644 --- a/devtools/server/actors/utils/capture-screenshot.js +++ b/devtools/server/actors/utils/capture-screenshot.js @@ -118,8 +118,7 @@ async function captureScreenshot(args, browsingContext) { const snapshot = await browsingContext.currentWindowGlobal.drawSnapshot( rect, actualRatio, - "rgb(255,255,255)", - args.fullpage + "rgb(255,255,255)" ); const fileScale = args.fileScale || actualRatio; diff --git a/dom/canvas/test/test_drawSnapshot_fixed.html b/dom/canvas/test/test_drawSnapshot_fixed.html index 968fe0e4e0f0..4370999deff6 100644 --- a/dom/canvas/test/test_drawSnapshot_fixed.html +++ b/dom/canvas/test/test_drawSnapshot_fixed.html @@ -43,7 +43,7 @@ // be visually in the middle of the root scroll frame, but should still be at the // top of the snapshot (since snapshots with a rect are taken relative to the document). var rect = new window.DOMRect(0, 0, 500, 2000); - let image = await SpecialPowers.snapshotContext(window, rect, "rgb(255, 255, 255)", true); + let image = await SpecialPowers.snapshotContext(window, rect, "rgb(255, 255, 255)"); testWrapCx.drawImage(image, 0, 0); var refCanvas = make_canvas(); diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl index ed00b873b5ac..688210ca2ae5 100644 --- a/dom/chrome-webidl/WindowGlobalActors.webidl +++ b/dom/chrome-webidl/WindowGlobalActors.webidl @@ -128,10 +128,6 @@ interface WindowGlobalParent : WindowContext { * @param scale The scale to render the window at. Use devicePixelRatio * to have comparable rendering to the OS. * @param backgroundColor The background color to use. - * @param resetScrollPosition If true, temporarily resets the scroll position - * of the root scroll frame to 0, such that position:fixed elements are drawn - * at their initial position. This parameter only takes effect when passing a - * non-null rect. * * This API can only be used in the parent process, as content processes * cannot access the rendering of out of process iframes. This API works @@ -140,8 +136,7 @@ interface WindowGlobalParent : WindowContext { [Throws] Promise drawSnapshot(DOMRect? rect, double scale, - UTF8String backgroundColor, - optional boolean resetScrollPosition = false); + UTF8String backgroundColor); /** * Fetches the securityInfo object for this window. This function will diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 6a5f6462bae4..f2d76ca63058 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -930,7 +930,7 @@ void WindowGlobalParent::PermitUnload(std::function&& aResolver) { already_AddRefed WindowGlobalParent::DrawSnapshot( const DOMRect* aRect, double aScale, const nsACString& aBackgroundColor, - bool aResetScrollPosition, mozilla::ErrorResult& aRv) { + mozilla::ErrorResult& aRv) { nsIGlobalObject* global = GetParentObject(); RefPtr promise = Promise::Create(global, aRv); if (NS_WARN_IF(aRv.Failed())) { @@ -949,8 +949,6 @@ already_AddRefed WindowGlobalParent::DrawSnapshot( if (!aRect) { // If no explicit Rect was passed, we want the currently visible viewport. flags = gfx::CrossProcessPaintFlags::DrawView; - } else if (aResetScrollPosition) { - flags = gfx::CrossProcessPaintFlags::ResetScrollPosition; } if (!gfx::CrossProcessPaint::Start(this, aRect, (float)aScale, color, flags, diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h index 9d4d4bf7af3e..c8f35b94ca33 100644 --- a/dom/ipc/WindowGlobalParent.h +++ b/dom/ipc/WindowGlobalParent.h @@ -160,7 +160,7 @@ class WindowGlobalParent final : public WindowContext, already_AddRefed DrawSnapshot( const DOMRect* aRect, double aScale, const nsACString& aBackgroundColor, - bool aResetScrollPosition, mozilla::ErrorResult& aRv); + mozilla::ErrorResult& aRv); already_AddRefed GetSecurityInfo(ErrorResult& aRv); diff --git a/dom/media/systemservices/video_engine/tab_capturer.cc b/dom/media/systemservices/video_engine/tab_capturer.cc index b46160b03d41..37776771851f 100644 --- a/dom/media/systemservices/video_engine/tab_capturer.cc +++ b/dom/media/systemservices/video_engine/tab_capturer.cc @@ -178,7 +178,7 @@ void TabCapturer::CaptureFrameNow() { // XXX This would be more efficient if it returned a MozPromise, and // even more if we used CrossProcessPaint directly and returned a surface. RefPtr promise = - wgp->DrawSnapshot(nullptr, 1.0, "white"_ns, false, IgnoreErrors()); + wgp->DrawSnapshot(nullptr, 1.0, "white"_ns, IgnoreErrors()); if (!promise) { return; } diff --git a/gfx/ipc/CrossProcessPaint.cpp b/gfx/ipc/CrossProcessPaint.cpp index a3969b802d39..65b144d03a64 100644 --- a/gfx/ipc/CrossProcessPaint.cpp +++ b/gfx/ipc/CrossProcessPaint.cpp @@ -122,10 +122,8 @@ PaintFragment PaintFragment::Record(dom::BrowsingContext* aBc, RenderDocumentFlags renderDocFlags = RenderDocumentFlags::None; if (!(aFlags & CrossProcessPaintFlags::DrawView)) { renderDocFlags = (RenderDocumentFlags::IgnoreViewportScrolling | + RenderDocumentFlags::ResetViewportScrolling | RenderDocumentFlags::DocumentRelative); - if (aFlags & CrossProcessPaintFlags::ResetScrollPosition) { - renderDocFlags |= RenderDocumentFlags::ResetViewportScrolling; - } } // Perform the actual rendering diff --git a/gfx/ipc/CrossProcessPaint.h b/gfx/ipc/CrossProcessPaint.h index fd1df2f4061d..e7ee10931ee7 100644 --- a/gfx/ipc/CrossProcessPaint.h +++ b/gfx/ipc/CrossProcessPaint.h @@ -43,7 +43,6 @@ class CrossProcessPaint; enum class CrossProcessPaintFlags { None = 0, DrawView = 1 << 1, - ResetScrollPosition = 1 << 2, }; MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CrossProcessPaintFlags) diff --git a/toolkit/components/extensions/parent/ext-tabs-base.js b/toolkit/components/extensions/parent/ext-tabs-base.js index 0d1c1f663089..a0793d296cb3 100644 --- a/toolkit/components/extensions/parent/ext-tabs-base.js +++ b/toolkit/components/extensions/parent/ext-tabs-base.js @@ -132,20 +132,8 @@ class TabBase { let scale = options?.scale || win.devicePixelRatio; let rect = options?.rect && win.DOMRect.fromRect(options.rect); - // We only allow mozilla addons to use the resetScrollPosition option, - // since it's not standardized. - let resetScrollPosition = false; - if (!context.extension.restrictSchemes) { - resetScrollPosition = !!options?.resetScrollPosition; - } - let wgp = this.browsingContext.currentWindowGlobal; - let image = await wgp.drawSnapshot( - rect, - scale * zoom, - "white", - resetScrollPosition - ); + let image = await wgp.drawSnapshot(rect, scale * zoom, "white"); let doc = Services.appShell.hiddenDOMWindow.document; let canvas = doc.createElement("canvas"); diff --git a/toolkit/components/extensions/schemas/extension_types.json b/toolkit/components/extensions/schemas/extension_types.json index 8c2eea131c27..e94ecd9e0e62 100644 --- a/toolkit/components/extensions/schemas/extension_types.json +++ b/toolkit/components/extensions/schemas/extension_types.json @@ -45,11 +45,6 @@ "type": "number", "optional": true, "description": "The scale of the resulting image. Defaults to devicePixelRatio." - }, - "resetScrollPosition": { - "type": "boolean", - "optional": true, - "description": "If true, temporarily resets the scroll position of the document to 0. Only takes effect if rect is also specified." } } },