<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26562</bug_id>
          
          <creation_ts>2014-08-12 18:21:24 +0000</creation_ts>
          <short_desc>The IDL for createImageBitmap seems to be wrong</short_desc>
          <delta_ts>2014-09-17 22:43:12 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ehsan Akhgari [:ehsan]">ehsan</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>110105</commentid>
    <comment_count>0</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2014-08-12 18:21:24 +0000</bug_when>
    <thetext>From the prose it seems like the spec is trying to only allow calling this function with 1 or 5 arguments, so the IDL should be something along the lines of:

  Promise&lt;ImageBitmap&gt; createImageBitmap(ImageBitmapSource image);
  Promise&lt;ImageBitmap&gt; createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110253</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-18 20:42:24 +0000</bug_when>
    <thetext>You sure? I thought &quot;optional&quot; as used here did exactly what I wanted, i.e. the same as what you list.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110262</commentid>
    <comment_count>2</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2014-08-18 21:07:51 +0000</bug_when>
    <thetext>I can&apos;t find anything in http://heycam.github.io/webidl/ to suggest that it would work like that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110380</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-08-21 05:08:02 +0000</bug_when>
    <thetext>In Web IDL as currently specified, I believe doing this:

  void foo(optional long a, long b);

will construct an effective overload set with only one element, since it will immediately run into a non-optional argument.  Therefore only a call with 2 arguments will be allowed.

Similarly, in the createImageBitmap spec as currently written only calls with 5 arguments are allowed.  Unless I&apos;m totally misreading http://heycam.github.io/webidl/#dfn-effective-overload-set somehow, of course...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110553</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-25 20:47:07 +0000</bug_when>
    <thetext>Well in that case WebIDL should either ban that case or make it work like I describe...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110557</commentid>
    <comment_count>5</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2014-08-25 21:11:33 +0000</bug_when>
    <thetext>I think it should be banned.  The behavior you&apos;re describing is totally non-intuitive. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110572</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-08-26 04:12:36 +0000</bug_when>
    <thetext>IDL very purposefully _allowed_ this case to align more closely with how arguments work in ES.

Keep in mind that &quot;optional&quot; in IDL right now doesn&apos;t just mean &quot;can be omitted&quot;.  It also means &quot;can have undefined explicitly passed to mean the argument is missing&quot;.

So there is a practical difference between these two methods:

  void foo(optional long a, long b);
  void bar(long a, long b);

both expect to be called with two arguments, but the former allows passing undefined for the first argument and treats that as &quot;not passed&quot;, while the latter coerces undefined to 0.  Or to make it more interesting:

  void foo(optional Node a, long b);
  void bar(Node a, long b);

the second method requires a Node as the first argument while the first one will accept a Node or undefined, with the latter meaning &quot;no node&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110624</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-26 17:55:59 +0000</bug_when>
    <thetext>That&apos;s highly unintuitive to me. I think a [TreatUndefinedAsUndefined] annotation would be clearer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110633</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-08-26 18:01:22 +0000</bug_when>
    <thetext>The current setup is basically where we ended up after a bunch of public-script-coord discussion with the ES folks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111722</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-17 22:42:59 +0000</bug_when>
    <thetext>Well I still think the definition of &apos;optional&apos; here is unintuitive, but I&apos;ve updated the spec to avoid this case by never having non-optional arguments after optional ones.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111723</commentid>
    <comment_count>10</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-09-17 22:43:12 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8783.
Check-in comment: Fix IDL blocks due to my misunderstanding what &apos;optional&apos; meant
https://html5.org/tools/web-apps-tracker?from=8782&amp;to=8783</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>