Chromium Code Reviews| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 , m_parserScheduler(HTMLParserScheduler::create(this)) | 112 , m_parserScheduler(HTMLParserScheduler::create(this)) |
| 113 , m_xssAuditorDelegate(&document) | 113 , m_xssAuditorDelegate(&document) |
| 114 , m_weakFactory(this) | 114 , m_weakFactory(this) |
| 115 , m_preloader(HTMLResourcePreloader::create(document)) | 115 , m_preloader(HTMLResourcePreloader::create(document)) |
| 116 , m_isPinnedToMainThread(false) | 116 , m_isPinnedToMainThread(false) |
| 117 , m_endWasDelayed(false) | 117 , m_endWasDelayed(false) |
| 118 , m_haveBackgroundParser(false) | 118 , m_haveBackgroundParser(false) |
| 119 , m_tasksWereSuspended(false) | 119 , m_tasksWereSuspended(false) |
| 120 , m_pumpSessionNestingLevel(0) | 120 , m_pumpSessionNestingLevel(0) |
| 121 , m_pumpSpeculationsSessionNestingLevel(0) | 121 , m_pumpSpeculationsSessionNestingLevel(0) |
| 122 , m_hasLineNumber(false) | |
| 122 { | 123 { |
| 123 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); | 124 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
| 124 } | 125 } |
| 125 | 126 |
| 126 // FIXME: Member variables should be grouped into self-initializing structs to | 127 // FIXME: Member variables should be grouped into self-initializing structs to |
| 127 // minimize code duplication between these constructors. | 128 // minimize code duplication between these constructors. |
| 128 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy) | 129 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy) |
| 129 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) | 130 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) |
| 130 , m_options(&fragment->document()) | 131 , m_options(&fragment->document()) |
| 131 , m_token(adoptPtr(new HTMLToken)) | 132 , m_token(adoptPtr(new HTMLToken)) |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 checkpoint->unparsedInput = m_input.current().toString().isolatedCopy(); | 409 checkpoint->unparsedInput = m_input.current().toString().isolatedCopy(); |
| 409 m_input.current().clear(); // FIXME: This should be passed in instead of cle ared. | 410 m_input.current().clear(); // FIXME: This should be passed in instead of cle ared. |
| 410 | 411 |
| 411 ASSERT(checkpoint->unparsedInput.isSafeToSendToAnotherThread()); | 412 ASSERT(checkpoint->unparsedInput.isSafeToSendToAnotherThread()); |
| 412 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::resumeFrom, m_backgroundParser, checkpoint.release())); | 413 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::resumeFrom, m_backgroundParser, checkpoint.release())); |
| 413 } | 414 } |
| 414 | 415 |
| 415 size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<Par sedChunk> popChunk) | 416 size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<Par sedChunk> popChunk) |
| 416 { | 417 { |
| 417 TRACE_EVENT0("blink", "HTMLDocumentParser::processParsedChunkFromBackgroundP arser"); | 418 TRACE_EVENT0("blink", "HTMLDocumentParser::processParsedChunkFromBackgroundP arser"); |
| 419 m_hasLineNumber = true; | |
|
rmcilroy
2014/12/12 14:18:31
nit - how about using TemporaryChange here?
pfeldman
2014/12/12 17:21:06
Done.
| |
| 418 | 420 |
| 419 ASSERT_WITH_SECURITY_IMPLICATION(document()->activeParserCount() == 1); | 421 ASSERT_WITH_SECURITY_IMPLICATION(document()->activeParserCount() == 1); |
| 420 ASSERT(!isParsingFragment()); | 422 ASSERT(!isParsingFragment()); |
| 421 ASSERT(!isWaitingForScripts()); | 423 ASSERT(!isWaitingForScripts()); |
| 422 ASSERT(!isStopped()); | 424 ASSERT(!isStopped()); |
| 423 #if !ENABLE(OILPAN) | 425 #if !ENABLE(OILPAN) |
| 424 // ASSERT that this object is both attached to the Document and protected. | 426 // ASSERT that this object is both attached to the Document and protected. |
| 425 ASSERT(refCount() >= 2); | 427 ASSERT(refCount() >= 2); |
| 426 #endif | 428 #endif |
| 427 ASSERT(shouldUseThreading()); | 429 ASSERT(shouldUseThreading()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 | 484 |
| 483 ASSERT(!m_tokenizer); | 485 ASSERT(!m_tokenizer); |
| 484 ASSERT(!m_token); | 486 ASSERT(!m_token); |
| 485 } | 487 } |
| 486 | 488 |
| 487 // Make sure all required pending text nodes are emitted before returning. | 489 // Make sure all required pending text nodes are emitted before returning. |
| 488 // This leaves "script", "style" and "svg" nodes text nodes intact. | 490 // This leaves "script", "style" and "svg" nodes text nodes intact. |
| 489 if (!isStopped()) | 491 if (!isStopped()) |
| 490 m_treeBuilder->flush(FlushIfAtTextLimit); | 492 m_treeBuilder->flush(FlushIfAtTextLimit); |
| 491 | 493 |
| 494 m_hasLineNumber = false; | |
| 495 | |
| 492 return elementTokenCount; | 496 return elementTokenCount; |
| 493 } | 497 } |
| 494 | 498 |
| 495 void HTMLDocumentParser::pumpPendingSpeculations() | 499 void HTMLDocumentParser::pumpPendingSpeculations() |
| 496 { | 500 { |
| 497 #if !ENABLE(OILPAN) | 501 #if !ENABLE(OILPAN) |
| 498 // ASSERT that this object is both attached to the Document and protected. | 502 // ASSERT that this object is both attached to the Document and protected. |
| 499 ASSERT(refCount() >= 2); | 503 ASSERT(refCount() >= 2); |
| 500 #endif | 504 #endif |
| 501 // If this assert fails, you need to call validateSpeculations to make sure | 505 // If this assert fails, you need to call validateSpeculations to make sure |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 attemptToEnd(); | 904 attemptToEnd(); |
| 901 } | 905 } |
| 902 | 906 |
| 903 bool HTMLDocumentParser::isExecutingScript() const | 907 bool HTMLDocumentParser::isExecutingScript() const |
| 904 { | 908 { |
| 905 if (!m_scriptRunner) | 909 if (!m_scriptRunner) |
| 906 return false; | 910 return false; |
| 907 return m_scriptRunner->isExecutingScript(); | 911 return m_scriptRunner->isExecutingScript(); |
| 908 } | 912 } |
| 909 | 913 |
| 914 bool HTMLDocumentParser::hasLineNumber() const | |
| 915 { | |
| 916 return m_hasLineNumber; | |
| 917 } | |
| 918 | |
| 910 OrdinalNumber HTMLDocumentParser::lineNumber() const | 919 OrdinalNumber HTMLDocumentParser::lineNumber() const |
| 911 { | 920 { |
| 912 if (m_haveBackgroundParser) | 921 if (m_haveBackgroundParser) |
| 913 return m_textPosition.m_line; | 922 return m_textPosition.m_line; |
| 914 | 923 |
| 915 return m_input.current().currentLine(); | 924 return m_input.current().currentLine(); |
| 916 } | 925 } |
| 917 | 926 |
| 918 TextPosition HTMLDocumentParser::textPosition() const | 927 TextPosition HTMLDocumentParser::textPosition() const |
| 919 { | 928 { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1081 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
| 1073 { | 1082 { |
| 1074 ASSERT(decoder); | 1083 ASSERT(decoder); |
| 1075 DecodedDataDocumentParser::setDecoder(decoder); | 1084 DecodedDataDocumentParser::setDecoder(decoder); |
| 1076 | 1085 |
| 1077 if (m_haveBackgroundParser) | 1086 if (m_haveBackgroundParser) |
| 1078 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); | 1087 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); |
| 1079 } | 1088 } |
| 1080 | 1089 |
| 1081 } | 1090 } |
| OLD | NEW |