Skip to content

Commit

Permalink
browser(webkit): fix screencast scale on Mac headful (#3797)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s authored Sep 8, 2020
1 parent 658b34e commit 1d4601b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions browser_patches/webkit/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1341
Changed: [email protected] Thu Sep 3 23:32:06 PDT 2020
1342
Changed: [email protected] Tue Sep 8 12:53:25 PDT 2020
13 changes: 7 additions & 6 deletions browser_patches/webkit/patches/bootstrap.diff
Original file line number Diff line number Diff line change
Expand Up @@ -9837,10 +9837,10 @@ index f9c26832d3e91e8d747c5c1e0f0d76c34f4c3096..8b73efbba93362d8eebcc3a52158d8b0
} // 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..9b1e182c9f41a132df8c18b3655d52627b9d7686
index 0000000000000000000000000000000000000000..0700f3624b34ab536f4101a12ba5fbd9a81e9a58
--- /dev/null
+++ b/Source/WebKit/UIProcess/Inspector/mac/ScreencastEncoderMac.mm
@@ -0,0 +1,57 @@
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2020 Microsoft Corporation.
+ *
Expand Down Expand Up @@ -9884,16 +9884,17 @@ index 0000000000000000000000000000000000000000..9b1e182c9f41a132df8c18b3655d5262
+ RetainPtr<CGContextRef> 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 || imageHeight > height) {
+ ratio = std::min(width / imageWidth, height / imageHeight);
+ } else if (imageWidth > width || pageHeight > height) {
+ ratio = std::min(width / imageWidth, height / pageHeight);
+ }
+ imageWidth *= ratio;
+ imageHeight *= ratio;
+ // TODO: exclude controls from original screenshot
+ CGFloat pageHeight = static_cast<CGFloat>(imageHeight) - offsetTop * ratio;
+ pageHeight *= ratio;
+ CGContextDrawImage(context.get(), CGRectMake(0, height - pageHeight, imageWidth, imageHeight), image);
+}
+
Expand Down

0 comments on commit 1d4601b

Please sign in to comment.