Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: Source/core/html/parser/HTMLDocumentParser.cpp

Issue 798963002: Only populate line number in case parsing synchronously. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: deleted custom mac expectation Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/parser/HTMLDocumentParser.h ('k') | Source/core/inspector/ConsoleMessage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 #include "core/html/parser/HTMLParserThread.h" 38 #include "core/html/parser/HTMLParserThread.h"
39 #include "core/html/parser/HTMLScriptRunner.h" 39 #include "core/html/parser/HTMLScriptRunner.h"
40 #include "core/html/parser/HTMLTreeBuilder.h" 40 #include "core/html/parser/HTMLTreeBuilder.h"
41 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
42 #include "core/inspector/InspectorTraceEvents.h" 42 #include "core/inspector/InspectorTraceEvents.h"
43 #include "core/loader/DocumentLoader.h" 43 #include "core/loader/DocumentLoader.h"
44 #include "platform/SharedBuffer.h" 44 #include "platform/SharedBuffer.h"
45 #include "platform/TraceEvent.h" 45 #include "platform/TraceEvent.h"
46 #include "public/platform/WebThreadedDataReceiver.h" 46 #include "public/platform/WebThreadedDataReceiver.h"
47 #include "wtf/Functional.h" 47 #include "wtf/Functional.h"
48 #include "wtf/TemporaryChange.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 using namespace HTMLNames; 52 using namespace HTMLNames;
52 53
53 // This is a direct transcription of step 4 from: 54 // This is a direct transcription of step 4 from:
54 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#frag ment-case 55 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#frag ment-case
55 static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem ent, bool reportErrors, const HTMLParserOptions& options) 56 static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem ent, bool reportErrors, const HTMLParserOptions& options)
56 { 57 {
57 if (!contextElement) 58 if (!contextElement)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 , m_parserScheduler(HTMLParserScheduler::create(this)) 113 , m_parserScheduler(HTMLParserScheduler::create(this))
113 , m_xssAuditorDelegate(&document) 114 , m_xssAuditorDelegate(&document)
114 , m_weakFactory(this) 115 , m_weakFactory(this)
115 , m_preloader(HTMLResourcePreloader::create(document)) 116 , m_preloader(HTMLResourcePreloader::create(document))
116 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) 117 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing)
117 , m_endWasDelayed(false) 118 , m_endWasDelayed(false)
118 , m_haveBackgroundParser(false) 119 , m_haveBackgroundParser(false)
119 , m_tasksWereSuspended(false) 120 , m_tasksWereSuspended(false)
120 , m_pumpSessionNestingLevel(0) 121 , m_pumpSessionNestingLevel(0)
121 , m_pumpSpeculationsSessionNestingLevel(0) 122 , m_pumpSpeculationsSessionNestingLevel(0)
123 , m_isParsingAtLineNumber(false)
122 { 124 {
123 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); 125 ASSERT(shouldUseThreading() || (m_token && m_tokenizer));
124 } 126 }
125 127
126 // FIXME: Member variables should be grouped into self-initializing structs to 128 // FIXME: Member variables should be grouped into self-initializing structs to
127 // minimize code duplication between these constructors. 129 // minimize code duplication between these constructors.
128 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy) 130 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy)
129 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) 131 : ScriptableDocumentParser(fragment->document(), parserContentPolicy)
130 , m_options(&fragment->document()) 132 , m_options(&fragment->document())
131 , m_token(adoptPtr(new HTMLToken)) 133 , m_token(adoptPtr(new HTMLToken))
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 checkpoint->unparsedInput = m_input.current().toString().isolatedCopy(); 397 checkpoint->unparsedInput = m_input.current().toString().isolatedCopy();
396 m_input.current().clear(); // FIXME: This should be passed in instead of cle ared. 398 m_input.current().clear(); // FIXME: This should be passed in instead of cle ared.
397 399
398 ASSERT(checkpoint->unparsedInput.isSafeToSendToAnotherThread()); 400 ASSERT(checkpoint->unparsedInput.isSafeToSendToAnotherThread());
399 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::resumeFrom, m_backgroundParser, checkpoint.release())); 401 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::resumeFrom, m_backgroundParser, checkpoint.release()));
400 } 402 }
401 403
402 size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<Par sedChunk> popChunk) 404 size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<Par sedChunk> popChunk)
403 { 405 {
404 TRACE_EVENT0("blink", "HTMLDocumentParser::processParsedChunkFromBackgroundP arser"); 406 TRACE_EVENT0("blink", "HTMLDocumentParser::processParsedChunkFromBackgroundP arser");
407 TemporaryChange<bool> hasLineNumber(m_isParsingAtLineNumber, true);
405 408
406 ASSERT_WITH_SECURITY_IMPLICATION(document()->activeParserCount() == 1); 409 ASSERT_WITH_SECURITY_IMPLICATION(document()->activeParserCount() == 1);
407 ASSERT(!isParsingFragment()); 410 ASSERT(!isParsingFragment());
408 ASSERT(!isWaitingForScripts()); 411 ASSERT(!isWaitingForScripts());
409 ASSERT(!isStopped()); 412 ASSERT(!isStopped());
410 #if !ENABLE(OILPAN) 413 #if !ENABLE(OILPAN)
411 // ASSERT that this object is both attached to the Document and protected. 414 // ASSERT that this object is both attached to the Document and protected.
412 ASSERT(refCount() >= 2); 415 ASSERT(refCount() >= 2);
413 #endif 416 #endif
414 ASSERT(shouldUseThreading()); 417 ASSERT(shouldUseThreading());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 472
470 ASSERT(!m_tokenizer); 473 ASSERT(!m_tokenizer);
471 ASSERT(!m_token); 474 ASSERT(!m_token);
472 } 475 }
473 476
474 // Make sure all required pending text nodes are emitted before returning. 477 // Make sure all required pending text nodes are emitted before returning.
475 // This leaves "script", "style" and "svg" nodes text nodes intact. 478 // This leaves "script", "style" and "svg" nodes text nodes intact.
476 if (!isStopped()) 479 if (!isStopped())
477 m_treeBuilder->flush(FlushIfAtTextLimit); 480 m_treeBuilder->flush(FlushIfAtTextLimit);
478 481
482 m_isParsingAtLineNumber = false;
483
479 return elementTokenCount; 484 return elementTokenCount;
480 } 485 }
481 486
482 void HTMLDocumentParser::pumpPendingSpeculations() 487 void HTMLDocumentParser::pumpPendingSpeculations()
483 { 488 {
484 #if !ENABLE(OILPAN) 489 #if !ENABLE(OILPAN)
485 // ASSERT that this object is both attached to the Document and protected. 490 // ASSERT that this object is both attached to the Document and protected.
486 ASSERT(refCount() >= 2); 491 ASSERT(refCount() >= 2);
487 #endif 492 #endif
488 // If this assert fails, you need to call validateSpeculations to make sure 493 // If this assert fails, you need to call validateSpeculations to make sure
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 attemptToEnd(); 886 attemptToEnd();
882 } 887 }
883 888
884 bool HTMLDocumentParser::isExecutingScript() const 889 bool HTMLDocumentParser::isExecutingScript() const
885 { 890 {
886 if (!m_scriptRunner) 891 if (!m_scriptRunner)
887 return false; 892 return false;
888 return m_scriptRunner->isExecutingScript(); 893 return m_scriptRunner->isExecutingScript();
889 } 894 }
890 895
896 bool HTMLDocumentParser::isParsingAtLineNumber() const
897 {
898 return m_isParsingAtLineNumber && ScriptableDocumentParser::isParsingAtLineN umber();
899 }
900
891 OrdinalNumber HTMLDocumentParser::lineNumber() const 901 OrdinalNumber HTMLDocumentParser::lineNumber() const
892 { 902 {
893 if (m_haveBackgroundParser) 903 if (m_haveBackgroundParser)
894 return m_textPosition.m_line; 904 return m_textPosition.m_line;
895 905
896 return m_input.current().currentLine(); 906 return m_input.current().currentLine();
897 } 907 }
898 908
899 TextPosition HTMLDocumentParser::textPosition() const 909 TextPosition HTMLDocumentParser::textPosition() const
900 { 910 {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) 1063 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
1054 { 1064 {
1055 ASSERT(decoder); 1065 ASSERT(decoder);
1056 DecodedDataDocumentParser::setDecoder(decoder); 1066 DecodedDataDocumentParser::setDecoder(decoder);
1057 1067
1058 if (m_haveBackgroundParser) 1068 if (m_haveBackgroundParser)
1059 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); 1069 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder()));
1060 } 1070 }
1061 1071
1062 } 1072 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLDocumentParser.h ('k') | Source/core/inspector/ConsoleMessage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698