Skip to content

Commit 765d749

Browse files
authored
chore(ff): remove some dead code (#6423)
1 parent 9e36f5c commit 765d749

File tree

8 files changed

+17
-46
lines changed

8 files changed

+17
-46
lines changed

browser_patches/firefox/BUILD_NUMBER

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1252
2-
Changed: joel.einbinder@gmail.com Tue 04 May 2021 02:47:58 AM PDT
1+
1253
2+
Changed: pavel.feldman@gmail.com Wed 05 May 2021 01:22:39 PM PDT

browser_patches/firefox/juggler/TargetRegistry.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,24 +488,21 @@ class PageTarget {
488488
return await this._channel.connect('').send('hasFailedToOverrideTimezone').catch(e => true);
489489
}
490490

491-
async _startVideoRecording({width, height, scale, dir}) {
491+
async _startVideoRecording({width, height, dir}) {
492492
// On Mac the window may not yet be visible when TargetCreated and its
493493
// NSWindow.windowNumber may be -1, so we wait until the window is known
494494
// to be initialized and visible.
495495
await this.windowReady();
496496
const file = OS.Path.join(dir, helper.generateId() + '.webm');
497497
if (width < 10 || width > 10000 || height < 10 || height > 10000)
498498
throw new Error("Invalid size");
499-
if (scale && (scale <= 0 || scale > 1))
500-
throw new Error("Unsupported scale");
501499

502500
const screencast = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService);
503501
const docShell = this._gBrowser.ownerGlobal.docShell;
504502
// Exclude address bar and navigation control from the video.
505503
const rect = this.linkedBrowser().getBoundingClientRect();
506504
const devicePixelRatio = this._window.devicePixelRatio;
507-
const viewport = this._viewportSize || this._browserContext.defaultViewportSize || {width: 0, height: 0};
508-
const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, viewport.width, viewport.height, scale || 0, devicePixelRatio * rect.top);
505+
const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, devicePixelRatio * rect.top);
509506
this._screencastInfo = { videoSessionId, file };
510507
this.emit(PageTarget.Events.ScreencastStarted);
511508
}

browser_patches/firefox/juggler/protocol/PageHandler.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,6 @@ class PageHandler {
379379
throw new Error('ERROR: cannot find worker with id ' + workerId);
380380
return await worker.sendMessage(JSON.parse(message));
381381
}
382-
383-
async ['Page.stopVideoRecording']() {
384-
await this._pageTarget.stopVideoRecording();
385-
}
386382
}
387383

388384
var EXPORTED_SYMBOLS = ['PageHandler'];

browser_patches/firefox/juggler/protocol/Protocol.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ const Browser = {
426426
dir: t.String,
427427
width: t.Number,
428428
height: t.Number,
429-
scale: t.Optional(t.Number),
430429
},
431430
},
432431
},
@@ -896,16 +895,6 @@ const Page = {
896895
message: t.String,
897896
},
898897
},
899-
'startVideoRecording': {
900-
params: {
901-
file: t.String,
902-
width: t.Number,
903-
height: t.Number,
904-
scale: t.Optional(t.Number),
905-
},
906-
},
907-
'stopVideoRecording': {
908-
},
909898
},
910899
};
911900

browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ void createImage(unsigned int width, unsigned int height,
110110

111111
class ScreencastEncoder::VPXFrame {
112112
public:
113-
VPXFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, Maybe<double> scale, const gfx::IntMargin& margin)
113+
VPXFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, const gfx::IntMargin& margin)
114114
: m_frameBuffer(std::move(buffer))
115-
, m_scale(scale)
116115
, m_margin(margin)
117116
{ }
118117

@@ -137,8 +136,8 @@ class ScreencastEncoder::VPXFrame {
137136
double src_width = src->width() - m_margin.LeftRight();
138137
double src_height = src->height() - m_margin.top;
139138

140-
if (m_scale || (src_width > image->w || src_height > image->h)) {
141-
double scale = m_scale ? m_scale.value() : std::min(image->w / src_width, image->h / src_height);
139+
if (src_width > image->w || src_height > image->h) {
140+
double scale = std::min(image->w / src_width, image->h / src_height);
142141
double dst_width = src_width * scale;
143142
if (dst_width > image->w) {
144143
src_width *= image->w / dst_width;
@@ -174,7 +173,6 @@ class ScreencastEncoder::VPXFrame {
174173

175174
private:
176175
rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_frameBuffer;
177-
Maybe<double> m_scale;
178176
gfx::IntMargin m_margin;
179177
TimeDuration m_duration;
180178
};
@@ -276,9 +274,8 @@ class ScreencastEncoder::VPXCodec {
276274
std::unique_ptr<vpx_image_t> m_image;
277275
};
278276

279-
ScreencastEncoder::ScreencastEncoder(std::unique_ptr<VPXCodec>&& vpxCodec, Maybe<double> scale, const gfx::IntMargin& margin)
277+
ScreencastEncoder::ScreencastEncoder(std::unique_ptr<VPXCodec>&& vpxCodec, const gfx::IntMargin& margin)
280278
: m_vpxCodec(std::move(vpxCodec))
281-
, m_scale(scale)
282279
, m_margin(margin)
283280
{
284281
}
@@ -287,7 +284,7 @@ ScreencastEncoder::~ScreencastEncoder()
287284
{
288285
}
289286

290-
RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe<double> scale, const gfx::IntMargin& margin)
287+
RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin)
291288
{
292289
vpx_codec_iface_t* codec_interface = vpx_codec_vp8_cx();
293290
if (!codec_interface) {
@@ -328,7 +325,7 @@ RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, cons
328325

329326
std::unique_ptr<VPXCodec> vpxCodec(new VPXCodec(codec, cfg, file));
330327
// fprintf(stderr, "ScreencastEncoder initialized with: %s\n", vpx_codec_iface_name(codec_interface));
331-
return new ScreencastEncoder(std::move(vpxCodec), scale, margin);
328+
return new ScreencastEncoder(std::move(vpxCodec), margin);
332329
}
333330

334331
void ScreencastEncoder::flushLastFrame()
@@ -350,7 +347,7 @@ void ScreencastEncoder::encodeFrame(const webrtc::VideoFrame& videoFrame)
350347
// fprintf(stderr, "ScreencastEncoder::encodeFrame\n");
351348
flushLastFrame();
352349

353-
m_lastFrame = std::make_unique<VPXFrame>(videoFrame.video_frame_buffer(), m_scale, m_margin);
350+
m_lastFrame = std::make_unique<VPXFrame>(videoFrame.video_frame_buffer(), m_margin);
354351
}
355352

356353
void ScreencastEncoder::finish(std::function<void()>&& callback)

browser_patches/firefox/juggler/screencast/ScreencastEncoder.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class ScreencastEncoder {
2323
public:
2424
static constexpr int fps = 25;
2525

26-
static RefPtr<ScreencastEncoder> create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe<double> scale, const gfx::IntMargin& margin);
26+
static RefPtr<ScreencastEncoder> create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin);
2727

2828
class VPXCodec;
29-
ScreencastEncoder(std::unique_ptr<VPXCodec>&&, Maybe<double> scale, const gfx::IntMargin& margin);
29+
ScreencastEncoder(std::unique_ptr<VPXCodec>&&, const gfx::IntMargin& margin);
3030

3131
void encodeFrame(const webrtc::VideoFrame& videoFrame);
3232

@@ -38,7 +38,6 @@ class ScreencastEncoder {
3838
void flushLastFrame();
3939

4040
std::unique_ptr<VPXCodec> m_vpxCodec;
41-
Maybe<double> m_scale;
4241
gfx::IntMargin m_margin;
4342
TimeStamp m_lastFrameTimestamp;
4443
class VPXFrame;

browser_patches/firefox/juggler/screencast/nsIScreencastService.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface nsIDocShell;
1212
[scriptable, uuid(d8c4d9e0-9462-445e-9e43-68d3872ad1de)]
1313
interface nsIScreencastService : nsISupports
1414
{
15-
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);
15+
AString startVideoRecording(in nsIDocShell docShell, in ACString fileName, in uint32_t width, in uint32_t height, in int32_t offset_top);
1616

1717
/**
1818
* Will emit 'juggler-screencast-stopped' when the video file is saved.

browser_patches/firefox/juggler/screencast/nsScreencastService.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ nsScreencastService::nsScreencastService() = default;
140140
nsScreencastService::~nsScreencastService() {
141141
}
142142

143-
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) {
143+
nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const nsACString& aFileName, uint32_t width, uint32_t height, int32_t offsetTop, nsAString& sessionId) {
144144
MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Screencast service must be started on the Main thread.");
145145

146146
PresShell* presShell = aDocShell->GetPresShell();
@@ -158,23 +158,16 @@ nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const
158158
if (!capturer)
159159
return NS_ERROR_FAILURE;
160160

161-
nsCString error;
162-
Maybe<double> maybeScale;
163-
if (scale)
164-
maybeScale = Some(scale);
165-
166161
gfx::IntMargin margin;
167162
auto bounds = widget->GetScreenBounds().ToUnknownRect();
168163
auto clientBounds = widget->GetClientBounds().ToUnknownRect();
169-
// The browser window has a minimum size, so it might be larger than the viewport size.
170-
clientBounds.width = std::min((int)viewportWidth, clientBounds.width);
171-
clientBounds.height = std::min((int)viewportHeight, clientBounds.height);
172164
// Crop the image to exclude frame (if any).
173165
margin = bounds - clientBounds;
174166
// Crop the image to exclude controls.
175167
margin.top += offsetTop;
176168

177-
RefPtr<ScreencastEncoder> encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, maybeScale, margin);
169+
nsCString error;
170+
RefPtr<ScreencastEncoder> encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, margin);
178171
if (!encoder) {
179172
fprintf(stderr, "Failed to create ScreencastEncoder: %s\n", error.get());
180173
return NS_ERROR_FAILURE;

0 commit comments

Comments
 (0)