Changeset 202712 in webkit


Ignore:
Timestamp:
Jun 30, 2016 3:18:12 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

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 <Antoine Quint> 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.
Location:
trunk
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202694 r202712  
     12016-06-30  Antoine Quint  <graouts@apple.com>
     2
     3        Drawing an SVG image into a <canvas> that is not in the DOM draws the wrong region
     4        https://bugs.webkit.org/show_bug.cgi?id=159276
     5
     6        Reviewed by Dean Jackson.
     7
     8        Adding a series of new tests to check we correctly respect mismatching source and
     9        destination rectangles with SVG images as sources, both with the source <img> element
     10        being present and absent from the DOM, and explicit sizes being set or not set.
     11
     12        * svg/as-image/img-with-svg-resource-in-dom-and-drawImage-expected.html: Added.
     13        * svg/as-image/img-with-svg-resource-in-dom-and-drawImage.html: Added.
     14        * svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage-expected.html: Added.
     15        * svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage.html: Added.
     16        * svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage-expected.html: Added.
     17        * svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage.html: Added.
     18        * svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage-expected.html: Added.
     19        * svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage.html: Added.
     20
    1212016-06-30  Antoine Quint  <graouts@apple.com>
    222
  • trunk/Source/WebCore/ChangeLog

    r202704 r202712  
     12016-06-30  Antoine Quint  <graouts@apple.com>
     2
     3        Drawing an SVG image into a <canvas> that is not in the DOM draws the wrong region
     4        https://bugs.webkit.org/show_bug.cgi?id=159276
     5
     6        Reviewed by Dean Jackson.
     7
     8        In the event where the <img> element that we are passing to CanvasRenderingContext2D.drawImage()
     9        points to an SVG resource, we ensure that the container for the SVG image is sized to match the
     10        HTML element. The necessity for setting this container size, explained in webkit.org/b/148845,
     11        is that we must ensure a cached image does not have an outdated container size.
     12
     13        Tests: svg/as-image/img-with-svg-resource-in-dom-and-drawImage.html
     14               svg/as-image/img-with-svg-resource-in-dom-no-size-and-drawImage.html
     15               svg/as-image/img-with-svg-resource-not-in-dom-and-drawImage.html
     16               svg/as-image/img-with-svg-resource-not-in-dom-no-size-and-drawImage.html
     17
     18        * html/canvas/CanvasRenderingContext2D.cpp:
     19        (WebCore::CanvasRenderingContext2D::drawImage):
     20
    1212016-06-30  Eric Carlson  <eric.carlson@apple.com>
    222
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r202102 r202712  
    13991399    if (image->isSVGImage()) {
    14001400        image->setImageObserver(nullptr);
    1401         image->setContainerSize(normalizedSrcRect.size());
     1401        image->setContainerSize(imageRect.size());
    14021402    }
    14031403
Note: See TracChangeset for help on using the changeset viewer.