Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 80df4def20e353fcac0db435bb69dcec20f8c4b3
      
https://github.com/WebKit/WebKit/commit/80df4def20e353fcac0db435bb69dcec20f8c4b3
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-08-20 (Thu, 20 Aug 2026)

  Changed paths:
    M Source/WebCore/html/HTMLCanvasElement.idl

  Log Message:
  -----------
  Align HTMLCanvasElement interface with HTML spec for toDataURL() and toBlob()
https://bugs.webkit.org/show_bug.cgi?id=322163
rdar://185391614

Reviewed by Ryosuke Niwa.

Bring the IDL for HTMLCanvasElement.toDataURL() and toBlob() in line with
https://html.spec.whatwg.org/multipage/canvas.html#htmlcanvaselement:

    USVString toDataURL(optional DOMString type = "image/png", optional any 
quality);
    undefined toBlob(BlobCallback callback, optional DOMString type = 
"image/png", optional any quality);

Both changes are no-ops at the JS boundary, so there is nothing new to test:

1. toDataURL()'s return type becomes USVString. The implementation returns an
 UncachedString, and JSConverter<IDLUSVString>::convert(const UncachedString&)
 is identical to the IDLDOMString overload -- both are jsString(vm, 
value.string)
 -- so the generated binding is unchanged. USVString on a return type is a
 declarative claim that the value contains no unpaired surrogates, which is
 trivially true of a base64 data URL. The distinction only has teeth in the
 JS-to-native direction, where valueToUSVString() substitutes U+FFFD.

2. Defaulting `type` to "image/png" changes 
convertOptionalWithDefault<IDLDOMString>
 to hand the implementation "image/png" instead of a null String when the
 argument is omitted or undefined. The parameter's only consumer in either
 function is toEncodingMimeType(), which already maps both inputs to the same
 result: a null String is rejected by 
MIMETypeRegistry::isSupportedImageMIMETypeForEncoding()
 on its isEmpty() check and falls back to "image/png", while "image/png" is
 supported and returns its own ASCII-lowercased self. This also makes
 HTMLCanvasElement consistent with ImageEncodeOptions.type in 
OffscreenCanvas.idl,
 which already carries the same default.

Also add the spec URL to the top of the file, matching the convention used by 
the
other IDL files in this directory.

* Source/WebCore/html/HTMLCanvasElement.idl:

Canonical link: https://commits.webkit.org/319529@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to