Bug 217808 - REGRESSION(r268249): image-orientation:none is broken for local (file://) urls
Summary: REGRESSION(r268249): image-orientation:none is broken for local (file://) urls
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Noam Rosenthal
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-15 21:40 PDT by Myles C. Maxfield
Modified: 2020-10-29 10:53 PDT (History)
9 users (show)

See Also:


Attachments
Repro (14.95 KB, application/zip)
2020-10-15 21:40 PDT, Myles C. Maxfield
no flags Details
Patch (4.46 KB, patch)
2020-10-23 06:36 PDT, Noam Rosenthal
no flags Details | Formatted Diff | Diff
Patch (4.49 KB, patch)
2020-10-23 11:30 PDT, Noam Rosenthal
no flags Details | Formatted Diff | Diff
Patch (6.89 KB, patch)
2020-10-26 02:38 PDT, Noam Rosenthal
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2020-10-15 21:40:23 PDT
Created attachment 411533 [details]
Repro

View attached example. The two images should have different orientations. One image is rotated via EXIF, and the other has rotated pixel data.
Comment 1 Myles C. Maxfield 2020-10-15 21:56:59 PDT
I'm testing on ToT WebKit on 19G2021
Comment 2 Said Abou-Hallawa 2020-10-16 12:35:57 PDT
When opening LayoutTests/fast/images/image-orientation-none.html in Safari or mini browser, the display looks broken. However run-webkit-tests passes this test and matches the display of LayoutTests/fast/images/image-orientation-none-expected.html.

The bug happens because CachedImage::isOriginClean() returns false of local images files. So HTMLImageElement::allowsOrientationOverride() return false as well and finally RenderElement::imageOrientation() returns ImageOrientation::FromImage and ignores the css styling image-orientation.

When accessing the same page through an HTTP server, the display looks fine.
Comment 3 Noam Rosenthal 2020-10-16 23:33:10 PDT
A possible solution would be to make this an http test
Comment 4 Said Abou-Hallawa 2020-10-22 10:41:21 PDT
(In reply to Noam Rosenthal from comment #3)
> A possible solution would be to make this an http test

No. I think we need to fix it for local files. Having the layout for local images different from the layout for remote files is very confusing.
Comment 5 Noam Rosenthal 2020-10-22 10:56:34 PDT
Sure, I'll work on a patch that
Comment 6 Noam Rosenthal 2020-10-22 10:56:47 PDT
(In reply to Noam Rosenthal from comment #5)
> Sure, I'll work on a patch that
... fixes this.
Comment 7 Radar WebKit Bug Importer 2020-10-22 21:41:19 PDT
<rdar://problem/70603407>
Comment 8 Noam Rosenthal 2020-10-23 06:36:27 PDT
Created attachment 412172 [details]
Patch
Comment 9 Said Abou-Hallawa 2020-10-23 11:05:00 PDT
Comment on attachment 412172 [details]
Patch

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

> Source/WebCore/html/HTMLImageElement.cpp:689
> +        || (document().securityOrigin().canLoadLocalResources() && image->origin() && image->origin()->isLocal());

Do we need to check whether we canLoadLocalResources() or not here? I think this function should be used before loading the resource not after loading it.

> LayoutTests/fast/images/image-orientation-none-local-expected.html:10
> +            l.testRunner.pathToLocalResource(`file:///tmp/LayoutTests/fast/images/${l}`))

Why does the path have file:///tmp/? Are you sure this test load any resources at all? Does this test fail without your patch?

> LayoutTests/fast/images/image-orientation-none-local.html:6
> +        localImageLocation = testRunner.pathToLocalResource(`file:///tmp/LayoutTests/fast/images/${localImageLocation}`);

Ditto.
Comment 10 Noam Rosenthal 2020-10-23 11:29:31 PDT
Comment on attachment 412172 [details]
Patch

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

>> Source/WebCore/html/HTMLImageElement.cpp:689
>> +        || (document().securityOrigin().canLoadLocalResources() && image->origin() && image->origin()->isLocal());
> 
> Do we need to check whether we canLoadLocalResources() or not here? I think this function should be used before loading the resource not after loading it.

Maybe the check should be whether the

>> LayoutTests/fast/images/image-orientation-none-local-expected.html:10
>> +            l.testRunner.pathToLocalResource(`file:///tmp/LayoutTests/fast/images/${l}`))
> 
> Why does the path have file:///tmp/? Are you sure this test load any resources at all? Does this test fail without your patch?

Yes, see other tests using pathToLocalResource. This seems to be the way to do it.
Comment 11 Noam Rosenthal 2020-10-23 11:30:12 PDT
Created attachment 412200 [details]
Patch
Comment 12 Said Abou-Hallawa 2020-10-23 11:51:59 PDT
Comment on attachment 412172 [details]
Patch

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

>>> LayoutTests/fast/images/image-orientation-none-local-expected.html:10
>>> +            l.testRunner.pathToLocalResource(`file:///tmp/LayoutTests/fast/images/${l}`))
>> 
>> Why does the path have file:///tmp/? Are you sure this test load any resources at all? Does this test fail without your patch?
> 
> Yes, see other tests using pathToLocalResource. This seems to be the way to do it.

I applied your patch and I changed the text in the <p> element in image-orientation-none-local.html. I ran "run-webkit-test image-orientation-none-local.html" and of course the test failed. But when seeing the difference, there was no images displayed either in the test or in the expected page. Only the <p> is displayed.

I reverted your change HTMLImageElement::allowsOrientationOverride() and I ran "run-webkit-test image-orientation-none-local.html" without changing the <p> text. The test passed. This confirms no images were loaded in either the test of the expected page.
Comment 13 Noam Rosenthal 2020-10-23 11:54:31 PDT
(In reply to Said Abou-Hallawa from comment #12)
> Comment on attachment 412172 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=412172&action=review
> 
> >>> LayoutTests/fast/images/image-orientation-none-local-expected.html:10
> >>> +            l.testRunner.pathToLocalResource(`file:///tmp/LayoutTests/fast/images/${l}`))
> >> 
> >> Why does the path have file:///tmp/? Are you sure this test load any resources at all? Does this test fail without your patch?
> > 
> > Yes, see other tests using pathToLocalResource. This seems to be the way to do it.
> 
> I applied your patch and I changed the text in the <p> element in
> image-orientation-none-local.html. I ran "run-webkit-test
> image-orientation-none-local.html" and of course the test failed. But when
> seeing the difference, there was no images displayed either in the test or
> in the expected page. Only the <p> is displayed.
> 
> I reverted your change HTMLImageElement::allowsOrientationOverride() and I
> ran "run-webkit-test image-orientation-none-local.html" without changing the
> <p> text. The test passed. This confirms no images were loaded in either the
> test of the expected page.
Hmm I wonder what's the way to do this... I tested with mini-browser and loading those images with file URLs. Will investigate.
Comment 14 Said Abou-Hallawa 2020-10-23 11:57:08 PDT
Comment on attachment 412172 [details]
Patch

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

>>>> LayoutTests/fast/images/image-orientation-none-local-expected.html:10
>>>> +            l.testRunner.pathToLocalResource(`file:///tmp/LayoutTests/fast/images/${l}`))
>>> 
>>> Why does the path have file:///tmp/? Are you sure this test load any resources at all? Does this test fail without your patch?
>> 
>> Yes, see other tests using pathToLocalResource. This seems to be the way to do it.
> 
> I applied your patch and I changed the text in the <p> element in image-orientation-none-local.html. I ran "run-webkit-test image-orientation-none-local.html" and of course the test failed. But when seeing the difference, there was no images displayed either in the test or in the expected page. Only the <p> is displayed.
> 
> I reverted your change HTMLImageElement::allowsOrientationOverride() and I ran "run-webkit-test image-orientation-none-local.html" without changing the <p> text. The test passed. This confirms no images were loaded in either the test of the expected page.

I looked at all the instances of "pathToLocalResource('file:///tmp/" and I found all of them under LayoutTests/http/tests/. Maybe you need to change the location of this test to be under LayoutTests/http/tests/images.
Comment 15 Noam Rosenthal 2020-10-26 02:38:12 PDT
Created attachment 412297 [details]
Patch
Comment 16 EWS 2020-10-29 10:53:36 PDT
Committed r269155: <https://trac.webkit.org/changeset/269155>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 412297 [details].