mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Backed out changeset 24839edcf0ef (bug 1198381)
This commit is contained in:
parent
06858c2f4d
commit
2b410144bf
@ -7,7 +7,7 @@
|
||||
#include "Timeout.h"
|
||||
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsITimeoutHandler.h"
|
||||
#include "nsIScriptTimeoutHandler.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
class nsGlobalWindow;
|
||||
class nsIPrincipal;
|
||||
class nsITimeoutHandler;
|
||||
class nsIScriptTimeoutHandler;
|
||||
class nsITimer;
|
||||
|
||||
namespace mozilla {
|
||||
@ -22,7 +22,7 @@ namespace dom {
|
||||
|
||||
/*
|
||||
* Timeout struct that holds information about each script
|
||||
* timeout. Holds a strong reference to an nsITimeoutHandler, which
|
||||
* timeout. Holds a strong reference to an nsIScriptTimeoutHandler, which
|
||||
* abstracts the language specific cruft.
|
||||
*/
|
||||
class Timeout final
|
||||
@ -85,7 +85,7 @@ public:
|
||||
PopupControlState mPopupState;
|
||||
|
||||
// The language-specific information about the callback.
|
||||
nsCOMPtr<nsITimeoutHandler> mScriptHandler;
|
||||
nsCOMPtr<nsIScriptTimeoutHandler> mScriptHandler;
|
||||
|
||||
private:
|
||||
~Timeout();
|
||||
|
@ -102,7 +102,6 @@ EXPORTS += [
|
||||
'nsIScriptObjectPrincipal.h',
|
||||
'nsIScriptTimeoutHandler.h',
|
||||
'nsIStyleSheetLinkingElement.h',
|
||||
'nsITimeoutHandler.h',
|
||||
'nsJSEnvironment.h',
|
||||
'nsJSUtils.h',
|
||||
'nsLineBreaker.h',
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptTimeoutHandler.h"
|
||||
#include "nsITimeoutHandler.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsScriptNameSpaceManager.h"
|
||||
#include "nsISlowScriptDebug.h"
|
||||
@ -1999,7 +1998,10 @@ nsGlobalWindow::UnmarkGrayTimers()
|
||||
timeout;
|
||||
timeout = timeout->getNext()) {
|
||||
if (timeout->mScriptHandler) {
|
||||
timeout->mScriptHandler->MarkForCC();
|
||||
Function* f = timeout->mScriptHandler->GetCallback();
|
||||
if (f) {
|
||||
f->MarkForCC();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12057,7 +12059,7 @@ nsGlobalWindow::SetInterval(JSContext* aCx, const nsAString& aHandler,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::SetTimeoutOrInterval(nsITimeoutHandler* aHandler,
|
||||
nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler* aHandler,
|
||||
int32_t interval, bool aIsInterval,
|
||||
int32_t* aReturn)
|
||||
{
|
||||
@ -12255,46 +12257,40 @@ nsGlobalWindow::RunTimeoutHandler(Timeout* aTimeout,
|
||||
}
|
||||
|
||||
bool abortIntervalHandler = false;
|
||||
nsCOMPtr<nsITimeoutHandler> basicHandler(timeout->mScriptHandler);
|
||||
nsCOMPtr<nsIScriptTimeoutHandler> handler(do_QueryInterface(basicHandler));
|
||||
if (handler) {
|
||||
RefPtr<Function> callback = handler->GetCallback();
|
||||
nsCOMPtr<nsIScriptTimeoutHandler> handler(timeout->mScriptHandler);
|
||||
RefPtr<Function> callback = handler->GetCallback();
|
||||
|
||||
if (!callback) {
|
||||
// Evaluate the timeout expression.
|
||||
const nsAString& script = handler->GetHandlerText();
|
||||
if (!callback) {
|
||||
// Evaluate the timeout expression.
|
||||
const nsAString& script = handler->GetHandlerText();
|
||||
|
||||
const char* filename = nullptr;
|
||||
uint32_t lineNo = 0, dummyColumn = 0;
|
||||
handler->GetLocation(&filename, &lineNo, &dummyColumn);
|
||||
const char* filename = nullptr;
|
||||
uint32_t lineNo = 0, dummyColumn = 0;
|
||||
handler->GetLocation(&filename, &lineNo, &dummyColumn);
|
||||
|
||||
// New script entry point required, due to the "Create a script" sub-step of
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#timer-initialisation-steps
|
||||
nsAutoMicroTask mt;
|
||||
AutoEntryScript aes(this, reason, true);
|
||||
JS::CompileOptions options(aes.cx());
|
||||
options.setFileAndLine(filename, lineNo).setVersion(JSVERSION_DEFAULT);
|
||||
JS::Rooted<JSObject*> global(aes.cx(), FastGetGlobalJSObject());
|
||||
nsresult rv =
|
||||
nsJSUtils::EvaluateString(aes.cx(), script, global, options);
|
||||
if (rv == NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE) {
|
||||
abortIntervalHandler = true;
|
||||
}
|
||||
} else {
|
||||
// Hold strong ref to ourselves while we call the callback.
|
||||
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow*>(this));
|
||||
ErrorResult rv;
|
||||
JS::Rooted<JS::Value> ignoredVal(RootingCx());
|
||||
callback->Call(me, handler->GetArgs(), &ignoredVal, rv, reason);
|
||||
if (rv.IsUncatchableException()) {
|
||||
abortIntervalHandler = true;
|
||||
}
|
||||
|
||||
rv.SuppressException();
|
||||
// New script entry point required, due to the "Create a script" sub-step of
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#timer-initialisation-steps
|
||||
nsAutoMicroTask mt;
|
||||
AutoEntryScript aes(this, reason, true);
|
||||
JS::CompileOptions options(aes.cx());
|
||||
options.setFileAndLine(filename, lineNo)
|
||||
.setVersion(JSVERSION_DEFAULT);
|
||||
JS::Rooted<JSObject*> global(aes.cx(), FastGetGlobalJSObject());
|
||||
nsresult rv = nsJSUtils::EvaluateString(aes.cx(), script, global, options);
|
||||
if (rv == NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE) {
|
||||
abortIntervalHandler = true;
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsISupports> kungFuDeathGrip(static_cast<nsIDOMWindow*>(this));
|
||||
basicHandler->Call();
|
||||
// Hold strong ref to ourselves while we call the callback.
|
||||
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));
|
||||
ErrorResult rv;
|
||||
JS::Rooted<JS::Value> ignoredVal(RootingCx());
|
||||
callback->Call(me, handler->GetArgs(), &ignoredVal, rv, reason);
|
||||
if (rv.IsUncatchableException()) {
|
||||
abortIntervalHandler = true;
|
||||
}
|
||||
|
||||
rv.SuppressException();
|
||||
}
|
||||
|
||||
// If we received an uncatchable exception, do not schedule the timeout again.
|
||||
|
@ -86,7 +86,6 @@ class nsIControllers;
|
||||
class nsIJSID;
|
||||
class nsIScriptContext;
|
||||
class nsIScriptTimeoutHandler;
|
||||
class nsITimeoutHandler;
|
||||
class nsIWebBrowserChrome;
|
||||
|
||||
class nsDOMWindowList;
|
||||
@ -1441,7 +1440,7 @@ public:
|
||||
// Timeout Functions
|
||||
// Language agnostic timeout function (all args passed).
|
||||
// |interval| is in milliseconds.
|
||||
nsresult SetTimeoutOrInterval(nsITimeoutHandler* aHandler,
|
||||
nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler* aHandler,
|
||||
int32_t interval, bool aIsInterval,
|
||||
int32_t* aReturn);
|
||||
int32_t SetTimeoutOrInterval(JSContext* aCx,
|
||||
|
@ -6,7 +6,6 @@
|
||||
#ifndef nsIScriptTimeoutHandler_h___
|
||||
#define nsIScriptTimeoutHandler_h___
|
||||
|
||||
#include "nsITimeoutHandler.h"
|
||||
#include "nsTArray.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Function.h"
|
||||
@ -27,7 +26,7 @@ class Function;
|
||||
* language agnostic way.
|
||||
*/
|
||||
|
||||
class nsIScriptTimeoutHandler : public nsITimeoutHandler
|
||||
class nsIScriptTimeoutHandler : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTTIMEOUTHANDLER_IID)
|
||||
@ -42,6 +41,8 @@ public:
|
||||
// Get the location of the script.
|
||||
// Note: The memory pointed to by aFileName is owned by the
|
||||
// nsIScriptTimeoutHandler and should not be freed by the caller.
|
||||
virtual void GetLocation(const char **aFileName, uint32_t *aLineNo,
|
||||
uint32_t *aColumn) = 0;
|
||||
|
||||
// If we have a Function, get the arguments for passing to it.
|
||||
virtual const nsTArray<JS::Value>& GetArgs() = 0;
|
||||
|
@ -1,31 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef nsITimeoutHandler_h___
|
||||
#define nsITimeoutHandler_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_ITIMEOUTHANDLER_IID \
|
||||
{ 0xb071a1d3, 0xfd54, 0x40a8, \
|
||||
{ 0x91, 0x9f, 0xc8, 0xf3, 0x3e, 0xb8, 0x3c, 0xfe } }
|
||||
|
||||
class nsITimeoutHandler : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITIMEOUTHANDLER_IID)
|
||||
|
||||
virtual nsresult Call() = 0;
|
||||
|
||||
virtual void GetLocation(const char** aFileName, uint32_t* aLineNo,
|
||||
uint32_t* aColumn) = 0;
|
||||
|
||||
virtual void MarkForCC() = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsITimeoutHandler,
|
||||
NS_ITIMEOUTHANDLER_IID)
|
||||
|
||||
#endif // nsITimeoutHandler_h___
|
@ -60,16 +60,6 @@ public:
|
||||
return mFunction;
|
||||
}
|
||||
|
||||
virtual const nsTArray<JS::Value>& GetArgs() override
|
||||
{
|
||||
return mArgs;
|
||||
}
|
||||
|
||||
virtual nsresult Call() override
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
virtual void GetLocation(const char** aFileName, uint32_t* aLineNo,
|
||||
uint32_t* aColumn) override
|
||||
{
|
||||
@ -78,11 +68,9 @@ public:
|
||||
*aColumn = mColumn;
|
||||
}
|
||||
|
||||
virtual void MarkForCC() override
|
||||
virtual const nsTArray<JS::Value>& GetArgs() override
|
||||
{
|
||||
if (mFunction) {
|
||||
mFunction->MarkForCC();
|
||||
}
|
||||
return mArgs;
|
||||
}
|
||||
|
||||
void ReleaseJSObjects();
|
||||
@ -163,7 +151,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsJSScriptTimeoutHandler)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptTimeoutHandler)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITimeoutHandler)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user