Commit a139d251 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Implement window.cancelAnimationFrame.

parent 76f5875c
......@@ -3152,6 +3152,20 @@ static HRESULT WINAPI window_private_requestAnimationFrame(IWineHTMLWindowPrivat
return hres;
}
static HRESULT WINAPI window_private_cancelAnimationFrame(IWineHTMLWindowPrivate *iface, VARIANT timer_id)
{
HTMLWindow *This = impl_from_IWineHTMLWindowPrivateVtbl(iface);
HRESULT hres;
TRACE("iface %p, timer_id %s\n", iface, debugstr_variant(&timer_id));
hres = VariantChangeType(&timer_id, &timer_id, 0, VT_I4);
if(SUCCEEDED(hres))
clear_animation_timer(This->inner_window, V_I4(&timer_id));
return S_OK;
}
static HRESULT WINAPI window_private_get_console(IWineHTMLWindowPrivate *iface, IDispatch **console)
{
HTMLWindow *This = impl_from_IWineHTMLWindowPrivateVtbl(iface);
......@@ -3176,6 +3190,7 @@ static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = {
window_private_GetIDsOfNames,
window_private_Invoke,
window_private_requestAnimationFrame,
window_private_cancelAnimationFrame,
window_private_get_console,
};
......
......@@ -1247,6 +1247,7 @@ enum timer_type {
HRESULT set_task_timer(HTMLInnerWindow*,LONG,enum timer_type,IDispatch*,LONG*) DECLSPEC_HIDDEN;
HRESULT clear_task_timer(HTMLInnerWindow*,DWORD) DECLSPEC_HIDDEN;
HRESULT clear_animation_timer(HTMLInnerWindow*,DWORD) DECLSPEC_HIDDEN;
BOOL parse_compat_version(const WCHAR*,compat_mode_t*) DECLSPEC_HIDDEN;
......
......@@ -87,7 +87,9 @@ interface IWineHTMLWindowPrivate : IDispatch
{
[id(50)]
HRESULT requestAnimationFrame([in] VARIANT *expr, [retval, out] VARIANT *timer_id);
[propget, id(51)]
[id(51)]
HRESULT cancelAnimationFrame([in] VARIANT timer_id);
[propget, id(52)]
HRESULT console([retval, out] IDispatch **console);
}
......
......@@ -208,7 +208,8 @@ HRESULT clear_task_timer(HTMLInnerWindow *window, DWORD id)
LIST_FOR_EACH_ENTRY(iter, &thread_data->timer_list, task_timer_t, entry) {
if(iter->id == id && iter->window == window) {
release_task_timer(thread_data->thread_hwnd, iter);
if(iter->type != TIMER_ANIMATION_FRAME)
release_task_timer(thread_data->thread_hwnd, iter);
return S_OK;
}
}
......@@ -217,6 +218,26 @@ HRESULT clear_task_timer(HTMLInnerWindow *window, DWORD id)
return S_OK;
}
HRESULT clear_animation_timer(HTMLInnerWindow *window, DWORD id)
{
thread_data_t *thread_data = get_thread_data(FALSE);
task_timer_t *iter;
if(!thread_data)
return S_OK;
LIST_FOR_EACH_ENTRY(iter, &thread_data->timer_list, task_timer_t, entry) {
if(iter->id == id && iter->window == window) {
if(iter->type == TIMER_ANIMATION_FRAME)
release_task_timer(thread_data->thread_hwnd, iter);
return S_OK;
}
}
WARN("timer not found\n");
return S_OK;
}
static const char *debugstr_timer_type(enum timer_type type)
{
switch(type) {
......
......@@ -357,6 +357,7 @@ sync_test("window_props", function() {
test_exposed("getSelection", v >= 9);
test_exposed("onfocusout", v >= 9);
test_exposed("getComputedStyle", v >= 9);
test_exposed("cancelAnimationFrame", v >= 10);
test_exposed("requestAnimationFrame", v >= 10);
test_exposed("Map", v >= 11);
test_exposed("Set", v >= 11);
......
......@@ -494,13 +494,21 @@ sync_test("elem_props", function() {
});
async_test("animation_frame", function() {
var id = requestAnimationFrame(function(x) {
var id = requestAnimationFrame(function(x) { ok(false, "request was supposed to be cancelled"); });
id = cancelAnimationFrame(id);
ok(id === undefined, "cancelAnimationFrame returned " + id);
id = requestAnimationFrame(function(x) {
ok(this === window, "this != window");
ok(typeof(x) === "number", "x = " + x);
ok(arguments.length === 1, "arguments.length = " + arguments.length);
next_test();
});
cancelAnimationFrame(0);
clearInterval(id);
clearTimeout(id);
ok(typeof(id) === "number", "id = " + id);
ok(id !== 0, "id = 0");
});
sync_test("title", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment