diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER index 84632d67df..039e4217d7 100644 --- a/browser_patches/firefox/BUILD_NUMBER +++ b/browser_patches/firefox/BUILD_NUMBER @@ -1,2 +1,2 @@ -1241 -Changed: joel.einbinder@gmail.com Thu Apr 1 11:26:01 PDT 2021 +1242 +Changed: dgozman@gmail.com Thu Apr 1 13:10:41 PDT 2021 diff --git a/browser_patches/firefox/juggler/content/PageAgent.js b/browser_patches/firefox/juggler/content/PageAgent.js index 153da9071e..bb278e5f27 100644 --- a/browser_patches/firefox/juggler/content/PageAgent.js +++ b/browser_patches/firefox/juggler/content/PageAgent.js @@ -206,7 +206,6 @@ class PageAgent { dispatchMouseEvent: this._dispatchMouseEvent.bind(this), dispatchTouchEvent: this._dispatchTouchEvent.bind(this), dispatchTapEvent: this._dispatchTapEvent.bind(this), - getBoundingBox: this._getBoundingBox.bind(this), getContentQuads: this._getContentQuads.bind(this), getFullAXTree: this._getFullAXTree.bind(this), goBack: this._goBack.bind(this), @@ -622,31 +621,13 @@ class PageAgent { return {x: x1, y: y1, width: x2 - x1, height: y2 - y1}; } - async _getBoundingBox({frameId, objectId}) { - const frame = this._frameTree.frame(frameId); - if (!frame) - throw new Error('Failed to find frame with id = ' + frameId); - const unsafeObject = this._frameData.get(frame).unsafeObject(objectId); - const box = this._getNodeBoundingBox(unsafeObject); - if (!box) - return {boundingBox: null}; - return {boundingBox: {x: box.x + frame.domWindow().scrollX, y: box.y + frame.domWindow().scrollY, width: box.width, height: box.height}}; - } - - async _screenshot({mimeType, fullPage, clip}) { + async _screenshot({mimeType, clip, omitDeviceScaleFactor}) { const content = this._messageManager.content; if (clip) { - const data = takeScreenshot(content, clip.x, clip.y, clip.width, clip.height, mimeType); + const data = takeScreenshot(content, clip.x, clip.y, clip.width, clip.height, mimeType, omitDeviceScaleFactor); return {data}; } - if (fullPage) { - const rect = content.document.documentElement.getBoundingClientRect(); - const width = content.innerWidth + content.scrollMaxX - content.scrollMinX; - const height = content.innerHeight + content.scrollMaxY - content.scrollMinY; - const data = takeScreenshot(content, 0, 0, width, height, mimeType); - return {data}; - } - const data = takeScreenshot(content, content.scrollX, content.scrollY, content.innerWidth, content.innerHeight, mimeType); + const data = takeScreenshot(content, content.scrollX, content.scrollY, content.innerWidth, content.innerHeight, mimeType, omitDeviceScaleFactor); return {data}; } @@ -1021,10 +1002,10 @@ class PageAgent { } } -function takeScreenshot(win, left, top, width, height, mimeType) { +function takeScreenshot(win, left, top, width, height, mimeType, omitDeviceScaleFactor) { const MAX_SKIA_DIMENSIONS = 32767; - const scale = win.devicePixelRatio; + const scale = omitDeviceScaleFactor ? 1 : win.devicePixelRatio; const canvasWidth = width * scale; const canvasHeight = height * scale; diff --git a/browser_patches/firefox/juggler/protocol/PageHandler.js b/browser_patches/firefox/juggler/protocol/PageHandler.js index 9a1ea24fcc..b5b52d106d 100644 --- a/browser_patches/firefox/juggler/protocol/PageHandler.js +++ b/browser_patches/firefox/juggler/protocol/PageHandler.js @@ -299,10 +299,6 @@ class PageHandler { return await this._contentPage.send('screenshot', options); } - async ['Page.getBoundingBox'](options) { - return await this._contentPage.send('getBoundingBox', options); - } - async ['Page.getContentQuads'](options) { return await this._contentPage.send('getContentQuads', options); } diff --git a/browser_patches/firefox/juggler/protocol/Protocol.js b/browser_patches/firefox/juggler/protocol/Protocol.js index 55842a7a15..c9693b162b 100644 --- a/browser_patches/firefox/juggler/protocol/Protocol.js +++ b/browser_patches/firefox/juggler/protocol/Protocol.js @@ -71,7 +71,7 @@ pageTypes.Size = { pageTypes.Viewport = { viewportSize: pageTypes.Size, - deviceScaleFactor: t.Number, + deviceScaleFactor: t.Optional(t.Number), }; pageTypes.DOMQuad = { @@ -801,15 +801,6 @@ const Page = { frameId: t.String, }, }, - 'getBoundingBox': { - params: { - frameId: t.String, - objectId: t.String, - }, - returns: { - boundingBox: t.Nullable(pageTypes.Rect), - }, - }, 'adoptNode': { params: { frameId: t.String, @@ -823,8 +814,8 @@ const Page = { 'screenshot': { params: { mimeType: t.Enum(['image/png', 'image/jpeg']), - fullPage: t.Optional(t.Boolean), clip: t.Optional(pageTypes.Clip), + omitDeviceScaleFactor: t.Optional(t.Boolean), }, returns: { data: t.String,