Backed out changeset 8868fe82dafd (bug 1708403) for causing failures on test_drawSnapshot_fixed.html. CLOSED TREE

This commit is contained in:
criss 2021-08-25 04:08:24 +03:00
Родитель d5e1071c25
Коммит bccf559d4b
11 изменённых файлов: 8 добавлений и 37 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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;

Просмотреть файл

@ -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();

Просмотреть файл

@ -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<ImageBitmap> drawSnapshot(DOMRect? rect,
double scale,
UTF8String backgroundColor,
optional boolean resetScrollPosition = false);
UTF8String backgroundColor);
/**
* Fetches the securityInfo object for this window. This function will

Просмотреть файл

@ -930,7 +930,7 @@ void WindowGlobalParent::PermitUnload(std::function<void(bool)>&& aResolver) {
already_AddRefed<mozilla::dom::Promise> WindowGlobalParent::DrawSnapshot(
const DOMRect* aRect, double aScale, const nsACString& aBackgroundColor,
bool aResetScrollPosition, mozilla::ErrorResult& aRv) {
mozilla::ErrorResult& aRv) {
nsIGlobalObject* global = GetParentObject();
RefPtr<Promise> promise = Promise::Create(global, aRv);
if (NS_WARN_IF(aRv.Failed())) {
@ -949,8 +949,6 @@ already_AddRefed<mozilla::dom::Promise> 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,

Просмотреть файл

@ -160,7 +160,7 @@ class WindowGlobalParent final : public WindowContext,
already_AddRefed<mozilla::dom::Promise> DrawSnapshot(
const DOMRect* aRect, double aScale, const nsACString& aBackgroundColor,
bool aResetScrollPosition, mozilla::ErrorResult& aRv);
mozilla::ErrorResult& aRv);
already_AddRefed<Promise> GetSecurityInfo(ErrorResult& aRv);

Просмотреть файл

@ -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<dom::Promise> promise =
wgp->DrawSnapshot(nullptr, 1.0, "white"_ns, false, IgnoreErrors());
wgp->DrawSnapshot(nullptr, 1.0, "white"_ns, IgnoreErrors());
if (!promise) {
return;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -43,7 +43,6 @@ class CrossProcessPaint;
enum class CrossProcessPaintFlags {
None = 0,
DrawView = 1 << 1,
ResetScrollPosition = 1 << 2,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CrossProcessPaintFlags)

Просмотреть файл

@ -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");

Просмотреть файл

@ -45,11 +45,6 @@
"type": "number",
"optional": true,
"description": "The scale of the resulting image. Defaults to <code>devicePixelRatio</code>."
},
"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."
}
}
},