/*
 * Copyright (C) 2010, 2011, 2014-2015 Apple Inc. 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
 */

dictionary MonitorWheelEventsOptions {
    boolean resetLatching = true;
};

interface EventSendingController {
    void mouseDown(long buttonNumber, object modifierArray);
    void mouseUp(long buttonNumber, object modifierArray);
    void mouseMoveTo(long x, long y);
    void mouseForceClick();
    void startAndCancelMouseForceClick();
    void mouseForceDown();
    void mouseForceUp();
    void mouseForceChanged(double force);
    void mouseScrollBy(long x, long y);
    void mouseScrollByWithWheelAndMomentumPhases(long x, long y, DOMString phase, DOMString momentum);
    void continuousMouseScrollBy(long x, long y, optional boolean paged);
    object contextClick();
    void scheduleAsynchronousClick();

    void leapForward(long milliseconds);

    void keyDown(DOMString key, object modifierArray, long location);
    void scheduleAsynchronousKeyDown(DOMString key);

    // Zoom functions.
    void textZoomIn();
    void textZoomOut();
    void zoomPageIn();
    void zoomPageOut();
    void scalePageBy(double scale, double x, double y);

    void monitorWheelEvents(optional MonitorWheelEventsOptions options);
    void callAfterScrollingCompletes(object functionCallback);

#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
    // Touch events.
    void addTouchPoint(long x, long y);
    void updateTouchPoint(long index, long x, long y);
    void setTouchModifier(DOMString modifier, boolean enable);
    void setTouchPointRadius(long radiusX, long radiusY);
    void touchStart();
    void touchMove();
    void touchEnd();
    void touchCancel();
    void clearTouchPoints();
    void releaseTouchPoint(long index);
    void cancelTouchPoint(long index);
#endif
};

