| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 : m_document(document) | 39 : m_document(document) |
| 40 , m_timer(this, &ScriptRunner::timerFired) | 40 , m_timer(this, &ScriptRunner::timerFired) |
| 41 { | 41 { |
| 42 ASSERT(document); | 42 ASSERT(document); |
| 43 } | 43 } |
| 44 | 44 |
| 45 ScriptRunner::~ScriptRunner() | 45 ScriptRunner::~ScriptRunner() |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ScriptRunner::addPendingAsyncScript(ScriptLoader* scriptLoader, const Pendi
ngScript& pendingScript) |
| 50 { |
| 51 m_document->incrementLoadEventDelayCount(); |
| 52 m_pendingAsyncScripts.add(scriptLoader, pendingScript); |
| 53 } |
| 54 |
| 49 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, ResourceP
tr<ScriptResource> resource, ExecutionType executionType) | 55 void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, ResourceP
tr<ScriptResource> resource, ExecutionType executionType) |
| 50 { | 56 { |
| 51 ASSERT(scriptLoader); | 57 ASSERT(scriptLoader); |
| 52 ASSERT(resource.get()); | 58 ASSERT(resource.get()); |
| 53 | 59 |
| 54 Element* element = scriptLoader->element(); | 60 Element* element = scriptLoader->element(); |
| 55 ASSERT(element); | 61 ASSERT(element); |
| 56 ASSERT(element->inDocument()); | 62 ASSERT(element->inDocument()); |
| 57 | 63 |
| 58 m_document->incrementLoadEventDelayCount(); | |
| 59 | |
| 60 switch (executionType) { | 64 switch (executionType) { |
| 61 case ASYNC_EXECUTION: | 65 case ASYNC_EXECUTION: |
| 62 m_pendingAsyncScripts.add(scriptLoader, PendingScript(element, resource.
get())); | 66 addPendingAsyncScript(scriptLoader, PendingScript(element, resource.get(
))); |
| 63 break; | 67 break; |
| 64 | 68 |
| 65 case IN_ORDER_EXECUTION: | 69 case IN_ORDER_EXECUTION: |
| 70 m_document->incrementLoadEventDelayCount(); |
| 66 m_scriptsToExecuteInOrder.append(PendingScript(element, resource.get()))
; | 71 m_scriptsToExecuteInOrder.append(PendingScript(element, resource.get()))
; |
| 67 break; | 72 break; |
| 68 } | 73 } |
| 69 } | 74 } |
| 70 | 75 |
| 71 void ScriptRunner::suspend() | 76 void ScriptRunner::suspend() |
| 72 { | 77 { |
| 73 m_timer.stop(); | 78 m_timer.stop(); |
| 74 } | 79 } |
| 75 | 80 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 m_pendingAsyncScripts.remove(scriptLoader); | 107 m_pendingAsyncScripts.remove(scriptLoader); |
| 103 m_document->decrementLoadEventDelayCount(); | 108 m_document->decrementLoadEventDelayCount(); |
| 104 break; | 109 break; |
| 105 | 110 |
| 106 case IN_ORDER_EXECUTION: | 111 case IN_ORDER_EXECUTION: |
| 107 ASSERT(!m_scriptsToExecuteInOrder.isEmpty()); | 112 ASSERT(!m_scriptsToExecuteInOrder.isEmpty()); |
| 108 break; | 113 break; |
| 109 } | 114 } |
| 110 } | 115 } |
| 111 | 116 |
| 117 void ScriptRunner::movePendingAsyncScript(ScriptRunner* newRunner, ScriptLoader*
scriptLoader) |
| 118 { |
| 119 if (m_pendingAsyncScripts.contains(scriptLoader)) { |
| 120 newRunner->addPendingAsyncScript(scriptLoader, m_pendingAsyncScripts.tak
e(scriptLoader)); |
| 121 m_document->decrementLoadEventDelayCount(); |
| 122 } |
| 123 } |
| 124 |
| 112 void ScriptRunner::timerFired(Timer<ScriptRunner>* timer) | 125 void ScriptRunner::timerFired(Timer<ScriptRunner>* timer) |
| 113 { | 126 { |
| 114 ASSERT_UNUSED(timer, timer == &m_timer); | 127 ASSERT_UNUSED(timer, timer == &m_timer); |
| 115 | 128 |
| 116 RefPtrWillBeRawPtr<Document> protect(m_document.get()); | 129 RefPtrWillBeRawPtr<Document> protect(m_document.get()); |
| 117 | 130 |
| 118 Vector<PendingScript> scripts; | 131 Vector<PendingScript> scripts; |
| 119 scripts.swap(m_scriptsToExecuteSoon); | 132 scripts.swap(m_scriptsToExecuteSoon); |
| 120 | 133 |
| 121 size_t numInOrderScriptsToExecute = 0; | 134 size_t numInOrderScriptsToExecute = 0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 137 { | 150 { |
| 138 #if ENABLE(OILPAN) | 151 #if ENABLE(OILPAN) |
| 139 visitor->trace(m_document); | 152 visitor->trace(m_document); |
| 140 visitor->trace(m_scriptsToExecuteInOrder); | 153 visitor->trace(m_scriptsToExecuteInOrder); |
| 141 visitor->trace(m_scriptsToExecuteSoon); | 154 visitor->trace(m_scriptsToExecuteSoon); |
| 142 visitor->trace(m_pendingAsyncScripts); | 155 visitor->trace(m_pendingAsyncScripts); |
| 143 #endif | 156 #endif |
| 144 } | 157 } |
| 145 | 158 |
| 146 } | 159 } |
| OLD | NEW |