⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 187250 in webkit


Ignore:
Timestamp:
Jul 23, 2015, 1:53:47 PM (11 years ago)
Author:
Beth Dakin
Message:

Should not allow previews of 1x1 images
https://bugs.webkit.org/show_bug.cgi?id=147237
-and corresponding-
rdar://problem/21968460

Reviewed by Tim Horton.

1x1 images are used on some sites to cover actual images, which leads to a
misleading preview experience. There is not any reason why you would really
want to preview an image this small nor any reason to believe that the
preview would result in anything useful.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::getPositionInformation):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r187248 r187250  
     12015-07-23  Beth Dakin  <bdakin@apple.com>
     2
     3        Should not allow previews of 1x1 images
     4        https://bugs.webkit.org/show_bug.cgi?id=147237
     5        -and corresponding-
     6        rdar://problem/21968460
     7
     8        Reviewed by Tim Horton.
     9
     10        1x1 images are used on some sites to cover actual images, which leads to a
     11        misleading preview experience. There is not any reason why you would really
     12        want to preview an image this small nor any reason to believe that the
     13        preview would result in anything useful.
     14        * WebProcess/WebPage/ios/WebPageIOS.mm:
     15        (WebKit::WebPage::getPositionInformation):
     16
    1172015-07-23  Brady Eidson  <beidson@apple.com>
    218
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r187220 r187250  
    22222222                    auto& renderImage = downcast<RenderImage>(*(element->renderer()));
    22232223                    if (renderImage.cachedImage() && !renderImage.cachedImage()->errorOccurred()) {
    2224                         info.imageURL = [(NSURL *)element->document().completeURL(renderImage.cachedImage()->url()) absoluteString];
    22252224                        if (Image* image = renderImage.cachedImage()->imageForRenderer(&renderImage)) {
    2226                             info.isAnimatedImage = image->isAnimated();
    2227                             FloatSize screenSizeInPixels = screenSize();
    2228                             screenSizeInPixels.scale(corePage()->deviceScaleFactor());
    2229                             FloatSize scaledSize = largestRectWithAspectRatioInsideRect(image->size().width() / image->size().height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size();
    2230                             FloatSize bitmapSize = scaledSize.width() < image->size().width() ? scaledSize : image->size();
    2231                             if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), ShareableBitmap::SupportsAlpha)) {
    2232                                 auto graphicsContext = sharedBitmap->createGraphicsContext();
    2233                                 graphicsContext->drawImage(image, ColorSpaceDeviceRGB, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height()));
    2234                                 info.image = sharedBitmap;
     2225                            if (image->width() > 1 && image->height() > 1) {
     2226                                info.imageURL = [(NSURL *)element->document().completeURL(renderImage.cachedImage()->url()) absoluteString];
     2227                                info.isAnimatedImage = image->isAnimated();
     2228                                FloatSize screenSizeInPixels = screenSize();
     2229                                screenSizeInPixels.scale(corePage()->deviceScaleFactor());
     2230                                FloatSize scaledSize = largestRectWithAspectRatioInsideRect(image->size().width() / image->size().height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size();
     2231                                FloatSize bitmapSize = scaledSize.width() < image->size().width() ? scaledSize : image->size();
     2232                                if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), ShareableBitmap::SupportsAlpha)) {
     2233                                    auto graphicsContext = sharedBitmap->createGraphicsContext();
     2234                                    graphicsContext->drawImage(image, ColorSpaceDeviceRGB, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height()));
     2235                                    info.image = sharedBitmap;
     2236                                }
    22352237                            }
    22362238                        }
Note: See TracChangeset for help on using the changeset viewer.