Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
browser(firefox): autoscale screencast to fit frame (#3720)
Yury Semikhatskyee1becd897e0
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBERindex 5b3ada0456..70cd825f99 100644--- a/browser_patches/firefox/BUILD_NUMBER+++ b/browser_patches/firefox/BUILD_NUMBER@@ -1,2 +1,2 @@-1168-Changed: [email protected] Thu 27 Aug 2020 03:42:20 AM PDT+1169+Changed: [email protected] Tue Sep 1 17:07:52 PDT 2020diff --git a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cppindex 9989484824..e281857211 100644--- a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp+++ b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp@@ -122,23 +122,24 @@ public:}auto src = m_frameBuffer->GetI420();-- const int y_stride = image->stride[0];- MOZ_ASSERT(image->stride[1] == image->stride[2]);+ const int y_stride = image->stride[VPX_PLANE_Y];+ MOZ_ASSERT(image->stride[VPX_PLANE_U] == image->stride[VPX_PLANE_V]);const int uv_stride = image->stride[1];- uint8_t* y_data = image->planes[0];- uint8_t* u_data = image->planes[1];- uint8_t* v_data = image->planes[2];+ uint8_t* y_data = image->planes[VPX_PLANE_Y];+ uint8_t* u_data = image->planes[VPX_PLANE_U];+ uint8_t* v_data = image->planes[VPX_PLANE_V];++ double src_width = src->width() - m_margin.LeftRight();+ double src_height = src->height() - m_margin.top;- if (m_scale) {- int src_width = src->width() - m_margin.LeftRight();- double dst_width = src_width * m_scale.value();+ 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);+ double dst_width = src_width * scale;if (dst_width > image->w) {src_width *= image->w / dst_width;dst_width = image->w;}- int src_height = src->height() - m_margin.TopBottom();- double dst_height = src_height * m_scale.value();+ double dst_height = src_height * scale;if (dst_height > image->h) {src_height *= image->h / dst_height;dst_height = image->h;@@ -153,8 +154,8 @@ public:dst_width, dst_height,libyuv::kFilterBilinear);} else {- int width = std::min<int>(image->w, src->width() - m_margin.LeftRight());- int height = std::min<int>(image->h, src->height() - m_margin.TopBottom());+ int width = std::min<int>(image->w, src_width);+ int height = std::min<int>(image->h, src_height);libyuv::I420Copy(src->DataY() + m_margin.top * src->StrideY() + m_margin.left, src->StrideY(),src->DataU() + (m_margin.top * src->StrideU() + m_margin.left) / 2, src->StrideU(),diff --git a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp b/browser_patches/firefox/juggler/screencast/nsScreencastService.cppindex 595a7cef5e..e4b6fadf86 100644--- a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp+++ b/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp@@ -148,10 +148,16 @@ nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, constif (scale)maybeScale = Some(scale);+ gfx::IntMargin margin;+ // On GTK the bottom of the client rect is below the bounds and+ // client size is actually equal to the size of the bounds so+ // we don't need an adjustment.+#ifndef MOZ_WIDGET_GTKauto bounds = widget->GetScreenBounds().ToUnknownRect();auto clientBounds = widget->GetClientBounds().ToUnknownRect();// Crop the image to exclude frame (if any).- gfx::IntMargin margin = bounds - clientBounds;+ margin = bounds - clientBounds;+#endif// Crop the image to exclude controls.margin.top += offsetTop;