Changeset 249364 in webkit


Ignore:
Timestamp:
Aug 31, 2019 5:47:39 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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:
Location:
trunk
Files:
18 added
7 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249363 r249364  
     12019-08-31  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        EXIF orientation should be respected when rendering images
     4        https://bugs.webkit.org/show_bug.cgi?id=201123
     5
     6        Reviewed by Simon Fraser.
     7
     8        Existing tests are made ref-tests. New tests were added to cover more
     9        cases for drawing images.
     10
     11        * fast/images/exif-orientation-background-expected.html: Added.
     12        * fast/images/exif-orientation-background.html: Added.
     13        * fast/images/exif-orientation-canvas-expected.html: Added.
     14        * fast/images/exif-orientation-canvas.html: Added.
     15        * fast/images/exif-orientation-composited-expected.html: Added.
     16        * fast/images/exif-orientation-composited-expected.txt: Removed.
     17        * fast/images/exif-orientation-composited.html:
     18        * fast/images/exif-orientation-content-expected.html: Added.
     19        * fast/images/exif-orientation-content.html: Added.
     20        * fast/images/exif-orientation-css-expected.txt: Removed.
     21        * fast/images/exif-orientation-css.html: Removed.
     22        * fast/images/exif-orientation-element-expected.html: Added.
     23        * fast/images/exif-orientation-element-object-fit-expected.html: Added.
     24        * fast/images/exif-orientation-element-object-fit.html: Added.
     25        * fast/images/exif-orientation-element.html: Added.
     26        * fast/images/exif-orientation-expected.txt: Removed.
     27        * fast/images/exif-orientation-image-document-expected.html: Added.
     28        * fast/images/exif-orientation-image-document-expected.txt: Removed.
     29        * fast/images/exif-orientation-image-document.html:
     30        * fast/images/exif-orientation-image-object-expected.html: Added.
     31        * fast/images/exif-orientation-image-object.html: Added.
     32        * fast/images/exif-orientation-svg-feimage-expected.html: Added.
     33        * fast/images/exif-orientation-svg-feimage.html: Added.
     34        * fast/images/exif-orientation-svg-image-expected.html: Added.
     35        * fast/images/exif-orientation-svg-image.html: Added.
     36        * fast/images/exif-orientation.html: Removed.
     37        * platform/gtk/TestExpectations:
     38        * platform/mac/fast/images/exif-orientation-composited-expected.png: Removed.
     39        * platform/win/TestExpectations:
     40
    1412019-08-31  Wenson Hsieh  <wenson_hsieh@apple.com>
    242
  • trunk/LayoutTests/fast/images/exif-orientation-composited.html

    r218754 r249364  
    1 <html>
    2 <head>
    3 <script>
    4 if (window.internals)
    5     internals.settings.setShouldRespectImageOrientation(true);
    6 if (window.testRunner)
    7     testRunner.dumpAsText(true);
     1<!DOCTYPE html>
     2<style>
     3    div.container {
     4        display: inline-block;
     5        margin-right: 20px;
     6        margin-bottom: 10px;
     7        width: 100px;
     8        vertical-align: top;
     9    }
     10    div.horizontal {
     11        width: 102;
     12        height: 52px;
     13    }
     14    div.vertical {
     15        width: 52px;
     16        height: 102px;
     17    }
     18    img {
     19        -webkit-transform: translateZ(0);
     20        border: 1px solid black;
     21    }
     22</style>
     23<body>
     24    <b>The images of the composited &lt;img&gt; elements should be rotated respecting their EXIF orientation.</b>
     25    <br>
     26    <br>
     27    <div class="container">
     28        <div class="horizontal">
     29            <img id="img1" src="resources/exif-orientation-1-ul.jpg">
     30        </div>
     31        <br>Normal
     32    </div>
     33    <div class="container">
     34        <div class="horizontal">
     35            <img id="img2" src="resources/exif-orientation-2-ur.jpg">
     36        </div>
     37        <br>Flipped horizontally
     38    </div>
     39    <div class="container">
     40        <div class="horizontal">
     41            <img id="img3" src="resources/exif-orientation-3-lr.jpg">
     42        </div>
     43        <br>Rotated 180&deg;
     44    </div>
     45    <div class="container">
     46        <div class="horizontal">
     47            <img id="img4" src="resources/exif-orientation-4-lol.jpg">
     48        </div>
     49        <br>Flipped vertically
     50    </div>
     51    <br>
     52    <div class="container">
     53        <div class="vertical">
     54            <img id="img5" src="resources/exif-orientation-5-lu.jpg">
     55        </div>
     56        <br>Rotated 90&deg; CCW and flipped vertically
     57    </div>
     58    <div class="container">
     59        <div class="vertical">
     60            <img id="img6" src="resources/exif-orientation-6-ru.jpg">
     61        </div>
     62        <br>Rotated 90&deg; CCW
     63    </div>
     64    <div class="container">
     65        <div class="vertical">
     66            <img id="img7" src="resources/exif-orientation-7-rl.jpg">
     67        </div>
     68        <br>Rotated 90&deg; CW and flipped vertically
     69    </div>
     70    <div class="container">
     71        <div class="vertical">
     72            <img id="img8" src="resources/exif-orientation-8-llo.jpg">
     73        </div>
     74        <br>Rotated 90&deg; CW
     75    </div>
     76    <br>
     77    <div class="container">
     78        <div class="horizontal">
     79            <img id="img9" src="resources/exif-orientation-9-u.jpg">
     80        </div>
     81        <br>Undefined (invalid value)
     82    </div>
     83    <br>
     84    <ul id="console"></ul>
     85    <script>
     86        function log(str) {
     87            var li = document.createElement("li");
     88            li.appendChild(document.createTextNode(str));
     89            var console = document.getElementById("console");
     90            console.appendChild(li);
     91        }
    892
    9 function log(str) {
    10     var li = document.createElement("li");
    11     li.appendChild(document.createTextNode(str));
    12     var console = document.getElementById("console");
    13     console.appendChild(li);
    14 }
     93          function imageSize(el) {
     94            var computedStyle = window.getComputedStyle(el);
     95            return computedStyle.width + " by " + computedStyle.height;
     96        }
    1597
    16 function imageSize(el) {
    17     var computedStyle = window.getComputedStyle(el);
    18     return computedStyle.width + " by " + computedStyle.height;
    19 }
    20 
    21 
    22 function load() {
    23     for(var i = 1; i <= 7; i++)
    24         log("img" + i + " size = " + imageSize(document.getElementById("img" + i)))
    25 }
    26 
    27 </script>
    28 <style>
    29 img { -webkit-transform: translateZ(0); }
    30 div { display: inline-block; margin-right: 20px; margin-bottom: 10px; width: 100px; vertical-align: top; }
    31 </style>
    32 </head>
    33 <body onload="load()">
    34 <b>The images should be rotated respecting their EXIF orientation. This test can only be run with testRunner (or by manually setting WebKitShouldRespectImageOrientation to true).</b><br><br>
    35 <div><img id="img1" src="resources/exif-orientation-2-ur.jpg"><br>Flipped horizontally</div>
    36 <div><img id="img2" src="resources/exif-orientation-3-lr.jpg"><br>Rotated 180&deg;</div>
    37 <div><img id="img3" src="resources/exif-orientation-4-lol.jpg"><br>Flipped vertically</div>
    38 <br>
    39 <div><img id="img4" src="resources/exif-orientation-5-lu.jpg"><br>Rotated 90&deg; CCW and flipped vertically</div>
    40 <div><img id="img5" src="resources/exif-orientation-6-ru.jpg"><br>Rotated 90&deg; CCW</div>
    41 <div><img id="img6" src="resources/exif-orientation-7-rl.jpg"><br>Rotated 90&deg; CW and flipped vertically </div>
    42 <div><img id="img7" src="resources/exif-orientation-8-llo.jpg"><br>Rotated 90&deg; CW</div>
    43 <br>
    44 <ul id="console"></ul>
     98         window.addEventListener('load', (event) => {
     99            for(var i = 1; i <= 9; i++)
     100                log("img" + i + " size = " + imageSize(document.getElementById("img" + i)));
     101        });
     102    </script>
    45103</body>
    46 </html>
  • trunk/LayoutTests/fast/images/exif-orientation-image-document.html

    r191652 r249364  
    1 <html>
    2 <head>
    3 <script>
    4 if (window.testRunner) {
    5     // Note that this test only passes in DRT. In browsers, the cross-iframe dom inspection usually causes a security exception.
    6     testRunner.dumpAsText(true);
    7 }
     1<!DOCTYPE html>
     2<style>
     3    div.container {
     4        display: inline-block;
     5        margin-right: 20px;
     6        margin-bottom: 10px;
     7        width: 100px;
     8        vertical-align: top;
     9    }
     10    div.horizontal {
     11        width: 102;
     12        height: 52px;
     13    }
     14    div.vertical {
     15        width: 52px;
     16        height: 102px;
     17    }
     18    iframe {
     19        border: 1px solid black;
     20    }
     21    iframe.horizontal {
     22        width: 100px;
     23        height: 50px;
     24    }
     25    iframe.vertical {
     26        width: 50px;
     27        height: 100px;
     28    }
     29</style>
     30<body>
     31    <b>The images of the ImageDocuments should be rotated respecting their EXIF orientation.</b>
     32    <br>
     33    <br>
     34    <div class="container">
     35        <div class="horizontal">
     36            <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-1-ul.jpg"></iframe>
     37        </div>
     38        <br>Normal
     39    </div>
     40    <div class="container">
     41        <div class="horizontal">
     42            <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-2-ur.jpg"></iframe>
     43        </div>
     44        <br>Flipped horizontally
     45    </div>
     46    <div class="container">
     47        <div class="horizontal">
     48            <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-3-lr.jpg"></iframe>
     49        </div>
     50        <br>Rotated 180&deg;
     51    </div>
     52    <div class="container">
     53        <div class="horizontal">
     54            <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-4-lol.jpg"></iframe>
     55        </div>
     56        <br>Flipped vertically
     57    </div>
     58    <br>
     59    <div class="container">
     60        <div class="vertical">
     61            <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-5-lu.jpg"></iframe>
     62        </div>
     63        <br>Rotated 90&deg; CCW and flipped vertically
     64    </div>
     65    <div class="container">
     66        <div class="vertical">
     67            <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-6-ru.jpg"></iframe>
     68        </div>
     69        <br>Rotated 90&deg; CCW
     70    </div>
     71    <div class="container">
     72        <div class="vertical">
     73            <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-7-rl.jpg"></iframe>
     74        </div>
     75        <br>Rotated 90&deg; CW and flipped vertically
     76    </div>
     77    <div class="container">
     78        <div class="vertical">
     79            <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-8-llo.jpg"></iframe>
     80        </div>
     81        <br>Rotated 90&deg; CW
     82    </div>
     83    <br>
     84    <div class="container">
     85        <div class="horizontal">
     86            <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-9-u.jpg"></iframe>
     87        </div>
     88        <br>Undefined (invalid value)
     89    </div>
     90    <script>
     91        if (window.testRunner)
     92            window.testRunner.waitUntilDone();
    893
    9 function log(str) {
    10     var li = document.createElement("li");
    11     li.appendChild(document.createTextNode(str));
    12     var console = document.getElementById("console");
    13     console.appendChild(li);
    14 }
     94         var iFrameLoadedCount = 0;
    1595
    16 function imageSize(name) {
    17     var img = window.frames[name].document.querySelector('img');
    18     return [img.offsetWidth, img.offsetHeight];
    19 }
    20 
    21 
    22 function load() {
    23     var expected = [
    24       [100, 50], [100, 50], [100, 50], [100, 50],
    25       [50, 100], [50, 100], [50, 100], [50, 100],
    26       [100, 50],
    27     ];
    28     var success = true;
    29     for(var i = 1; i <= 9; i++) {
    30         var s = imageSize("img" + i);
    31         if (s[0] !== expected[i - 1][0] || s[1] !== expected[i - 1][1])
    32             success = false;
    33     }
    34     log(success ? "PASS" : "FAIL");
    35 }
    36 
    37 </script>
    38 <style>
    39 iframe { display: inline-block; margin-right: 20px; margin-bottom: 10px; width: 120px; height: 110px; vertical-align: top; border: 1px solid black; }
    40 </style>
    41 </head>
    42 <body onload="load()">
    43 <b>The images should be rotated respecting their EXIF orientation. In image documents, this happens independent of WebKitShouldRespectImageOrientation.</b><br><br>
    44 <iframe name="img1" src="resources/exif-orientation-1-ul.jpg" frameborder=0></iframe>
    45 <iframe name="img2" src="resources/exif-orientation-2-ur.jpg" frameborder=0></iframe>
    46 <iframe name="img3" src="resources/exif-orientation-3-lr.jpg" frameborder=0></iframe>
    47 <iframe name="img4" src="resources/exif-orientation-4-lol.jpg" frameborder=0></iframe>
    48 <br>
    49 <iframe name="img5" src="resources/exif-orientation-5-lu.jpg" frameborder=0></iframe>
    50 <iframe name="img6" src="resources/exif-orientation-6-ru.jpg" frameborder=0></iframe>
    51 <iframe name="img7" src="resources/exif-orientation-7-rl.jpg" frameborder=0></iframe>
    52 <iframe name="img8" src="resources/exif-orientation-8-llo.jpg" frameborder=0></iframe>
    53 <br>
    54 <iframe name="img9" src="resources/exif-orientation-9-u.jpg" frameborder=0></iframe>
    55 <br>
    56 <ul id="console"></ul>
     96         function onFrameLoad() {
     97            if (++iFrameLoadedCount == 9) {
     98                if (window.testRunner)
     99                    window.testRunner.notifyDone();
     100            }
     101        }
     102    </script>
    57103</body>
    58 </html>
    59 
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r249325 r249364  
    29452945webkit.org/b/120839 legacy-animation-engine/animations/cross-fade-background-image.html [ ImageOnlyFailure ]
    29462946
    2947 webkit.org/b/121905 fast/images/exif-orientation.html [ Failure ]
    2948 
    29492947webkit.org/b/180581 css3/shapes/shape-outside/values/shape-margin-001.html [ Failure ]
    29502948webkit.org/b/180581 css3/shapes/shape-outside/values/shape-outside-circle-004.html [ Failure ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r249101 r249364  
    28122812
    28132813fast/images/image-controls-basic.html [ Failure ]
    2814 fast/images/exif-orientation-composited.html [ Failure ]
    28152814webkit.org/b/140516 [ Debug ] fast/images/large-size-image-crash.html [ Skip ]  # Crashing
    28162815fast/images/pdf-as-image-with-annotations.html [ ImageOnlyFailure ]
    28172816fast/images/support-broken-image-delegate.html [ Failure ]
    2818 fast/images/exif-orientation.html [ Failure ]
    28192817
    28202818fast/inline/positionedLifetime.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r249361 r249364  
     12019-08-31  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        EXIF orientation should be respected when rendering images
     4        https://bugs.webkit.org/show_bug.cgi?id=201123
     5
     6        Reviewed by Simon Fraser.
     7
     8        -- Image::size() will return the rendered size based on the image
     9           orientation. If image orientation is FromImage, ImageSource will query
     10           the actual image orientation from the ImageDecoder. The low level APIs
     11           might transpose the size just before calling the system API to draw
     12           the image.
     13
     14        -- RenderElement::imageOrientation() will return ImageOrientation::FromImage
     15           for all images and for all ports till the CSS image-orientation specs
     16           is finalized.
     17
     18        -- The default of ImagePaintingOptions argument of GraphicsContext::drawImage()
     19           will be changed to { ImageOrientation::FromImage }.
     20
     21        -- Image element: RenderImage::paintIntoRect() will pass imageOrientation()
     22           which returns ImageOrientation::FromImage to GraphicsContext::drawImage().
     23
     24        -- CSS background image: RenderBoxModelObject::paintFillLayerExtended will
     25           pass ImageOrientation::FromImage by default to GraphicsContext::drawTiledImage().
     26
     27        -- Images on canvas: CanvasRenderingContext2DBase::drawImage() will pass
     28           ImageOrientation::FromImage by default to GraphicsContext::drawImage().
     29
     30        -- SVG images: RenderSVGImage::paintForeground() calls GraphicsContext::drawImage()
     31           with the default ImagePaintingOptions which is now { ImageOrientation::FromImage }.
     32
     33        -- SVG feImage filters: FEImage::platformApplySoftware() calls
     34           GraphicsContext::drawImage() with the default ImagePaintingOptions
     35           which is now { ImageOrientation::FromImage }.
     36
     37        -- ImageDocument: RenderElement::imageOrientation() returns FromImage
     38           always and for all ports.
     39
     40        Tests: fast/images/exif-orientation-background.html
     41               fast/images/exif-orientation-canvas.html
     42               fast/images/exif-orientation-content.html
     43               fast/images/exif-orientation-element-object-fit.html
     44               fast/images/exif-orientation-element.html
     45               fast/images/exif-orientation-image-object.html
     46               fast/images/exif-orientation-svg-feimage.html
     47               fast/images/exif-orientation-svg-image.html
     48
     49        * html/canvas/CanvasRenderingContext2DBase.cpp:
     50        (WebCore::CanvasRenderingContext2DBase::drawImage):
     51        * loader/cache/CachedImage.cpp:
     52        (WebCore::CachedImage::imageSizeForRenderer const):
     53        * platform/graphics/BitmapImage.h:
     54        * platform/graphics/CrossfadeGeneratedImage.h:
     55        * platform/graphics/GeneratedImage.h:
     56        * platform/graphics/GraphicsContext.h:
     57        (WebCore::GraphicsContext::drawImage):
     58        * platform/graphics/Image.h:
     59        * platform/graphics/ImageFrame.h:
     60        (WebCore::ImageFrame::sizeRespectingOrientation const): Deleted.
     61        * platform/graphics/ImageSource.cpp:
     62        (WebCore::ImageSource::ImageSource):
     63        (WebCore::ImageSource::orientation):
     64        (WebCore::ImageSource::size):
     65        (WebCore::ImageSource::sizeRespectingOrientation): Deleted.
     66        * platform/graphics/ImageSource.h:
     67        * platform/graphics/cg/PDFDocumentImage.cpp:
     68        (WebCore::PDFDocumentImage::size const):
     69        * platform/graphics/cg/PDFDocumentImage.h:
     70        * platform/mac/DragImageMac.mm:
     71        (WebCore::createDragImageFromImage):
     72        * rendering/RenderBoxModelObject.cpp:
     73        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     74        * rendering/RenderElement.cpp:
     75        (WebCore::RenderElement::imageOrientation const):
     76        * rendering/RenderImage.cpp:
     77        (WebCore::RenderImage::paintIntoRect):
     78        * svg/graphics/SVGImage.h:
     79        * svg/graphics/SVGImageForContainer.cpp:
     80        (WebCore::SVGImageForContainer::size const):
     81        * svg/graphics/SVGImageForContainer.h:
     82
    1832019-08-31  Rob Buis  <rbuis@igalia.com>
    284
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp

    r249217 r249364  
    15791579    }
    15801580
     1581    ImagePaintingOptions options = { op, blendMode, ImageOrientation::FromImage };
     1582
    15811583    if (rectContainsCanvas(normalizedDstRect)) {
    1582         c->drawImage(*image, normalizedDstRect, normalizedSrcRect, { op, blendMode });
     1584        c->drawImage(*image, normalizedDstRect, normalizedSrcRect, options);
    15831585        didDrawEntireCanvas();
    15841586    } else if (isFullCanvasCompositeMode(op)) {
     
    15871589    } else if (op == CompositeCopy) {
    15881590        clearCanvas();
    1589         c->drawImage(*image, normalizedDstRect, normalizedSrcRect, { op, blendMode });
     1591        c->drawImage(*image, normalizedDstRect, normalizedSrcRect, options);
    15901592        didDrawEntireCanvas();
    15911593    } else {
    1592         c->drawImage(*image, normalizedDstRect, normalizedSrcRect, { op, blendMode });
     1594        c->drawImage(*image, normalizedDstRect, normalizedSrcRect, options);
    15931595        didDraw(normalizedDstRect);
    15941596    }
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r248846 r249364  
    281281        return { };
    282282
    283     if (is<BitmapImage>(*m_image) && renderer && renderer->imageOrientation() == ImageOrientation::FromImage)
    284         return downcast<BitmapImage>(*m_image).sizeRespectingOrientation();
    285 
    286283    if (is<SVGImage>(*m_image) && sizeType == UsedSize)
    287284        return m_svgImageCache->imageSizeForRenderer(renderer);
    288285
    289     return m_image->size();
     286    return m_image->size(renderer ? renderer->imageOrientation() : ImageOrientation(ImageOrientation::FromImage));
    290287}
    291288
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r249217 r249364  
    8282
    8383    // FloatSize due to override.
    84     FloatSize size() const override { return m_source->size(); }
    85     IntSize sizeRespectingOrientation() const { return m_source->sizeRespectingOrientation(); }
     84    FloatSize size(ImageOrientation orientation = ImageOrientation::FromImage) const override { return m_source->size(orientation); }
    8685    Color singlePixelSolidColor() const override { return m_source->singlePixelSolidColor(); }
    8786    bool frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(size_t index, const DecodingOptions& decodingOptions) const { return m_source->frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(index, decodingOptions); }
  • trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h

    r249217 r249364  
    4545    bool hasRelativeHeight() const override { return false; }
    4646
    47     FloatSize size() const override { return m_crossfadeSize; }
     47    FloatSize size(ImageOrientation = ImageOrientation::FromImage) const override { return m_crossfadeSize; }
    4848
    4949protected:
  • trunk/Source/WebCore/platform/graphics/GeneratedImage.h

    r249217 r249364  
    4141    void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
    4242
    43     FloatSize size() const override { return m_size; }
     43    FloatSize size(ImageOrientation = ImageOrientation::FromImage) const override { return m_size; }
    4444
    4545    // Assume that generated content has no decoded data we need to worry about
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r249217 r249364  
    360360    WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth);
    361361
    362     WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatPoint& destination, const ImagePaintingOptions& = { });
    363     WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatRect& destination, const ImagePaintingOptions& = { });
    364     ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });
     362    WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatPoint& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage });
     363    WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatRect& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage });
     364    ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { ImageOrientation::FromImage });
    365365
    366366    ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& = { });
  • trunk/Source/WebCore/platform/graphics/Image.h

    r249217 r249364  
    112112    virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
    113113
    114     virtual FloatSize size() const = 0;
     114    virtual FloatSize size(ImageOrientation = ImageOrientation::FromImage) const = 0;
    115115    FloatRect rect() const { return FloatRect(FloatPoint(), size()); }
    116116    float width() const { return size().width(); }
  • trunk/Source/WebCore/platform/graphics/ImageFrame.h

    r248657 r249364  
    6262
    6363    IntSize size() const;
    64     IntSize sizeRespectingOrientation() const { return !m_orientation.usesWidthAsHeight() ? size() : size().transposedSize(); }
    6564    unsigned frameBytes() const { return hasNativeImage() ? (size().area() * sizeof(uint32_t)).unsafeGet() : 0; }
    6665    SubsamplingLevel subsamplingLevel() const { return m_subsamplingLevel; }
  • trunk/Source/WebCore/platform/graphics/ImageSource.cpp

    r248703 r249364  
    6464    m_decodedSize = m_frames[0].frameBytes();
    6565
    66     // The assumption is the memory image will be displayed with the default
    67     // orientation. So set m_sizeRespectingOrientation to be the same as m_size.
    6866    m_size = m_frames[0].size();
    69     m_sizeRespectingOrientation = m_size;
     67    m_orientation = ImageOrientation(ImageOrientation::None);
    7068}
    7169
     
    560558}
    561559
    562 IntSize ImageSource::size()
    563 {
     560ImageOrientation ImageSource::orientation()
     561{
     562    return frameMetadataAtIndexCacheIfNeeded<ImageOrientation>(0, (&ImageFrame::orientation), &m_orientation, ImageFrame::Caching::Metadata);
     563}
     564
     565IntSize ImageSource::size(ImageOrientation orientation)
     566{
     567    IntSize size;
    564568#if !USE(CG)
    565569    // It's possible that we have decoded the metadata, but not frame contents yet. In that case ImageDecoder claims to
    566570    // have the size available, but the frame cache is empty. Return the decoder size without caching in such case.
    567571    if (m_frames.isEmpty() && isDecoderAvailable())
    568         return m_decoder->size();
     572        size = m_decoder->size();
     573    else
    569574#endif
    570     return frameMetadataAtIndexCacheIfNeeded<IntSize>(0, (&ImageFrame::size), &m_size, ImageFrame::Caching::Metadata, SubsamplingLevel::Default);
    571 }
    572 
    573 IntSize ImageSource::sizeRespectingOrientation()
    574 {
    575     return frameMetadataAtIndexCacheIfNeeded<IntSize>(0, (&ImageFrame::sizeRespectingOrientation), &m_sizeRespectingOrientation, ImageFrame::Caching::Metadata, SubsamplingLevel::Default);
     575        size = frameMetadataAtIndexCacheIfNeeded<IntSize>(0, (&ImageFrame::size), &m_size, ImageFrame::Caching::Metadata, SubsamplingLevel::Default);
     576   
     577    if (orientation == ImageOrientation::FromImage)
     578        orientation = this->orientation();
     579
     580    return orientation.usesWidthAsHeight() ? size.transposedSize() : size;
    576581}
    577582
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r248703 r249364  
    9494    String filenameExtension();
    9595    Optional<IntPoint> hotSpot();
     96    ImageOrientation orientation();
    9697
    9798    // Image metadata which is calculated from the first ImageFrame.
    98     WEBCORE_EXPORT IntSize size();
     99    WEBCORE_EXPORT IntSize size(ImageOrientation = ImageOrientation::FromImage);
    99100    IntSize sizeRespectingOrientation();
    100101    Color singlePixelSolidColor();
     
    197198    // Image metadata which is calculated from the first ImageFrame.
    198199    Optional<IntSize> m_size;
    199     Optional<IntSize> m_sizeRespectingOrientation;
     200    Optional<ImageOrientation> m_orientation;
    200201    Optional<Color> m_singlePixelSolidColor;
    201202    Optional<SubsamplingLevel> m_maximumSubsamplingLevel;
  • trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp

    r249217 r249364  
    6767}
    6868
    69 FloatSize PDFDocumentImage::size() const
     69FloatSize PDFDocumentImage::size(ImageOrientation) const
    7070{
    7171    FloatSize expandedCropBoxSize = FloatSize(expandedIntSize(m_cropBox.size()));
  • trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h

    r249217 r249364  
    7777
    7878    void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
    79     FloatSize size() const override;
     79    FloatSize size(ImageOrientation = ImageOrientation::FromImage) const override;
    8080
    8181    ImageDrawResult draw(GraphicsContext&, const FloatRect& dstRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }) override;
  • trunk/Source/WebCore/platform/mac/DragImageMac.mm

    r248697 r249364  
    9595RetainPtr<NSImage> createDragImageFromImage(Image* image, ImageOrientation orientation)
    9696{
    97     FloatSize size = image->size();
    98 
    9997    if (is<BitmapImage>(*image)) {
    10098        BitmapImage& bitmapImage = downcast<BitmapImage>(*image);
    101         IntSize sizeRespectingOrientation = bitmapImage.sizeRespectingOrientation();
    10299
    103100        if (orientation == ImageOrientation::FromImage)
     
    106103        if (orientation != ImageOrientation::None) {
    107104            // Construct a correctly-rotated copy of the image to use as the drag image.
    108             FloatRect destRect(FloatPoint(), sizeRespectingOrientation);
    109 
    110             RetainPtr<NSImage> rotatedDragImage = adoptNS([[NSImage alloc] initWithSize:(NSSize)(sizeRespectingOrientation)]);
     105            FloatSize imageSize = image->size(orientation);
     106            RetainPtr<NSImage> rotatedDragImage = adoptNS([[NSImage alloc] initWithSize:(NSSize)(imageSize)]);
    111107            [rotatedDragImage lockFocus];
    112108
    113109            // ImageOrientation uses top-left coordinates, need to flip to bottom-left, apply...
    114             CGAffineTransform transform = CGAffineTransformMakeTranslation(0, destRect.height());
     110            CGAffineTransform transform = CGAffineTransformMakeTranslation(0, imageSize.height());
    115111            transform = CGAffineTransformScale(transform, 1, -1);
    116             transform = CGAffineTransformConcat(orientation.transformFromDefault(sizeRespectingOrientation), transform);
     112            transform = CGAffineTransformConcat(orientation.transformFromDefault(imageSize), transform);
    117113
    118114            if (orientation.usesWidthAsHeight())
    119                 destRect = FloatRect(destRect.x(), destRect.y(), destRect.height(), destRect.width());
     115                imageSize = imageSize.transposedSize();
    120116
    121117            // ...and flip back.
    122             transform = CGAffineTransformTranslate(transform, 0, destRect.height());
     118            transform = CGAffineTransformTranslate(transform, 0, imageSize.height());
    123119            transform = CGAffineTransformScale(transform, 1, -1);
    124120
     
    127123            [cocoaTransform concat];
    128124
    129             [image->snapshotNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositingOperationSourceOver fraction:1.0];
     125            FloatRect imageRect(FloatPoint(), imageSize);
     126            [image->snapshotNSImage() drawInRect:imageRect fromRect:imageRect operation:NSCompositingOperationSourceOver fraction:1.0];
    130127
    131128            [rotatedDragImage unlockFocus];
     
    135132    }
    136133
     134    FloatSize imageSize = image->size();
    137135    auto dragImage = image->snapshotNSImage();
    138     [dragImage setSize:(NSSize)size];
     136    [dragImage setSize:(NSSize)imageSize];
    139137    return dragImage;
    140138}
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r249217 r249364  
    948948        RefPtr<Image> image;
    949949        if (!geometry.destRect().isEmpty() && (image = bgImage->image(backgroundObject ? backgroundObject : this, geometry.tileSize()))) {
    950             auto compositeOp = op == CompositeSourceOver ? bgLayer.composite() : op;
    951950            context.setDrawLuminanceMask(bgLayer.maskSourceType() == MaskSourceType::Luminance);
    952951
     
    954953                downcast<BitmapImage>(*image).updateFromSettings(settings());
    955954
    956             auto interpolation = chooseInterpolationQuality(context, *image, &bgLayer, geometry.tileSize());
    957             auto decodingMode = decodingModeForImageDraw(*image, paintInfo);
    958             auto drawResult = context.drawTiledImage(*image, geometry.destRect(), toLayoutPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), { compositeOp, bgLayer.blendMode(), decodingMode, interpolation });
     955            ImagePaintingOptions options = {
     956                op == CompositeSourceOver ? bgLayer.composite() : op,
     957                bgLayer.blendMode(),
     958                decodingModeForImageDraw(*image, paintInfo),
     959                ImageOrientation::FromImage,
     960                chooseInterpolationQuality(context, *image, &bgLayer, geometry.tileSize())
     961            };
     962
     963            auto drawResult = context.drawTiledImage(*image, geometry.destRect(), toLayoutPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), options);
    959964            if (drawResult == ImageDrawResult::DidRequestDecoding) {
    960965                ASSERT(bgImage->isCachedImage());
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r249309 r249364  
    20542054ImageOrientation RenderElement::imageOrientation() const
    20552055{
    2056 #if USE(CG) || USE(CAIRO) || USE(DIRECT2D)
    2057     // This can only be enabled for ports which honor the orientation flag in their drawing code.
    2058     if (document().isImageDocument())
    2059         return ImageOrientation::FromImage;
    2060 #endif
    2061     // Respect the image's orientation if it's being used as a full-page image or it's
    2062     // an <img> and the setting to respect it everywhere is set.
    2063     if (settings().shouldRespectImageOrientation() && is<HTMLImageElement>(element()))
    2064         return ImageOrientation::FromImage;
    2065     return style().imageOrientation();
     2056    return ImageOrientation::FromImage;
    20662057}
    20672058
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r249217 r249364  
    618618
    619619    HTMLImageElement* imageElement = is<HTMLImageElement>(element()) ? downcast<HTMLImageElement>(element()) : nullptr;
    620     CompositeOperator compositeOperator = imageElement ? imageElement->compositeOperator() : CompositeSourceOver;
    621620
    622621    // FIXME: Document when image != img.get().
    623622    Image* image = imageResource().image().get();
    624     InterpolationQuality interpolation = image ? chooseInterpolationQuality(paintInfo.context(), *image, image, LayoutSize(rect.size())) : InterpolationDefault;
    625623
    626624#if USE(CG)
     
    632630        downcast<BitmapImage>(*image).updateFromSettings(settings());
    633631
    634     auto decodingMode = decodingModeForImageDraw(*image, paintInfo);
    635     auto drawResult = paintInfo.context().drawImage(*img, rect, { compositeOperator, BlendMode::Normal, decodingMode, imageOrientation(), interpolation });
     632    ImagePaintingOptions options = {
     633        imageElement ? imageElement->compositeOperator() : CompositeSourceOver,
     634        decodingModeForImageDraw(*image, paintInfo),
     635        imageOrientation(),
     636        image ? chooseInterpolationQuality(paintInfo.context(), *image, image, LayoutSize(rect.size())) : InterpolationDefault
     637    };
     638
     639    auto drawResult = paintInfo.context().drawImage(*img, rect, options);
    636640    if (drawResult == ImageDrawResult::DidRequestDecoding)
    637641        imageResource().cachedImage()->addClientWaitingForAsyncDecoding(*this);
  • trunk/Source/WebCore/svg/graphics/SVGImage.h

    r249217 r249364  
    4949
    5050    bool isSVGImage() const final { return true; }
    51     FloatSize size() const final { return m_intrinsicSize; }
     51    FloatSize size(ImageOrientation = ImageOrientation::FromImage) const final { return m_intrinsicSize; }
    5252
    5353    bool hasSingleSecurityOrigin() const final;
  • trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp

    r249217 r249364  
    2828namespace WebCore {
    2929
    30 FloatSize SVGImageForContainer::size() const
     30FloatSize SVGImageForContainer::size(ImageOrientation) const
    3131{
    3232    FloatSize scaledContainerSize(m_containerSize);
  • trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h

    r249217 r249364  
    4444    bool isSVGImage() const final { return true; }
    4545
    46     FloatSize size() const final;
     46    FloatSize size(ImageOrientation = ImageOrientation::FromImage) const final;
    4747
    4848    bool usesContainerSize() const final { return m_image->usesContainerSize(); }
Note: See TracChangeset for help on using the changeset viewer.