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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLSourceTracker.cpp

Issue 2751483005: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/html/parser/ (Closed)
Patch Set: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/html/parser/ Created 3 years, 9 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Adam Barth. All Rights Reserved. 2 * Copyright (C) 2010 Adam Barth. 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 String HTMLSourceTracker::sourceForToken(const HTMLToken& token) { 69 String HTMLSourceTracker::sourceForToken(const HTMLToken& token) {
70 if (!m_cachedSourceForToken.isEmpty()) 70 if (!m_cachedSourceForToken.isEmpty())
71 return m_cachedSourceForToken; 71 return m_cachedSourceForToken;
72 72
73 size_t length; 73 size_t length;
74 if (token.type() == HTMLToken::EndOfFile) { 74 if (token.type() == HTMLToken::EndOfFile) {
75 // Consume the remainder of the input, omitting the null character we use to 75 // Consume the remainder of the input, omitting the null character we use to
76 // mark the end of the file. 76 // mark the end of the file.
77 length = m_previousSource.length() + m_currentSource.length() - 1; 77 length = m_previousSource.length() + m_currentSource.length() - 1;
78 } else { 78 } else {
79 ASSERT(!token.startIndex()); 79 DCHECK(!token.startIndex());
80 length = static_cast<size_t>(token.endIndex() - token.startIndex()); 80 length = static_cast<size_t>(token.endIndex() - token.startIndex());
81 } 81 }
82 82
83 StringBuilder source; 83 StringBuilder source;
84 source.reserveCapacity(length); 84 source.reserveCapacity(length);
85 85
86 size_t i = 0; 86 size_t i = 0;
87 for (; i < length && !m_previousSource.isEmpty(); ++i) { 87 for (; i < length && !m_previousSource.isEmpty(); ++i) {
88 source.append(m_previousSource.currentChar()); 88 source.append(m_previousSource.currentChar());
89 m_previousSource.advance(); 89 m_previousSource.advance();
90 } 90 }
91 for (; i < length; ++i) { 91 for (; i < length; ++i) {
92 ASSERT(!m_currentSource.isEmpty()); 92 DCHECK(!m_currentSource.isEmpty());
93 source.append(m_currentSource.currentChar()); 93 source.append(m_currentSource.currentChar());
94 m_currentSource.advance(); 94 m_currentSource.advance();
95 } 95 }
96 96
97 m_cachedSourceForToken = source.toString(); 97 m_cachedSourceForToken = source.toString();
98 return m_cachedSourceForToken; 98 return m_cachedSourceForToken;
99 } 99 }
100 100
101 bool HTMLSourceTracker::needToCheckTokenizerBuffer(HTMLTokenizer* tokenizer) { 101 bool HTMLSourceTracker::needToCheckTokenizerBuffer(HTMLTokenizer* tokenizer) {
102 HTMLTokenizer::State state = tokenizer->getState(); 102 HTMLTokenizer::State state = tokenizer->getState();
103 // The temporary buffer must not be used unconditionally, because in some 103 // The temporary buffer must not be used unconditionally, because in some
104 // states (e.g. ScriptDataDoubleEscapedStartState), data is appended to 104 // states (e.g. ScriptDataDoubleEscapedStartState), data is appended to
105 // both the temporary buffer and the token itself. 105 // both the temporary buffer and the token itself.
106 return state == HTMLTokenizer::DataState || 106 return state == HTMLTokenizer::DataState ||
107 HTMLTokenizer::isEndTagBufferingState(state); 107 HTMLTokenizer::isEndTagBufferingState(state);
108 } 108 }
109 109
110 } // namespace blink 110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698