| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const ScriptV
alue& handler, int timeout, const Vector<ScriptValue>& arguments) | 68 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const ScriptV
alue& handler, int timeout, const Vector<ScriptValue>& arguments) |
| 69 { | 69 { |
| 70 ExecutionContext* executionContext = eventTarget.getExecutionContext(); | 70 ExecutionContext* executionContext = eventTarget.getExecutionContext(); |
| 71 if (!isAllowed(scriptState, executionContext, false)) | 71 if (!isAllowed(scriptState, executionContext, false)) |
| 72 return 0; | 72 return 0; |
| 73 if (timeout >= 0 && executionContext->isDocument()) { | 73 if (timeout >= 0 && executionContext->isDocument()) { |
| 74 // FIXME: Crude hack that attempts to pass idle time to V8. This should | 74 // FIXME: Crude hack that attempts to pass idle time to V8. This should |
| 75 // be done using the scheduler instead. | 75 // be done using the scheduler instead. |
| 76 V8GCForContextDispose::instance().notifyIdle(); | 76 V8GCForContextDispose::instance().notifyIdle(); |
| 77 } | 77 } |
| 78 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler, arguments); | 78 RawPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r, arguments); |
| 79 return DOMTimer::install(executionContext, action.release(), timeout, true); | 79 return DOMTimer::install(executionContext, action.release(), timeout, true); |
| 80 } | 80 } |
| 81 | 81 |
| 82 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const String&
handler, int timeout, const Vector<ScriptValue>&) | 82 int setTimeout(ScriptState* scriptState, EventTarget& eventTarget, const String&
handler, int timeout, const Vector<ScriptValue>&) |
| 83 { | 83 { |
| 84 ExecutionContext* executionContext = eventTarget.getExecutionContext(); | 84 ExecutionContext* executionContext = eventTarget.getExecutionContext(); |
| 85 if (!isAllowed(scriptState, executionContext, true)) | 85 if (!isAllowed(scriptState, executionContext, true)) |
| 86 return 0; | 86 return 0; |
| 87 // Don't allow setting timeouts to run empty functions. Was historically a | 87 // Don't allow setting timeouts to run empty functions. Was historically a |
| 88 // perfomance issue. | 88 // perfomance issue. |
| 89 if (handler.isEmpty()) | 89 if (handler.isEmpty()) |
| 90 return 0; | 90 return 0; |
| 91 if (timeout >= 0 && executionContext->isDocument()) { | 91 if (timeout >= 0 && executionContext->isDocument()) { |
| 92 // FIXME: Crude hack that attempts to pass idle time to V8. This should | 92 // FIXME: Crude hack that attempts to pass idle time to V8. This should |
| 93 // be done using the scheduler instead. | 93 // be done using the scheduler instead. |
| 94 V8GCForContextDispose::instance().notifyIdle(); | 94 V8GCForContextDispose::instance().notifyIdle(); |
| 95 } | 95 } |
| 96 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler); | 96 RawPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r); |
| 97 return DOMTimer::install(executionContext, action.release(), timeout, true); | 97 return DOMTimer::install(executionContext, action.release(), timeout, true); |
| 98 } | 98 } |
| 99 | 99 |
| 100 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const Script
Value& handler, int timeout, const Vector<ScriptValue>& arguments) | 100 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const Script
Value& handler, int timeout, const Vector<ScriptValue>& arguments) |
| 101 { | 101 { |
| 102 ExecutionContext* executionContext = eventTarget.getExecutionContext(); | 102 ExecutionContext* executionContext = eventTarget.getExecutionContext(); |
| 103 if (!isAllowed(scriptState, executionContext, false)) | 103 if (!isAllowed(scriptState, executionContext, false)) |
| 104 return 0; | 104 return 0; |
| 105 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler, arguments); | 105 RawPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r, arguments); |
| 106 return DOMTimer::install(executionContext, action.release(), timeout, false)
; | 106 return DOMTimer::install(executionContext, action.release(), timeout, false)
; |
| 107 } | 107 } |
| 108 | 108 |
| 109 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const String
& handler, int timeout, const Vector<ScriptValue>&) | 109 int setInterval(ScriptState* scriptState, EventTarget& eventTarget, const String
& handler, int timeout, const Vector<ScriptValue>&) |
| 110 { | 110 { |
| 111 ExecutionContext* executionContext = eventTarget.getExecutionContext(); | 111 ExecutionContext* executionContext = eventTarget.getExecutionContext(); |
| 112 if (!isAllowed(scriptState, executionContext, true)) | 112 if (!isAllowed(scriptState, executionContext, true)) |
| 113 return 0; | 113 return 0; |
| 114 // Don't allow setting timeouts to run empty functions. Was historically a | 114 // Don't allow setting timeouts to run empty functions. Was historically a |
| 115 // perfomance issue. | 115 // perfomance issue. |
| 116 if (handler.isEmpty()) | 116 if (handler.isEmpty()) |
| 117 return 0; | 117 return 0; |
| 118 OwnPtrWillBeRawPtr<ScheduledAction> action = ScheduledAction::create(scriptS
tate, handler); | 118 RawPtr<ScheduledAction> action = ScheduledAction::create(scriptState, handle
r); |
| 119 return DOMTimer::install(executionContext, action.release(), timeout, false)
; | 119 return DOMTimer::install(executionContext, action.release(), timeout, false)
; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void clearTimeout(EventTarget& eventTarget, int timeoutID) | 122 void clearTimeout(EventTarget& eventTarget, int timeoutID) |
| 123 { | 123 { |
| 124 if (ExecutionContext* context = eventTarget.getExecutionContext()) | 124 if (ExecutionContext* context = eventTarget.getExecutionContext()) |
| 125 DOMTimer::removeByID(context, timeoutID); | 125 DOMTimer::removeByID(context, timeoutID); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void clearInterval(EventTarget& eventTarget, int timeoutID) | 128 void clearInterval(EventTarget& eventTarget, int timeoutID) |
| 129 { | 129 { |
| 130 if (ExecutionContext* context = eventTarget.getExecutionContext()) | 130 if (ExecutionContext* context = eventTarget.getExecutionContext()) |
| 131 DOMTimer::removeByID(context, timeoutID); | 131 DOMTimer::removeByID(context, timeoutID); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace DOMWindowTimers | 134 } // namespace DOMWindowTimers |
| 135 | 135 |
| 136 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |