Bug 203355

Summary: EXIF orientation is ignored for some CSS images
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: CSSAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, ews-watchlist, glenn, jbedard, kondapallykalyan, pdr, sabouhallawa, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=201123
Bug Depends on:    
Bug Blocks: 89052    
Attachments:
Description Flags
Testcase
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Simon Fraser (smfr) 2019-10-23 22:31:57 PDT
Created attachment 381775 [details]
Testcase

We ignore EXIF orientation when hitting the rendering codepaths that go through GraphicsContext::drawTiledImage(), so fail to respect EXIF orientation for CSS images in tiled background-image, border-image etc.
Comment 1 Radar WebKit Bug Importer 2019-10-23 22:33:57 PDT
<rdar://problem/56568303>
Comment 2 Said Abou-Hallawa 2020-01-16 15:47:55 PST
Created attachment 387973 [details]
Patch
Comment 3 Said Abou-Hallawa 2020-01-17 15:07:36 PST
Created attachment 388093 [details]
Patch
Comment 4 Said Abou-Hallawa 2020-01-17 15:08:49 PST
(In reply to Said Abou-Hallawa from comment #3)
> Created attachment 388093 [details]
> Patch

In this patch the EXIF orientation is respected with css background images and css border images.
Comment 5 Said Abou-Hallawa 2020-01-17 15:34:24 PST
Created attachment 388097 [details]
Patch
Comment 6 Simon Fraser (smfr) 2020-01-17 16:31:01 PST
Comment on attachment 388097 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=388097&action=review

> Source/WebCore/platform/graphics/BitmapImage.cpp:162
> +    FloatRect rect = { IntPoint::zero(), size() };

It's a bit weird to initialize the location of a FloatRect with IntPoint::zero

Is size() computed respecting orientation? I.e. do we know this code won't distort the image?
Comment 7 Said Abou-Hallawa 2020-01-17 16:38:23 PST
Comment on attachment 388097 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=388097&action=review

>> Source/WebCore/platform/graphics/BitmapImage.cpp:162
>> +    FloatRect rect = { IntPoint::zero(), size() };
> 
> It's a bit weird to initialize the location of a FloatRect with IntPoint::zero
> 
> Is size() computed respecting orientation? I.e. do we know this code won't distort the image?

I will replace the IntPoint::zero() by FloatPoint().

Yes size() is computed respecting orientation since it takes an ImageOrientation argument which has a default value 'FromImage'. The definition of it in Image.h is

virtual FloatSize size(ImageOrientation = ImageOrientation::FromImage) const = 0;
Comment 8 Said Abou-Hallawa 2020-01-17 16:49:26 PST
Created attachment 388116 [details]
Patch
Comment 9 Said Abou-Hallawa 2020-01-20 11:14:35 PST
Created attachment 388248 [details]
Patch
Comment 10 WebKit Commit Bot 2020-01-20 18:54:27 PST
Comment on attachment 388248 [details]
Patch

Clearing flags on attachment: 388248

Committed r254841: <https://trac.webkit.org/changeset/254841>
Comment 11 WebKit Commit Bot 2020-01-20 18:54:28 PST
All reviewed patches have been landed.  Closing bug.
Comment 14 Said Abou-Hallawa 2020-01-21 15:53:51 PST
(In reply to Jonathan Bedard from comment #13)
> Oops, wrong tests:
> https://results.webkit.org/?suite=layout-tests&suite=layout-
> tests&test=fast%2Fimages%2Fexif-orientation-border-image.
> html&test=fast%2Fimages%2Fexif-orientation-background-image-no-repeat.html

Yes. The non CG ports have to skip these tests or to respect the EXIF image orientation when drawing the native image for CSS background and border.