Source/WebCore:
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Sep 2019 00:47:39 +0000 (00:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Sep 2019 00:47:39 +0000 (00:47 +0000)
commit192d9fa20bcc05cd6cdc442744e0333596fe8de4
tree50fd94d560ebdc43d0ffe5cd2bb703885a93d941
parentb7d95ac8ef539bd6ab64e49b36e9e03956bb2c38
Source/WebCore:
EXIF orientation should be respected when rendering images
https://bugs.webkit.org/show_bug.cgi?id=201123

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-08-31
Reviewed by Simon Fraser.

-- Image::size() will return the rendered size based on the image
   orientation. If image orientation is FromImage, ImageSource will query
   the actual image orientation from the ImageDecoder. The low level APIs
   might transpose the size just before calling the system API to draw
   the image.

-- RenderElement::imageOrientation() will return ImageOrientation::FromImage
   for all images and for all ports till the CSS image-orientation specs
   is finalized.

-- The default of ImagePaintingOptions argument of GraphicsContext::drawImage()
   will be changed to { ImageOrientation::FromImage }.

-- Image element: RenderImage::paintIntoRect() will pass imageOrientation()
   which returns ImageOrientation::FromImage to GraphicsContext::drawImage().

-- CSS background image: RenderBoxModelObject::paintFillLayerExtended will
   pass ImageOrientation::FromImage by default to GraphicsContext::drawTiledImage().

-- Images on canvas: CanvasRenderingContext2DBase::drawImage() will pass
   ImageOrientation::FromImage by default to GraphicsContext::drawImage().

-- SVG images: RenderSVGImage::paintForeground() calls GraphicsContext::drawImage()
   with the default ImagePaintingOptions which is now { ImageOrientation::FromImage }.

-- SVG feImage filters: FEImage::platformApplySoftware() calls
   GraphicsContext::drawImage() with the default ImagePaintingOptions
   which is now { ImageOrientation::FromImage }.

-- ImageDocument: RenderElement::imageOrientation() returns FromImage
   always and for all ports.

Tests: fast/images/exif-orientation-background.html
       fast/images/exif-orientation-canvas.html
       fast/images/exif-orientation-content.html
       fast/images/exif-orientation-element-object-fit.html
       fast/images/exif-orientation-element.html
       fast/images/exif-orientation-image-object.html
       fast/images/exif-orientation-svg-feimage.html
       fast/images/exif-orientation-svg-image.html

* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::drawImage):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::imageSizeForRenderer const):
* platform/graphics/BitmapImage.h:
* platform/graphics/CrossfadeGeneratedImage.h:
* platform/graphics/GeneratedImage.h:
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::drawImage):
* platform/graphics/Image.h:
* platform/graphics/ImageFrame.h:
(WebCore::ImageFrame::sizeRespectingOrientation const): Deleted.
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::ImageSource):
(WebCore::ImageSource::orientation):
(WebCore::ImageSource::size):
(WebCore::ImageSource::sizeRespectingOrientation): Deleted.
* platform/graphics/ImageSource.h:
* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::PDFDocumentImage::size const):
* platform/graphics/cg/PDFDocumentImage.h:
* platform/mac/DragImageMac.mm:
(WebCore::createDragImageFromImage):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::imageOrientation const):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintIntoRect):
* svg/graphics/SVGImage.h:
* svg/graphics/SVGImageForContainer.cpp:
(WebCore::SVGImageForContainer::size const):
* svg/graphics/SVGImageForContainer.h:

LayoutTests:
EXIF orientation should be respected when rendering images
https://bugs.webkit.org/show_bug.cgi?id=201123

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-08-31
Reviewed by Simon Fraser.

Existing tests are made ref-tests. New tests were added to cover more
cases for drawing images.

* fast/images/exif-orientation-background-expected.html: Added.
* fast/images/exif-orientation-background.html: Added.
* fast/images/exif-orientation-canvas-expected.html: Added.
* fast/images/exif-orientation-canvas.html: Added.
* fast/images/exif-orientation-composited-expected.html: Added.
* fast/images/exif-orientation-composited-expected.txt: Removed.
* fast/images/exif-orientation-composited.html:
* fast/images/exif-orientation-content-expected.html: Added.
* fast/images/exif-orientation-content.html: Added.
* fast/images/exif-orientation-css-expected.txt: Removed.
* fast/images/exif-orientation-css.html: Removed.
* fast/images/exif-orientation-element-expected.html: Added.
* fast/images/exif-orientation-element-object-fit-expected.html: Added.
* fast/images/exif-orientation-element-object-fit.html: Added.
* fast/images/exif-orientation-element.html: Added.
* fast/images/exif-orientation-expected.txt: Removed.
* fast/images/exif-orientation-image-document-expected.html: Added.
* fast/images/exif-orientation-image-document-expected.txt: Removed.
* fast/images/exif-orientation-image-document.html:
* fast/images/exif-orientation-image-object-expected.html: Added.
* fast/images/exif-orientation-image-object.html: Added.
* fast/images/exif-orientation-svg-feimage-expected.html: Added.
* fast/images/exif-orientation-svg-feimage.html: Added.
* fast/images/exif-orientation-svg-image-expected.html: Added.
* fast/images/exif-orientation-svg-image.html: Added.
* fast/images/exif-orientation.html: Removed.
* platform/gtk/TestExpectations:
* platform/mac/fast/images/exif-orientation-composited-expected.png: Removed.
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
50 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/images/exif-orientation-background-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-background.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-canvas-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-canvas.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-composited-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-composited-expected.txt [deleted file]
LayoutTests/fast/images/exif-orientation-composited.html
LayoutTests/fast/images/exif-orientation-content-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-content.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-css-expected.txt [deleted file]
LayoutTests/fast/images/exif-orientation-css.html [deleted file]
LayoutTests/fast/images/exif-orientation-element-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-element-object-fit-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-element-object-fit.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-element.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-expected.txt [deleted file]
LayoutTests/fast/images/exif-orientation-image-document-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-image-document-expected.txt [deleted file]
LayoutTests/fast/images/exif-orientation-image-document.html
LayoutTests/fast/images/exif-orientation-image-object-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-image-object.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-svg-feimage-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-svg-feimage.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-svg-image-expected.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation-svg-image.html [new file with mode: 0644]
LayoutTests/fast/images/exif-orientation.html [deleted file]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/fast/images/exif-orientation-composited-expected.png [deleted file]
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h
Source/WebCore/platform/graphics/GeneratedImage.h
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/graphics/ImageFrame.h
Source/WebCore/platform/graphics/ImageSource.cpp
Source/WebCore/platform/graphics/ImageSource.h
Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/svg/graphics/SVGImage.h
Source/WebCore/svg/graphics/SVGImageForContainer.cpp
Source/WebCore/svg/graphics/SVGImageForContainer.h