browser(webkit): scale down image only if it is larger than screencast frame (#14848)
It fixes should produce screencast frames fit test on macOS in headed mode. Pretty-diff: yury-s/WebKit@4b7a793
This commit is contained in:
Родитель
61536098be
Коммит
dae017c386
|
@ -1,2 +1,2 @@
|
|||
1664
|
||||
Changed: lushnikov@chromium.org Fri Jun 10 12:05:37 +03 2022
|
||||
1665
|
||||
Changed: yurys@chromium.org Mon Jun 13 15:30:54 PDT 2022
|
||||
|
|
|
@ -2238,7 +2238,7 @@ diff --git a/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm b/So
|
|||
index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d768ace22 100644
|
||||
--- a/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm
|
||||
+++ b/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm
|
||||
@@ -198,6 +198,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@@ -198,6 +198,7 @@ - (void)sendEndIfNeeded
|
||||
|
||||
- (void)speechRecognizer:(SFSpeechRecognizer *)speechRecognizer availabilityDidChange:(BOOL)available
|
||||
{
|
||||
|
@ -2246,7 +2246,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d
|
|||
ASSERT(isMainThread());
|
||||
|
||||
if (available || !_task)
|
||||
@@ -211,6 +212,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@@ -211,6 +212,7 @@ - (void)speechRecognizer:(SFSpeechRecognizer *)speechRecognizer availabilityDidC
|
||||
|
||||
- (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didHypothesizeTranscription:(SFTranscription *)transcription
|
||||
{
|
||||
|
@ -2254,7 +2254,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d
|
|||
ASSERT(isMainThread());
|
||||
|
||||
[self sendSpeechStartIfNeeded];
|
||||
@@ -219,6 +221,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@@ -219,6 +221,7 @@ - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didHypothesizeTran
|
||||
|
||||
- (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didFinishRecognition:(SFSpeechRecognitionResult *)recognitionResult
|
||||
{
|
||||
|
@ -2262,7 +2262,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d
|
|||
ASSERT(isMainThread());
|
||||
[self callbackWithTranscriptions:recognitionResult.transcriptions isFinal:YES];
|
||||
|
||||
@@ -230,6 +233,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@@ -230,6 +233,7 @@ - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didFinishRecogniti
|
||||
|
||||
- (void)speechRecognitionTaskWasCancelled:(SFSpeechRecognitionTask *)task
|
||||
{
|
||||
|
@ -8829,7 +8829,7 @@ diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/
|
|||
index 8b32817b6c0efbcbd221dc7a3ebe420b42d8b51d..a468653cffcfaca8824e94d628c48b7b5d61e164 100644
|
||||
--- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
|
||||
+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
|
||||
@@ -720,7 +720,7 @@ void NetworkSessionCocoa::setClientAuditToken(const WebCore::AuthenticationChall
|
||||
@@ -720,7 +720,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didRece
|
||||
|
||||
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
||||
sessionCocoa->setClientAuditToken(challenge);
|
||||
|
@ -10239,7 +10239,7 @@ index b8bf936e2eb8ca4dc0f445099dfb899395950bdb..30a2af76de0daac450c7afbb8a2dfe81
|
|||
#import <WebCore/Credential.h>
|
||||
#import <WebCore/RegistrationDatabase.h>
|
||||
#import <WebCore/ServiceWorkerClientData.h>
|
||||
@@ -234,6 +235,11 @@ static WallTime toSystemClockTime(NSDate *date)
|
||||
@@ -234,6 +235,11 @@ - (void)removeDataOfTypes:(NSSet *)dataTypes modifiedSince:(NSDate *)date comple
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10418,7 +10418,7 @@ diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm b/
|
|||
index 2e235bb880c638a0e74256b6d66cb0244ea0a3f1..3471eebb47e860f7c2071d0e7f2691c9f0a6355d 100644
|
||||
--- a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
|
||||
+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
|
||||
@@ -257,6 +257,16 @@
|
||||
@@ -257,6 +257,16 @@ - (BOOL)processSwapsOnNavigation
|
||||
return _processPoolConfiguration->processSwapsOnNavigation();
|
||||
}
|
||||
|
||||
|
@ -12365,10 +12365,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..68f4dfb777dc4b51d4e3e2f3f849131d40dd9879
|
||||
index 0000000000000000000000000000000000000000..dcd6d6283cfce4be647846514736c16dadb95263
|
||||
--- /dev/null
|
||||
+++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp
|
||||
@@ -0,0 +1,302 @@
|
||||
@@ -0,0 +1,304 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2020 Microsoft Corporation.
|
||||
+ *
|
||||
|
@ -12629,17 +12629,19 @@ index 0000000000000000000000000000000000000000..68f4dfb777dc4b51d4e3e2f3f849131d
|
|||
+ WebCore::IntSize displaySize = imageSize;
|
||||
+ displaySize.contract(0, m_screencastToolbarHeight);
|
||||
+ double scale = std::min(m_screencastWidth / displaySize.width(), m_screencastHeight / displaySize.height());
|
||||
+ RetainPtr<CGImageRef> scaledImageRef;
|
||||
+ RetainPtr<CGImageRef> transformedImageRef;
|
||||
+ if (scale < 1 || m_screencastToolbarHeight) {
|
||||
+ WebCore::IntSize screencastSize = displaySize;
|
||||
+ screencastSize.scale(scale);
|
||||
+ WebCore::IntSize scaledImageSize = imageSize;
|
||||
+ scaledImageSize.scale(scale);
|
||||
+ if (scale < 1) {
|
||||
+ screencastSize.scale(scale);
|
||||
+ scaledImageSize.scale(scale);
|
||||
+ }
|
||||
+ auto colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
|
||||
+ auto context = adoptCF(CGBitmapContextCreate(nullptr, screencastSize.width(), screencastSize.height(), 8, 4 * screencastSize.width(), colorSpace.get(), (CGBitmapInfo)kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
|
||||
+ CGContextDrawImage(context.get(), CGRectMake(0, 0, scaledImageSize.width(), scaledImageSize.height()), imagePtr);
|
||||
+ scaledImageRef = adoptCF(CGBitmapContextCreateImage(context.get()));
|
||||
+ imagePtr = scaledImageRef.get();
|
||||
+ transformedImageRef = adoptCF(CGBitmapContextCreateImage(context.get()));
|
||||
+ imagePtr = transformedImageRef.get();
|
||||
+ }
|
||||
+ auto data = WebCore::data(imagePtr, WebCore::jpegUTI(), m_screencastQuality * 0.1);
|
||||
+
|
||||
|
@ -20670,7 +20672,7 @@ diff --git a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm b/Source/WebKitLegac
|
|||
index 5fa2c59e5e93bc923d37ae5bb751e2f4d7fe68ee..73378254b62a7ec61b3efc3fd46aadaf45d55601 100644
|
||||
--- a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
|
||||
+++ b/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
|
||||
@@ -4189,7 +4189,7 @@ static BOOL currentScrollIsBlit(NSView *clipView)
|
||||
@@ -4189,7 +4189,7 @@ - (void)mouseDown:(WebEvent *)event
|
||||
_private->handlingMouseDownEvent = NO;
|
||||
}
|
||||
|
||||
|
@ -20683,7 +20685,7 @@ diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/ma
|
|||
index 59cecf9242ab834dadc904ef295365e1476f47f9..ca4cc96e62df62e92c22c3535f5972cc1fdc4cba 100644
|
||||
--- a/Source/WebKitLegacy/mac/WebView/WebView.mm
|
||||
+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm
|
||||
@@ -4039,7 +4039,7 @@ IGNORE_WARNINGS_END
|
||||
@@ -4039,7 +4039,7 @@ + (void)_doNotStartObservingNetworkReachability
|
||||
}
|
||||
#endif // PLATFORM(IOS_FAMILY)
|
||||
|
||||
|
@ -20692,7 +20694,7 @@ index 59cecf9242ab834dadc904ef295365e1476f47f9..ca4cc96e62df62e92c22c3535f5972cc
|
|||
|
||||
- (NSArray *)_touchEventRegions
|
||||
{
|
||||
@@ -4081,7 +4081,7 @@ IGNORE_WARNINGS_END
|
||||
@@ -4081,7 +4081,7 @@ - (NSArray *)_touchEventRegions
|
||||
}).autorelease();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче