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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 const double parserTimeLimit = 0.5; | 138 const double parserTimeLimit = 0.5; |
139 if (session.elapsedTime() > parserTimeLimit) | 139 if (session.elapsedTime() > parserTimeLimit) |
140 return true; | 140 return true; |
141 | 141 |
142 // Yield if a lot of DOM work has been done in this session and a script tag
is | 142 // Yield if a lot of DOM work has been done in this session and a script tag
is |
143 // about to be parsed. This significantly improves render performance for do
cuments | 143 // about to be parsed. This significantly improves render performance for do
cuments |
144 // that place their scripts at the bottom of the page. Yielding too often | 144 // that place their scripts at the bottom of the page. Yielding too often |
145 // significantly slows down the parsing so a balance needs to be struck to | 145 // significantly slows down the parsing so a balance needs to be struck to |
146 // only yield when enough changes have happened to make it worthwhile. | 146 // only yield when enough changes have happened to make it worthwhile. |
147 // Emperical testing shows that anything > ~40 and < ~200 gives all of the b
enefit | 147 // Empirical testing shows that anything > ~40 and < ~200 gives all of the b
enefit |
148 // without impacting parser performance, only adding a few yields per page b
ut at | 148 // without impacting parser performance, only adding a few yields per page b
ut at |
149 // just the right times. | 149 // just the right times. |
150 const size_t sufficientWork = 50; | 150 const size_t sufficientWork = 50; |
151 if (startingScript && session.processedElementTokens() > sufficientWork) | 151 if (startingScript && session.processedElementTokens() > sufficientWork) |
152 return true; | 152 return true; |
153 | 153 |
154 return false; | 154 return false; |
155 } | 155 } |
156 | 156 |
157 bool HTMLParserScheduler::yieldIfNeeded(const SpeculationsPumpSession& session,
bool startingScript) | 157 bool HTMLParserScheduler::yieldIfNeeded(const SpeculationsPumpSession& session,
bool startingScript) |
(...skipping 11 matching lines...) Expand all Loading... |
169 ASSERT(!m_cancellableContinueParse->isPending()); | 169 ASSERT(!m_cancellableContinueParse->isPending()); |
170 m_isSuspendedWithActiveTimer = true; | 170 m_isSuspendedWithActiveTimer = true; |
171 } | 171 } |
172 | 172 |
173 void HTMLParserScheduler::continueParsing() | 173 void HTMLParserScheduler::continueParsing() |
174 { | 174 { |
175 m_parser->resumeParsingAfterYield(); | 175 m_parser->resumeParsingAfterYield(); |
176 } | 176 } |
177 | 177 |
178 } | 178 } |
OLD | NEW |