| 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 m_parserScheduler->scheduleForResume(); | 609 m_parserScheduler->scheduleForResume(); |
| 610 return; | 610 return; |
| 611 } | 611 } |
| 612 | 612 |
| 613 // Do not allow pumping speculations in nested event loops. | 613 // Do not allow pumping speculations in nested event loops. |
| 614 if (m_pumpSpeculationsSessionNestingLevel) { | 614 if (m_pumpSpeculationsSessionNestingLevel) { |
| 615 m_parserScheduler->scheduleForResume(); | 615 m_parserScheduler->scheduleForResume(); |
| 616 return; | 616 return; |
| 617 } | 617 } |
| 618 | 618 |
| 619 // FIXME: Pass in current input length. | 619 probe::ParseHTML probe(document(), this); |
| 620 TRACE_EVENT_BEGIN1("devtools.timeline", "ParseHTML", "beginData", | |
| 621 InspectorParseHtmlEvent::beginData( | |
| 622 document(), lineNumber().zeroBasedInt())); | |
| 623 | 620 |
| 624 SpeculationsPumpSession session(m_pumpSpeculationsSessionNestingLevel); | 621 SpeculationsPumpSession session(m_pumpSpeculationsSessionNestingLevel); |
| 625 while (!m_speculations.isEmpty()) { | 622 while (!m_speculations.isEmpty()) { |
| 626 ASSERT(!isScheduledForResume()); | 623 ASSERT(!isScheduledForResume()); |
| 627 size_t elementTokenCount = | 624 size_t elementTokenCount = |
| 628 processTokenizedChunkFromBackgroundParser(m_speculations.takeFirst()); | 625 processTokenizedChunkFromBackgroundParser(m_speculations.takeFirst()); |
| 629 session.addedElementTokens(elementTokenCount); | 626 session.addedElementTokens(elementTokenCount); |
| 630 | 627 |
| 631 // Always check isParsing first as m_document may be null. Surprisingly, | 628 // Always check isParsing first as m_document may be null. Surprisingly, |
| 632 // isScheduledForResume() may be set here as a result of | 629 // isScheduledForResume() may be set here as a result of |
| 633 // processTokenizedChunkFromBackgroundParser running arbitrary javascript | 630 // processTokenizedChunkFromBackgroundParser running arbitrary javascript |
| 634 // which invokes nested event loops. (e.g. inspector breakpoints) | 631 // which invokes nested event loops. (e.g. inspector breakpoints) |
| 635 checkIfBodyStylesheetAdded(); | 632 checkIfBodyStylesheetAdded(); |
| 636 if (!isParsing() || isPaused() || isScheduledForResume()) | 633 if (!isParsing() || isPaused() || isScheduledForResume()) |
| 637 break; | 634 break; |
| 638 | 635 |
| 639 if (m_speculations.isEmpty() || | 636 if (m_speculations.isEmpty() || |
| 640 m_parserScheduler->yieldIfNeeded( | 637 m_parserScheduler->yieldIfNeeded( |
| 641 session, m_speculations.first()->startingScript)) | 638 session, m_speculations.first()->startingScript)) |
| 642 break; | 639 break; |
| 643 } | 640 } |
| 644 | |
| 645 TRACE_EVENT_END1( | |
| 646 "devtools.timeline", "ParseHTML", "endData", | |
| 647 InspectorParseHtmlEvent::endData(lineNumber().zeroBasedInt() - 1)); | |
| 648 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), | |
| 649 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", | |
| 650 InspectorUpdateCountersEvent::data()); | |
| 651 } | 641 } |
| 652 | 642 |
| 653 void HTMLDocumentParser::forcePlaintextForTextDocument() { | 643 void HTMLDocumentParser::forcePlaintextForTextDocument() { |
| 654 if (shouldUseThreading()) { | 644 if (shouldUseThreading()) { |
| 655 // This method is called before any data is appended, so we have to start | 645 // This method is called before any data is appended, so we have to start |
| 656 // the background parser ourselves. | 646 // the background parser ourselves. |
| 657 if (!m_haveBackgroundParser) | 647 if (!m_haveBackgroundParser) |
| 658 startBackgroundParser(); | 648 startBackgroundParser(); |
| 659 | 649 |
| 660 // This task should be synchronous, because otherwise synchronous | 650 // This task should be synchronous, because otherwise synchronous |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 successHistogram.count(duration); | 1320 successHistogram.count(duration); |
| 1331 } else { | 1321 } else { |
| 1332 DEFINE_STATIC_LOCAL( | 1322 DEFINE_STATIC_LOCAL( |
| 1333 CustomCountHistogram, failureHistogram, | 1323 CustomCountHistogram, failureHistogram, |
| 1334 ("PreloadScanner.DocumentWrite.ExecutionTime.Failure", 1, 10000, 50)); | 1324 ("PreloadScanner.DocumentWrite.ExecutionTime.Failure", 1, 10000, 50)); |
| 1335 failureHistogram.count(duration); | 1325 failureHistogram.count(duration); |
| 1336 } | 1326 } |
| 1337 } | 1327 } |
| 1338 | 1328 |
| 1339 } // namespace blink | 1329 } // namespace blink |
| OLD | NEW |