diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER index 2d0d9f4931..58690ebf23 100644 --- a/browser_patches/webkit/BUILD_NUMBER +++ b/browser_patches/webkit/BUILD_NUMBER @@ -1,2 +1,2 @@ -1582 -Changed: yurys@chromium.org Thu 02 Dec 2021 05:01:39 PM PST +1583 +Changed: yurys@chromium.org Thu 02 Dec 2021 07:00:45 PM PST diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diff index 4a5006d014..a5c33538a3 100644 --- a/browser_patches/webkit/patches/bootstrap.diff +++ b/browser_patches/webkit/patches/bootstrap.diff @@ -1611,10 +1611,10 @@ index 274b01596d490fb81b48cf89bf668e0634e8b423..d08a9ddd745c748767ba8055907daa7b "name": "getPreview", diff --git a/Source/JavaScriptCore/inspector/protocol/Screencast.json b/Source/JavaScriptCore/inspector/protocol/Screencast.json new file mode 100644 -index 0000000000000000000000000000000000000000..f6c541d63c0b8251874eaf8818aabe0e0449401d +index 0000000000000000000000000000000000000000..73a4e53ced3acc41316bb8d4c787306d3f28a27e --- /dev/null +++ b/Source/JavaScriptCore/inspector/protocol/Screencast.json -@@ -0,0 +1,65 @@ +@@ -0,0 +1,64 @@ +{ + "domain": "Screencast", + "availability": ["web"], @@ -1633,8 +1633,7 @@ index 0000000000000000000000000000000000000000..f6c541d63c0b8251874eaf8818aabe0e + { "name": "file", "type": "string", "description": "Output file location." }, + { "name": "width", "type": "integer" }, + { "name": "height", "type": "integer" }, -+ { "name": "toolbarHeight", "type": "integer" }, -+ { "name": "scale", "type": "number", "optional": true } ++ { "name": "toolbarHeight", "type": "integer" } + ], + "returns": [ + { "name": "screencastId", "$ref": "ScreencastId", "description": "Unique identifier of the screencast." } @@ -13084,10 +13083,10 @@ index 0000000000000000000000000000000000000000..4ec8b96bbbddf8a7b042f53a8068754a +cairo_status_t cairo_image_surface_write_to_jpeg_mem(cairo_surface_t *sfc, unsigned char **data, size_t *len, int quality); diff --git a/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp new file mode 100644 -index 0000000000000000000000000000000000000000..694b5afbc78861f0262a33959b3a1644acc8fc82 +index 0000000000000000000000000000000000000000..288f46125a3ed43af1ce977c658fd49ad4c97ee1 --- /dev/null +++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp -@@ -0,0 +1,298 @@ +@@ -0,0 +1,295 @@ +/* + * Copyright (C) 2020 Microsoft Corporation. + * @@ -13228,7 +13227,7 @@ index 0000000000000000000000000000000000000000..694b5afbc78861f0262a33959b3a1644 +} +#endif + -+Inspector::Protocol::ErrorStringOr InspectorScreencastAgent::startVideo(const String& file, int width, int height, int toolbarHeight, std::optional&& scale) ++Inspector::Protocol::ErrorStringOr InspectorScreencastAgent::startVideo(const String& file, int width, int height, int toolbarHeight) +{ + if (m_encoder) + return makeUnexpected("Already recording"_s); @@ -13236,11 +13235,8 @@ index 0000000000000000000000000000000000000000..694b5afbc78861f0262a33959b3a1644 + if (width < 10 || width > 10000 || height < 10 || height > 10000) + return makeUnexpected("Invalid size"_s); + -+ if (scale && (*scale <= 0 || *scale > 1)) -+ return makeUnexpected("Unsupported scale"_s); -+ + String errorString; -+ m_encoder = ScreencastEncoder::create(errorString, file, WebCore::IntSize(width, height), WTFMove(scale)); ++ m_encoder = ScreencastEncoder::create(errorString, file, WebCore::IntSize(width, height)); + if (!m_encoder) + return makeUnexpected(errorString); + @@ -13388,7 +13384,7 @@ index 0000000000000000000000000000000000000000..694b5afbc78861f0262a33959b3a1644 +} // namespace WebKit diff --git a/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h new file mode 100644 -index 0000000000000000000000000000000000000000..a45b32a1c839cf019fcece2f950e595d89d93fa7 +index 0000000000000000000000000000000000000000..d28dde452275f18739e3b1c8d709185c9bf0f40e --- /dev/null +++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h @@ -0,0 +1,97 @@ @@ -13457,7 +13453,7 @@ index 0000000000000000000000000000000000000000..a45b32a1c839cf019fcece2f950e595d + void didPaint(cairo_surface_t*); +#endif + -+ Inspector::Protocol::ErrorStringOr startVideo(const String& file, int width, int height, int toolbarHeight, std::optional&& scale) override; ++ Inspector::Protocol::ErrorStringOr startVideo(const String& file, int width, int height, int toolbarHeight) override; + void stopVideo(Ref&&) override; + + Inspector::Protocol::ErrorStringOr startScreencast(int width, int height, int toolbarHeight, int quality) override; @@ -13491,10 +13487,10 @@ index 0000000000000000000000000000000000000000..a45b32a1c839cf019fcece2f950e595d +} // namespace WebKit diff --git a/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.cpp b/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.cpp new file mode 100644 -index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90481bcb54 +index 0000000000000000000000000000000000000000..a3eebdc92962a46a4861e75cd9a7f931722748ff --- /dev/null +++ b/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.cpp -@@ -0,0 +1,385 @@ +@@ -0,0 +1,379 @@ +/* + * Copyright (c) 2010, The WebM Project authors. All rights reserved. + * Copyright (c) 2013 The Chromium Authors. All rights reserved. @@ -13617,9 +13613,8 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 + : m_surface(WTFMove(surface)) + { } +#elif PLATFORM(MAC) -+ VPXFrame(RetainPtr windowImage, std::optional scale, int offsetTop) ++ VPXFrame(RetainPtr windowImage, int offsetTop) + : m_windowImage(WTFMove(windowImage)) -+ , m_scale(scale) + , m_offsetTop(offsetTop) + { } +#endif @@ -13637,7 +13632,7 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 + int argb_stride = image->w * 4; + UniqueArray buffer = makeUniqueArray(argb_stride * image->h); + uint8_t* argb_data = buffer.get(); -+ ScreencastEncoder::imageToARGB(m_windowImage.get(), argb_data, image->w, image->h, m_scale, m_offsetTop); ++ ScreencastEncoder::imageToARGB(m_windowImage.get(), argb_data, image->w, image->h, m_offsetTop); +#endif + const int y_stride = image->stride[0]; + ASSERT(image->stride[1] == image->stride[2]); @@ -13659,7 +13654,6 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 + RefPtr m_surface; +#elif PLATFORM(MAC) + RetainPtr m_windowImage; -+ std::optional m_scale; + int m_offsetTop { 0 }; +#endif + Seconds m_duration; @@ -13750,10 +13744,9 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 + std::unique_ptr m_image; +}; + -+ScreencastEncoder::ScreencastEncoder(std::unique_ptr&& vpxCodec, IntSize size, std::optional scale) ++ScreencastEncoder::ScreencastEncoder(std::unique_ptr&& vpxCodec, IntSize size) + : m_vpxCodec(WTFMove(vpxCodec)) + , m_size(size) -+ , m_scale(scale) +{ + ASSERT(!size.isZero()); +} @@ -13762,7 +13755,7 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 +{ +} + -+RefPtr ScreencastEncoder::create(String& errorString, const String& filePath, IntSize size, std::optional scale) ++RefPtr ScreencastEncoder::create(String& errorString, const String& filePath, IntSize size) +{ + vpx_codec_iface_t* codec_interface = vpx_codec_vp8_cx(); + if (!codec_interface) { @@ -13802,7 +13795,7 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 + } + + std::unique_ptr vpxCodec(new VPXCodec(codec, cfg, file)); -+ return adoptRef(new ScreencastEncoder(WTFMove(vpxCodec), size, scale)); ++ return adoptRef(new ScreencastEncoder(WTFMove(vpxCodec), size)); +} + +void ScreencastEncoder::flushLastFrame() @@ -13835,10 +13828,7 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 + RefPtr cr = adoptRef(cairo_create(surface.get())); + + cairo_matrix_t transform; -+ if (m_scale) { -+ cairo_matrix_init_scale(&transform, *m_scale, *m_scale); -+ cairo_transform(cr.get(), &transform); -+ } else if (size.width() > m_size.width() || size.height() > m_size.height()) { ++ if (size.width() > m_size.width() || size.height() > m_size.height()) { + // If no scale is specified shrink to fit the frame. + double scale = std::min(static_cast(m_size.width()) / size.width(), + static_cast(m_size.height()) / size.height()); @@ -13859,7 +13849,7 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 +{ + flushLastFrame(); + -+ m_lastFrame = makeUnique(WTFMove(windowImage), m_scale, m_offsetTop); ++ m_lastFrame = makeUnique(WTFMove(windowImage), m_offsetTop); +} +#endif + @@ -13882,10 +13872,10 @@ index 0000000000000000000000000000000000000000..47b1594e0af11849dc975d9479c72e90 +} // namespace WebKit diff --git a/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.h b/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.h new file mode 100644 -index 0000000000000000000000000000000000000000..1683da93db6b9088c3a472472c1b71477b47a7fd +index 0000000000000000000000000000000000000000..36df6131950ca95f74dc191628376fc589dbcb33 --- /dev/null +++ b/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.h -@@ -0,0 +1,81 @@ +@@ -0,0 +1,80 @@ +/* + * Copyright (C) 2020 Microsoft Corporation. + * @@ -13934,10 +13924,10 @@ index 0000000000000000000000000000000000000000..1683da93db6b9088c3a472472c1b7147 +public: + static constexpr int fps = 25; + -+ static RefPtr create(String& errorString, const String& filePath, WebCore::IntSize, std::optional scale); ++ static RefPtr create(String& errorString, const String& filePath, WebCore::IntSize); + + class VPXCodec; -+ ScreencastEncoder(std::unique_ptr&&, WebCore::IntSize, std::optional scale); ++ ScreencastEncoder(std::unique_ptr&&, WebCore::IntSize); + ~ScreencastEncoder(); + +#if USE(CAIRO) @@ -13952,12 +13942,11 @@ index 0000000000000000000000000000000000000000..1683da93db6b9088c3a472472c1b7147 +private: + void flushLastFrame(); +#if PLATFORM(MAC) -+ static void imageToARGB(CGImageRef, uint8_t* rgba_data, int width, int height, std::optional scale, int offsetTop); ++ static void imageToARGB(CGImageRef, uint8_t* rgba_data, int width, int height, int offsetTop); +#endif + + std::unique_ptr m_vpxCodec; + const WebCore::IntSize m_size; -+ std::optional m_scale; + MonotonicTime m_lastFrameTimestamp; + class VPXFrame; + std::unique_ptr m_lastFrame; @@ -14674,10 +14663,10 @@ index 8c1339345d451874502b271f6aa2eca3fa0d3faf..1f8f5e74c86b61c1c5a16ac33d48afdd } // namespace WebKit diff --git a/Source/WebKit/UIProcess/Inspector/mac/ScreencastEncoderMac.mm b/Source/WebKit/UIProcess/Inspector/mac/ScreencastEncoderMac.mm new file mode 100644 -index 0000000000000000000000000000000000000000..66d1c743de1cb35e29d6fc9b69379d265a59961f +index 0000000000000000000000000000000000000000..235e9a3f8455f1113109631b54c7e90cfad8a614 --- /dev/null +++ b/Source/WebKit/UIProcess/Inspector/mac/ScreencastEncoderMac.mm -@@ -0,0 +1,58 @@ +@@ -0,0 +1,55 @@ +/* + * Copyright (C) 2020 Microsoft Corporation. + * @@ -14712,7 +14701,7 @@ index 0000000000000000000000000000000000000000..66d1c743de1cb35e29d6fc9b69379d26 + +namespace WebKit { + -+void ScreencastEncoder::imageToARGB(CGImageRef image, uint8_t* argb_data, int width, int height, std::optional scale, int offsetTop) ++void ScreencastEncoder::imageToARGB(CGImageRef image, uint8_t* argb_data, int width, int height, int offsetTop) +{ + size_t bitsPerComponent = 8; + size_t bytesPerPixel = 4; @@ -14721,12 +14710,9 @@ index 0000000000000000000000000000000000000000..66d1c743de1cb35e29d6fc9b69379d26 + RetainPtr context = adoptCF(CGBitmapContextCreate(argb_data, width, height, bitsPerComponent, bytesPerRow, colorSpace.get(), kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little)); + double imageWidth = CGImageGetWidth(image); + double imageHeight = CGImageGetHeight(image); -+ // TODO: exclude controls from original screenshot + double pageHeight = imageHeight - offsetTop; + double ratio = 1; -+ if (scale) { -+ ratio = *scale; -+ } else if (imageWidth > width || pageHeight > height) { ++ if (imageWidth > width || pageHeight > height) { + ratio = std::min(width / imageWidth, height / pageHeight); + } + imageWidth *= ratio;