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