Changeset 276984 in webkit


Ignore:
Timestamp:
May 4, 2021 2:40:29 PM (15 months ago)
Author:
Cameron McCormack
Message:

Handle clamping of heights for images affected by background-size and EXIF orientation correctly
https://bugs.webkit.org/show_bug.cgi?id=221005
<rdar://problem/73692426>

Reviewed by Simon Fraser.

Source/WebCore:

GraphicsContext::drawPlatformImage handles requests with source rects
whose heights are greater than the image (which can happen due to
rounding issues) by clamping the source rect. This clamping incorrectly
looks at the CGImage's height, which for an image rotated 90deg due to
EXIF orientation metadata, is the wrong dimension.

Test: fast/images/image-orientation-background-size-bug.html

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::drawPlatformImage):

LayoutTests:

  • fast/images/image-orientation-background-size-bug-expected.html: Added.
  • fast/images/image-orientation-background-size-bug.html: Added.
  • fast/images/resources/green-504x378-90deg.jpg: Added. This is a

solid green 504x378 JPEG with an EXIF orientation tag requiring a
90deg rotation.

Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r276971 r276984  
     12021-05-04  Cameron McCormack  <heycam@apple.com>
     2
     3        Handle clamping of heights for images affected by background-size and EXIF orientation correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=221005
     5        <rdar://problem/73692426>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * fast/images/image-orientation-background-size-bug-expected.html: Added.
     10        * fast/images/image-orientation-background-size-bug.html: Added.
     11        * fast/images/resources/green-504x378-90deg.jpg: Added.  This is a
     12        solid green 504x378 JPEG with an EXIF orientation tag requiring a
     13        90deg rotation.
     14
    1152021-05-04  Sergio Villar Senin  <svillar@igalia.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r276981 r276984  
     12021-05-04  Cameron McCormack  <heycam@apple.com>
     2
     3        Handle clamping of heights for images affected by background-size and EXIF orientation correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=221005
     5        <rdar://problem/73692426>
     6
     7        Reviewed by Simon Fraser.
     8
     9        GraphicsContext::drawPlatformImage handles requests with source rects
     10        whose heights are greater than the image (which can happen due to
     11        rounding issues) by clamping the source rect.  This clamping incorrectly
     12        looks at the CGImage's height, which for an image rotated 90deg due to
     13        EXIF orientation metadata, is the wrong dimension.
     14
     15        Test: fast/images/image-orientation-background-size-bug.html
     16
     17        * platform/graphics/cg/GraphicsContextCG.cpp:
     18        (WebCore::GraphicsContext::drawPlatformImage):
     19
    1202021-05-04  Jer Noble  <jer.noble@apple.com>
    221
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r275650 r276984  
    215215    RetainPtr<CGImageRef> subImage(image);
    216216
    217     float currHeight = options.orientation().usesWidthAsHeight() ? CGImageGetWidth(subImage.get()) : CGImageGetHeight(subImage.get());
     217    auto logicalHeight = [&](CGImageRef image) {
     218        return options.orientation().usesWidthAsHeight() ? CGImageGetWidth(image) : CGImageGetHeight(image);
     219    };
     220
     221    float currHeight = logicalHeight(subImage.get());
    218222    if (currHeight <= srcRect.y())
    219223        return;
     
    266270#endif
    267271            if (currHeight < srcRect.maxY()) {
    268                 ASSERT(CGImageGetHeight(subImage.get()) == currHeight - CGRectIntegral(srcRect).origin.y);
    269                 adjustedDestRect.setHeight(CGImageGetHeight(subImage.get()) / yScale);
     272                ASSERT(logicalHeight(subImage.get()) == currHeight - CGRectIntegral(srcRect).origin.y);
     273                adjustedDestRect.setHeight(logicalHeight(subImage.get()) / yScale);
    270274            }
    271275        } else {
Note: See TracChangeset for help on using the changeset viewer.