Title: [276348] trunk/Source
- Revision
- 276348
- Author
- [email protected]
- Date
- 2021-04-21 00:21:40 -0700 (Wed, 21 Apr 2021)
Log Message
[macOS] Avoid triggering image extraction for animated images
https://bugs.webkit.org/show_bug.cgi?id=224851
Reviewed by Megan Gardner.
Source/WebCore:
Avoid adding the "Reveal Image" context menu item for animated images. Testing is currently blocked on
webkit.org/b/224641.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate):
Source/WebKit:
Avoid making image extraction requests for animated images by adding an optional `AllowsAnimatedImages`
argument to `createShareableBitmap`, and passing in `AllowsAnimatedImages::No` in the case where we're creating
a shareable bitmap for image extraction.
* WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp:
(WebKit::createShareableBitmap):
* WebProcess/WebCoreSupport/ShareableBitmapUtilities.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::requestImageExtraction):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (276347 => 276348)
--- trunk/Source/WebCore/ChangeLog 2021-04-21 07:18:16 UTC (rev 276347)
+++ trunk/Source/WebCore/ChangeLog 2021-04-21 07:21:40 UTC (rev 276348)
@@ -1,3 +1,16 @@
+2021-04-21 Wenson Hsieh <[email protected]>
+
+ [macOS] Avoid triggering image extraction for animated images
+ https://bugs.webkit.org/show_bug.cgi?id=224851
+
+ Reviewed by Megan Gardner.
+
+ Avoid adding the "Reveal Image" context menu item for animated images. Testing is currently blocked on
+ webkit.org/b/224641.
+
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::populate):
+
2021-04-21 Megan Gardner <[email protected]>
Support scrolling to a selected AppHighlight
Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (276347 => 276348)
--- trunk/Source/WebCore/page/ContextMenuController.cpp 2021-04-21 07:18:16 UTC (rev 276347)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp 2021-04-21 07:21:40 UTC (rev 276348)
@@ -895,11 +895,14 @@
appendItem(OpenImageInNewWindowItem, m_contextMenu.get());
appendItem(DownloadImageItem, m_contextMenu.get());
- if (imageURL.isLocalFile() || m_context.hitTestResult().image()) {
+
+ auto image = m_context.hitTestResult().image();
+ if (imageURL.isLocalFile() || image) {
appendItem(CopyImageItem, m_contextMenu.get());
#if ENABLE(IMAGE_EXTRACTION)
- appendItem(RevealImageItem, m_contextMenu.get());
+ if (image && !image->isAnimated())
+ appendItem(RevealImageItem, m_contextMenu.get());
#endif
}
#if PLATFORM(GTK)
Modified: trunk/Source/WebKit/ChangeLog (276347 => 276348)
--- trunk/Source/WebKit/ChangeLog 2021-04-21 07:18:16 UTC (rev 276347)
+++ trunk/Source/WebKit/ChangeLog 2021-04-21 07:21:40 UTC (rev 276348)
@@ -1,3 +1,20 @@
+2021-04-21 Wenson Hsieh <[email protected]>
+
+ [macOS] Avoid triggering image extraction for animated images
+ https://bugs.webkit.org/show_bug.cgi?id=224851
+
+ Reviewed by Megan Gardner.
+
+ Avoid making image extraction requests for animated images by adding an optional `AllowsAnimatedImages`
+ argument to `createShareableBitmap`, and passing in `AllowsAnimatedImages::No` in the case where we're creating
+ a shareable bitmap for image extraction.
+
+ * WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp:
+ (WebKit::createShareableBitmap):
+ * WebProcess/WebCoreSupport/ShareableBitmapUtilities.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::requestImageExtraction):
+
2021-04-21 Megan Gardner <[email protected]>
Support scrolling to a selected AppHighlight
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp (276347 => 276348)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp 2021-04-21 07:18:16 UTC (rev 276347)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp 2021-04-21 07:21:40 UTC (rev 276348)
@@ -37,7 +37,7 @@
namespace WebKit {
using namespace WebCore;
-RefPtr<ShareableBitmap> createShareableBitmap(RenderImage& renderImage, Optional<FloatSize> screenSizeInPixels)
+RefPtr<ShareableBitmap> createShareableBitmap(RenderImage& renderImage, Optional<FloatSize> screenSizeInPixels, AllowAnimatedImages allowAnimatedImages)
{
auto* cachedImage = renderImage.cachedImage();
if (!cachedImage || cachedImage->errorOccurred())
@@ -47,6 +47,9 @@
if (!image || image->width() <= 1 || image->height() <= 1)
return nullptr;
+ if (allowAnimatedImages == AllowAnimatedImages::No && image->isAnimated())
+ return nullptr;
+
auto bitmapSize = cachedImage->imageSizeForRenderer(&renderImage);
if (screenSizeInPixels) {
auto scaledSize = largestRectWithAspectRatioInsideRect(bitmapSize.width() / bitmapSize.height(), { FloatPoint(), *screenSizeInPixels }).size();
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.h (276347 => 276348)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.h 2021-04-21 07:18:16 UTC (rev 276347)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.h 2021-04-21 07:21:40 UTC (rev 276348)
@@ -37,6 +37,7 @@
class ShareableBitmap;
-RefPtr<ShareableBitmap> createShareableBitmap(WebCore::RenderImage&, Optional<WebCore::FloatSize> screenSizeInPixels = WTF::nullopt);
+enum class AllowAnimatedImages : bool { No, Yes };
+RefPtr<ShareableBitmap> createShareableBitmap(WebCore::RenderImage&, Optional<WebCore::FloatSize> screenSizeInPixels = WTF::nullopt, AllowAnimatedImages = AllowAnimatedImages::Yes);
};
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (276347 => 276348)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-04-21 07:18:16 UTC (rev 276347)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-04-21 07:21:40 UTC (rev 276348)
@@ -7318,7 +7318,7 @@
}
auto& renderImage = downcast<RenderImage>(*renderer);
- auto bitmap = createShareableBitmap(renderImage);
+ auto bitmap = createShareableBitmap(renderImage, WTF::nullopt, AllowAnimatedImages::No);
if (!bitmap) {
if (completion)
completion({ });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes