Bug 100698

Summary: Add a test for reading exif orientation off image documents
Product: WebKit Reporter: Nico Weber <thakis>
Component: New BugsAssignee: Nico Weber <thakis>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, d-r, eric, hclam, noel.gordon, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 100191    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch for landing
none
Patch for landing none

Description Nico Weber 2012-10-29 14:22:59 PDT
Add a test for reading exif orientation off image documents
Comment 1 Nico Weber 2012-10-29 14:23:43 PDT
Created attachment 171313 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-10-29 16:17:02 PDT
Comment on attachment 171313 [details]
Patch

Could we make this say PASS/FAIL instead?  You, the test writer, have that information better than someone bringing up a new port and staring at this for the first time. :)
Comment 3 Nico Weber 2012-10-29 16:34:48 PDT
Created attachment 171334 [details]
Patch
Comment 4 Nico Weber 2012-10-29 16:35:25 PDT
(In reply to comment #2)
> (From update of attachment 171313 [details])
> Could we make this say PASS/FAIL instead?  You, the test writer, have that information better than someone bringing up a new port and staring at this for the first time. :)

Sure thing, done. (I copied the behavior of exif-orientation.html, but I agree that it's better now.)
Comment 5 Nico Weber 2012-10-29 16:36:56 PDT
Created attachment 171335 [details]
Patch
Comment 6 Eric Seidel (no email) 2012-10-29 16:37:16 PDT
Comment on attachment 171334 [details]
Patch

I would have done something like expectHorizontal(1); expectVertical(2); for each of the cases.  But this is fine too.
Comment 7 WebKit Review Bot 2012-10-29 17:59:06 PDT
Comment on attachment 171335 [details]
Patch

Rejecting attachment 171335 [details] from commit-queue.

New failing tests:
platform/chromium/virtual/deferred/fast/images/exif-orientation-image-document.html
Full output: http://queues.webkit.org/results/14631303
Comment 8 WebKit Review Bot 2012-10-29 18:57:49 PDT
Comment on attachment 171334 [details]
Patch

Attachment 171334 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14623550

New failing tests:
platform/chromium/virtual/deferred/fast/images/exif-orientation-image-document.html
Comment 9 Nico Weber 2012-10-29 20:03:11 PDT
Created attachment 171364 [details]
Patch for landing
Comment 10 Nico Weber 2012-10-29 20:04:50 PDT
hclam: The test I'm adding in this CL fails with in the deferred image decoding suite. I'm adding it to TestExpectations to the block of other failing tests. It'll need to be fixed before deferred decoding can become turned on by default.
Comment 11 Hin-Chung Lam 2012-10-29 20:06:03 PDT
(In reply to comment #10)
> hclam: The test I'm adding in this CL fails with in the deferred image decoding suite. I'm adding it to TestExpectations to the block of other failing tests. It'll need to be fixed before deferred decoding can become turned on by default.

okay sounds good to me.
Comment 12 WebKit Review Bot 2012-10-29 20:53:04 PDT
Comment on attachment 171364 [details]
Patch for landing

Rejecting attachment 171364 [details] from commit-queue.

New failing tests:
platform/chromium/virtual/deferred/fast/images/exif-orientation-image-document.html
Full output: http://queues.webkit.org/results/14642307
Comment 13 Nico Weber 2012-10-29 21:13:12 PDT
Created attachment 171368 [details]
Patch for landing
Comment 14 WebKit Review Bot 2012-10-30 01:02:53 PDT
Comment on attachment 171368 [details]
Patch for landing

Clearing flags on attachment: 171368

Committed r132877: <http://trac.webkit.org/changeset/132877>
Comment 15 WebKit Review Bot 2012-10-30 01:03:01 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 noel gordon 2012-10-31 03:22:44 PDT
Chromium Expectations added in r132989 <http://trac.webkit.org/changeset/132989>
Comment 17 Dominik Röttsches (drott) 2012-11-06 06:38:35 PST
Nico, are you sure this should work without overriding the preference? My suspicion is, it passes on Chromium since the preference is default on, isn't it?

I would suggest to add
 testRunner.overridePreference('WebKitShouldRespectImageOrientation', 1);
Comment 18 Nico Weber 2012-11-06 07:52:49 PST
Hi Dominik,

(In reply to comment #17)
> Nico, are you sure this should work without overriding the preference?

Yes, that's correct: The preference controls if exif information is used for <img> elements in html documents. For image documents, exif information is always used on ports that support it.

> My suspicion is, it passes on Chromium since the preference is default on, isn't it?

No, the pref is off by default in chromium, and we don't plan to turn it on in the close future.

> I would suggest to add
>  testRunner.overridePreference('WebKitShouldRespectImageOrientation', 1);

That won't have an effect on the test.


For the exif stuff to work, your port needs to have explicit code to support drawing of rotated images. For that reason, RenderObject::shouldRespectImageOrientation() has an #ifdef for the imagedocument code that's currently only on for mac and chromium. If your port's drawing code doesn't support honoring image orientation, then without that ifdef images would be laid out according to their exif information, but then only stretched (instead of rotated) at paint time – which is worse than them being 90 degree rotated. (To see what I mean, remove the ifdef in RenderObject::shouldRespectImageOrientation() and look at the test this bug added in your port). If you want to get this test passing on your port, you need to implement drawing support first and then enable the ifdef for your port.
Comment 19 Eric Seidel (no email) 2012-11-06 11:45:15 PST
Comment on attachment 171368 [details]
Patch for landing

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

Isn't this a text test?

> LayoutTests/platform/chromium/TestExpectations:3829
> +Bug(thakis) fast/images/exif-orientation-image-document.html [ ImageOnlyFailure ] 

image?
Comment 20 Nico Weber 2012-11-06 12:48:04 PST
(In reply to comment #19)
> (From update of attachment 171368 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=171368&action=review
> 
> Isn't this a text test?

No. The test says `testRunner.dumpAsText(true);`, and the `true` means "generate pixel dumps" as far as I know.

If your question is "shouldn't it be sufficient to make this a text-only test?": No, because the image bounds alone don't tell you if an image is upside down.

> 
> > LayoutTests/platform/chromium/TestExpectations:3829
> > +Bug(thakis) fast/images/exif-orientation-image-document.html [ ImageOnlyFailure ] 
> 
> image?
Comment 21 Dominik Röttsches (drott) 2012-11-06 23:49:51 PST
(In reply to comment #18)

Thanks Nico for the detailed explanations.

I did implement the rotation/flipping code in bug 101207 for Cairo, however, i didn't find that RenderObject #ifdef earlier. 

> > I would suggest to add
> >  testRunner.overridePreference('WebKitShouldRespectImageOrientation', 1);
> 
> That won't have an effect on the test.

Actually, it does. If I enable the setting inside the test, it passes on Cairo/EFL since the second line of the if-condition in RenderObject::shouldRespectImageOrientation checks for the setting.

> For the exif stuff to work, your port needs to have explicit code to support drawing of rotated images. For that reason, RenderObject::shouldRespectImageOrientation() has an #ifdef for the imagedocument code that's currently only on for mac and chromium.  [...] If you want to get this test passing on your port, you need to implement drawing support first and then enable the ifdef for your port.

Yep, I'll add USE(CAIRO) to the ifdef in RenderObject that you mentioned. Thanks again.