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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 void HTMLDocumentParser::stopBackgroundParser() | 748 void HTMLDocumentParser::stopBackgroundParser() |
749 { | 749 { |
750 ASSERT(shouldUseThreading()); | 750 ASSERT(shouldUseThreading()); |
751 ASSERT(m_haveBackgroundParser); | 751 ASSERT(m_haveBackgroundParser); |
752 m_haveBackgroundParser = false; | 752 m_haveBackgroundParser = false; |
753 | 753 |
754 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::stop, m_bac
kgroundParser)); | 754 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::stop, m_bac
kgroundParser)); |
755 m_weakFactory.revokeAll(); | 755 m_weakFactory.revokeAll(); |
756 } | 756 } |
757 | 757 |
758 void HTMLDocumentParser::append(PassRefPtr<StringImpl> inputSource) | 758 void HTMLDocumentParser::append(const String& inputSource) |
759 { | 759 { |
760 if (isStopped()) | 760 if (isStopped()) |
761 return; | 761 return; |
762 | 762 |
763 // We should never reach this point if we're using a parser thread, | 763 // We should never reach this point if we're using a parser thread, |
764 // as appendBytes() will directly ship the data to the thread. | 764 // as appendBytes() will directly ship the data to the thread. |
765 ASSERT(!shouldUseThreading()); | 765 ASSERT(!shouldUseThreading()); |
766 | 766 |
767 // pumpTokenizer can cause this parser to be detached from the Document, | 767 // pumpTokenizer can cause this parser to be detached from the Document, |
768 // but we need to ensure it isn't deleted yet. | 768 // but we need to ensure it isn't deleted yet. |
769 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); | 769 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); |
770 TRACE_EVENT1("net", "HTMLDocumentParser::append", "size", inputSource->lengt
h()); | 770 TRACE_EVENT1("net", "HTMLDocumentParser::append", "size", inputSource.length
()); |
771 String source(inputSource); | 771 const SegmentedString source(inputSource); |
772 | 772 |
773 if (m_preloadScanner) { | 773 if (m_preloadScanner) { |
774 if (m_input.current().isEmpty() && !isWaitingForScripts()) { | 774 if (m_input.current().isEmpty() && !isWaitingForScripts()) { |
775 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. | 775 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. |
776 // Clear the scanner so we know to scan starting from the current in
put point if we block again. | 776 // Clear the scanner so we know to scan starting from the current in
put point if we block again. |
777 m_preloadScanner.clear(); | 777 m_preloadScanner.clear(); |
778 } else { | 778 } else { |
779 m_preloadScanner->appendToEnd(source); | 779 m_preloadScanner->appendToEnd(source); |
780 if (isWaitingForScripts()) | 780 if (isWaitingForScripts()) |
781 m_preloadScanner->scan(m_preloader.get(), document()->baseElemen
tURL()); | 781 m_preloadScanner->scan(m_preloader.get(), document()->baseElemen
tURL()); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 // but we need to ensure it isn't deleted yet. | 999 // but we need to ensure it isn't deleted yet. |
1000 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); | 1000 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); |
1001 m_scriptRunner->executeScriptsWaitingForResources(); | 1001 m_scriptRunner->executeScriptsWaitingForResources(); |
1002 if (!isWaitingForScripts()) | 1002 if (!isWaitingForScripts()) |
1003 resumeParsingAfterScriptExecution(); | 1003 resumeParsingAfterScriptExecution(); |
1004 } | 1004 } |
1005 | 1005 |
1006 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra
gment* fragment, Element* contextElement, ParserContentPolicy parserContentPolic
y) | 1006 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra
gment* fragment, Element* contextElement, ParserContentPolicy parserContentPolic
y) |
1007 { | 1007 { |
1008 RefPtrWillBeRawPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(f
ragment, contextElement, parserContentPolicy); | 1008 RefPtrWillBeRawPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(f
ragment, contextElement, parserContentPolicy); |
1009 parser->append(source.impl()); | 1009 parser->append(source); |
1010 parser->finish(); | 1010 parser->finish(); |
1011 ASSERT(!parser->processingData()); // Make sure we're done. <rdar://problem/
3963151> | 1011 ASSERT(!parser->processingData()); // Make sure we're done. <rdar://problem/
3963151> |
1012 parser->detach(); // Allows ~DocumentParser to assert it was detached before
destruction. | 1012 parser->detach(); // Allows ~DocumentParser to assert it was detached before
destruction. |
1013 } | 1013 } |
1014 | 1014 |
1015 void HTMLDocumentParser::suspendScheduledTasks() | 1015 void HTMLDocumentParser::suspendScheduledTasks() |
1016 { | 1016 { |
1017 ASSERT(!m_tasksWereSuspended); | 1017 ASSERT(!m_tasksWereSuspended); |
1018 m_tasksWereSuspended = true; | 1018 m_tasksWereSuspended = true; |
1019 if (m_parserScheduler) | 1019 if (m_parserScheduler) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1063 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
1064 { | 1064 { |
1065 ASSERT(decoder); | 1065 ASSERT(decoder); |
1066 DecodedDataDocumentParser::setDecoder(decoder); | 1066 DecodedDataDocumentParser::setDecoder(decoder); |
1067 | 1067 |
1068 if (m_haveBackgroundParser) | 1068 if (m_haveBackgroundParser) |
1069 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco
der, m_backgroundParser, takeDecoder())); | 1069 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco
der, m_backgroundParser, takeDecoder())); |
1070 } | 1070 } |
1071 | 1071 |
1072 } | 1072 } |
OLD | NEW |