Skip to content

Commit b36bf21

Browse files
committed
LibWeb/HTML: Add spec comment to CRC2D::put_image_data()
Also rename imagedata -> imageData, as done here: whatwg/html@6a3787f
1 parent d10332e commit b36bf21

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Libraries/LibWeb/HTML/Canvas/CanvasImageData.idl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagedata
44
interface mixin CanvasImageData {
55
ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh, optional ImageDataSettings settings = {});
6-
ImageData createImageData(ImageData imagedata);
6+
ImageData createImageData(ImageData imageData);
77

88
ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh, optional ImageDataSettings settings = {});
99

10-
undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy);
11-
[FIXME] undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
10+
undefined putImageData(ImageData imageData, [EnforceRange] long dx, [EnforceRange] long dy);
11+
[FIXME] undefined putImageData(ImageData imageData, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
1212
};

Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ WebIDL::ExceptionOr<GC::Ref<ImageData>> CanvasRenderingContext2D::create_image_d
379379
WebIDL::ExceptionOr<GC::Ref<ImageData>> CanvasRenderingContext2D::create_image_data(ImageData const& image_data) const
380380
{
381381
// 1. Let newImageData be a new ImageData object.
382-
// 2. Initialize newImageData given the value of imagedata's width attribute, the value of imagedata's height attribute, and defaultColorSpace set to the value of imagedata's colorSpace attribute.
382+
// 2. Initialize newImageData given the value of imageData's width attribute, the value of imageData's height attribute, and defaultColorSpace set to the value of imageData's colorSpace attribute.
383383
// FIXME: Set defaultColorSpace to the value of image_data's colorSpace attribute
384384
// 3. Initialize the image data of newImageData to transparent black.
385385
// NOTE: No-op, already done during creation.
@@ -440,8 +440,13 @@ WebIDL::ExceptionOr<GC::Ptr<ImageData>> CanvasRenderingContext2D::get_image_data
440440
return image_data;
441441
}
442442

443+
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-putimagedata-short
443444
void CanvasRenderingContext2D::put_image_data(ImageData const& image_data, float x, float y)
444445
{
446+
// The putImageData(imageData, dx, dy) method steps are to put pixels from an ImageData onto a bitmap,
447+
// given imageData, this's output bitmap, dx, dy, 0, 0, imageData's width, and imageData's height.
448+
// FIXME: "put pixels from an ImageData onto a bitmap" is a spec algorithm.
449+
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context2d-putimagedata-common
445450
if (auto* painter = this->painter()) {
446451
auto dst_rect = Gfx::FloatRect(x, y, image_data.width(), image_data.height());
447452
painter->draw_bitmap(dst_rect, Gfx::ImmutableBitmap::create(image_data.bitmap()), image_data.bitmap().rect(), Gfx::ScalingMode::NearestNeighbor, drawing_state().filters, 1.0f, Gfx::CompositingAndBlendingOperator::SourceOver);

0 commit comments

Comments
 (0)