| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 void HTMLParserScheduler::continueNextChunkTimerFired(Timer<HTMLParserScheduler>
* timer) | 88 void HTMLParserScheduler::continueNextChunkTimerFired(Timer<HTMLParserScheduler>
* timer) |
| 89 { | 89 { |
| 90 ASSERT_UNUSED(timer, timer == &m_continueNextChunkTimer); | 90 ASSERT_UNUSED(timer, timer == &m_continueNextChunkTimer); |
| 91 // FIXME: The timer class should handle timer priorities instead of this cod
e. | 91 // FIXME: The timer class should handle timer priorities instead of this cod
e. |
| 92 // If a layout is scheduled, wait again to let the layout timer run first. | 92 // If a layout is scheduled, wait again to let the layout timer run first. |
| 93 // FIXME: We should fix this by reducing the max-parse-time instead of | 93 // FIXME: We should fix this by reducing the max-parse-time instead of |
| 94 // artificially forcing the parser to yield agressively before first layout. | 94 // artificially forcing the parser to yield agressively before first layout. |
| 95 if (m_parser->document()->shouldParserYieldAgressivelyBeforeScriptExecution(
)) { | 95 if (m_parser->document()->shouldParserYieldAgressivelyBeforeScriptExecution(
)) { |
| 96 m_continueNextChunkTimer.startOneShot(0); | 96 m_continueNextChunkTimer.startOneShot(0, FROM_HERE); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 m_parser->resumeParsingAfterYield(); | 99 m_parser->resumeParsingAfterYield(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void HTMLParserScheduler::checkForYieldBeforeScript(PumpSession& session) | 102 void HTMLParserScheduler::checkForYieldBeforeScript(PumpSession& session) |
| 103 { | 103 { |
| 104 // If we've never painted before and a layout is pending, yield prior to run
ning | 104 // If we've never painted before and a layout is pending, yield prior to run
ning |
| 105 // scripts to give the page a chance to paint earlier. | 105 // scripts to give the page a chance to paint earlier. |
| 106 Document* document = m_parser->document(); | 106 Document* document = m_parser->document(); |
| 107 bool needsFirstPaint = document->view() && !document->view()->hasEverPainted
(); | 107 bool needsFirstPaint = document->view() && !document->view()->hasEverPainted
(); |
| 108 if (needsFirstPaint && document->shouldParserYieldAgressivelyBeforeScriptExe
cution()) | 108 if (needsFirstPaint && document->shouldParserYieldAgressivelyBeforeScriptExe
cution()) |
| 109 session.needsYield = true; | 109 session.needsYield = true; |
| 110 session.didSeeScript = true; | 110 session.didSeeScript = true; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void HTMLParserScheduler::scheduleForResume() | 113 void HTMLParserScheduler::scheduleForResume() |
| 114 { | 114 { |
| 115 m_continueNextChunkTimer.startOneShot(0); | 115 m_continueNextChunkTimer.startOneShot(0, FROM_HERE); |
| 116 } | 116 } |
| 117 | 117 |
| 118 | 118 |
| 119 void HTMLParserScheduler::suspend() | 119 void HTMLParserScheduler::suspend() |
| 120 { | 120 { |
| 121 ASSERT(!m_isSuspendedWithActiveTimer); | 121 ASSERT(!m_isSuspendedWithActiveTimer); |
| 122 if (!m_continueNextChunkTimer.isActive()) | 122 if (!m_continueNextChunkTimer.isActive()) |
| 123 return; | 123 return; |
| 124 m_isSuspendedWithActiveTimer = true; | 124 m_isSuspendedWithActiveTimer = true; |
| 125 m_continueNextChunkTimer.stop(); | 125 m_continueNextChunkTimer.stop(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void HTMLParserScheduler::resume() | 128 void HTMLParserScheduler::resume() |
| 129 { | 129 { |
| 130 ASSERT(!m_continueNextChunkTimer.isActive()); | 130 ASSERT(!m_continueNextChunkTimer.isActive()); |
| 131 if (!m_isSuspendedWithActiveTimer) | 131 if (!m_isSuspendedWithActiveTimer) |
| 132 return; | 132 return; |
| 133 m_isSuspendedWithActiveTimer = false; | 133 m_isSuspendedWithActiveTimer = false; |
| 134 m_continueNextChunkTimer.startOneShot(0); | 134 m_continueNextChunkTimer.startOneShot(0, FROM_HERE); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } | 137 } |
| OLD | NEW |