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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 HTMLParserScheduler::~HTMLParserScheduler() | 83 HTMLParserScheduler::~HTMLParserScheduler() |
84 { | 84 { |
85 m_continueNextChunkTimer.stop(); | 85 m_continueNextChunkTimer.stop(); |
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 if (m_parser->document()->isLayoutTimerActive()) { | 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. |
| 95 if (m_parser->document()->parserShouldYieldAgressivelyBeforeFirstLayout()) { |
94 m_continueNextChunkTimer.startOneShot(0); | 96 m_continueNextChunkTimer.startOneShot(0); |
95 return; | 97 return; |
96 } | 98 } |
97 m_parser->resumeParsingAfterYield(); | 99 m_parser->resumeParsingAfterYield(); |
98 } | 100 } |
99 | 101 |
100 void HTMLParserScheduler::checkForYieldBeforeScript(PumpSession& session) | 102 void HTMLParserScheduler::checkForYieldBeforeScript(PumpSession& session) |
101 { | 103 { |
102 // 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 |
103 // scripts to give the page a chance to paint earlier. | 105 // scripts to give the page a chance to paint earlier. |
104 Document* document = m_parser->document(); | 106 Document* document = m_parser->document(); |
105 bool needsFirstPaint = document->view() && !document->view()->hasEverPainted
(); | 107 bool needsFirstPaint = document->view() && !document->view()->hasEverPainted
(); |
106 if (needsFirstPaint && document->isLayoutTimerActive()) | 108 if (needsFirstPaint && document->parserShouldYieldAgressivelyBeforeFirstLayo
ut()) |
107 session.needsYield = true; | 109 session.needsYield = true; |
108 session.didSeeScript = true; | 110 session.didSeeScript = true; |
109 } | 111 } |
110 | 112 |
111 void HTMLParserScheduler::scheduleForResume() | 113 void HTMLParserScheduler::scheduleForResume() |
112 { | 114 { |
113 m_continueNextChunkTimer.startOneShot(0); | 115 m_continueNextChunkTimer.startOneShot(0); |
114 } | 116 } |
115 | 117 |
116 | 118 |
117 void HTMLParserScheduler::suspend() | 119 void HTMLParserScheduler::suspend() |
118 { | 120 { |
119 ASSERT(!m_isSuspendedWithActiveTimer); | 121 ASSERT(!m_isSuspendedWithActiveTimer); |
120 if (!m_continueNextChunkTimer.isActive()) | 122 if (!m_continueNextChunkTimer.isActive()) |
121 return; | 123 return; |
122 m_isSuspendedWithActiveTimer = true; | 124 m_isSuspendedWithActiveTimer = true; |
123 m_continueNextChunkTimer.stop(); | 125 m_continueNextChunkTimer.stop(); |
124 } | 126 } |
125 | 127 |
126 void HTMLParserScheduler::resume() | 128 void HTMLParserScheduler::resume() |
127 { | 129 { |
128 ASSERT(!m_continueNextChunkTimer.isActive()); | 130 ASSERT(!m_continueNextChunkTimer.isActive()); |
129 if (!m_isSuspendedWithActiveTimer) | 131 if (!m_isSuspendedWithActiveTimer) |
130 return; | 132 return; |
131 m_isSuspendedWithActiveTimer = false; | 133 m_isSuspendedWithActiveTimer = false; |
132 m_continueNextChunkTimer.startOneShot(0); | 134 m_continueNextChunkTimer.startOneShot(0); |
133 } | 135 } |
134 | 136 |
135 } | 137 } |
OLD | NEW |