Commit 0421f88a authored by weinig@apple.com's avatar weinig@apple.com

2009-04-28 Sam Weinig <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Move timer code from JSDOMWindow to DOMWindow. clearTimeout and
        clearInterval can now be autogenerated.

        * bindings/js/JSDOMWindowBase.cpp:
        * bindings/js/JSDOMWindowBase.h:
        * bindings/js/JSDOMWindowCustom.cpp:
        (WebCore::createScheduledAction):
        (WebCore::JSDOMWindow::setTimeout):
        (WebCore::JSDOMWindow::setInterval):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::setTimeout):
        (WebCore::DOMWindow::clearTimeout):
        (WebCore::DOMWindow::setInterval):
        (WebCore::DOMWindow::clearInterval):
        * page/DOMWindow.h:
        * page/DOMWindow.idl:



git-svn-id: svn://svn.chromium.org/blink/trunk@42938 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent a5b97d28
2009-04-28 Sam Weinig <sam@webkit.org>
Reviewed by Dan Bernstein.
Move timer code from JSDOMWindow to DOMWindow. clearTimeout and
clearInterval can now be autogenerated.
* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::createScheduledAction):
(WebCore::JSDOMWindow::setTimeout):
(WebCore::JSDOMWindow::setInterval):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::setTimeout):
(WebCore::DOMWindow::clearTimeout):
(WebCore::DOMWindow::setInterval):
(WebCore::DOMWindow::clearInterval):
* page/DOMWindow.h:
* page/DOMWindow.idl:
2009-04-28 Kevin Watters <kevinwatters@gmail.com>
Reviewed by Kevin Ollivier.
......@@ -278,26 +278,6 @@ void JSDOMWindowBase::setReturnValueSlot(JSValuePtr* slot)
d()->returnValueSlot = slot;
}
int JSDOMWindowBase::installTimeout(ScheduledAction* a, int t, bool singleShot)
{
return DOMTimer::install(scriptExecutionContext(), a, t, singleShot);
}
int JSDOMWindowBase::installTimeout(const UString& handler, int t, bool singleShot)
{
return installTimeout(new ScheduledAction(handler), t, singleShot);
}
int JSDOMWindowBase::installTimeout(ExecState* exec, JSValuePtr func, const ArgList& args, int t, bool singleShot)
{
return installTimeout(new ScheduledAction(exec, func, args), t, singleShot);
}
void JSDOMWindowBase::removeTimeout(int timeoutId)
{
DOMTimer::removeById(scriptExecutionContext(), timeoutId);
}
void JSDOMWindowBase::disconnectFrame()
{
}
......
......@@ -62,10 +62,6 @@ namespace WebCore {
virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValuePtr, JSC::PutPropertySlot&);
int installTimeout(const JSC::UString& handler, int t, bool singleShot);
int installTimeout(JSC::ExecState*, JSC::JSValuePtr function, const JSC::ArgList& args, int t, bool singleShot);
void removeTimeout(int timeoutId);
void clear();
// Set a place to put a dialog return value when the window is cleared.
......@@ -109,7 +105,6 @@ namespace WebCore {
static JSC::JSValuePtr namedItemGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&);
void clearHelperObjectProperties();
int installTimeout(ScheduledAction*, int interval, bool singleShot);
bool allowsAccessFromPrivate(const JSC::JSGlobalObject*) const;
String crossDomainAccessErrorMessage(const JSC::JSGlobalObject*) const;
......
......@@ -53,6 +53,7 @@
#include "Page.h"
#include "PlatformScreen.h"
#include "RegisteredEventListener.h"
#include "ScheduledAction.h"
#include "ScriptController.h"
#include "Settings.h"
#include "WindowFeatures.h"
......@@ -494,40 +495,35 @@ JSValuePtr JSDOMWindow::postMessage(ExecState* exec, const ArgList& args)
return jsUndefined();
}
static JSValuePtr setTimeoutOrInterval(ExecState* exec, JSDOMWindow* window, const ArgList& args, bool timeout)
static ScheduledAction* createScheduledAction(ExecState* exec, const ArgList& args)
{
JSValuePtr v = args.at(exec, 0);
int delay = args.at(exec, 1).toInt32(exec);
if (v.isString())
return jsNumber(exec, window->installTimeout(asString(v)->value(), delay, timeout));
return new ScheduledAction(asString(v)->value());
CallData callData;
if (v.getCallData(callData) == CallTypeNone)
return jsUndefined();
return 0;
ArgList argsTail;
args.getSlice(2, argsTail);
return jsNumber(exec, window->installTimeout(exec, v, argsTail, delay, timeout));
return new ScheduledAction(exec, v, argsTail);
}
JSValuePtr JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args)
{
return setTimeoutOrInterval(exec, this, args, true);
}
JSValuePtr JSDOMWindow::clearTimeout(ExecState* exec, const ArgList& args)
{
removeTimeout(args.at(exec, 0).toInt32(exec));
return jsUndefined();
ScheduledAction* action = createScheduledAction(exec, args);
if (!action)
return jsUndefined();
int delay = args.at(exec, 1).toInt32(exec);
return jsNumber(exec, impl()->setTimeout(action, delay));
}
JSValuePtr JSDOMWindow::setInterval(ExecState* exec, const ArgList& args)
{
return setTimeoutOrInterval(exec, this, args, false);
}
JSValuePtr JSDOMWindow::clearInterval(ExecState* exec, const ArgList& args)
{
removeTimeout(args.at(exec, 0).toInt32(exec));
return jsUndefined();
ScheduledAction* action = createScheduledAction(exec, args);
if (!action)
return jsUndefined();
int delay = args.at(exec, 1).toInt32(exec);
return jsNumber(exec, impl()->setInterval(action, delay));
}
JSValuePtr JSDOMWindow::atob(ExecState* exec, const ArgList& args)
......
......@@ -35,6 +35,7 @@
#include "Chrome.h"
#include "Console.h"
#include "DOMSelection.h"
#include "DOMTimer.h"
#include "Document.h"
#include "Element.h"
#include "EventException.h"
......@@ -1162,6 +1163,26 @@ void DOMWindow::resizeTo(float width, float height) const
page->chrome()->setWindowRect(fr);
}
int DOMWindow::setTimeout(ScheduledAction* action, int timeout)
{
return DOMTimer::install(scriptExecutionContext(), action, timeout, true);
}
void DOMWindow::clearTimeout(int timeoutId)
{
DOMTimer::removeById(scriptExecutionContext(), timeoutId);
}
int DOMWindow::setInterval(ScheduledAction* action, int timeout)
{
return DOMTimer::install(scriptExecutionContext(), action, timeout, false);
}
void DOMWindow::clearInterval(int timeoutId)
{
DOMTimer::removeById(scriptExecutionContext(), timeoutId);
}
void DOMWindow::handleEvent(Event* event, bool useCapture, RegisteredEventListenerVector* alternateListeners)
{
RegisteredEventListenerVector& listeners = (alternateListeners ? *alternateListeners : m_eventListeners);
......
......@@ -56,6 +56,7 @@ namespace WebCore {
class Navigator;
class Node;
class PostMessageTimer;
class ScheduledAction;
class Screen;
class WebKitPoint;
......@@ -212,13 +213,20 @@ namespace WebCore {
void resizeBy(float x, float y) const;
void resizeTo(float width, float height) const;
void handleEvent(Event*, bool useCapture, RegisteredEventListenerVector* = 0);
// Timers
int setTimeout(ScheduledAction*, int timeout);
void clearTimeout(int timeoutId);
int setInterval(ScheduledAction*, int timeout);
void clearInterval(int timeoutId);
// Events
// EventTarget API
virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&);
void handleEvent(Event*, bool useCapture, RegisteredEventListenerVector* = 0);
void dispatchEvent(const AtomicString& eventType, bool canBubble, bool cancelable);
void dispatchLoadEvent();
void dispatchUnloadEvent(RegisteredEventListenerVector* = 0);
......
......@@ -172,12 +172,13 @@ module window {
// Timers
[Custom] long setTimeout(in TimeoutHandler handler, in long timeout);
// [Custom] long setTimeout(in TimeoutHandler handler, in long timeout, arguments...);
// [Custom] long setTimeout(in DOMString code, in long timeout);
[Custom] void clearTimeout(in long handle);
void clearTimeout(in long handle);
[Custom] long setInterval(in TimeoutHandler handler, in long timeout);
// [Custom] long setInterval(in TimeoutHandler handler, in long timeout, arguments...);
// [Custom] long setInterval(in DOMString code, in long timeout);
[Custom] void clearInterval(in long handle);
void clearInterval(in long handle);
// Base64
[Custom] DOMString atob(in DOMString string)
......@@ -475,10 +476,9 @@ module window {
#endif // defined(LANGUAGE_JAVASCRIPT)
#if defined(V8_BINDING)
// window.toString() requires special handling in V8
[V8DoNotCheckSignature, DoNotCheckDomainSecurity, Custom, DontEnum] DOMString toString();
// window.toString() requires special handling in V8
[V8DoNotCheckSignature, DoNotCheckDomainSecurity, Custom, DontEnum] DOMString toString();
#endif // defined(V8_BINDING)
};
}
};
}
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