| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const ScriptV
alue& handler, int timeout, const Vector<ScriptValue>& arguments) | 69 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const ScriptV
alue& handler, int timeout, const Vector<ScriptValue>& arguments) |
| 70 { | 70 { |
| 71 ExecutionContext* executionContext = eventTarget.executionContext(); | 71 ExecutionContext* executionContext = eventTarget.executionContext(); |
| 72 if (!isAllowed(executionContext, false)) | 72 if (!isAllowed(executionContext, false)) |
| 73 return 0; | 73 return 0; |
| 74 if (timeout >= 0 && executionContext->isDocument()) { | 74 if (timeout >= 0 && executionContext->isDocument()) { |
| 75 // FIXME: Crude hack that attempts to pass idle time to V8. This should | 75 // FIXME: Crude hack that attempts to pass idle time to V8. This should |
| 76 // be done using the scheduler instead. | 76 // be done using the scheduler instead. |
| 77 V8GCForContextDispose::instance().notifyIdle(); | 77 V8GCForContextDispose::instance().notifyIdle(); |
| 78 } | 78 } |
| 79 OwnPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r, arguments); | 79 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler, arguments); |
| 80 return DOMTimer::install(executionContext, action.release(), timeout, true); | 80 return DOMTimer::install(executionContext, action.release(), timeout, true); |
| 81 } | 81 } |
| 82 | 82 |
| 83 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const String&
handler, int timeout, const Vector<ScriptValue>&) | 83 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const String&
handler, int timeout, const Vector<ScriptValue>&) |
| 84 { | 84 { |
| 85 ExecutionContext* executionContext = eventTarget.executionContext(); | 85 ExecutionContext* executionContext = eventTarget.executionContext(); |
| 86 if (!isAllowed(executionContext, true)) | 86 if (!isAllowed(executionContext, true)) |
| 87 return 0; | 87 return 0; |
| 88 // Don't allow setting timeouts to run empty functions. Was historically a | 88 // Don't allow setting timeouts to run empty functions. Was historically a |
| 89 // perfomance issue. | 89 // perfomance issue. |
| 90 if (handler.isEmpty()) | 90 if (handler.isEmpty()) |
| 91 return 0; | 91 return 0; |
| 92 if (timeout >= 0 && executionContext->isDocument()) { | 92 if (timeout >= 0 && executionContext->isDocument()) { |
| 93 // FIXME: Crude hack that attempts to pass idle time to V8. This should | 93 // FIXME: Crude hack that attempts to pass idle time to V8. This should |
| 94 // be done using the scheduler instead. | 94 // be done using the scheduler instead. |
| 95 V8GCForContextDispose::instance().notifyIdle(); | 95 V8GCForContextDispose::instance().notifyIdle(); |
| 96 } | 96 } |
| 97 OwnPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r); | 97 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler); |
| 98 return DOMTimer::install(executionContext, action.release(), timeout, true); | 98 return DOMTimer::install(executionContext, action.release(), timeout, true); |
| 99 } | 99 } |
| 100 | 100 |
| 101 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const Script
Value& handler, int timeout, const Vector<ScriptValue>& arguments) | 101 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const Script
Value& handler, int timeout, const Vector<ScriptValue>& arguments) |
| 102 { | 102 { |
| 103 ExecutionContext* executionContext = eventTarget.executionContext(); | 103 ExecutionContext* executionContext = eventTarget.executionContext(); |
| 104 if (!isAllowed(executionContext, false)) | 104 if (!isAllowed(executionContext, false)) |
| 105 return 0; | 105 return 0; |
| 106 OwnPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r, arguments); | 106 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler, arguments); |
| 107 return DOMTimer::install(executionContext, action.release(), timeout, false)
; | 107 return DOMTimer::install(executionContext, action.release(), timeout, false)
; |
| 108 } | 108 } |
| 109 | 109 |
| 110 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const String
& handler, int timeout, const Vector<ScriptValue>&) | 110 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const String
& handler, int timeout, const Vector<ScriptValue>&) |
| 111 { | 111 { |
| 112 ExecutionContext* executionContext = eventTarget.executionContext(); | 112 ExecutionContext* executionContext = eventTarget.executionContext(); |
| 113 if (!isAllowed(executionContext, true)) | 113 if (!isAllowed(executionContext, true)) |
| 114 return 0; | 114 return 0; |
| 115 // Don't allow setting timeouts to run empty functions. Was historically a | 115 // Don't allow setting timeouts to run empty functions. Was historically a |
| 116 // perfomance issue. | 116 // perfomance issue. |
| 117 if (handler.isEmpty()) | 117 if (handler.isEmpty()) |
| 118 return 0; | 118 return 0; |
| 119 OwnPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r); | 119 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler); |
| 120 return DOMTimer::install(executionContext, action.release(), timeout, false)
; | 120 return DOMTimer::install(executionContext, action.release(), timeout, false)
; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void clearTimeout(EventTarget& eventTarget, int timeoutID) | 123 void clearTimeout(EventTarget& eventTarget, int timeoutID) |
| 124 { | 124 { |
| 125 if (ExecutionContext* context = eventTarget.executionContext()) | 125 if (ExecutionContext* context = eventTarget.executionContext()) |
| 126 DOMTimer::removeByID(context, timeoutID); | 126 DOMTimer::removeByID(context, timeoutID); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void clearInterval(EventTarget& eventTarget, int timeoutID) | 129 void clearInterval(EventTarget& eventTarget, int timeoutID) |
| 130 { | 130 { |
| 131 if (ExecutionContext* context = eventTarget.executionContext()) | 131 if (ExecutionContext* context = eventTarget.executionContext()) |
| 132 DOMTimer::removeByID(context, timeoutID); | 132 DOMTimer::removeByID(context, timeoutID); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace DOMWindowTimers | 135 } // namespace DOMWindowTimers |
| 136 | 136 |
| 137 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |