Drawing an SVG image into a <canvas> that is not in the DOM draws the wrong region
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jun 2016 22:18:12 +0000 (22:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jun 2016 22:18:12 +0000 (22:18 +0000)
commit8d1962a132ce46c5c40bb6e695b03f9d9a52992b
tree6c749ba1b72cb9cb675a23819c035928c614b42a
parent161dc024303422c8b364e285b0fb3e0821f1480c
Drawing an SVG image into a <canvas> that is not in the DOM draws the wrong region
https://bugs.webkit.org/show_bug.cgi?id=159276

Patch by Antoine Quint <graouts@apple.com> on 2016-06-30
Reviewed by Dean Jackson.

Source/WebCore:

In the event where the <img> element that we are passing to CanvasRenderingContext2D.drawImage()
points to an SVG resource, we ensure that the container for the SVG image is sized to match the
HTML element. The necessity for setting this container size, explained in webkit.org/b/148845,
is that we must ensure a cached image does not have an outdated container size.

Tests: svg/as-image/img-with-svg-resource-in-dom-and-drawImage.html
       svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage.html
       svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage.html
       svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage.html

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawImage):

LayoutTests:

Adding a series of new tests to check we correctly respect mismatching source and
destination rectangles with SVG images as sources, both with the source <img> element
being present and absent from the DOM, and explicit sizes being set or not set.

* svg/as-image/img-with-svg-resource-in-dom-and-drawImage-expected.html: Added.
* svg/as-image/img-with-svg-resource-in-dom-and-drawImage.html: Added.
* svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage-expected.html: Added.
* svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage.html: Added.
* svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage-expected.html: Added.
* svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage.html: Added.
* svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage-expected.html: Added.
* svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/svg/as-image/img-with-svg-resource-in-dom-and-drawImage-expected.html [new file with mode: 0644]
LayoutTests/svg/as-image/img-with-svg-resource-in-dom-and-drawImage.html [new file with mode: 0644]
LayoutTests/svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage-expected.html [new file with mode: 0644]
LayoutTests/svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage.html [new file with mode: 0644]
LayoutTests/svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage-expected.html [new file with mode: 0644]
LayoutTests/svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage.html [new file with mode: 0644]
LayoutTests/svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage-expected.html [new file with mode: 0644]
LayoutTests/svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp