Diff
Modified: trunk/Source/WebCore/ChangeLog (176064 => 176065)
--- trunk/Source/WebCore/ChangeLog 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/ChangeLog 2014-11-13 03:28:32 UTC (rev 176065)
@@ -1,3 +1,43 @@
+2014-11-12 Chris Dumez <[email protected]>
+
+ Have DOMTimer deal with more ScriptExecutionContext references
+ https://bugs.webkit.org/show_bug.cgi?id=138679
+
+ Reviewed by Andreas Kling.
+
+ Have DOMTimer deal with more ScriptExecutionContext references instead
+ of pointers, to make it clear the script execution context cannot be
+ null.
+
+ No new tests, no behavior change.
+
+ * bindings/js/ScheduledAction.cpp:
+ (WebCore::ScheduledAction::execute):
+ (WebCore::ScheduledAction::executeFunctionInContext):
+ * bindings/js/ScheduledAction.h:
+ * dom/DocumentEventQueue.cpp:
+ * page/DOMTimer.cpp:
+ (WebCore::DOMTimerFireState::DOMTimerFireState):
+ (WebCore::NestedTimersMap::instanceForContext):
+ (WebCore::DOMTimer::DOMTimer):
+ (WebCore::DOMTimer::install):
+ (WebCore::DOMTimer::removeById):
+ (WebCore::DOMTimer::fired):
+ * page/DOMTimer.h:
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::setTimeout):
+ (WebCore::DOMWindow::clearTimeout):
+ (WebCore::DOMWindow::setInterval):
+ (WebCore::DOMWindow::clearInterval):
+ * page/SuspendableTimer.cpp:
+ (WebCore::SuspendableTimer::SuspendableTimer):
+ * page/SuspendableTimer.h:
+ * workers/WorkerGlobalScope.cpp:
+ (WebCore::WorkerGlobalScope::setTimeout):
+ (WebCore::WorkerGlobalScope::clearTimeout):
+ (WebCore::WorkerGlobalScope::setInterval):
+ (WebCore::WorkerGlobalScope::clearInterval):
+
2014-11-12 Dean Jackson <[email protected]>
Support unprefixed animation property names
Modified: trunk/Source/WebCore/bindings/js/ScheduledAction.cpp (176064 => 176065)
--- trunk/Source/WebCore/bindings/js/ScheduledAction.cpp 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/bindings/js/ScheduledAction.cpp 2014-11-13 03:28:32 UTC (rev 176065)
@@ -72,18 +72,18 @@
m_args.append(Strong<JSC::Unknown>(exec->vm(), exec->uncheckedArgument(i)));
}
-void ScheduledAction::execute(ScriptExecutionContext* context)
+void ScheduledAction::execute(ScriptExecutionContext& context)
{
- if (is<Document>(*context))
+ if (is<Document>(context))
execute(downcast<Document>(context));
else
execute(downcast<WorkerGlobalScope>(context));
}
-void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSValue thisValue, ScriptExecutionContext* context)
+void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSValue thisValue, ScriptExecutionContext& context)
{
ASSERT(m_function);
- JSLockHolder lock(context->vm());
+ JSLockHolder lock(context.vm());
CallData callData;
CallType callType = getCallData(m_function.get(), callData);
@@ -97,23 +97,23 @@
for (size_t i = 0; i < size; ++i)
args.append(m_args[i].get());
- InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData);
+ InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(&context, callType, callData);
JSValue exception;
- if (context->isDocument())
+ if (is<Document>(context))
JSMainThreadExecState::call(exec, m_function.get(), callType, callData, thisValue, args, &exception);
else
JSC::call(exec, m_function.get(), callType, callData, thisValue, args, &exception);
- InspectorInstrumentation::didCallFunction(cookie, context);
+ InspectorInstrumentation::didCallFunction(cookie, &context);
if (exception)
reportException(exec, exception);
}
-void ScheduledAction::execute(Document* document)
+void ScheduledAction::execute(Document& document)
{
- JSDOMWindow* window = toJSDOMWindow(document->frame(), *m_isolatedWorld);
+ JSDOMWindow* window = toJSDOMWindow(document.frame(), *m_isolatedWorld);
if (!window)
return;
@@ -127,18 +127,18 @@
frame->script().executeScriptInWorld(*m_isolatedWorld, m_code);
}
-void ScheduledAction::execute(WorkerGlobalScope* workerGlobalScope)
+void ScheduledAction::execute(WorkerGlobalScope& workerGlobalScope)
{
// In a Worker, the execution should always happen on a worker thread.
- ASSERT(workerGlobalScope->thread().threadID() == currentThread());
+ ASSERT(workerGlobalScope.thread().threadID() == currentThread());
- WorkerScriptController* scriptController = workerGlobalScope->script();
+ WorkerScriptController* scriptController = workerGlobalScope.script();
if (m_function) {
JSWorkerGlobalScope* contextWrapper = scriptController->workerGlobalScopeWrapper();
executeFunctionInContext(contextWrapper, contextWrapper, workerGlobalScope);
} else {
- ScriptSourceCode code(m_code, workerGlobalScope->url());
+ ScriptSourceCode code(m_code, workerGlobalScope.url());
scriptController->evaluate(code);
}
}
Modified: trunk/Source/WebCore/bindings/js/ScheduledAction.h (176064 => 176065)
--- trunk/Source/WebCore/bindings/js/ScheduledAction.h 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/bindings/js/ScheduledAction.h 2014-11-13 03:28:32 UTC (rev 176065)
@@ -48,7 +48,7 @@
public:
static std::unique_ptr<ScheduledAction> create(JSC::ExecState*, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy*);
- void execute(ScriptExecutionContext*);
+ void execute(ScriptExecutionContext&);
private:
ScheduledAction(JSC::ExecState*, JSC::JSValue function, DOMWrapperWorld& isolatedWorld);
@@ -59,9 +59,9 @@
{
}
- void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue, ScriptExecutionContext*);
- void execute(Document*);
- void execute(WorkerGlobalScope*);
+ void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue, ScriptExecutionContext&);
+ void execute(Document&);
+ void execute(WorkerGlobalScope&);
JSC::Strong<JSC::Unknown> m_function;
Vector<JSC::Strong<JSC::Unknown>> m_args;
Modified: trunk/Source/WebCore/dom/DocumentEventQueue.cpp (176064 => 176065)
--- trunk/Source/WebCore/dom/DocumentEventQueue.cpp 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/dom/DocumentEventQueue.cpp 2014-11-13 03:28:32 UTC (rev 176065)
@@ -39,7 +39,7 @@
class DocumentEventQueue::Timer final : public SuspendableTimer {
public:
Timer(DocumentEventQueue& eventQueue)
- : SuspendableTimer(&eventQueue.m_document)
+ : SuspendableTimer(eventQueue.m_document)
, m_eventQueue(eventQueue)
{
}
Modified: trunk/Source/WebCore/page/DOMTimer.cpp (176064 => 176065)
--- trunk/Source/WebCore/page/DOMTimer.cpp 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/page/DOMTimer.cpp 2014-11-13 03:28:32 UTC (rev 176065)
@@ -55,10 +55,10 @@
static const double _oneMillisecond_ = 0.001;
struct DOMTimerFireState {
- DOMTimerFireState(ScriptExecutionContext* context)
+ explicit DOMTimerFireState(ScriptExecutionContext& context)
: scriptDidInteractWithNonUserObservablePlugin(false)
, scriptDidInteractWithUserObservablePlugin(false)
- , shouldSetCurrent(context->isDocument())
+ , shouldSetCurrent(is<Document>(context))
{
// For worker threads, don't update the current DOMTimerFireState.
// Setting this from workers would not be thread-safe, and its not relevant to current uses.
@@ -89,11 +89,11 @@
struct NestedTimersMap {
typedef HashMap<int, DOMTimer*>::const_iterator const_iterator;
- static NestedTimersMap* instanceForContext(ScriptExecutionContext* context)
+ static NestedTimersMap* instanceForContext(ScriptExecutionContext& context)
{
// For worker threads, we don't use NestedTimersMap as doing so would not
// be thread safe.
- if (context->isDocument())
+ if (is<Document>(context))
return &instance();
return nullptr;
}
@@ -148,9 +148,9 @@
&& !nestingLevel; // Gestures should not be forwarded to nested timers.
}
-DOMTimer::DOMTimer(ScriptExecutionContext* context, std::unique_ptr<ScheduledAction> action, int interval, bool singleShot)
+DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, int interval, bool singleShot)
: SuspendableTimer(context)
- , m_nestingLevel(context->timerNestingLevel())
+ , m_nestingLevel(context.timerNestingLevel())
, m_action(WTF::move(action))
, m_originalInterval(interval)
, m_throttleState(Undetermined)
@@ -161,8 +161,8 @@
// Keep asking for the next id until we're given one that we don't already have.
do {
- m_timeoutId = context->circularSequentialID();
- } while (!context->addTimeout(m_timeoutId, reference));
+ m_timeoutId = context.circularSequentialID();
+ } while (!context.addTimeout(m_timeoutId, reference));
if (singleShot)
startOneShot(m_currentTimerInterval);
@@ -170,15 +170,15 @@
startRepeating(m_currentTimerInterval);
}
-int DOMTimer::install(ScriptExecutionContext* context, std::unique_ptr<ScheduledAction> action, int timeout, bool singleShot)
+int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, int timeout, bool singleShot)
{
// DOMTimer constructor passes ownership of the initial ref on the object to the constructor.
// This reference will be released automatically when a one-shot timer fires, when the context
// is destroyed, or if explicitly cancelled by removeById.
DOMTimer* timer = new DOMTimer(context, WTF::move(action), timeout, singleShot);
#if PLATFORM(IOS)
- if (is<Document>(*context)) {
- Document& document = downcast<Document>(*context);
+ if (is<Document>(context)) {
+ Document& document = downcast<Document>(context);
bool didDeferTimeout = document.frame() && document.frame()->timersPaused();
if (!didDeferTimeout && timeout <= 100 && singleShot) {
WKSetObservedContentChange(WKContentIndeterminateChange);
@@ -188,7 +188,7 @@
#endif
timer->suspendIfNeeded();
- InspectorInstrumentation::didInstallTimer(context, timer->m_timeoutId, timeout, singleShot);
+ InspectorInstrumentation::didInstallTimer(&context, timer->m_timeoutId, timeout, singleShot);
// Keep track of nested timer installs.
if (NestedTimersMap* nestedTimers = NestedTimersMap::instanceForContext(context))
@@ -197,7 +197,7 @@
return timer->m_timeoutId;
}
-void DOMTimer::removeById(ScriptExecutionContext* context, int timeoutId)
+void DOMTimer::removeById(ScriptExecutionContext& context, int timeoutId)
{
// timeout IDs have to be positive, and 0 and -1 are unsafe to
// even look up since they are the empty and deleted value
@@ -208,8 +208,8 @@
if (NestedTimersMap* nestedTimers = NestedTimersMap::instanceForContext(context))
nestedTimers->remove(timeoutId);
- InspectorInstrumentation::didRemoveTimer(context, timeoutId);
- context->removeTimeout(timeoutId);
+ InspectorInstrumentation::didRemoveTimer(&context, timeoutId);
+ context.removeTimeout(timeoutId);
}
void DOMTimer::updateThrottlingStateIfNecessary(const DOMTimerFireState& fireState)
@@ -245,27 +245,27 @@
// wait unit the end of this function to delete DOMTimer.
RefPtr<DOMTimer> reference = this;
- ScriptExecutionContext* context = scriptExecutionContext();
- ASSERT(context);
+ ASSERT(scriptExecutionContext());
+ ScriptExecutionContext& context = *scriptExecutionContext();
DOMTimerFireState fireState(context);
#if PLATFORM(IOS)
Document* document = nullptr;
- if (is<Document>(*context)) {
- document = downcast<Document>(context);
+ if (is<Document>(context)) {
+ document = &downcast<Document>(context);
ASSERT(!document->frame()->timersPaused());
}
#endif
- context->setTimerNestingLevel(std::min(m_nestingLevel + 1, maxTimerNestingLevel));
+ context.setTimerNestingLevel(std::min(m_nestingLevel + 1, maxTimerNestingLevel));
ASSERT(!isSuspended());
- ASSERT(!context->activeDOMObjectsAreSuspended());
+ ASSERT(!context.activeDOMObjectsAreSuspended());
UserGestureIndicator gestureIndicator(m_shouldForwardUserGesture ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
// Only the first execution of a multi-shot timer should get an affirmative user gesture indicator.
m_shouldForwardUserGesture = false;
- InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTimer(context, m_timeoutId);
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTimer(&context, m_timeoutId);
// Simple case for non-one-shot timers.
if (isActive()) {
@@ -282,7 +282,7 @@
return;
}
- context->removeTimeout(m_timeoutId);
+ context.removeTimeout(m_timeoutId);
#if PLATFORM(IOS)
bool shouldReportLackOfChanges;
@@ -330,7 +330,7 @@
nestedTimers->stopTracking();
}
- context->setTimerNestingLevel(0);
+ context.setTimerNestingLevel(0);
}
void DOMTimer::didStop()
Modified: trunk/Source/WebCore/page/DOMTimer.h (176064 => 176065)
--- trunk/Source/WebCore/page/DOMTimer.h 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/page/DOMTimer.h 2014-11-13 03:28:32 UTC (rev 176065)
@@ -43,8 +43,8 @@
public:
// Creates a new timer owned by specified ScriptExecutionContext, starts it
// and returns its Id.
- static int install(ScriptExecutionContext*, std::unique_ptr<ScheduledAction>, int timeout, bool singleShot);
- static void removeById(ScriptExecutionContext*, int timeoutId);
+ static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int timeout, bool singleShot);
+ static void removeById(ScriptExecutionContext&, int timeoutId);
// Notify that the interval may need updating (e.g. because the minimum interval
// setting for the context has changed).
@@ -53,7 +53,7 @@
static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
private:
- DOMTimer(ScriptExecutionContext*, std::unique_ptr<ScheduledAction>, int interval, bool singleShot);
+ DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int interval, bool singleShot);
double intervalClampedToMinimum() const;
void updateThrottlingStateIfNecessary(const DOMTimerFireState&);
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (176064 => 176065)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2014-11-13 03:28:32 UTC (rev 176065)
@@ -1606,7 +1606,7 @@
ec = INVALID_ACCESS_ERR;
return -1;
}
- return DOMTimer::install(context, WTF::move(action), timeout, true);
+ return DOMTimer::install(*context, WTF::move(action), timeout, true);
}
void DOMWindow::clearTimeout(int timeoutId)
@@ -1630,7 +1630,7 @@
ScriptExecutionContext* context = scriptExecutionContext();
if (!context)
return;
- DOMTimer::removeById(context, timeoutId);
+ DOMTimer::removeById(*context, timeoutId);
}
int DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, ExceptionCode& ec)
@@ -1640,7 +1640,7 @@
ec = INVALID_ACCESS_ERR;
return -1;
}
- return DOMTimer::install(context, WTF::move(action), timeout, false);
+ return DOMTimer::install(*context, WTF::move(action), timeout, false);
}
void DOMWindow::clearInterval(int timeoutId)
@@ -1648,7 +1648,7 @@
ScriptExecutionContext* context = scriptExecutionContext();
if (!context)
return;
- DOMTimer::removeById(context, timeoutId);
+ DOMTimer::removeById(*context, timeoutId);
}
#if ENABLE(REQUEST_ANIMATION_FRAME)
Modified: trunk/Source/WebCore/page/SuspendableTimer.cpp (176064 => 176065)
--- trunk/Source/WebCore/page/SuspendableTimer.cpp 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/page/SuspendableTimer.cpp 2014-11-13 03:28:32 UTC (rev 176065)
@@ -31,8 +31,8 @@
namespace WebCore {
-SuspendableTimer::SuspendableTimer(ScriptExecutionContext* context)
- : ActiveDOMObject(context)
+SuspendableTimer::SuspendableTimer(ScriptExecutionContext& context)
+ : ActiveDOMObject(&context)
, m_suspended(false)
, m_savedNextFireInterval(0)
, m_savedRepeatInterval(0)
Modified: trunk/Source/WebCore/page/SuspendableTimer.h (176064 => 176065)
--- trunk/Source/WebCore/page/SuspendableTimer.h 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/page/SuspendableTimer.h 2014-11-13 03:28:32 UTC (rev 176065)
@@ -34,7 +34,7 @@
class SuspendableTimer : private TimerBase, public ActiveDOMObject {
public:
- explicit SuspendableTimer(ScriptExecutionContext*);
+ explicit SuspendableTimer(ScriptExecutionContext&);
virtual ~SuspendableTimer();
// A hook for derived classes to perform cleanup.
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (176064 => 176065)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2014-11-13 03:28:32 UTC (rev 176065)
@@ -154,22 +154,22 @@
int WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
{
- return DOMTimer::install(scriptExecutionContext(), WTF::move(action), timeout, true);
+ return DOMTimer::install(*this, WTF::move(action), timeout, true);
}
void WorkerGlobalScope::clearTimeout(int timeoutId)
{
- DOMTimer::removeById(scriptExecutionContext(), timeoutId);
+ DOMTimer::removeById(*this, timeoutId);
}
int WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
{
- return DOMTimer::install(scriptExecutionContext(), WTF::move(action), timeout, false);
+ return DOMTimer::install(*this, WTF::move(action), timeout, false);
}
void WorkerGlobalScope::clearInterval(int timeoutId)
{
- DOMTimer::removeById(scriptExecutionContext(), timeoutId);
+ DOMTimer::removeById(*this, timeoutId);
}
void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode& ec)
Modified: trunk/Source/WebKit/win/ChangeLog (176064 => 176065)
--- trunk/Source/WebKit/win/ChangeLog 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebKit/win/ChangeLog 2014-11-13 03:28:32 UTC (rev 176065)
@@ -1,3 +1,18 @@
+2014-11-12 Chris Dumez <[email protected]>
+
+ Have DOMTimer deal with more ScriptExecutionContext references
+ https://bugs.webkit.org/show_bug.cgi?id=138679
+
+ Reviewed by Andreas Kling.
+
+ Update WindowCloseTimer to deal with ScriptExecutionContext references
+ instead of pointers as it subclasses SuspendableTimer and its
+ constructor takes a ScriptExecutionContext& in argument.
+
+ * WebView.cpp:
+ (WindowCloseTimer::create):
+ (WindowCloseTimer::WindowCloseTimer):
+
2014-11-05 Jer Noble <[email protected]>
De-templatize Timer
Modified: trunk/Source/WebKit/win/WebView.cpp (176064 => 176065)
--- trunk/Source/WebKit/win/WebView.cpp 2014-11-13 03:19:37 UTC (rev 176064)
+++ trunk/Source/WebKit/win/WebView.cpp 2014-11-13 03:28:32 UTC (rev 176065)
@@ -1267,7 +1267,7 @@
static WindowCloseTimer* create(WebView*);
private:
- WindowCloseTimer(ScriptExecutionContext*, WebView*);
+ WindowCloseTimer(ScriptExecutionContext&, WebView*);
virtual void contextDestroyed();
virtual void fired();
@@ -1280,21 +1280,20 @@
Frame* frame = core(webView->topLevelFrame());
ASSERT(frame);
if (!frame)
- return 0;
+ return nullptr;
Document* document = frame->document();
ASSERT(document);
if (!document)
- return 0;
+ return nullptr;
- return new WindowCloseTimer(document, webView);
+ return new WindowCloseTimer(*document, webView);
}
-WindowCloseTimer::WindowCloseTimer(ScriptExecutionContext* context, WebView* webView)
+WindowCloseTimer::WindowCloseTimer(ScriptExecutionContext& context, WebView* webView)
: SuspendableTimer(context)
, m_webView(webView)
{
- ASSERT_ARG(context, context);
ASSERT_ARG(webView, webView);
}