2006-06-18 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
* kjs/interpreter.cpp:
(KJS::TimeoutChecker::pauseTimeoutCheck):
Do nothing if the timeout check hasn't been started.
(KJS::TimeoutChecker::resumeTimeoutCheck):
Do nothing if the timeout check hasn't been started.
Use the right signal handler when unblocking.
(KJS::Interpreter::handleTimeout):
pause/resume the timeout check around the call to
shouldInterruptScript().
WebCore:
2006-06-17 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
* bindings/js/kjs_binding.cpp:
(KJS::ScriptInterpreter::ScriptInterpreter):
Set the default script timeout.
(KJS::ScriptInterpreter::shouldInterruptScript):
New function which asks the frame if the script should be interrupted.
* bindings/js/kjs_binding.h:
* bindings/js/kjs_events.cpp:
(KJS::JSAbstractEventListener::handleEvent):
* bindings/js/kjs_proxy.cpp:
(WebCore::KJSProxy::evaluate):
Add calls to startTimeoutCheck/stopTimeoutCheck
* bindings/js/kjs_window.cpp:
(KJS::WindowFunc::callAsFunction):
Add calls to pauseTimeoutCheck/unpauseTimeoutCheck
(KJS::ScheduledAction::execute):
Add calls to startTimeoutCheck/stopTimeoutCheck
* bridge/mac/FrameMac.h:
* bridge/mac/FrameMac.mm:
(WebCore::FrameMac::shouldInterruptJavaScript):
New function which asks the bridge if the script should be interrupted.
* bridge/mac/WebCoreFrameBridge.h:
* page/Frame.h:
Add function declarations.
WebKit:
2006-06-18 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
* WebCoreSupport/WebFrameBridge.m:
(-[WebFrameBridge shouldInterruptJavaScript]):
Ask the UI delegate if the script should be interrupted.
* WebView/WebUIDelegatePrivate.h:
Declare webViewShouldInterruptJavaScript: delegate method
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14904
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-06-18 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Geoff.
+
+ * kjs/interpreter.cpp:
+ (KJS::TimeoutChecker::pauseTimeoutCheck):
+ Do nothing if the timeout check hasn't been started.
+
+ (KJS::TimeoutChecker::resumeTimeoutCheck):
+ Do nothing if the timeout check hasn't been started.
+ Use the right signal handler when unblocking.
+
+ (KJS::Interpreter::handleTimeout):
+ pause/resume the timeout check around the call to
+ shouldInterruptScript().
+
2006-06-16 Ben Goodger <beng@google.com>
Reviewed by Maciej
Make sure to only assert equality with s_executingInterpreter when it
is being used (i.e. when HAVE(SYS_TIME_H) == true)
-
2006-06-17 David Kilzer <ddkilzer@kilzer.net>
Reviewed by darin.
void TimeoutChecker::pauseTimeoutCheck(Interpreter* interpreter)
{
-#if HAVE(SYS_TIME_H)
+ if (interpreter->m_startTimeoutCheckCount == 0)
+ return;
+
+#if HAVE(SYS_TIME_H)
ASSERT(interpreter == s_executingInterpreter);
void (*currentSignalHandler)(int);
void TimeoutChecker::resumeTimeoutCheck(Interpreter* interpreter)
{
+ if (interpreter->m_startTimeoutCheckCount == 0)
+ return;
+
#if HAVE(SYS_TIME_H)
ASSERT(interpreter == s_executingInterpreter);
#endif
setitimer(ITIMER_REAL, 0L, &m_pausetv);
// Unblock signal
- currentSignalHandler = signal(SIGALRM, SIG_IGN);
+ currentSignalHandler = signal(SIGALRM, alarmHandler);
#endif
}
bool Interpreter::handleTimeout()
{
m_timedOut = false;
+
+ pauseTimeoutCheck();
+ bool retval = shouldInterruptScript();
+ resumeTimeoutCheck();
- return shouldInterruptScript();
+ return retval;
}
bool checkTimeout();
protected:
- virtual bool shouldInterruptScript() { return true; }
+ virtual bool shouldInterruptScript() const { return true; }
long m_timeoutTime;
private:
+2006-06-17 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Geoff.
+
+ * bindings/js/kjs_binding.cpp:
+ (KJS::ScriptInterpreter::ScriptInterpreter):
+ Set the default script timeout.
+
+ (KJS::ScriptInterpreter::shouldInterruptScript):
+ New function which asks the frame if the script should be interrupted.
+
+ * bindings/js/kjs_binding.h:
+
+ * bindings/js/kjs_events.cpp:
+ (KJS::JSAbstractEventListener::handleEvent):
+ * bindings/js/kjs_proxy.cpp:
+ (WebCore::KJSProxy::evaluate):
+ Add calls to startTimeoutCheck/stopTimeoutCheck
+
+ * bindings/js/kjs_window.cpp:
+ (KJS::WindowFunc::callAsFunction):
+ Add calls to pauseTimeoutCheck/unpauseTimeoutCheck
+
+ (KJS::ScheduledAction::execute):
+ Add calls to startTimeoutCheck/stopTimeoutCheck
+
+ * bridge/mac/FrameMac.h:
+ * bridge/mac/FrameMac.mm:
+ (WebCore::FrameMac::shouldInterruptJavaScript):
+ New function which asks the bridge if the script should be interrupted.
+
+ * bridge/mac/WebCoreFrameBridge.h:
+ * page/Frame.h:
+ Add function declarations.
+
2006-06-17 Alexey Proskuryakov <ap@nypop.com>
Reviewed by ggaren.
: Interpreter( global ), m_frame(frame),
m_evt( 0L ), m_inlineCode(false), m_timerCallback(false)
{
+ // Time in milliseconds before the script timeout handler kicks in
+ const unsigned ScriptTimeoutTimeMS = 5000;
+
+ setTimeoutTime(ScriptTimeoutTimeMS);
}
ScriptInterpreter::~ScriptInterpreter()
return result;
}
-
+bool ScriptInterpreter::shouldInterruptScript() const
+{
+ return m_frame->shouldInterruptJavaScript();
+}
+
//////
JSValue *jsStringOrNull(const String &s)
virtual void *createLanguageInstanceForValue (ExecState *exec, int language, JSObject *value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
void *createObjcInstanceForValue (ExecState *exec, JSObject *value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
+ virtual bool shouldInterruptScript() const;
+
private:
WebCore::Frame* m_frame;
interpreter->setCurrentEvent(event);
JSValue* retval;
- if (handleEventFunc)
+ if (handleEventFunc) {
+ interpreter->startTimeoutCheck();
retval = handleEventFunc->call(exec, listener, args);
- else {
+ } else {
JSObject* thisObj;
if (isWindowEvent)
thisObj = window;
else
thisObj = static_cast<JSObject*>(toJS(exec, event->currentTarget()));
+ interpreter->startTimeoutCheck();
retval = listener->call(exec, thisObj, args);
}
+ interpreter->stopTimeoutCheck();
window->setCurrentEvent(0);
interpreter->setCurrentEvent(0);
JSLock lock;
JSValue* thisNode = n ? Window::retrieve(m_frame) : toJS(m_script->globalExec(), n);
+
+ m_script->startTimeoutCheck();
Completion comp = m_script->evaluate(filename, baseLine, reinterpret_cast<const KJS::UChar*>(str.characters()), str.length(), thisNode);
-
+ m_script->stopTimeoutCheck();
+
if (comp.complType() == Normal || comp.complType() == ReturnValue)
return comp.value();
case Window::Alert:
if (frame && frame->document())
frame->document()->updateRendering();
+ exec->dynamicInterpreter()->pauseTimeoutCheck();
frame->runJavaScriptAlert(str);
+ exec->dynamicInterpreter()->resumeTimeoutCheck();
return jsUndefined();
- case Window::Confirm:
+ case Window::Confirm: {
if (frame && frame->document())
frame->document()->updateRendering();
- return jsBoolean(frame->runJavaScriptConfirm(str));
+ exec->dynamicInterpreter()->pauseTimeoutCheck();
+ bool result = frame->runJavaScriptConfirm(str);
+ exec->dynamicInterpreter()->resumeTimeoutCheck();
+ return jsBoolean(result);
+ }
case Window::Prompt:
{
if (frame && frame->document())
if (Document *doc = frame->document())
doc->removeWindowEventListener(AtomicString(args[0]->toString(exec)), listener, args[2]->toBoolean(exec));
return jsUndefined();
- case Window::ShowModalDialog:
- return showModalDialog(exec, window, args);
+ case Window::ShowModalDialog: {
+ exec->dynamicInterpreter()->pauseTimeoutCheck();
+ JSValue* result = showModalDialog(exec, window, args);
+ exec->dynamicInterpreter()->resumeTimeoutCheck();
+ return result;
+ }
}
return jsUndefined();
}
ExecState *exec = interpreter->globalExec();
ASSERT(window == interpreter->globalObject());
JSLock lock;
+ interpreter->startTimeoutCheck();
static_cast<JSObject *>(func)->call(exec, window, m_args);
+ interpreter->stopTimeoutCheck();
if (exec->hadException()) {
JSObject* exception = exec->exception()->toObject(exec);
exec->clearException();
virtual void runJavaScriptAlert(const String&);
virtual bool runJavaScriptConfirm(const String&);
virtual bool runJavaScriptPrompt(const String& message, const String& defaultValue, String& result);
+ virtual bool shouldInterruptJavaScript();
virtual bool locationbarVisible();
virtual bool menubarVisible();
virtual bool personalbarVisible();
return false;
}
+bool FrameMac::shouldInterruptJavaScript()
+{
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ return [_bridge shouldInterruptJavaScript];
+ END_BLOCK_OBJC_EXCEPTIONS;
+
+ return false;
+}
+
bool FrameMac::locationbarVisible()
{
return [_bridge areToolbarsVisible];
- (void)runJavaScriptAlertPanelWithMessage:(NSString *)message;
- (BOOL)runJavaScriptConfirmPanelWithMessage:(NSString *)message;
- (BOOL)runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText returningText:(NSString **)result;
+- (BOOL)shouldInterruptJavaScript;
- (BOOL)canRunBeforeUnloadConfirmPanel;
- (BOOL)runBeforeUnloadConfirmPanelWithMessage:(NSString *)message;
- (void)addMessageToConsole:(NSDictionary *)message;
virtual void runJavaScriptAlert(const String& message) = 0;
virtual bool runJavaScriptConfirm(const String& message) = 0;
virtual bool runJavaScriptPrompt(const String& message, const String& defaultValue, String& result) = 0;
+ virtual bool shouldInterruptJavaScript() = 0;
virtual bool locationbarVisible() = 0;
virtual bool menubarVisible() = 0;
virtual bool personalbarVisible() = 0;
+2006-06-18 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Geoff.
+
+ * WebCoreSupport/WebFrameBridge.m:
+ (-[WebFrameBridge shouldInterruptJavaScript]):
+ Ask the UI delegate if the script should be interrupted.
+
+ * WebView/WebUIDelegatePrivate.h:
+ Declare webViewShouldInterruptJavaScript: delegate method
+
2006-06-17 Mitz Pettel <opendarwin.org@mitzpettel.com>
Reviewed by Darin.
return [[WebDefaultUIDelegate sharedUIDelegate] webView:wv runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:_frame];
}
+- (BOOL)shouldInterruptJavaScript
+{
+ WebView *wv = [self webView];
+ id wd = [wv UIDelegate];
+
+ if ([wd respondsToSelector:@selector(webViewShouldInterruptJavaScript:)])
+ return [wd webViewShouldInterruptJavaScript:wv];
+ return NO;
+}
+
- (BOOL)canRunBeforeUnloadConfirmPanel
{
WebView *wv = [self webView];
- (void)webView:(WebView *)sender dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag forView:(NSView *)view;
+- (BOOL)webViewShouldInterruptJavaScript:(WebView *)sender;
+
@end