/*
 * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.
 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

// https://html.spec.whatwg.org/#the-canvas-element

interface HTMLCanvasElement : HTMLElement {
    // FIXME: width and height should be unsigned long.
    attribute long width;
    attribute long height;

    // Note: this differs deliberately from the specified Web IDL for this function:
    //     RenderingContext? getContext(DOMString contextId, any... arguments);
    // in order to eliminate the custom binding. It is functionally equivalent.
    //
    // The PermissiveDictionaryConversion extended attribute is needed to allow the
    // autogenerated code to match the behavior of the custom binding. Web IDL
    // requires throwing TypeError if the incoming argument is not an object type
    // (and is not undefined or null). The binding must ignore this.
    //
    // Also note: the only reason this must return type "any" is to allow the
    // InspectorInstrumentation wrappers to be called for canvases. If that could be
    // handled differently the return type could be changed to "RenderingContext?"
    // and the [CallWith=ScriptState] extended attribute removed.
    //
    // FIXME: The contextId argument should not be optional.
    [CallWith=ScriptState] any getContext([Default=Undefined] optional DOMString contextId, [PermissiveDictionaryConversion] optional CanvasContextCreationAttributes attributes);

    // Note: The arguments argument is variadic in the spec, but not here as
    // only one extra argument is actually used.
    // FIXME: type should not be nullable or have a default value.
    [RaisesException] DOMString toDataURL(optional DOMString? type = null, optional any arguments);
};
