RESOLVED FIXED 154636
A function named canTakeNextToken executing blocking scripts is misleading
https://bugs.webkit.org/show_bug.cgi?id=154636
Summary A function named canTakeNextToken executing blocking scripts is misleading
Ryosuke Niwa
Reported 2016-02-24 00:10:55 PST
A function named "canTakeNextToken" shouldn't implicitly execute blocking scripts
Attachments
Cleanup (13.03 KB, patch)
2016-02-24 00:34 PST, Ryosuke Niwa
darin: review+
Ryosuke Niwa
Comment 1 2016-02-24 00:34:53 PST
Darin Adler
Comment 2 2016-02-24 08:27:37 PST
Comment on attachment 272104 [details] Cleanup View in context: https://bugs.webkit.org/attachment.cgi?id=272104&action=review > Source/WebCore/ChangeLog:3 > + HTMLDocumentParser::canTakeNextToken shouldn't execute blocking scripts Why no new test case? > Source/WebCore/html/parser/HTMLDocumentParser.cpp:222 > + // happen instead is that assigning window.location causes the parser to stop parsing cleanly. Extra space here between "instead" and "is". > Source/WebCore/html/parser/HTMLParserScheduler.h:104 > + // monotonicallyIncreasingTime() can be expensive. By delaying, we avoided calling > + // monotonicallyIncreasingTime() when constructing non-yielding PumpSessions. > + if (!session.startTime) > + session.startTime = monotonicallyIncreasingTime(); > + > + session.processedTokens = 1; > + session.didSeeScript = false; > + > + double elapsedTime = monotonicallyIncreasingTime() - session.startTime; > + return elapsedTime > m_parserTimeLimit; Would be nice to refactor this so it only calls monotonicallyIncreasingTime() *once* the first time it’s called. Instead of calling it twice and subtracting the values. Maybe like this: if (!session.startTime) { session.startTime = monotonicallyIncreasingTime(); return false; } return monotonicallyIncreasingTime() - session.startTime > m_parserTimeLimit;
Ryosuke Niwa
Comment 3 2016-02-24 12:18:20 PST
Comment on attachment 272104 [details] Cleanup View in context: https://bugs.webkit.org/attachment.cgi?id=272104&action=review >> Source/WebCore/ChangeLog:3 >> + HTMLDocumentParser::canTakeNextToken shouldn't execute blocking scripts > > Why no new test case? Sorry, maybe this bug title is misleading. This patch is pure refactoring and there should be no behavioral change. I've renamed the bug and clarified it in the change log. >> Source/WebCore/html/parser/HTMLDocumentParser.cpp:222 >> + // happen instead is that assigning window.location causes the parser to stop parsing cleanly. > > Extra space here between "instead" and "is". Removed. >> Source/WebCore/html/parser/HTMLParserScheduler.h:104 >> + return elapsedTime > m_parserTimeLimit; > > Would be nice to refactor this so it only calls monotonicallyIncreasingTime() *once* the first time it’s called. Instead of calling it twice and subtracting the values. Maybe like this: > > if (!session.startTime) { > session.startTime = monotonicallyIncreasingTime(); > return false; > } > return monotonicallyIncreasingTime() - session.startTime > m_parserTimeLimit; Fixed.
Ryosuke Niwa
Comment 4 2016-02-24 12:25:55 PST
Note You need to log in before you can comment on or make changes to this bug.