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

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

Issue 2386893002: Reformat comments in core/html/parser (Closed)
Patch Set: self review Created 4 years, 2 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 token.end(currentInput.numberOfCharactersConsumed() - 59 token.end(currentInput.numberOfCharactersConsumed() -
60 tokenizer->numberOfBufferedCharacters()); 60 tokenizer->numberOfBufferedCharacters());
61 } 61 }
62 62
63 String HTMLSourceTracker::sourceForToken(const HTMLToken& token) { 63 String HTMLSourceTracker::sourceForToken(const HTMLToken& token) {
64 if (!m_cachedSourceForToken.isEmpty()) 64 if (!m_cachedSourceForToken.isEmpty())
65 return m_cachedSourceForToken; 65 return m_cachedSourceForToken;
66 66
67 size_t length; 67 size_t length;
68 if (token.type() == HTMLToken::EndOfFile) { 68 if (token.type() == HTMLToken::EndOfFile) {
69 // Consume the remainder of the input, omitting the null character we use to mark the end of the file. 69 // Consume the remainder of the input, omitting the null character we use to
70 // mark the end of the file.
70 length = m_previousSource.length() + m_currentSource.length() - 1; 71 length = m_previousSource.length() + m_currentSource.length() - 1;
71 } else { 72 } else {
72 ASSERT(!token.startIndex()); 73 ASSERT(!token.startIndex());
73 length = static_cast<size_t>(token.endIndex() - token.startIndex()); 74 length = static_cast<size_t>(token.endIndex() - token.startIndex());
74 } 75 }
75 76
76 StringBuilder source; 77 StringBuilder source;
77 source.reserveCapacity(length); 78 source.reserveCapacity(length);
78 79
79 size_t i = 0; 80 size_t i = 0;
80 for (; i < length && !m_previousSource.isEmpty(); ++i) { 81 for (; i < length && !m_previousSource.isEmpty(); ++i) {
81 source.append(m_previousSource.currentChar()); 82 source.append(m_previousSource.currentChar());
82 m_previousSource.advance(); 83 m_previousSource.advance();
83 } 84 }
84 for (; i < length; ++i) { 85 for (; i < length; ++i) {
85 ASSERT(!m_currentSource.isEmpty()); 86 ASSERT(!m_currentSource.isEmpty());
86 source.append(m_currentSource.currentChar()); 87 source.append(m_currentSource.currentChar());
87 m_currentSource.advance(); 88 m_currentSource.advance();
88 } 89 }
89 90
90 m_cachedSourceForToken = source.toString(); 91 m_cachedSourceForToken = source.toString();
91 return m_cachedSourceForToken; 92 return m_cachedSourceForToken;
92 } 93 }
93 94
94 } // namespace blink 95 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698