toDataURL

第二引数がある。

バイナリを呼び出してフィルタに出来るっぽい。

content/html/content/src/nsHTMLCanvasElement.cpp

// nsHTMLCanvasElement::toDataURL

NS_IMETHODIMP
nsHTMLCanvasElement::ToDataURL(nsAString& aDataURL)
{

....

  // 0-arg case; convert to png
  if (argc == 0) {
    return ToDataURLImpl(NS_LITERAL_STRING("image/png"), EmptyString(), aDataURL);
  }

  JSAutoRequest ar(ctx);

  // 1-arg case; convert to given mime type
  if (argc == 1) {
    if (!JSVAL_IS_STRING(argv[0]))
      return NS_ERROR_DOM_SYNTAX_ERR;
    JSString *type = JS_ValueToString(ctx, argv[0]);
    return ToDataURLImpl (nsDependentString(reinterpret_cast<PRUnichar*>((JS_GetStringChars(type)))),
                          EmptyString(), aDataURL);
  }

  // 2-arg case; trusted only (checked above), convert to mime type with params
  if (argc == 2) {
    if (!JSVAL_IS_STRING(argv[0]) && !JSVAL_IS_STRING(argv[1]))
      return NS_ERROR_DOM_SYNTAX_ERR;