⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259567 in webkit


Ignore:
Timestamp:
Apr 6, 2020, 1:03:17 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

CanvasRenderingContext2D.drawImage should ignore the EXIF orientation if the image-orientation is none
https://bugs.webkit.org/show_bug.cgi?id=209849

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2020-04-06
Reviewed by Darin Adler.

Source/WebCore:

drawImage() will get the image-orientation of the HTMLImageElement from
its computed style. This will be passed to GraphicsContext::drawImage()
in the ImagePaintingOptions. Previously we were passing FromImage always.

Test: fast/images/image-orientation-none-canvas.html

  • html/canvas/CanvasRenderingContext2DBase.cpp:

(WebCore::CanvasRenderingContext2DBase::drawImage):

  • html/canvas/CanvasRenderingContext2DBase.h:

LayoutTests:

  • fast/images/image-orientation-none-canvas-expected.html: Added.
  • fast/images/image-orientation-none-canvas.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r259562 r259567  
     12020-04-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        CanvasRenderingContext2D.drawImage should ignore the EXIF orientation if the image-orientation is none
     4        https://bugs.webkit.org/show_bug.cgi?id=209849
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/images/image-orientation-none-canvas-expected.html: Added.
     9        * fast/images/image-orientation-none-canvas.html: Added.
     10
    1112020-04-05  Manuel Rego Casasnovas  <rego@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r259566 r259567  
     12020-04-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        CanvasRenderingContext2D.drawImage should ignore the EXIF orientation if the image-orientation is none
     4        https://bugs.webkit.org/show_bug.cgi?id=209849
     5
     6        Reviewed by Darin Adler.
     7
     8        drawImage() will get the image-orientation of the HTMLImageElement from
     9        its computed style. This will be passed to GraphicsContext::drawImage()
     10        in the ImagePaintingOptions. Previously we were passing FromImage always.
     11
     12        Test: fast/images/image-orientation-none-canvas.html
     13
     14        * html/canvas/CanvasRenderingContext2DBase.cpp:
     15        (WebCore::CanvasRenderingContext2DBase::drawImage):
     16        * html/canvas/CanvasRenderingContext2DBase.h:
     17
    1182020-04-05  Rob Buis  <rbuis@igalia.com>
    219
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp

    r259024 r259567  
    14651465    FloatRect imageRect = FloatRect(FloatPoint(), size(imageElement, ImageSizeType::BeforeDevicePixelRatio));
    14661466
    1467     auto result = drawImage(imageElement.document(), imageElement.cachedImage(), imageElement.renderer(), imageRect, srcRect, dstRect, op, blendMode);
     1467    auto orientation = ImageOrientation::FromImage;
     1468    if (auto* computedStyle = imageElement.computedStyle())
     1469        orientation = computedStyle->imageOrientation();
     1470
     1471    auto result = drawImage(imageElement.document(), imageElement.cachedImage(), imageElement.renderer(), imageRect, srcRect, dstRect, op, blendMode, orientation);
    14681472
    14691473    if (!result.hasException())
     
    14881492#endif
    14891493
    1490 ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(Document& document, CachedImage* cachedImage, const RenderObject* renderer, const FloatRect& imageRect, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMode& blendMode)
     1494ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(Document& document, CachedImage* cachedImage, const RenderObject* renderer, const FloatRect& imageRect, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMode& blendMode, ImageOrientation orientation)
    14911495{
    14921496    if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfinite(dstRect.width()) || !std::isfinite(dstRect.height())
     
    15441548    }
    15451549
    1546     ImagePaintingOptions options = { op, blendMode, ImageOrientation::FromImage };
     1550    ImagePaintingOptions options = { op, blendMode, orientation };
    15471551
    15481552    if (rectContainsCanvas(normalizedDstRect)) {
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h

    r258219 r259567  
    334334    ExceptionOr<void> drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator&, const BlendMode&);
    335335    ExceptionOr<void> drawImage(CanvasBase&, const FloatRect& srcRect, const FloatRect& dstRect);
    336     ExceptionOr<void> drawImage(Document&, CachedImage*, const RenderObject*, const FloatRect& imageRect, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator&, const BlendMode&);
     336    ExceptionOr<void> drawImage(Document&, CachedImage*, const RenderObject*, const FloatRect& imageRect, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator&, const BlendMode&, ImageOrientation = ImageOrientation::FromImage);
    337337#if ENABLE(VIDEO)
    338338    ExceptionOr<void> drawImage(HTMLVideoElement&, const FloatRect& srcRect, const FloatRect& dstRect);
Note: See TracChangeset for help on using the changeset viewer.