diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER index 971be60f4e9f9..b0ad0dfbc1762 100644 --- a/browser_patches/firefox/BUILD_NUMBER +++ b/browser_patches/firefox/BUILD_NUMBER @@ -1,2 +1,2 @@ -1252 -Changed: joel.einbinder@gmail.com Tue 04 May 2021 02:47:58 AM PDT +1253 +Changed: pavel.feldman@gmail.com Wed 05 May 2021 01:22:39 PM PDT diff --git a/browser_patches/firefox/juggler/TargetRegistry.js b/browser_patches/firefox/juggler/TargetRegistry.js index 0e646c83f2a7b..09f05bc0a923d 100644 --- a/browser_patches/firefox/juggler/TargetRegistry.js +++ b/browser_patches/firefox/juggler/TargetRegistry.js @@ -488,7 +488,7 @@ class PageTarget { return await this._channel.connect('').send('hasFailedToOverrideTimezone').catch(e => true); } - async _startVideoRecording({width, height, scale, dir}) { + async _startVideoRecording({width, height, dir}) { // On Mac the window may not yet be visible when TargetCreated and its // NSWindow.windowNumber may be -1, so we wait until the window is known // to be initialized and visible. @@ -496,16 +496,13 @@ class PageTarget { const file = OS.Path.join(dir, helper.generateId() + '.webm'); if (width < 10 || width > 10000 || height < 10 || height > 10000) throw new Error("Invalid size"); - if (scale && (scale <= 0 || scale > 1)) - throw new Error("Unsupported scale"); const screencast = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService); const docShell = this._gBrowser.ownerGlobal.docShell; // Exclude address bar and navigation control from the video. const rect = this.linkedBrowser().getBoundingClientRect(); const devicePixelRatio = this._window.devicePixelRatio; - const viewport = this._viewportSize || this._browserContext.defaultViewportSize || {width: 0, height: 0}; - const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, viewport.width, viewport.height, scale || 0, devicePixelRatio * rect.top); + const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, devicePixelRatio * rect.top); this._screencastInfo = { videoSessionId, file }; this.emit(PageTarget.Events.ScreencastStarted); } diff --git a/browser_patches/firefox/juggler/protocol/PageHandler.js b/browser_patches/firefox/juggler/protocol/PageHandler.js index b5b52d106d476..3989d54b1f862 100644 --- a/browser_patches/firefox/juggler/protocol/PageHandler.js +++ b/browser_patches/firefox/juggler/protocol/PageHandler.js @@ -379,10 +379,6 @@ class PageHandler { throw new Error('ERROR: cannot find worker with id ' + workerId); return await worker.sendMessage(JSON.parse(message)); } - - async ['Page.stopVideoRecording']() { - await this._pageTarget.stopVideoRecording(); - } } var EXPORTED_SYMBOLS = ['PageHandler']; diff --git a/browser_patches/firefox/juggler/protocol/Protocol.js b/browser_patches/firefox/juggler/protocol/Protocol.js index c9693b162b81e..ba7fa099e2845 100644 --- a/browser_patches/firefox/juggler/protocol/Protocol.js +++ b/browser_patches/firefox/juggler/protocol/Protocol.js @@ -426,7 +426,6 @@ const Browser = { dir: t.String, width: t.Number, height: t.Number, - scale: t.Optional(t.Number), }, }, }, @@ -896,16 +895,6 @@ const Page = { message: t.String, }, }, - 'startVideoRecording': { - params: { - file: t.String, - width: t.Number, - height: t.Number, - scale: t.Optional(t.Number), - }, - }, - 'stopVideoRecording': { - }, }, }; diff --git a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp index d0352f1cfa12d..981bbc99150d0 100644 --- a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp +++ b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp @@ -110,9 +110,8 @@ void createImage(unsigned int width, unsigned int height, class ScreencastEncoder::VPXFrame { public: - VPXFrame(rtc::scoped_refptr&& buffer, Maybe scale, const gfx::IntMargin& margin) + VPXFrame(rtc::scoped_refptr&& buffer, const gfx::IntMargin& margin) : m_frameBuffer(std::move(buffer)) - , m_scale(scale) , m_margin(margin) { } @@ -137,8 +136,8 @@ class ScreencastEncoder::VPXFrame { double src_width = src->width() - m_margin.LeftRight(); double src_height = src->height() - m_margin.top; - if (m_scale || (src_width > image->w || src_height > image->h)) { - double scale = m_scale ? m_scale.value() : std::min(image->w / src_width, image->h / src_height); + if (src_width > image->w || src_height > image->h) { + double scale = std::min(image->w / src_width, image->h / src_height); double dst_width = src_width * scale; if (dst_width > image->w) { src_width *= image->w / dst_width; @@ -174,7 +173,6 @@ class ScreencastEncoder::VPXFrame { private: rtc::scoped_refptr m_frameBuffer; - Maybe m_scale; gfx::IntMargin m_margin; TimeDuration m_duration; }; @@ -276,9 +274,8 @@ class ScreencastEncoder::VPXCodec { std::unique_ptr m_image; }; -ScreencastEncoder::ScreencastEncoder(std::unique_ptr&& vpxCodec, Maybe scale, const gfx::IntMargin& margin) +ScreencastEncoder::ScreencastEncoder(std::unique_ptr&& vpxCodec, const gfx::IntMargin& margin) : m_vpxCodec(std::move(vpxCodec)) - , m_scale(scale) , m_margin(margin) { } @@ -287,7 +284,7 @@ ScreencastEncoder::~ScreencastEncoder() { } -RefPtr ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe scale, const gfx::IntMargin& margin) +RefPtr ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin) { vpx_codec_iface_t* codec_interface = vpx_codec_vp8_cx(); if (!codec_interface) { @@ -328,7 +325,7 @@ RefPtr ScreencastEncoder::create(nsCString& errorString, cons std::unique_ptr vpxCodec(new VPXCodec(codec, cfg, file)); // fprintf(stderr, "ScreencastEncoder initialized with: %s\n", vpx_codec_iface_name(codec_interface)); - return new ScreencastEncoder(std::move(vpxCodec), scale, margin); + return new ScreencastEncoder(std::move(vpxCodec), margin); } void ScreencastEncoder::flushLastFrame() @@ -350,7 +347,7 @@ void ScreencastEncoder::encodeFrame(const webrtc::VideoFrame& videoFrame) // fprintf(stderr, "ScreencastEncoder::encodeFrame\n"); flushLastFrame(); - m_lastFrame = std::make_unique(videoFrame.video_frame_buffer(), m_scale, m_margin); + m_lastFrame = std::make_unique(videoFrame.video_frame_buffer(), m_margin); } void ScreencastEncoder::finish(std::function&& callback) diff --git a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.h b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.h index b6827800bce37..bfc9b69e7694d 100644 --- a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.h +++ b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.h @@ -23,10 +23,10 @@ class ScreencastEncoder { public: static constexpr int fps = 25; - static RefPtr create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe scale, const gfx::IntMargin& margin); + static RefPtr create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin); class VPXCodec; - ScreencastEncoder(std::unique_ptr&&, Maybe scale, const gfx::IntMargin& margin); + ScreencastEncoder(std::unique_ptr&&, const gfx::IntMargin& margin); void encodeFrame(const webrtc::VideoFrame& videoFrame); @@ -38,7 +38,6 @@ class ScreencastEncoder { void flushLastFrame(); std::unique_ptr m_vpxCodec; - Maybe m_scale; gfx::IntMargin m_margin; TimeStamp m_lastFrameTimestamp; class VPXFrame; diff --git a/browser_patches/firefox/juggler/screencast/nsIScreencastService.idl b/browser_patches/firefox/juggler/screencast/nsIScreencastService.idl index b7edfe3c1a377..d39760371fb5b 100644 --- a/browser_patches/firefox/juggler/screencast/nsIScreencastService.idl +++ b/browser_patches/firefox/juggler/screencast/nsIScreencastService.idl @@ -12,7 +12,7 @@ interface nsIDocShell; [scriptable, uuid(d8c4d9e0-9462-445e-9e43-68d3872ad1de)] interface nsIScreencastService : nsISupports { - AString startVideoRecording(in nsIDocShell docShell, in ACString fileName, in uint32_t width, in uint32_t height, in uint32_t viewportWidth, in uint32_t viewportHeight, in double scale, in int32_t offset_top); + AString startVideoRecording(in nsIDocShell docShell, in ACString fileName, in uint32_t width, in uint32_t height, in int32_t offset_top); /** * Will emit 'juggler-screencast-stopped' when the video file is saved. diff --git a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp b/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp index cbebd9fbc19fe..d91f31c2c9cda 100644 --- a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp +++ b/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp @@ -140,7 +140,7 @@ nsScreencastService::nsScreencastService() = default; nsScreencastService::~nsScreencastService() { } -nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const nsACString& aFileName, uint32_t width, uint32_t height, uint32_t viewportWidth, uint32_t viewportHeight, double scale, int32_t offsetTop, nsAString& sessionId) { +nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const nsACString& aFileName, uint32_t width, uint32_t height, int32_t offsetTop, nsAString& sessionId) { MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Screencast service must be started on the Main thread."); PresShell* presShell = aDocShell->GetPresShell(); @@ -158,23 +158,16 @@ nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const if (!capturer) return NS_ERROR_FAILURE; - nsCString error; - Maybe maybeScale; - if (scale) - maybeScale = Some(scale); - gfx::IntMargin margin; auto bounds = widget->GetScreenBounds().ToUnknownRect(); auto clientBounds = widget->GetClientBounds().ToUnknownRect(); - // The browser window has a minimum size, so it might be larger than the viewport size. - clientBounds.width = std::min((int)viewportWidth, clientBounds.width); - clientBounds.height = std::min((int)viewportHeight, clientBounds.height); // Crop the image to exclude frame (if any). margin = bounds - clientBounds; // Crop the image to exclude controls. margin.top += offsetTop; - RefPtr encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, maybeScale, margin); + nsCString error; + RefPtr encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, margin); if (!encoder) { fprintf(stderr, "Failed to create ScreencastEncoder: %s\n", error.get()); return NS_ERROR_FAILURE;