RESOLVED FIXED 116991
drawImage: clip source image when source rectangle outside of source image.
https://bugs.webkit.org/show_bug.cgi?id=116991
Summary drawImage: clip source image when source rectangle outside of source image.
arno.
Reported 2013-05-29 13:25:03 PDT
Hi, drawImage specification tells: When the source rectangle is outside the source image, the source rectangle must be clipped to the source image and the destination rectangle must be clipped in the same proportion.[1] Right now, when that happens, we draw nothing. Firefox gets it right (at least for HTMLImageElement; for HTMLCanvasElement, there are some strange artifacts) [1]: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-drawimage
Attachments
testcase: should display a quarter of circle (617 bytes, text/html)
2013-05-29 13:26 PDT, arno.
no flags
patch proposal (12.27 KB, patch)
2013-05-29 14:36 PDT, arno.
no flags
updated patch: use normalized rect when drawImage video + style issues (12.93 KB, patch)
2013-05-29 19:34 PDT, arno.
darin: review+
arno.
Comment 1 2013-05-29 13:26:37 PDT
Created attachment 203267 [details] testcase: should display a quarter of circle
arno.
Comment 2 2013-05-29 14:36:26 PDT
Created attachment 203279 [details] patch proposal This patches address the issue, and also create a new methode to factorise dimensions checking between the 3 drawImage main methods
WebKit Commit Bot
Comment 3 2013-05-29 14:38:24 PDT
Attachment 203279 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast/canvas/drawImage-source-rect-outside-image-expected.html', u'LayoutTests/fast/canvas/drawImage-source-rect-outside-image.html', u'Source/WebCore/ChangeLog', u'Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp', u'Source/WebCore/html/canvas/CanvasRenderingContext2D.h']" exit_code: 1 Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:1274: Place brace on its own line for function definitions. [whitespace/braces] [4] Total errors found: 1 in 6 files If any of these errors are false positives, please file a bug against check-webkit-style.
arno.
Comment 4 2013-05-29 19:34:19 PDT
Created attachment 203301 [details] updated patch: use normalized rect when drawImage video + style issues
Brent Fulgham
Comment 5 2022-07-18 15:16:26 PDT
This continues to be a problem in Safari 16.
Radar WebKit Bug Importer
Comment 6 2022-07-18 15:16:38 PDT
Brent Fulgham
Comment 7 2022-07-21 16:05:01 PDT
EWS
Comment 8 2022-07-22 09:28:09 PDT
Committed 252731@main (a31e58979ddb): <https://commits.webkit.org/252731@main> Reviewed commits have been landed. Closing PR #2640 and removing active labels.
Said Abou-Hallawa
Comment 9 2024-05-13 14:48:09 PDT
Altering the source rectangle is wrong. The fix of this bug was trying to scale the destination rectangle to match the clipped source rectangle. For the record, I think the approach of fixing this bug was incorrect.
Note You need to log in before you can comment on or make changes to this bug.